@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,55 @@
|
|
|
1
|
+
import { coreSystem } from "../core/index.js";
|
|
2
|
+
import { DiffSourceWrapper } from "./DiffSourceWrapper.js";
|
|
3
|
+
import { system } from "../../gurx/realmFactory.js";
|
|
4
|
+
import { realmPlugin } from "../../gurx/react.js";
|
|
5
|
+
const diffSourceSystem = system(
|
|
6
|
+
(r, [{ markdown, setMarkdown }]) => {
|
|
7
|
+
const diffMarkdown = r.node("");
|
|
8
|
+
const markdownSourceEditorValue = r.node("");
|
|
9
|
+
r.link(markdown, markdownSourceEditorValue);
|
|
10
|
+
const viewMode = r.node("rich-text");
|
|
11
|
+
r.sub(
|
|
12
|
+
r.pipe(
|
|
13
|
+
viewMode,
|
|
14
|
+
r.o.scan(
|
|
15
|
+
(prev, next) => {
|
|
16
|
+
return {
|
|
17
|
+
current: prev.next,
|
|
18
|
+
next
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
{ current: "rich-text", next: "rich-text" }
|
|
22
|
+
),
|
|
23
|
+
r.o.withLatestFrom(markdownSourceEditorValue)
|
|
24
|
+
),
|
|
25
|
+
([{ current }, markdownSourceFromEditor]) => {
|
|
26
|
+
if (current === "source") {
|
|
27
|
+
r.pub(setMarkdown, markdownSourceFromEditor);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
return { viewMode, diffMarkdown, markdownSourceEditorValue };
|
|
32
|
+
},
|
|
33
|
+
[coreSystem]
|
|
34
|
+
);
|
|
35
|
+
const [
|
|
36
|
+
/** @internal */
|
|
37
|
+
diffSourcePlugin,
|
|
38
|
+
/** @internal */
|
|
39
|
+
diffSourcePluginHooks
|
|
40
|
+
] = realmPlugin({
|
|
41
|
+
id: "diff-source",
|
|
42
|
+
systemSpec: diffSourceSystem,
|
|
43
|
+
applyParamsToSystem(r, params) {
|
|
44
|
+
r.pubKey("viewMode", (params == null ? void 0 : params.viewMode) || "rich-text");
|
|
45
|
+
},
|
|
46
|
+
init(r, params) {
|
|
47
|
+
r.pubKey("diffMarkdown", (params == null ? void 0 : params.diffMarkdown) || "");
|
|
48
|
+
r.pubKey("addEditorWrapper", DiffSourceWrapper);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
export {
|
|
52
|
+
diffSourcePlugin,
|
|
53
|
+
diffSourcePluginHooks,
|
|
54
|
+
diffSourceSystem
|
|
55
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
3
|
+
import { DecoratorNode } from 'lexical';
|
|
4
|
+
import { Directive } from 'mdast-util-directive';
|
|
5
|
+
import { VoidEmitter } from '../../utils/voidEmitter';
|
|
6
|
+
/**
|
|
7
|
+
* A serialized representation of an {@link DirectiveNode}.
|
|
8
|
+
*/
|
|
9
|
+
export type SerializedDirectiveNode = Spread<{
|
|
10
|
+
mdastNode: Directive;
|
|
11
|
+
type: 'directive';
|
|
12
|
+
version: 1;
|
|
13
|
+
}, SerializedLexicalNode>;
|
|
14
|
+
/**
|
|
15
|
+
* A lexical node that represents an image. Use {@link "$createDirectiveNode"} to construct one.
|
|
16
|
+
*/
|
|
17
|
+
export declare class DirectiveNode extends DecoratorNode<React.JSX.Element> {
|
|
18
|
+
__mdastNode: Directive;
|
|
19
|
+
__focusEmitter: {
|
|
20
|
+
publish: () => void;
|
|
21
|
+
subscribe: (cb: () => void) => void;
|
|
22
|
+
};
|
|
23
|
+
static getType(): string;
|
|
24
|
+
static clone(node: DirectiveNode): DirectiveNode;
|
|
25
|
+
static importJSON(serializedNode: SerializedDirectiveNode): DirectiveNode;
|
|
26
|
+
constructor(mdastNode: Directive, key?: NodeKey);
|
|
27
|
+
getMdastNode(): Directive;
|
|
28
|
+
exportJSON(): SerializedDirectiveNode;
|
|
29
|
+
createDOM(): HTMLElement;
|
|
30
|
+
updateDOM(): false;
|
|
31
|
+
setMdastNode(mdastNode: Directive): void;
|
|
32
|
+
select: () => void;
|
|
33
|
+
decorate(parentEditor: LexicalEditor, config: EditorConfig): JSX.Element;
|
|
34
|
+
isInline(): boolean;
|
|
35
|
+
isKeyboardSelectable(): boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare function DirectiveEditorContainer(props: {
|
|
38
|
+
parentEditor: LexicalEditor;
|
|
39
|
+
lexicalNode: DirectiveNode;
|
|
40
|
+
mdastNode: Directive;
|
|
41
|
+
config: EditorConfig;
|
|
42
|
+
focusEmitter: VoidEmitter;
|
|
43
|
+
}): React.JSX.Element;
|
|
44
|
+
/**
|
|
45
|
+
* Creates an {@link DirectiveNode}.
|
|
46
|
+
*/
|
|
47
|
+
export declare function $createDirectiveNode(mdastNode: Directive, key?: NodeKey): DirectiveNode;
|
|
48
|
+
/**
|
|
49
|
+
* Retruns true if the node is an {@link DirectiveNode}.
|
|
50
|
+
*/
|
|
51
|
+
export declare function $isDirectiveNode(node: LexicalNode | null | undefined): node is DirectiveNode;
|
|
@@ -0,0 +1,92 @@
|
|
|
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 { NestedEditorsContext } from "../core/NestedLexicalEditor.js";
|
|
10
|
+
import { directivesPluginHooks } from "./index.js";
|
|
11
|
+
import { voidEmitter } from "../../utils/voidEmitter.js";
|
|
12
|
+
let GENERATION = 0;
|
|
13
|
+
class DirectiveNode extends DecoratorNode {
|
|
14
|
+
constructor(mdastNode, key) {
|
|
15
|
+
super(key);
|
|
16
|
+
__publicField(this, "__mdastNode");
|
|
17
|
+
__publicField(this, "__focusEmitter", voidEmitter());
|
|
18
|
+
__publicField(this, "select", () => {
|
|
19
|
+
this.__focusEmitter.publish();
|
|
20
|
+
});
|
|
21
|
+
this.__mdastNode = mdastNode;
|
|
22
|
+
this.generation = GENERATION++;
|
|
23
|
+
}
|
|
24
|
+
static getType() {
|
|
25
|
+
return "directive";
|
|
26
|
+
}
|
|
27
|
+
static clone(node) {
|
|
28
|
+
return new DirectiveNode(structuredClone(node.__mdastNode), node.__key);
|
|
29
|
+
}
|
|
30
|
+
static importJSON(serializedNode) {
|
|
31
|
+
return $createDirectiveNode(serializedNode.mdastNode);
|
|
32
|
+
}
|
|
33
|
+
getMdastNode() {
|
|
34
|
+
return this.__mdastNode;
|
|
35
|
+
}
|
|
36
|
+
exportJSON() {
|
|
37
|
+
return {
|
|
38
|
+
mdastNode: structuredClone(this.__mdastNode),
|
|
39
|
+
type: "directive",
|
|
40
|
+
version: 1
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
createDOM() {
|
|
44
|
+
return document.createElement(this.__mdastNode.type === "textDirective" ? "span" : "div");
|
|
45
|
+
}
|
|
46
|
+
updateDOM() {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
setMdastNode(mdastNode) {
|
|
50
|
+
this.getWritable().__mdastNode = mdastNode;
|
|
51
|
+
}
|
|
52
|
+
decorate(parentEditor, config) {
|
|
53
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
54
|
+
DirectiveEditorContainer,
|
|
55
|
+
{
|
|
56
|
+
lexicalNode: this,
|
|
57
|
+
mdastNode: this.getMdastNode(),
|
|
58
|
+
parentEditor,
|
|
59
|
+
config,
|
|
60
|
+
focusEmitter: this.__focusEmitter
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
isInline() {
|
|
65
|
+
return this.__mdastNode.type === "textDirective";
|
|
66
|
+
}
|
|
67
|
+
isKeyboardSelectable() {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function DirectiveEditorContainer(props) {
|
|
72
|
+
const { mdastNode } = props;
|
|
73
|
+
const [directiveDescriptors] = directivesPluginHooks.useEmitterValues("directiveDescriptors");
|
|
74
|
+
const descriptor = directiveDescriptors.find((descriptor2) => descriptor2.testNode(mdastNode));
|
|
75
|
+
if (!descriptor) {
|
|
76
|
+
throw new Error(`No descriptor found for directive ${mdastNode.name}`);
|
|
77
|
+
}
|
|
78
|
+
const Editor = descriptor.Editor;
|
|
79
|
+
return /* @__PURE__ */ React__default.createElement(NestedEditorsContext.Provider, { value: props }, /* @__PURE__ */ React__default.createElement(Editor, { descriptor, mdastNode, lexicalNode: props.lexicalNode, parentEditor: props.parentEditor }));
|
|
80
|
+
}
|
|
81
|
+
function $createDirectiveNode(mdastNode, key) {
|
|
82
|
+
return new DirectiveNode(mdastNode, key);
|
|
83
|
+
}
|
|
84
|
+
function $isDirectiveNode(node) {
|
|
85
|
+
return node instanceof DirectiveNode;
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
$createDirectiveNode,
|
|
89
|
+
$isDirectiveNode,
|
|
90
|
+
DirectiveEditorContainer,
|
|
91
|
+
DirectiveNode
|
|
92
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { $isDirectiveNode } from "./DirectiveNode.js";
|
|
2
|
+
const DirectiveVisitor = {
|
|
3
|
+
testLexicalNode: $isDirectiveNode,
|
|
4
|
+
visitLexicalNode({ actions, mdastParent, lexicalNode }) {
|
|
5
|
+
actions.appendToParent(mdastParent, lexicalNode.getMdastNode());
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
DirectiveVisitor
|
|
10
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { $createDirectiveNode } from "./DirectiveNode.js";
|
|
2
|
+
const DIRECTIVE_TYPES = ["leafDirective", "containerDirective", "textDirective"];
|
|
3
|
+
const MdastDirectiveVisitor = {
|
|
4
|
+
testNode: (node) => {
|
|
5
|
+
return DIRECTIVE_TYPES.includes(node.type);
|
|
6
|
+
},
|
|
7
|
+
visitNode({ lexicalParent, mdastNode }) {
|
|
8
|
+
lexicalParent.append($createDirectiveNode(mdastNode));
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
MdastDirectiveVisitor
|
|
13
|
+
};
|