@mdxeditor/editor 0.9.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/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 -1094
- package/dist/index.js +133 -72
- 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-ad505654.js → plugins/image/ImageEditor.js} +12 -47
- 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-177e9901.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-44bef804.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-ce4c85ed.js +0 -79
- package/dist/CodeBlockEditor-ed222322.cjs +0 -1
- package/dist/FrontmatterEditor-914aa241.cjs +0 -1
- package/dist/FrontmatterEditor-e2f25a6a.js +0 -118
- package/dist/ImageEditor-c4e65554.cjs +0 -1
- package/dist/JsxEditor-6cff258d.cjs +0 -1
- package/dist/JsxEditor-88d55ef8.js +0 -108
- package/dist/LeafDirectiveEditor-0e1328e6.cjs +0 -1
- package/dist/LeafDirectiveEditor-34ead530.js +0 -59
- package/dist/SandpackEditor-a999ca47.cjs +0 -1
- package/dist/SandpackEditor-b1e22784.js +0 -99
- package/dist/SourceEditor-0c46ec47.cjs +0 -1
- package/dist/SourceEditor-e509d0a5.js +0 -64
- package/dist/TableEditor-ced03ce4.cjs +0 -1
- package/dist/index-21fcefae.cjs +0 -1
- package/dist/index-ce0832cc.js +0 -4361
- package/dist/index.cjs +0 -1
- package/dist/useCodeMirrorRef-6cb866bd.cjs +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { $isHeadingNode } from "@lexical/rich-text";
|
|
2
|
+
const LexicalHeadingVisitor = {
|
|
3
|
+
testLexicalNode: $isHeadingNode,
|
|
4
|
+
visitLexicalNode: ({ lexicalNode, actions }) => {
|
|
5
|
+
const depth = parseInt(lexicalNode.getTag()[1], 10);
|
|
6
|
+
actions.addAndStepInto("heading", { depth });
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
LexicalHeadingVisitor
|
|
11
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { $createHeadingNode } from "@lexical/rich-text";
|
|
2
|
+
const MdastHeadingVisitor = {
|
|
3
|
+
testNode: "heading",
|
|
4
|
+
visitNode: function({ mdastNode, actions }) {
|
|
5
|
+
actions.addAndStepInto($createHeadingNode(`h${mdastNode.depth}`));
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
MdastHeadingVisitor
|
|
10
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare const headingsSystem: import("../../gurx").SystemSpec<[import("../../gurx").SystemSpec<[], (r: import("../../gurx").Realm) => {
|
|
6
|
+
activeEditor: import("../../gurx").RealmNode<import("lexical").LexicalEditor | null>;
|
|
7
|
+
inFocus: import("../../gurx").RealmNode<boolean>;
|
|
8
|
+
historyState: import("../../gurx").RealmNode<import("@lexical/history").HistoryState>;
|
|
9
|
+
currentSelection: import("../../gurx").RealmNode<import("lexical").RangeSelection | null>;
|
|
10
|
+
jsxIsAvailable: import("../../gurx").RealmNode<boolean>;
|
|
11
|
+
jsxComponentDescriptors: import("../../gurx").RealmNode<import("../jsx").JsxComponentDescriptor[]>;
|
|
12
|
+
initialRootEditorState: import("../../gurx").RealmNode<import("@lexical/react/LexicalComposer").InitialEditorStateType>;
|
|
13
|
+
rootEditor: import("../../gurx").RealmNode<import("lexical").LexicalEditor | null>;
|
|
14
|
+
createRootEditorSubscription: import("../../gurx").RealmNode<import("../core").EditorSubscription>;
|
|
15
|
+
createActiveEditorSubscription: import("../../gurx").RealmNode<import("../core").EditorSubscription>;
|
|
16
|
+
importVisitors: import("../../gurx").RealmNode<import("../../importMarkdownToLexical").MdastImportVisitor<import("mdast").Content>[]>;
|
|
17
|
+
syntaxExtensions: import("../../gurx").RealmNode<import("micromark-util-types").Extension[]>;
|
|
18
|
+
mdastExtensions: import("../../gurx").RealmNode<(Partial<import("mdast-util-from-markdown/lib").Config> | Partial<import("mdast-util-from-markdown/lib").Config>[])[] | null | undefined>;
|
|
19
|
+
usedLexicalNodes: import("../../gurx").RealmNode<import("lexical").Klass<import("lexical").LexicalNode>[]>;
|
|
20
|
+
addImportVisitor: import("../../gurx").RealmNode<import("../../importMarkdownToLexical").MdastImportVisitor<import("mdast").Content>>;
|
|
21
|
+
addLexicalNode: import("../../gurx").RealmNode<import("lexical").Klass<import("lexical").LexicalNode>>;
|
|
22
|
+
addSyntaxExtension: import("../../gurx").RealmNode<import("micromark-util-types").Extension>;
|
|
23
|
+
addMdastExtension: import("../../gurx").RealmNode<Partial<import("mdast-util-from-markdown/lib").Config> | Partial<import("mdast-util-from-markdown/lib").Config>[]>;
|
|
24
|
+
toMarkdownExtensions: import("../../gurx").RealmNode<import("mdast-util-to-markdown").Options[]>;
|
|
25
|
+
toMarkdownOptions: import("../../gurx").RealmNode<import("mdast-util-to-markdown").Options>;
|
|
26
|
+
addToMarkdownExtension: import("../../gurx").RealmNode<import("mdast-util-to-markdown").Options>;
|
|
27
|
+
addExportVisitor: import("../../gurx").RealmNode<import("../../exportMarkdownFromLexical").LexicalVisitor>;
|
|
28
|
+
exportVisitors: import("../../gurx").RealmNode<import("../../exportMarkdownFromLexical").LexicalVisitor[]>;
|
|
29
|
+
initialMarkdown: import("../../gurx").RealmNode<string>;
|
|
30
|
+
setMarkdown: import("../../gurx").RealmNode<string>;
|
|
31
|
+
markdown: import("../../gurx").RealmNode<string>;
|
|
32
|
+
editorRootElementRef: import("../../gurx").RealmNode<import("react").RefObject<HTMLDivElement> | null>;
|
|
33
|
+
contentEditableClassName: import("../../gurx").RealmNode<string>;
|
|
34
|
+
composerChildren: import("../../gurx").RealmNode<import("react").ComponentType<{}>[]>;
|
|
35
|
+
addComposerChild: import("../../gurx").RealmNode<import("react").ComponentType<{}>>;
|
|
36
|
+
topAreaChildren: import("../../gurx").RealmNode<import("react").ComponentType<{}>[]>;
|
|
37
|
+
addTopAreaChild: import("../../gurx").RealmNode<import("react").ComponentType<{}>>;
|
|
38
|
+
nestedEditorChildren: import("../../gurx").RealmNode<import("react").ComponentType<{}>[]>;
|
|
39
|
+
addNestedEditorChild: import("../../gurx").RealmNode<import("react").ComponentType<{}>>;
|
|
40
|
+
editorWrappers: import("../../gurx").RealmNode<import("react").ComponentType<{
|
|
41
|
+
children: import("react").ReactNode;
|
|
42
|
+
}>[]>;
|
|
43
|
+
addEditorWrapper: import("../../gurx").RealmNode<import("react").ComponentType<{
|
|
44
|
+
children: import("react").ReactNode;
|
|
45
|
+
}>>;
|
|
46
|
+
currentFormat: import("../../gurx").RealmNode<number>;
|
|
47
|
+
editorInFocus: import("../../gurx").RealmNode<import("../core").EditorInFocus | null>;
|
|
48
|
+
applyFormat: import("../../gurx").RealmNode<import("lexical").TextFormatType>;
|
|
49
|
+
currentBlockType: import("../../gurx").RealmNode<import("../core").BlockType>;
|
|
50
|
+
applyBlockType: import("../../gurx").RealmNode<import("../core").BlockType>;
|
|
51
|
+
convertSelectionToNode: import("../../gurx").RealmNode<() => import("lexical").ElementNode>;
|
|
52
|
+
insertDecoratorNode: import("../../gurx").RealmNode<() => import("lexical").DecoratorNode<unknown>>;
|
|
53
|
+
}>], (_: import("../../gurx").Realm) => {}>;
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
export declare const headingsPlugin: import("../../gurx").PluginConstructor<import("../../gurx").SystemSpec<[import("../../gurx").SystemSpec<[], (r: import("../../gurx").Realm) => {
|
|
58
|
+
activeEditor: import("../../gurx").RealmNode<import("lexical").LexicalEditor | null>;
|
|
59
|
+
inFocus: import("../../gurx").RealmNode<boolean>;
|
|
60
|
+
historyState: import("../../gurx").RealmNode<import("@lexical/history").HistoryState>;
|
|
61
|
+
currentSelection: import("../../gurx").RealmNode<import("lexical").RangeSelection | null>;
|
|
62
|
+
jsxIsAvailable: import("../../gurx").RealmNode<boolean>;
|
|
63
|
+
jsxComponentDescriptors: import("../../gurx").RealmNode<import("../jsx").JsxComponentDescriptor[]>;
|
|
64
|
+
initialRootEditorState: import("../../gurx").RealmNode<import("@lexical/react/LexicalComposer").InitialEditorStateType>;
|
|
65
|
+
rootEditor: import("../../gurx").RealmNode<import("lexical").LexicalEditor | null>;
|
|
66
|
+
createRootEditorSubscription: import("../../gurx").RealmNode<import("../core").EditorSubscription>;
|
|
67
|
+
createActiveEditorSubscription: import("../../gurx").RealmNode<import("../core").EditorSubscription>;
|
|
68
|
+
importVisitors: import("../../gurx").RealmNode<import("../../importMarkdownToLexical").MdastImportVisitor<import("mdast").Content>[]>;
|
|
69
|
+
syntaxExtensions: import("../../gurx").RealmNode<import("micromark-util-types").Extension[]>;
|
|
70
|
+
mdastExtensions: import("../../gurx").RealmNode<(Partial<import("mdast-util-from-markdown/lib").Config> | Partial<import("mdast-util-from-markdown/lib").Config>[])[] | null | undefined>;
|
|
71
|
+
usedLexicalNodes: import("../../gurx").RealmNode<import("lexical").Klass<import("lexical").LexicalNode>[]>;
|
|
72
|
+
addImportVisitor: import("../../gurx").RealmNode<import("../../importMarkdownToLexical").MdastImportVisitor<import("mdast").Content>>;
|
|
73
|
+
addLexicalNode: import("../../gurx").RealmNode<import("lexical").Klass<import("lexical").LexicalNode>>;
|
|
74
|
+
addSyntaxExtension: import("../../gurx").RealmNode<import("micromark-util-types").Extension>;
|
|
75
|
+
addMdastExtension: import("../../gurx").RealmNode<Partial<import("mdast-util-from-markdown/lib").Config> | Partial<import("mdast-util-from-markdown/lib").Config>[]>;
|
|
76
|
+
toMarkdownExtensions: import("../../gurx").RealmNode<import("mdast-util-to-markdown").Options[]>;
|
|
77
|
+
toMarkdownOptions: import("../../gurx").RealmNode<import("mdast-util-to-markdown").Options>;
|
|
78
|
+
addToMarkdownExtension: import("../../gurx").RealmNode<import("mdast-util-to-markdown").Options>;
|
|
79
|
+
addExportVisitor: import("../../gurx").RealmNode<import("../../exportMarkdownFromLexical").LexicalVisitor>;
|
|
80
|
+
exportVisitors: import("../../gurx").RealmNode<import("../../exportMarkdownFromLexical").LexicalVisitor[]>;
|
|
81
|
+
initialMarkdown: import("../../gurx").RealmNode<string>;
|
|
82
|
+
setMarkdown: import("../../gurx").RealmNode<string>;
|
|
83
|
+
markdown: import("../../gurx").RealmNode<string>;
|
|
84
|
+
editorRootElementRef: import("../../gurx").RealmNode<import("react").RefObject<HTMLDivElement> | null>;
|
|
85
|
+
contentEditableClassName: import("../../gurx").RealmNode<string>;
|
|
86
|
+
composerChildren: import("../../gurx").RealmNode<import("react").ComponentType<{}>[]>;
|
|
87
|
+
addComposerChild: import("../../gurx").RealmNode<import("react").ComponentType<{}>>;
|
|
88
|
+
topAreaChildren: import("../../gurx").RealmNode<import("react").ComponentType<{}>[]>;
|
|
89
|
+
addTopAreaChild: import("../../gurx").RealmNode<import("react").ComponentType<{}>>;
|
|
90
|
+
nestedEditorChildren: import("../../gurx").RealmNode<import("react").ComponentType<{}>[]>;
|
|
91
|
+
addNestedEditorChild: import("../../gurx").RealmNode<import("react").ComponentType<{}>>;
|
|
92
|
+
editorWrappers: import("../../gurx").RealmNode<import("react").ComponentType<{
|
|
93
|
+
children: import("react").ReactNode;
|
|
94
|
+
}>[]>;
|
|
95
|
+
addEditorWrapper: import("../../gurx").RealmNode<import("react").ComponentType<{
|
|
96
|
+
children: import("react").ReactNode;
|
|
97
|
+
}>>;
|
|
98
|
+
currentFormat: import("../../gurx").RealmNode<number>;
|
|
99
|
+
editorInFocus: import("../../gurx").RealmNode<import("../core").EditorInFocus | null>;
|
|
100
|
+
applyFormat: import("../../gurx").RealmNode<import("lexical").TextFormatType>;
|
|
101
|
+
currentBlockType: import("../../gurx").RealmNode<import("../core").BlockType>;
|
|
102
|
+
applyBlockType: import("../../gurx").RealmNode<import("../core").BlockType>;
|
|
103
|
+
convertSelectionToNode: import("../../gurx").RealmNode<() => import("lexical").ElementNode>;
|
|
104
|
+
insertDecoratorNode: import("../../gurx").RealmNode<() => import("lexical").DecoratorNode<unknown>>;
|
|
105
|
+
}>], (_: import("../../gurx").Realm) => {}>, object>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { coreSystem } from "../core/index.js";
|
|
2
|
+
import { MdastHeadingVisitor } from "./MdastHeadingVisitor.js";
|
|
3
|
+
import { HeadingNode } from "@lexical/rich-text";
|
|
4
|
+
import { LexicalHeadingVisitor } from "./LexicalHeadingVisitor.js";
|
|
5
|
+
import { system } from "../../gurx/realmFactory.js";
|
|
6
|
+
import { realmPlugin } from "../../gurx/react.js";
|
|
7
|
+
const headingsSystem = system((_) => ({}), [coreSystem]);
|
|
8
|
+
const [headingsPlugin] = realmPlugin({
|
|
9
|
+
id: "headings",
|
|
10
|
+
systemSpec: headingsSystem,
|
|
11
|
+
init: (realm) => {
|
|
12
|
+
realm.pubKey("addImportVisitor", MdastHeadingVisitor);
|
|
13
|
+
realm.pubKey("addLexicalNode", HeadingNode);
|
|
14
|
+
realm.pubKey("addExportVisitor", LexicalHeadingVisitor);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
headingsPlugin,
|
|
19
|
+
headingsSystem
|
|
20
|
+
};
|
|
@@ -1,46 +1,11 @@
|
|
|
1
|
-
import React__default
|
|
1
|
+
import React__default from "react";
|
|
2
2
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
3
3
|
import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection";
|
|
4
4
|
import { mergeRegister } from "@lexical/utils";
|
|
5
5
|
import { $isNodeSelection, $getSelection, $getNodeByKey, $setSelection, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_LOW, CLICK_COMMAND, DRAGSTART_COMMAND, KEY_DELETE_COMMAND, KEY_BACKSPACE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND } from "lexical";
|
|
6
|
-
import
|
|
6
|
+
import styles from "../../styles/ui.module.css.js";
|
|
7
7
|
import classNames from "classnames";
|
|
8
|
-
import "
|
|
9
|
-
import "@lexical/react/LexicalContentEditable";
|
|
10
|
-
import "@lexical/react/LexicalErrorBoundary";
|
|
11
|
-
import "@lexical/react/LexicalHorizontalRulePlugin";
|
|
12
|
-
import "@lexical/react/LexicalLinkPlugin";
|
|
13
|
-
import "@lexical/react/LexicalListPlugin";
|
|
14
|
-
import "@lexical/react/LexicalRichTextPlugin";
|
|
15
|
-
import "@lexical/react/LexicalTabIndentationPlugin";
|
|
16
|
-
import "@lexical/code";
|
|
17
|
-
import "@lexical/link";
|
|
18
|
-
import "@lexical/list";
|
|
19
|
-
import "@lexical/react/LexicalHorizontalRuleNode";
|
|
20
|
-
import "@lexical/rich-text";
|
|
21
|
-
import "mdast-util-directive";
|
|
22
|
-
import "mdast-util-from-markdown";
|
|
23
|
-
import "mdast-util-frontmatter";
|
|
24
|
-
import "mdast-util-gfm-table";
|
|
25
|
-
import "mdast-util-mdx";
|
|
26
|
-
import "micromark-extension-directive";
|
|
27
|
-
import "micromark-extension-frontmatter";
|
|
28
|
-
import "micromark-extension-gfm-table";
|
|
29
|
-
import "micromark-extension-mdxjs";
|
|
30
|
-
import "@lexical/selection";
|
|
31
|
-
import "@lexical/react/LexicalHistoryPlugin";
|
|
32
|
-
import "mdast-util-to-markdown";
|
|
33
|
-
import "@radix-ui/react-popover";
|
|
34
|
-
import "@radix-ui/react-tooltip";
|
|
35
|
-
import "downshift";
|
|
36
|
-
import "@lexical/markdown";
|
|
37
|
-
import "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
38
|
-
import "react-diff-view";
|
|
39
|
-
import "unidiff";
|
|
40
|
-
import "@radix-ui/react-toolbar";
|
|
41
|
-
import "@radix-ui/react-select";
|
|
42
|
-
import "@radix-ui/react-dialog";
|
|
43
|
-
import "@lexical/react/LexicalNestedComposer";
|
|
8
|
+
import { $isImageNode } from "./ImageNode.js";
|
|
44
9
|
const imageCache = /* @__PURE__ */ new Set();
|
|
45
10
|
function useSuspenseImage(src) {
|
|
46
11
|
if (!imageCache.has(src)) {
|
|
@@ -64,13 +29,13 @@ function LazyImage({
|
|
|
64
29
|
return /* @__PURE__ */ React__default.createElement("img", { className: className || void 0, src, title, ref: imageRef, draggable: "false" });
|
|
65
30
|
}
|
|
66
31
|
function ImageEditor({ src, title, nodeKey }) {
|
|
67
|
-
const imageRef = useRef(null);
|
|
68
|
-
const buttonRef = useRef(null);
|
|
32
|
+
const imageRef = React__default.useRef(null);
|
|
33
|
+
const buttonRef = React__default.useRef(null);
|
|
69
34
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
70
35
|
const [editor] = useLexicalComposerContext();
|
|
71
|
-
const [selection, setSelection] = useState(null);
|
|
72
|
-
const activeEditorRef = useRef(null);
|
|
73
|
-
const onDelete = useCallback(
|
|
36
|
+
const [selection, setSelection] = React__default.useState(null);
|
|
37
|
+
const activeEditorRef = React__default.useRef(null);
|
|
38
|
+
const onDelete = React__default.useCallback(
|
|
74
39
|
(payload) => {
|
|
75
40
|
if (isSelected && $isNodeSelection($getSelection())) {
|
|
76
41
|
const event = payload;
|
|
@@ -84,7 +49,7 @@ function ImageEditor({ src, title, nodeKey }) {
|
|
|
84
49
|
},
|
|
85
50
|
[isSelected, nodeKey]
|
|
86
51
|
);
|
|
87
|
-
const onEnter = useCallback(
|
|
52
|
+
const onEnter = React__default.useCallback(
|
|
88
53
|
(event) => {
|
|
89
54
|
const latestSelection = $getSelection();
|
|
90
55
|
const buttonElem = buttonRef.current;
|
|
@@ -99,7 +64,7 @@ function ImageEditor({ src, title, nodeKey }) {
|
|
|
99
64
|
},
|
|
100
65
|
[isSelected]
|
|
101
66
|
);
|
|
102
|
-
const onEscape = useCallback(
|
|
67
|
+
const onEscape = React__default.useCallback(
|
|
103
68
|
(event) => {
|
|
104
69
|
if (buttonRef.current === event.target) {
|
|
105
70
|
$setSelection(null);
|
|
@@ -116,7 +81,7 @@ function ImageEditor({ src, title, nodeKey }) {
|
|
|
116
81
|
},
|
|
117
82
|
[editor, setSelected]
|
|
118
83
|
);
|
|
119
|
-
useEffect(() => {
|
|
84
|
+
React__default.useEffect(() => {
|
|
120
85
|
let isMounted = true;
|
|
121
86
|
const unregister = mergeRegister(
|
|
122
87
|
editor.registerUpdateListener(({ editorState }) => {
|
|
@@ -172,7 +137,7 @@ function ImageEditor({ src, title, nodeKey }) {
|
|
|
172
137
|
}, [clearSelection, editor, isSelected, nodeKey, onDelete, onEnter, onEscape, setSelected]);
|
|
173
138
|
const draggable = $isNodeSelection(selection);
|
|
174
139
|
const isFocused = isSelected;
|
|
175
|
-
return /* @__PURE__ */ React__default.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { draggable, className: styles.imageWrapper, "data-editor-block-type": "image" }, /* @__PURE__ */ React__default.createElement(
|
|
140
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: null }, /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { draggable, className: styles.imageWrapper, "data-editor-block-type": "image" }, /* @__PURE__ */ React__default.createElement(
|
|
176
141
|
LazyImage,
|
|
177
142
|
{
|
|
178
143
|
className: classNames({
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
3
|
+
import { DecoratorNode } from 'lexical';
|
|
4
|
+
/**
|
|
5
|
+
* A serialized representation of an {@link ImageNode}.
|
|
6
|
+
*/
|
|
7
|
+
export type SerializedImageNode = Spread<{
|
|
8
|
+
altText: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
src: string;
|
|
11
|
+
type: 'image';
|
|
12
|
+
version: 1;
|
|
13
|
+
}, SerializedLexicalNode>;
|
|
14
|
+
/**
|
|
15
|
+
* A lexical node that represents an image. Use {@link "$createImageNode"} to construct one.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ImageNode extends DecoratorNode<JSX.Element> {
|
|
18
|
+
__src: string;
|
|
19
|
+
__altText: string;
|
|
20
|
+
__title: string | undefined;
|
|
21
|
+
static getType(): string;
|
|
22
|
+
static clone(node: ImageNode): ImageNode;
|
|
23
|
+
static importJSON(serializedNode: SerializedImageNode): ImageNode;
|
|
24
|
+
exportDOM(): DOMExportOutput;
|
|
25
|
+
static importDOM(): DOMConversionMap | null;
|
|
26
|
+
constructor(src: string, altText: string, title: string | undefined, key?: NodeKey);
|
|
27
|
+
exportJSON(): SerializedImageNode;
|
|
28
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
29
|
+
updateDOM(): false;
|
|
30
|
+
getSrc(): string;
|
|
31
|
+
getAltText(): string;
|
|
32
|
+
getTitle(): string | undefined;
|
|
33
|
+
setTitle(title: string | undefined): void;
|
|
34
|
+
decorate(_parentEditor: LexicalEditor): JSX.Element;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The payload to create an {@link ImageNode}.
|
|
38
|
+
*/
|
|
39
|
+
export interface CreateImageNodeOptions {
|
|
40
|
+
altText: string;
|
|
41
|
+
title?: string;
|
|
42
|
+
key?: NodeKey;
|
|
43
|
+
src: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates an {@link ImageNode}.
|
|
47
|
+
* @param options - The payload to create an image. The keys map to the img tag attributes.
|
|
48
|
+
*/
|
|
49
|
+
export declare function $createImageNode(options: CreateImageNodeOptions): ImageNode;
|
|
50
|
+
/**
|
|
51
|
+
* Retruns true if the node is an {@link ImageNode}.
|
|
52
|
+
*/
|
|
53
|
+
export declare function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode;
|
|
@@ -0,0 +1,108 @@
|
|
|
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 { ImageEditor } from "./ImageEditor.js";
|
|
10
|
+
function convertImageElement(domNode) {
|
|
11
|
+
if (domNode instanceof HTMLImageElement) {
|
|
12
|
+
const { alt: altText, src, title } = domNode;
|
|
13
|
+
const node = $createImageNode({ altText, src, title });
|
|
14
|
+
return { node };
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
class ImageNode extends DecoratorNode {
|
|
19
|
+
constructor(src, altText, title, key) {
|
|
20
|
+
super(key);
|
|
21
|
+
__publicField(this, "__src");
|
|
22
|
+
__publicField(this, "__altText");
|
|
23
|
+
__publicField(this, "__title");
|
|
24
|
+
this.__src = src;
|
|
25
|
+
this.__title = title;
|
|
26
|
+
this.__altText = altText;
|
|
27
|
+
}
|
|
28
|
+
static getType() {
|
|
29
|
+
return "image";
|
|
30
|
+
}
|
|
31
|
+
static clone(node) {
|
|
32
|
+
return new ImageNode(node.__src, node.__altText, node.__title, node.__key);
|
|
33
|
+
}
|
|
34
|
+
static importJSON(serializedNode) {
|
|
35
|
+
const { altText, title, src } = serializedNode;
|
|
36
|
+
const node = $createImageNode({
|
|
37
|
+
altText,
|
|
38
|
+
title,
|
|
39
|
+
src
|
|
40
|
+
});
|
|
41
|
+
return node;
|
|
42
|
+
}
|
|
43
|
+
exportDOM() {
|
|
44
|
+
const element = document.createElement("img");
|
|
45
|
+
element.setAttribute("src", this.__src);
|
|
46
|
+
element.setAttribute("alt", this.__altText);
|
|
47
|
+
if (this.__title) {
|
|
48
|
+
element.setAttribute("title", this.__title);
|
|
49
|
+
}
|
|
50
|
+
return { element };
|
|
51
|
+
}
|
|
52
|
+
static importDOM() {
|
|
53
|
+
return {
|
|
54
|
+
img: () => ({
|
|
55
|
+
conversion: convertImageElement,
|
|
56
|
+
priority: 0
|
|
57
|
+
})
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
exportJSON() {
|
|
61
|
+
return {
|
|
62
|
+
altText: this.getAltText(),
|
|
63
|
+
title: this.getTitle(),
|
|
64
|
+
src: this.getSrc(),
|
|
65
|
+
type: "image",
|
|
66
|
+
version: 1
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
createDOM(config) {
|
|
70
|
+
const span = document.createElement("span");
|
|
71
|
+
const theme = config.theme;
|
|
72
|
+
const className = theme.image;
|
|
73
|
+
if (className !== void 0) {
|
|
74
|
+
span.className = className;
|
|
75
|
+
}
|
|
76
|
+
return span;
|
|
77
|
+
}
|
|
78
|
+
updateDOM() {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
getSrc() {
|
|
82
|
+
return this.__src;
|
|
83
|
+
}
|
|
84
|
+
getAltText() {
|
|
85
|
+
return this.__altText;
|
|
86
|
+
}
|
|
87
|
+
getTitle() {
|
|
88
|
+
return this.__title;
|
|
89
|
+
}
|
|
90
|
+
setTitle(title) {
|
|
91
|
+
this.getWritable().__title = title;
|
|
92
|
+
}
|
|
93
|
+
decorate(_parentEditor) {
|
|
94
|
+
return /* @__PURE__ */ React__default.createElement(ImageEditor, { src: this.getSrc(), title: this.getTitle(), nodeKey: this.getKey() });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function $createImageNode(options) {
|
|
98
|
+
const { altText, title, src, key } = options;
|
|
99
|
+
return new ImageNode(src, altText, title, key);
|
|
100
|
+
}
|
|
101
|
+
function $isImageNode(node) {
|
|
102
|
+
return node instanceof ImageNode;
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
$createImageNode,
|
|
106
|
+
$isImageNode,
|
|
107
|
+
ImageNode
|
|
108
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { $isImageNode } from "./ImageNode.js";
|
|
2
|
+
const LexicalImageVisitor = {
|
|
3
|
+
testLexicalNode: $isImageNode,
|
|
4
|
+
visitLexicalNode({ mdastParent, lexicalNode, actions }) {
|
|
5
|
+
actions.appendToParent(mdastParent, {
|
|
6
|
+
type: "image",
|
|
7
|
+
url: lexicalNode.getSrc(),
|
|
8
|
+
alt: lexicalNode.getAltText(),
|
|
9
|
+
title: lexicalNode.getTitle()
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
LexicalImageVisitor
|
|
15
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { $createImageNode } from "./ImageNode.js";
|
|
2
|
+
const MdastImageVisitor = {
|
|
3
|
+
testNode: "image",
|
|
4
|
+
visitNode({ mdastNode, actions }) {
|
|
5
|
+
actions.addAndStepInto(
|
|
6
|
+
$createImageNode({
|
|
7
|
+
src: mdastNode.url,
|
|
8
|
+
altText: mdastNode.alt || "",
|
|
9
|
+
title: mdastNode.title || ""
|
|
10
|
+
})
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
MdastImageVisitor
|
|
16
|
+
};
|