@mdxeditor/editor 0.8.0 → 0.10.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/FormatConstants.d.ts +9 -0
- package/dist/FormatConstants.js +10 -0
- package/dist/MDXEditor.d.ts +31 -0
- package/dist/MDXEditor.js +105 -0
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +4 -0
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.js +29 -0
- package/dist/directive-editors/GenericDirectiveEditor.d.ts +3 -0
- package/dist/directive-editors/GenericDirectiveEditor.js +32 -0
- package/dist/exportMarkdownFromLexical.d.ts +114 -0
- package/dist/exportMarkdownFromLexical.js +199 -0
- package/dist/gurx/index.d.ts +3 -0
- package/dist/gurx/react.d.ts +121 -0
- package/dist/gurx/react.js +112 -0
- package/dist/gurx/realm.d.ts +133 -0
- package/dist/gurx/realm.js +491 -0
- package/dist/gurx/realmFactory.d.ts +58 -0
- package/dist/gurx/realmFactory.js +28 -0
- package/dist/icons/add_column.svg.js +8 -0
- package/dist/icons/add_photo.svg.js +8 -0
- package/dist/icons/add_row.svg.js +8 -0
- package/dist/icons/arrow_drop_down.svg.js +8 -0
- package/dist/icons/arrow_right.svg.js +8 -0
- package/dist/icons/check.svg.js +8 -0
- package/dist/icons/close.svg.js +8 -0
- package/dist/icons/code.svg.js +8 -0
- package/dist/icons/content_copy.svg.js +8 -0
- package/dist/icons/delete.svg.js +8 -0
- package/dist/icons/delete_small.svg.js +8 -0
- package/dist/icons/deployed_code.svg.js +8 -0
- package/dist/icons/difference.svg.js +8 -0
- package/dist/icons/edit.svg.js +8 -0
- package/dist/icons/emergency_home.svg.js +8 -0
- package/dist/icons/format_align_center.svg.js +8 -0
- package/dist/icons/format_align_left.svg.js +8 -0
- package/dist/icons/format_align_right.svg.js +8 -0
- package/dist/icons/format_bold.svg.js +8 -0
- package/dist/icons/format_italic.svg.js +8 -0
- package/dist/icons/format_list_bulleted.svg.js +8 -0
- package/dist/icons/format_list_numbered.svg.js +8 -0
- package/dist/icons/format_underlined.svg.js +8 -0
- package/dist/icons/frame_source.svg.js +8 -0
- package/dist/icons/frontmatter.svg.js +8 -0
- package/dist/icons/horizontal_rule.svg.js +8 -0
- package/dist/icons/insert_col_left.svg.js +8 -0
- package/dist/icons/insert_col_right.svg.js +8 -0
- package/dist/icons/insert_row_above.svg.js +8 -0
- package/dist/icons/insert_row_below.svg.js +8 -0
- package/dist/icons/link.svg.js +8 -0
- package/dist/icons/link_off.svg.js +8 -0
- package/dist/icons/markdown.svg.js +8 -0
- package/dist/icons/more_horiz.svg.js +8 -0
- package/dist/icons/open_in_new.svg.js +8 -0
- package/dist/icons/redo.svg.js +8 -0
- package/dist/icons/rich_text.svg.js +8 -0
- package/dist/icons/settings.svg.js +8 -0
- package/dist/icons/table.svg.js +8 -0
- package/dist/icons/undo.svg.js +8 -0
- package/dist/importMarkdownToLexical.d.ts +84 -0
- package/dist/importMarkdownToLexical.js +65 -0
- package/dist/index.d.ts +49 -973
- package/dist/index.js +133 -66
- package/dist/jsx-editors/GenericJsxEditor.d.ts +3 -0
- package/dist/jsx-editors/GenericJsxEditor.js +56 -0
- package/dist/node_modules/react-diff-view/style/index.css.js +4 -0
- package/dist/plugins/codeblock/CodeBlockNode.d.ts +99 -0
- package/dist/plugins/codeblock/CodeBlockNode.js +155 -0
- package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
- package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
- package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
- package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
- package/dist/plugins/codeblock/index.d.ts +604 -0
- package/dist/plugins/codeblock/index.js +73 -0
- package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
- package/dist/plugins/codemirror/CodeMirrorEditor.js +33 -0
- package/dist/plugins/codemirror/index.d.ts +786 -0
- package/dist/plugins/codemirror/index.js +62 -0
- package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
- package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
- package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalRootVisitor.js +10 -0
- package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
- package/dist/plugins/core/LexicalTextVisitor.js +85 -0
- package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
- package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
- package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastInlineCodeVisitor.js +11 -0
- package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
- package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastRootVisitor.js +9 -0
- package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastTextVisitor.js +10 -0
- package/dist/plugins/core/NestedLexicalEditor.d.ts +69 -0
- package/dist/plugins/core/NestedLexicalEditor.js +181 -0
- package/dist/plugins/core/PropertyPopover.d.ts +8 -0
- package/dist/plugins/core/PropertyPopover.js +36 -0
- package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
- package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
- package/dist/plugins/core/index.d.ts +419 -0
- package/dist/plugins/core/index.js +343 -0
- package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
- package/dist/plugins/core/ui/PopoverUtils.js +17 -0
- package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
- package/dist/plugins/diff-source/DiffSourceWrapper.js +11 -0
- package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
- package/dist/plugins/diff-source/DiffViewer.js +18 -0
- package/dist/plugins/diff-source/SourceEditor.d.ts +2 -0
- package/dist/plugins/diff-source/SourceEditor.js +25 -0
- package/dist/plugins/diff-source/index.d.ts +530 -0
- package/dist/plugins/diff-source/index.js +55 -0
- package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
- package/dist/plugins/directives/DirectiveNode.js +92 -0
- package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
- package/dist/plugins/directives/DirectiveVisitor.js +10 -0
- package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
- package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
- package/dist/plugins/directives/index.d.ts +591 -0
- package/dist/plugins/directives/index.js +53 -0
- package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
- package/dist/plugins/frontmatter/FrontmatterEditor.js +69 -0
- package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
- package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
- package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
- package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
- package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
- package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
- package/dist/plugins/frontmatter/index.d.ts +510 -0
- package/dist/plugins/frontmatter/index.js +53 -0
- package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
- package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
- package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
- package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
- package/dist/plugins/headings/index.d.ts +105 -0
- package/dist/plugins/headings/index.js +20 -0
- package/dist/plugins/image/ImageEditor.d.ts +7 -0
- package/dist/{ImageEditor-5f203a1c.js → plugins/image/ImageEditor.js} +12 -46
- package/dist/plugins/image/ImageNode.d.ts +53 -0
- package/dist/plugins/image/ImageNode.js +108 -0
- package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
- package/dist/plugins/image/LexicalImageVisitor.js +15 -0
- package/dist/plugins/image/MdastImageVisitor.d.ts +3 -0
- package/dist/plugins/image/MdastImageVisitor.js +16 -0
- package/dist/plugins/image/index.d.ts +541 -0
- package/dist/plugins/image/index.js +244 -0
- package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
- package/dist/plugins/jsx/LexicalJsxNode.js +99 -0
- package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
- package/dist/plugins/jsx/LexicalJsxVisitor.js +12 -0
- package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
- package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
- package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
- package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
- package/dist/plugins/jsx/index.d.ts +461 -0
- package/dist/plugins/jsx/index.js +37 -0
- package/dist/plugins/link/LexicalLinkVisitor.d.ts +4 -0
- package/dist/plugins/link/LexicalLinkVisitor.js +10 -0
- package/dist/plugins/link/MdastLinkVisitor.d.ts +3 -0
- package/dist/plugins/link/MdastLinkVisitor.js +14 -0
- package/dist/plugins/link/index.d.ts +108 -0
- package/dist/plugins/link/index.js +24 -0
- package/dist/plugins/link-dialog/LinkDialog.d.ts +12 -0
- package/dist/plugins/link-dialog/LinkDialog.js +174 -0
- package/dist/plugins/link-dialog/index.d.ts +496 -0
- package/dist/plugins/link-dialog/index.js +242 -0
- package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
- package/dist/plugins/lists/LexicalListItemVisitor.js +22 -0
- package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
- package/dist/plugins/lists/LexicalListVisitor.js +14 -0
- package/dist/plugins/lists/MdastListItemVisitor.d.ts +3 -0
- package/dist/plugins/lists/MdastListItemVisitor.js +10 -0
- package/dist/plugins/lists/MdastListVisitor.d.ts +3 -0
- package/dist/plugins/lists/MdastListVisitor.js +18 -0
- package/dist/plugins/lists/index.d.ts +521 -0
- package/dist/plugins/lists/index.js +111 -0
- package/dist/plugins/markdown-shortcut/index.d.ts +51 -0
- package/dist/plugins/markdown-shortcut/index.js +34 -0
- package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
- package/dist/plugins/quote/LexicalQuoteVisitor.js +14 -0
- package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +3 -0
- package/dist/plugins/quote/MdastBlockQuoteVisitor.js +10 -0
- package/dist/plugins/quote/index.d.ts +348 -0
- package/dist/plugins/quote/index.js +26 -0
- package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
- package/dist/plugins/sandpack/SandpackEditor.js +35 -0
- package/dist/plugins/sandpack/index.d.ts +826 -0
- package/dist/plugins/sandpack/index.js +93 -0
- package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
- package/dist/{useCodeMirrorRef-ff0c2781.js → plugins/sandpack/useCodeMirrorRef.js} +22 -10
- package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
- package/dist/plugins/table/LexicalTableVisitor.js +10 -0
- package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
- package/dist/plugins/table/MdastTableVisitor.js +10 -0
- package/dist/plugins/table/TableEditor.d.ts +21 -0
- package/dist/{TableEditor-bb94be2b.js → plugins/table/TableEditor.js} +109 -161
- package/dist/plugins/table/TableNode.d.ts +52 -0
- package/dist/plugins/table/TableNode.js +147 -0
- package/dist/plugins/table/index.d.ts +511 -0
- package/dist/plugins/table/index.js +59 -0
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
- package/dist/plugins/thematic-break/index.d.ts +510 -0
- package/dist/plugins/thematic-break/index.js +39 -0
- package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +2 -0
- package/dist/plugins/toolbar/components/BlockTypeSelect.js +52 -0
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +2 -0
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +35 -0
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +2 -0
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +2 -0
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
- package/dist/plugins/toolbar/components/CodeToggle.d.ts +2 -0
- package/dist/plugins/toolbar/components/CodeToggle.js +20 -0
- package/dist/plugins/toolbar/components/CreateLink.d.ts +2 -0
- package/dist/plugins/toolbar/components/CreateLink.js +11 -0
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +4 -0
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +27 -0
- package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +2 -0
- package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
- package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +2 -0
- package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
- package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +2 -0
- package/dist/plugins/toolbar/components/InsertFrontmatter.js +11 -0
- package/dist/plugins/toolbar/components/InsertImage.d.ts +2 -0
- package/dist/plugins/toolbar/components/InsertImage.js +23 -0
- package/dist/plugins/toolbar/components/InsertSandpack.d.ts +2 -0
- package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
- package/dist/plugins/toolbar/components/InsertTable.d.ts +2 -0
- package/dist/plugins/toolbar/components/InsertTable.js +20 -0
- package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +2 -0
- package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +2 -0
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
- package/dist/plugins/toolbar/components/ListsToggle.d.ts +2 -0
- package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
- package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +2 -0
- package/dist/plugins/toolbar/components/ShowSandpackInfo.js +32 -0
- package/dist/plugins/toolbar/components/UndoRedo.d.ts +2 -0
- package/dist/plugins/toolbar/components/UndoRedo.js +59 -0
- package/dist/plugins/toolbar/index.d.ts +416 -0
- package/dist/plugins/toolbar/index.js +39 -0
- package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
- package/dist/plugins/toolbar/primitives/DialogButton.js +115 -0
- package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +5 -0
- package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
- package/dist/plugins/toolbar/primitives/select.d.ts +31 -0
- package/dist/plugins/toolbar/primitives/select.js +44 -0
- package/dist/plugins/toolbar/primitives/toolbar.d.ts +85 -0
- package/dist/plugins/toolbar/primitives/toolbar.js +111 -0
- package/dist/style.css +480 -240
- package/dist/styles/globals.css.js +4 -0
- package/dist/styles/lexical-theme.module.css.js +53 -0
- package/dist/styles/lexicalTheme.d.ts +2 -0
- package/dist/styles/lexicalTheme.js +28 -0
- package/dist/styles/ui.module.css.js +227 -0
- package/dist/utils/detectMac.d.ts +2 -0
- package/dist/utils/detectMac.js +6 -0
- package/dist/utils/fp.d.ts +47 -0
- package/dist/utils/fp.js +10 -0
- package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
- package/dist/utils/isPartOftheEditorUI.js +12 -0
- package/dist/utils/lexicalHelpers.d.ts +11 -0
- package/dist/utils/lexicalHelpers.js +49 -0
- package/dist/utils/uuid4.d.ts +1 -0
- package/dist/utils/uuid4.js +10 -0
- package/dist/utils/voidEmitter.d.ts +14 -0
- package/dist/utils/voidEmitter.js +15 -0
- package/package.json +184 -14
- package/dist/CodeBlockEditor-59b65408.js +0 -78
- package/dist/CodeBlockEditor-5ae8b0a9.cjs +0 -1
- package/dist/FrontmatterEditor-2b27f5a7.js +0 -117
- package/dist/FrontmatterEditor-74ad4eb7.cjs +0 -1
- package/dist/ImageEditor-e5fd6b26.cjs +0 -1
- package/dist/JsxEditor-95724372.cjs +0 -1
- package/dist/JsxEditor-f061cc75.js +0 -108
- package/dist/SandpackEditor-37261889.cjs +0 -1
- package/dist/SandpackEditor-ce901c3c.js +0 -98
- package/dist/SourceEditor-6135bf63.cjs +0 -1
- package/dist/SourceEditor-e499b8bb.js +0 -63
- package/dist/TableEditor-4d00f956.cjs +0 -1
- package/dist/index-383c60bb.cjs +0 -1
- package/dist/index-470693d8.js +0 -4095
- package/dist/index.cjs +0 -1
- package/dist/useCodeMirrorRef-72d8430b.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,68 +1,135 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import "
|
|
4
|
-
import "
|
|
5
|
-
import "
|
|
6
|
-
import "
|
|
7
|
-
import "
|
|
8
|
-
import "
|
|
9
|
-
import "
|
|
10
|
-
import "
|
|
11
|
-
import "
|
|
12
|
-
import "
|
|
13
|
-
import "
|
|
14
|
-
import "
|
|
15
|
-
import "
|
|
16
|
-
import "
|
|
17
|
-
import "
|
|
18
|
-
import "
|
|
19
|
-
import "
|
|
20
|
-
import "
|
|
21
|
-
import "
|
|
22
|
-
import "
|
|
23
|
-
import "
|
|
24
|
-
import "
|
|
25
|
-
import "
|
|
26
|
-
import "
|
|
27
|
-
import "
|
|
28
|
-
import "
|
|
29
|
-
import "
|
|
30
|
-
import "
|
|
31
|
-
import "
|
|
32
|
-
import "
|
|
33
|
-
import "
|
|
34
|
-
import "
|
|
35
|
-
import "
|
|
36
|
-
import "
|
|
37
|
-
import "
|
|
38
|
-
import "
|
|
39
|
-
import "
|
|
40
|
-
import "
|
|
41
|
-
import "
|
|
1
|
+
import "./styles/globals.css.js";
|
|
2
|
+
import { MDXEditor } from "./MDXEditor.js";
|
|
3
|
+
import { headingsPlugin, headingsSystem } from "./plugins/headings/index.js";
|
|
4
|
+
import { thematicBreakPlugin, thematicBreakPluginHooks, thematicBreakSystem } from "./plugins/thematic-break/index.js";
|
|
5
|
+
import { listsPlugin, listsPluginHooks, listsSystem } from "./plugins/lists/index.js";
|
|
6
|
+
import { tablePlugin, tablePluginHooks, tableSystem } from "./plugins/table/index.js";
|
|
7
|
+
import { linkPlugin, linkSystem } from "./plugins/link/index.js";
|
|
8
|
+
import { INSERT_IMAGE_COMMAND, imagePlugin, imagePluginHooks, imageSystem } from "./plugins/image/index.js";
|
|
9
|
+
import { frontmatterPlugin, frontmatterPluginHooks, frontmatterSystem } from "./plugins/frontmatter/index.js";
|
|
10
|
+
import { quotePlugin, quotePluginHooks } from "./plugins/quote/index.js";
|
|
11
|
+
import { jsxPlugin, jsxPluginHooks, jsxSystem } from "./plugins/jsx/index.js";
|
|
12
|
+
import { GenericJsxEditor } from "./jsx-editors/GenericJsxEditor.js";
|
|
13
|
+
import { sandpackPlugin, sandpackPluginHooks, sandpackSystem } from "./plugins/sandpack/index.js";
|
|
14
|
+
import { codeMirrorHooks, codeMirrorPlugin, codeMirrorSystem } from "./plugins/codemirror/index.js";
|
|
15
|
+
import { codeBlockPlugin, codeBlockPluginHooks, codeBlockSystem } from "./plugins/codeblock/index.js";
|
|
16
|
+
import { directivesPlugin, directivesPluginHooks, directivesSystem } from "./plugins/directives/index.js";
|
|
17
|
+
import { ADMONITION_TYPES, AdmonitionDirectiveDescriptor } from "./directive-editors/AdmonitionDirectiveDescriptor.js";
|
|
18
|
+
import { GenericDirectiveEditor } from "./directive-editors/GenericDirectiveEditor.js";
|
|
19
|
+
import { linkDialogPlugin, linkDialogPluginHooks } from "./plugins/link-dialog/index.js";
|
|
20
|
+
import { toolbarPlugin, toolbarPluginHooks, toolbarSystem } from "./plugins/toolbar/index.js";
|
|
21
|
+
import { diffSourcePlugin, diffSourcePluginHooks, diffSourceSystem } from "./plugins/diff-source/index.js";
|
|
22
|
+
import { markdownShortcutPlugin } from "./plugins/markdown-shortcut/index.js";
|
|
23
|
+
import { BlockTypeSelect } from "./plugins/toolbar/components/BlockTypeSelect.js";
|
|
24
|
+
import { BoldItalicUnderlineToggles } from "./plugins/toolbar/components/BoldItalicUnderlineToggles.js";
|
|
25
|
+
import { ChangeAdmonitionType } from "./plugins/toolbar/components/ChangeAdmonitionType.js";
|
|
26
|
+
import { ChangeCodeMirrorLanguage } from "./plugins/toolbar/components/ChangeCodeMirrorLanguage.js";
|
|
27
|
+
import { CodeToggle } from "./plugins/toolbar/components/CodeToggle.js";
|
|
28
|
+
import { CreateLink } from "./plugins/toolbar/components/CreateLink.js";
|
|
29
|
+
import { DiffSourceToggleWrapper } from "./plugins/toolbar/components/DiffSourceToggleWrapper.js";
|
|
30
|
+
import { InsertAdmonition } from "./plugins/toolbar/components/InsertAdmonition.js";
|
|
31
|
+
import { InsertCodeBlock } from "./plugins/toolbar/components/InsertCodeBlock.js";
|
|
32
|
+
import { InsertFrontmatter } from "./plugins/toolbar/components/InsertFrontmatter.js";
|
|
33
|
+
import { InsertImage } from "./plugins/toolbar/components/InsertImage.js";
|
|
34
|
+
import { InsertSandpack } from "./plugins/toolbar/components/InsertSandpack.js";
|
|
35
|
+
import { InsertTable } from "./plugins/toolbar/components/InsertTable.js";
|
|
36
|
+
import { InsertThematicBreak } from "./plugins/toolbar/components/InsertThematicBreak.js";
|
|
37
|
+
import { ListsToggle } from "./plugins/toolbar/components/ListsToggle.js";
|
|
38
|
+
import { ShowSandpackInfo } from "./plugins/toolbar/components/ShowSandpackInfo.js";
|
|
39
|
+
import { UndoRedo } from "./plugins/toolbar/components/UndoRedo.js";
|
|
40
|
+
import { KitchenSinkToolbar } from "./plugins/toolbar/components/KitchenSinkToolbar.js";
|
|
41
|
+
import { Button, ButtonOrDropdownButton, ButtonWithTooltip, ConditionalContents, MultipleChoiceToggleGroup, Root, Separator, SingleChoiceToggleGroup, SingleToggleGroup, ToggleSingleGroupWithItem, ToolbarToggleItem } from "./plugins/toolbar/primitives/toolbar.js";
|
|
42
|
+
import { DialogButton } from "./plugins/toolbar/primitives/DialogButton.js";
|
|
43
|
+
import { TooltipWrap } from "./plugins/toolbar/primitives/TooltipWrap.js";
|
|
44
|
+
import { Select, SelectButtonTrigger, SelectContent, SelectItem, SelectTrigger } from "./plugins/toolbar/primitives/select.js";
|
|
45
|
+
import { useCodeBlockEditorContext } from "./plugins/codeblock/CodeBlockNode.js";
|
|
42
46
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
47
|
+
ADMONITION_TYPES,
|
|
48
|
+
AdmonitionDirectiveDescriptor,
|
|
49
|
+
BlockTypeSelect,
|
|
50
|
+
BoldItalicUnderlineToggles,
|
|
51
|
+
Button,
|
|
52
|
+
ButtonOrDropdownButton,
|
|
53
|
+
ButtonWithTooltip,
|
|
54
|
+
ChangeAdmonitionType,
|
|
55
|
+
ChangeCodeMirrorLanguage,
|
|
56
|
+
CodeToggle,
|
|
57
|
+
ConditionalContents,
|
|
58
|
+
CreateLink,
|
|
59
|
+
DialogButton,
|
|
60
|
+
DiffSourceToggleWrapper,
|
|
61
|
+
GenericDirectiveEditor,
|
|
62
|
+
GenericJsxEditor,
|
|
63
|
+
INSERT_IMAGE_COMMAND,
|
|
64
|
+
InsertAdmonition,
|
|
65
|
+
InsertCodeBlock,
|
|
66
|
+
InsertFrontmatter,
|
|
67
|
+
InsertImage,
|
|
68
|
+
InsertSandpack,
|
|
69
|
+
InsertTable,
|
|
70
|
+
InsertThematicBreak,
|
|
71
|
+
KitchenSinkToolbar,
|
|
72
|
+
ListsToggle,
|
|
73
|
+
MDXEditor,
|
|
74
|
+
MultipleChoiceToggleGroup,
|
|
75
|
+
Root,
|
|
76
|
+
Select,
|
|
77
|
+
SelectButtonTrigger,
|
|
78
|
+
SelectContent,
|
|
79
|
+
SelectItem,
|
|
80
|
+
SelectTrigger,
|
|
81
|
+
Separator,
|
|
82
|
+
ShowSandpackInfo,
|
|
83
|
+
SingleChoiceToggleGroup,
|
|
84
|
+
SingleToggleGroup,
|
|
85
|
+
ToggleSingleGroupWithItem,
|
|
86
|
+
ToolbarToggleItem,
|
|
87
|
+
TooltipWrap,
|
|
88
|
+
UndoRedo,
|
|
89
|
+
codeBlockPlugin,
|
|
90
|
+
codeBlockPluginHooks,
|
|
91
|
+
codeBlockSystem,
|
|
92
|
+
codeMirrorHooks,
|
|
93
|
+
codeMirrorPlugin,
|
|
94
|
+
codeMirrorSystem,
|
|
95
|
+
diffSourcePlugin,
|
|
96
|
+
diffSourcePluginHooks,
|
|
97
|
+
diffSourceSystem,
|
|
98
|
+
directivesPlugin,
|
|
99
|
+
directivesPluginHooks,
|
|
100
|
+
directivesSystem,
|
|
101
|
+
frontmatterPlugin,
|
|
102
|
+
frontmatterPluginHooks,
|
|
103
|
+
frontmatterSystem,
|
|
104
|
+
headingsPlugin,
|
|
105
|
+
headingsSystem,
|
|
106
|
+
imagePlugin,
|
|
107
|
+
imagePluginHooks,
|
|
108
|
+
imageSystem,
|
|
109
|
+
jsxPlugin,
|
|
110
|
+
jsxPluginHooks,
|
|
111
|
+
jsxSystem,
|
|
112
|
+
linkDialogPlugin,
|
|
113
|
+
linkDialogPluginHooks,
|
|
114
|
+
linkPlugin,
|
|
115
|
+
linkSystem,
|
|
116
|
+
listsPlugin,
|
|
117
|
+
listsPluginHooks,
|
|
118
|
+
listsSystem,
|
|
119
|
+
markdownShortcutPlugin,
|
|
120
|
+
quotePlugin,
|
|
121
|
+
quotePluginHooks,
|
|
122
|
+
sandpackPlugin,
|
|
123
|
+
sandpackPluginHooks,
|
|
124
|
+
sandpackSystem,
|
|
125
|
+
tablePlugin,
|
|
126
|
+
tablePluginHooks,
|
|
127
|
+
tableSystem,
|
|
128
|
+
thematicBreakPlugin,
|
|
129
|
+
thematicBreakPluginHooks,
|
|
130
|
+
thematicBreakSystem,
|
|
131
|
+
toolbarPlugin,
|
|
132
|
+
toolbarPluginHooks,
|
|
133
|
+
toolbarSystem,
|
|
134
|
+
useCodeBlockEditorContext
|
|
68
135
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { useMdastNodeUpdater, NestedLexicalEditor } from "../plugins/core/NestedLexicalEditor.js";
|
|
3
|
+
import { PropertyPopover } from "../plugins/core/PropertyPopover.js";
|
|
4
|
+
import styles from "../styles/ui.module.css.js";
|
|
5
|
+
const GenericJsxEditor = ({ mdastNode, descriptor }) => {
|
|
6
|
+
const updateMdastNode = useMdastNodeUpdater();
|
|
7
|
+
const properties = React__default.useMemo(() => {
|
|
8
|
+
return descriptor.props.reduce((acc, descriptor2) => {
|
|
9
|
+
const attribute = mdastNode.attributes.find((attr) => attr.name === descriptor2.name);
|
|
10
|
+
if (attribute) {
|
|
11
|
+
acc[descriptor2.name] = attribute.value;
|
|
12
|
+
} else {
|
|
13
|
+
acc[descriptor2.name] = "";
|
|
14
|
+
}
|
|
15
|
+
return acc;
|
|
16
|
+
}, {});
|
|
17
|
+
}, [mdastNode, descriptor]);
|
|
18
|
+
const onChange = React__default.useCallback(
|
|
19
|
+
(values) => {
|
|
20
|
+
const newAttributes = mdastNode.attributes.slice();
|
|
21
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
22
|
+
const attributeToUpdate = newAttributes.find((attr) => attr.name === key);
|
|
23
|
+
if (value === "") {
|
|
24
|
+
if (attributeToUpdate) {
|
|
25
|
+
newAttributes.splice(newAttributes.indexOf(attributeToUpdate), 1);
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
if (attributeToUpdate) {
|
|
29
|
+
attributeToUpdate.value = value;
|
|
30
|
+
} else {
|
|
31
|
+
newAttributes.push({
|
|
32
|
+
type: "mdxJsxAttribute",
|
|
33
|
+
name: key,
|
|
34
|
+
value
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
updateMdastNode({ attributes: newAttributes });
|
|
40
|
+
},
|
|
41
|
+
[mdastNode, updateMdastNode]
|
|
42
|
+
);
|
|
43
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: descriptor.kind === "text" ? styles.inlineEditor : styles.blockEditor }, descriptor.props.length == 0 && descriptor.hasChildren && descriptor.kind === "flow" ? /* @__PURE__ */ React__default.createElement("span", { className: styles.genericComponentName }, mdastNode.name) : null, descriptor.props.length > 0 ? /* @__PURE__ */ React__default.createElement(PropertyPopover, { properties, title: mdastNode.name || "", onChange }) : null, descriptor.hasChildren ? /* @__PURE__ */ React__default.createElement(
|
|
44
|
+
NestedLexicalEditor,
|
|
45
|
+
{
|
|
46
|
+
block: descriptor.kind === "flow",
|
|
47
|
+
getContent: (node) => node.children,
|
|
48
|
+
getUpdatedMdastNode: (mdastNode2, children) => {
|
|
49
|
+
return { ...mdastNode2, children };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
) : /* @__PURE__ */ React__default.createElement("span", { className: styles.genericComponentName }, mdastNode.name));
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
GenericJsxEditor
|
|
56
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DecoratorNode, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
3
|
+
import { CodeBlockEditorProps } from '.';
|
|
4
|
+
/**
|
|
5
|
+
* The options necessary to construct a new code block node.
|
|
6
|
+
*/
|
|
7
|
+
export interface CreateCodeBlockNodeOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The code contents of the block.
|
|
10
|
+
*/
|
|
11
|
+
code: string;
|
|
12
|
+
/**
|
|
13
|
+
* The language of the code block (i.e. `js`, `jsx`, etc.). This is used for syntax highlighting.
|
|
14
|
+
*/
|
|
15
|
+
language: string;
|
|
16
|
+
/**
|
|
17
|
+
* The additional meta data of the block.
|
|
18
|
+
*/
|
|
19
|
+
meta: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A serialized representation of an {@link CodeBlockNode}.
|
|
23
|
+
*/
|
|
24
|
+
export type SerializedCodeBlockNode = Spread<CreateCodeBlockNodeOptions & {
|
|
25
|
+
type: 'codeblock';
|
|
26
|
+
version: 1;
|
|
27
|
+
}, SerializedLexicalNode>;
|
|
28
|
+
/**
|
|
29
|
+
* A lexical node that represents a fenced code block. Use {@link "$createCodeBlockNode"} to construct one.
|
|
30
|
+
*/
|
|
31
|
+
export declare class CodeBlockNode extends DecoratorNode<JSX.Element> {
|
|
32
|
+
__code: string;
|
|
33
|
+
__meta: string;
|
|
34
|
+
__language: string;
|
|
35
|
+
__focusEmitter: {
|
|
36
|
+
publish: () => void; /**
|
|
37
|
+
* The code contents of the block.
|
|
38
|
+
*/
|
|
39
|
+
subscribe: (cb: () => void) => void;
|
|
40
|
+
};
|
|
41
|
+
static getType(): string;
|
|
42
|
+
static clone(node: CodeBlockNode): CodeBlockNode;
|
|
43
|
+
static importJSON(serializedNode: SerializedCodeBlockNode): CodeBlockNode;
|
|
44
|
+
constructor(code: string, language: string, meta: string, key?: NodeKey);
|
|
45
|
+
exportJSON(): SerializedCodeBlockNode;
|
|
46
|
+
createDOM(_config: EditorConfig): HTMLDivElement;
|
|
47
|
+
updateDOM(): false;
|
|
48
|
+
getCode(): string;
|
|
49
|
+
getMeta(): string;
|
|
50
|
+
getLanguage(): string;
|
|
51
|
+
setCode: (code: string) => void;
|
|
52
|
+
setMeta: (meta: string) => void;
|
|
53
|
+
setLanguage: (language: string) => void;
|
|
54
|
+
select: () => void;
|
|
55
|
+
decorate(editor: LexicalEditor): JSX.Element;
|
|
56
|
+
}
|
|
57
|
+
interface CodeBlockEditorContainerProps extends CodeBlockEditorProps {
|
|
58
|
+
/** The Lexical editor that contains the node */
|
|
59
|
+
parentEditor: LexicalEditor;
|
|
60
|
+
/** The Lexical node that is being edited */
|
|
61
|
+
codeBlockNode: CodeBlockNode;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A set of functions that modify the underlying code block node. Get this with the {@link useCodeBlockEditorContext} hook.
|
|
65
|
+
*/
|
|
66
|
+
export interface CodeBlockEditorContextValue {
|
|
67
|
+
/**
|
|
68
|
+
* Updates the code contents of the code block.
|
|
69
|
+
*/
|
|
70
|
+
setCode(code: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* Updates the language of the code block. See {@link https://www.markdownguide.org/extended-syntax/#syntax-highlighting} for language examples.
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
setLanguage(language: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Updates the meta of the code block. The meta is the additional string that comes after the code block language.
|
|
78
|
+
*/
|
|
79
|
+
setMeta(meta: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* The Lexical node that's being edited.
|
|
82
|
+
*/
|
|
83
|
+
lexicalNode: CodeBlockNode;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Use this hook in your custom code block editors to modify the underlying node code, language, and meta.
|
|
87
|
+
*/
|
|
88
|
+
export declare function useCodeBlockEditorContext(): CodeBlockEditorContextValue;
|
|
89
|
+
export declare function CodeBlockEditorContainer(props: CodeBlockEditorContainerProps): React.JSX.Element;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a {@link CodeBlockNode}.
|
|
92
|
+
* @param options - The code contents, the language (i.e. js, jsx, etc.), and the additional meta data of the block.
|
|
93
|
+
*/
|
|
94
|
+
export declare function $createCodeBlockNode(options: Partial<CreateCodeBlockNodeOptions>): CodeBlockNode;
|
|
95
|
+
/**
|
|
96
|
+
* Returns true if the given node is a {@link CodeBlockNode}.
|
|
97
|
+
*/
|
|
98
|
+
export declare function $isCodeBlockNode(node: LexicalNode | null | undefined): node is CodeBlockNode;
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import React__default from "react";
|
|
8
|
+
import { DecoratorNode } from "lexical";
|
|
9
|
+
import { codeBlockPluginHooks } from "./index.js";
|
|
10
|
+
import { voidEmitter } from "../../utils/voidEmitter.js";
|
|
11
|
+
import { NESTED_EDITOR_UPDATED_COMMAND } from "../core/index.js";
|
|
12
|
+
class CodeBlockNode extends DecoratorNode {
|
|
13
|
+
constructor(code, language, meta, key) {
|
|
14
|
+
super(key);
|
|
15
|
+
__publicField(this, "__code");
|
|
16
|
+
__publicField(this, "__meta");
|
|
17
|
+
__publicField(this, "__language");
|
|
18
|
+
__publicField(this, "__focusEmitter", voidEmitter());
|
|
19
|
+
__publicField(this, "setCode", (code) => {
|
|
20
|
+
if (code !== this.__code) {
|
|
21
|
+
this.getWritable().__code = code;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
__publicField(this, "setMeta", (meta) => {
|
|
25
|
+
if (meta !== this.__meta) {
|
|
26
|
+
this.getWritable().__meta = meta;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
__publicField(this, "setLanguage", (language) => {
|
|
30
|
+
if (language !== this.__language) {
|
|
31
|
+
this.getWritable().__language = language;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
__publicField(this, "select", () => {
|
|
35
|
+
this.__focusEmitter.publish();
|
|
36
|
+
});
|
|
37
|
+
this.__code = code;
|
|
38
|
+
this.__meta = meta;
|
|
39
|
+
this.__language = language;
|
|
40
|
+
}
|
|
41
|
+
static getType() {
|
|
42
|
+
return "codeblock";
|
|
43
|
+
}
|
|
44
|
+
static clone(node) {
|
|
45
|
+
return new CodeBlockNode(node.__code, node.__language, node.__meta, node.__key);
|
|
46
|
+
}
|
|
47
|
+
static importJSON(serializedNode) {
|
|
48
|
+
const { code, meta, language } = serializedNode;
|
|
49
|
+
return $createCodeBlockNode({
|
|
50
|
+
code,
|
|
51
|
+
language,
|
|
52
|
+
meta
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exportJSON() {
|
|
56
|
+
return {
|
|
57
|
+
code: this.getCode(),
|
|
58
|
+
language: this.getLanguage(),
|
|
59
|
+
meta: this.getMeta(),
|
|
60
|
+
type: "codeblock",
|
|
61
|
+
version: 1
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// View
|
|
65
|
+
createDOM(_config) {
|
|
66
|
+
return document.createElement("div");
|
|
67
|
+
}
|
|
68
|
+
updateDOM() {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
getCode() {
|
|
72
|
+
return this.__code;
|
|
73
|
+
}
|
|
74
|
+
getMeta() {
|
|
75
|
+
return this.__meta;
|
|
76
|
+
}
|
|
77
|
+
getLanguage() {
|
|
78
|
+
return this.__language;
|
|
79
|
+
}
|
|
80
|
+
decorate(editor) {
|
|
81
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
82
|
+
CodeBlockEditorContainer,
|
|
83
|
+
{
|
|
84
|
+
parentEditor: editor,
|
|
85
|
+
code: this.getCode(),
|
|
86
|
+
meta: this.getMeta(),
|
|
87
|
+
language: this.getLanguage(),
|
|
88
|
+
codeBlockNode: this,
|
|
89
|
+
nodeKey: this.getKey(),
|
|
90
|
+
focusEmitter: this.__focusEmitter
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const CodeBlockEditorContext = React__default.createContext(null);
|
|
96
|
+
const CodeBlockEditorContextProvider = ({ parentEditor, lexicalNode, children }) => {
|
|
97
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
98
|
+
CodeBlockEditorContext.Provider,
|
|
99
|
+
{
|
|
100
|
+
value: {
|
|
101
|
+
lexicalNode,
|
|
102
|
+
setCode: (code) => {
|
|
103
|
+
parentEditor.update(() => {
|
|
104
|
+
lexicalNode.setCode(code);
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
parentEditor.dispatchCommand(NESTED_EDITOR_UPDATED_COMMAND, void 0);
|
|
107
|
+
}, 0);
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
setLanguage: (language) => {
|
|
111
|
+
parentEditor.update(() => {
|
|
112
|
+
lexicalNode.setLanguage(language);
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
setMeta: (meta) => {
|
|
116
|
+
parentEditor.update(() => {
|
|
117
|
+
lexicalNode.setMeta(meta);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
children
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
function useCodeBlockEditorContext() {
|
|
126
|
+
const context = React__default.useContext(CodeBlockEditorContext);
|
|
127
|
+
if (!context) {
|
|
128
|
+
throw new Error("useCodeBlockEditor must be used within a CodeBlockEditor");
|
|
129
|
+
}
|
|
130
|
+
return context;
|
|
131
|
+
}
|
|
132
|
+
function CodeBlockEditorContainer(props) {
|
|
133
|
+
const [codeBlockEditorDescriptors] = codeBlockPluginHooks.useEmitterValues("codeBlockEditorDescriptors");
|
|
134
|
+
const descriptor = codeBlockEditorDescriptors.sort((a, b) => b.priority - a.priority).find((descriptor2) => descriptor2.match(props.language || "", props.meta || ""));
|
|
135
|
+
if (!descriptor) {
|
|
136
|
+
throw new Error(`No CodeBlockEditor registered for language=${props.language} meta=${props.meta}`);
|
|
137
|
+
}
|
|
138
|
+
const Editor = descriptor.Editor;
|
|
139
|
+
const { codeBlockNode: _, parentEditor: __, ...restProps } = props;
|
|
140
|
+
return /* @__PURE__ */ React__default.createElement(CodeBlockEditorContextProvider, { parentEditor: props.parentEditor, lexicalNode: props.codeBlockNode }, /* @__PURE__ */ React__default.createElement(Editor, { ...restProps }));
|
|
141
|
+
}
|
|
142
|
+
function $createCodeBlockNode(options) {
|
|
143
|
+
const { code = "", language = "", meta = "" } = options;
|
|
144
|
+
return new CodeBlockNode(code, language, meta);
|
|
145
|
+
}
|
|
146
|
+
function $isCodeBlockNode(node) {
|
|
147
|
+
return node instanceof CodeBlockNode;
|
|
148
|
+
}
|
|
149
|
+
export {
|
|
150
|
+
$createCodeBlockNode,
|
|
151
|
+
$isCodeBlockNode,
|
|
152
|
+
CodeBlockEditorContainer,
|
|
153
|
+
CodeBlockNode,
|
|
154
|
+
useCodeBlockEditorContext
|
|
155
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { $isCodeBlockNode } from "./CodeBlockNode.js";
|
|
2
|
+
const CodeBlockVisitor = {
|
|
3
|
+
testLexicalNode: $isCodeBlockNode,
|
|
4
|
+
visitLexicalNode: ({ lexicalNode, actions }) => {
|
|
5
|
+
actions.addAndStepInto("code", {
|
|
6
|
+
value: lexicalNode.getCode(),
|
|
7
|
+
lang: lexicalNode.getLanguage(),
|
|
8
|
+
meta: lexicalNode.getMeta()
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
CodeBlockVisitor
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { $createCodeBlockNode } from "./CodeBlockNode.js";
|
|
2
|
+
const MdastCodeVisitor = {
|
|
3
|
+
testNode: "code",
|
|
4
|
+
visitNode({ mdastNode, actions }) {
|
|
5
|
+
actions.addAndStepInto(
|
|
6
|
+
$createCodeBlockNode({
|
|
7
|
+
code: mdastNode.value,
|
|
8
|
+
language: mdastNode.lang,
|
|
9
|
+
meta: mdastNode.meta
|
|
10
|
+
})
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
MdastCodeVisitor
|
|
16
|
+
};
|