Skip to content

Commit 2e75806

Browse files
committed
UPDATE: add feature to mdx editor
1 parent f3545b6 commit 2e75806

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

apps/web/components/MdxEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const Mdxeditor = dynamic(
99
function MdxeditorComponent() {
1010
return (
1111
<div className="">
12-
<Mdxeditor markdown="" className="prose max-w-none bg-slate-200" />
12+
<Mdxeditor markdown="" className="prose max-w-none" />
1313
</div>
1414
);
1515
}

packages/ui/src/components/MdxEditor/InitializedMDXEditor.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import type { ForwardedRef } from "react";
22
import {
33
headingsPlugin,
4+
ListsToggle,
45
listsPlugin,
56
quotePlugin,
67
thematicBreakPlugin,
78
markdownShortcutPlugin,
89
MDXEditor,
10+
toolbarPlugin,
911
type MDXEditorMethods,
1012
type MDXEditorProps,
13+
UndoRedo,
14+
BoldItalicUnderlineToggles,
15+
BlockTypeSelect,
16+
directivesPlugin,
17+
AdmonitionDirectiveDescriptor,
18+
InsertAdmonition,
1119
} from "@mdxeditor/editor";
1220

1321
// Only import this to the next file
@@ -18,11 +26,28 @@ export default function InitializedMDXEditor({
1826
return (
1927
<MDXEditor
2028
plugins={[
29+
directivesPlugin({
30+
directiveDescriptors: [AdmonitionDirectiveDescriptor],
31+
}),
2132
headingsPlugin(),
2233
listsPlugin(),
2334
quotePlugin(),
2435
thematicBreakPlugin(),
2536
markdownShortcutPlugin(),
37+
toolbarPlugin({
38+
toolbarContents() {
39+
return (
40+
<>
41+
{" "}
42+
<UndoRedo />
43+
<BoldItalicUnderlineToggles />
44+
<BlockTypeSelect />
45+
<InsertAdmonition />
46+
<ListsToggle />
47+
</>
48+
);
49+
},
50+
}),
2651
]}
2752
{...props}
2853
ref={editorRef}

0 commit comments

Comments
 (0)