@mdxeditor/editor 0.0.0-development
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/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/FormatConstants.d.ts +9 -0
- package/dist/FormatConstants.js +10 -0
- package/dist/MDXEditor.d.ts +92 -0
- package/dist/MDXEditor.js +142 -0
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +17 -0
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.js +28 -0
- package/dist/directive-editors/GenericDirectiveEditor.d.ts +8 -0
- package/dist/directive-editors/GenericDirectiveEditor.js +32 -0
- package/dist/exportMarkdownFromLexical.d.ts +133 -0
- package/dist/exportMarkdownFromLexical.js +202 -0
- package/dist/gurx/index.d.ts +3 -0
- package/dist/gurx/react.d.ts +152 -0
- package/dist/gurx/react.js +206 -0
- package/dist/gurx/realm.d.ts +148 -0
- package/dist/gurx/realm.js +489 -0
- package/dist/gurx/realmFactory.d.ts +79 -0
- package/dist/gurx/realmFactory.js +32 -0
- package/dist/icons/add_column.svg.js +5 -0
- package/dist/icons/add_photo.svg.js +5 -0
- package/dist/icons/add_row.svg.js +5 -0
- package/dist/icons/admonition.svg.js +5 -0
- package/dist/icons/arrow_drop_down.svg.js +5 -0
- package/dist/icons/check.svg.js +5 -0
- package/dist/icons/check_small.svg.js +5 -0
- package/dist/icons/close.svg.js +5 -0
- package/dist/icons/code.svg.js +5 -0
- package/dist/icons/code_block.svg.js +5 -0
- package/dist/icons/content_copy.svg.js +5 -0
- package/dist/icons/delete_big.svg.js +5 -0
- package/dist/icons/delete_small.svg.js +5 -0
- package/dist/icons/difference.svg.js +5 -0
- package/dist/icons/edit.svg.js +5 -0
- package/dist/icons/format_align_center.svg.js +5 -0
- package/dist/icons/format_align_left.svg.js +5 -0
- package/dist/icons/format_align_right.svg.js +5 -0
- package/dist/icons/format_bold.svg.js +5 -0
- package/dist/icons/format_italic.svg.js +5 -0
- package/dist/icons/format_list_bulleted.svg.js +7 -0
- package/dist/icons/format_list_checked.svg.js +5 -0
- package/dist/icons/format_list_numbered.svg.js +5 -0
- package/dist/icons/format_underlined.svg.js +5 -0
- package/dist/icons/frontmatter.svg.js +5 -0
- package/dist/icons/horizontal_rule.svg.js +5 -0
- package/dist/icons/insert_col_left.svg.js +5 -0
- package/dist/icons/insert_col_right.svg.js +5 -0
- package/dist/icons/insert_row_above.svg.js +5 -0
- package/dist/icons/insert_row_below.svg.js +5 -0
- package/dist/icons/link.svg.js +5 -0
- package/dist/icons/link_off.svg.js +5 -0
- package/dist/icons/markdown.svg.js +5 -0
- package/dist/icons/more_horiz.svg.js +5 -0
- package/dist/icons/more_vert.svg.js +5 -0
- package/dist/icons/open_in_new.svg.js +5 -0
- package/dist/icons/redo.svg.js +5 -0
- package/dist/icons/rich_text.svg.js +5 -0
- package/dist/icons/sandpack.svg.js +5 -0
- package/dist/icons/settings.svg.js +7 -0
- package/dist/icons/table.svg.js +5 -0
- package/dist/icons/undo.svg.js +5 -0
- package/dist/importMarkdownToLexical.d.ts +91 -0
- package/dist/importMarkdownToLexical.js +69 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +175 -0
- package/dist/jsx-editors/GenericJsxEditor.d.ts +8 -0
- package/dist/jsx-editors/GenericJsxEditor.js +56 -0
- package/dist/plugins/codeblock/CodeBlockNode.d.ts +100 -0
- package/dist/plugins/codeblock/CodeBlockNode.js +158 -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 +697 -0
- package/dist/plugins/codeblock/index.js +73 -0
- package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
- package/dist/plugins/codemirror/CodeMirrorEditor.js +42 -0
- package/dist/plugins/codemirror/index.d.ts +912 -0
- package/dist/plugins/codemirror/index.js +62 -0
- package/dist/plugins/core/Icon.d.ts +6 -0
- package/dist/plugins/core/Icon.js +94 -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/MdastBreakVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastBreakVisitor.js +10 -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 +27 -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 +92 -0
- package/dist/plugins/core/NestedLexicalEditor.js +180 -0
- package/dist/plugins/core/PropertyPopover.d.ts +23 -0
- package/dist/plugins/core/PropertyPopover.js +39 -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 +506 -0
- package/dist/plugins/core/index.js +420 -0
- package/dist/plugins/core/ui/DownshiftAutoComplete.d.ts +15 -0
- package/dist/plugins/core/ui/DownshiftAutoComplete.js +83 -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 +59 -0
- package/dist/plugins/diff-source/SourceEditor.d.ts +4 -0
- package/dist/plugins/diff-source/SourceEditor.js +47 -0
- package/dist/plugins/diff-source/index.d.ts +635 -0
- package/dist/plugins/diff-source/index.js +57 -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 +683 -0
- package/dist/plugins/directives/index.js +53 -0
- package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
- package/dist/plugins/frontmatter/FrontmatterEditor.js +85 -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 +627 -0
- package/dist/plugins/frontmatter/index.js +76 -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 +617 -0
- package/dist/plugins/headings/index.js +69 -0
- package/dist/plugins/image/ImageDialog.d.ts +2 -0
- package/dist/plugins/image/ImageDialog.js +70 -0
- package/dist/plugins/image/ImageEditor.d.ts +10 -0
- package/dist/plugins/image/ImageEditor.js +227 -0
- package/dist/plugins/image/ImageNode.d.ts +65 -0
- package/dist/plugins/image/ImageNode.js +152 -0
- package/dist/plugins/image/ImageResizer.d.ts +18 -0
- package/dist/plugins/image/ImageResizer.js +214 -0
- package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
- package/dist/plugins/image/LexicalImageVisitor.js +35 -0
- package/dist/plugins/image/MdastImageVisitor.d.ts +6 -0
- package/dist/plugins/image/MdastImageVisitor.js +87 -0
- package/dist/plugins/image/index.d.ts +714 -0
- package/dist/plugins/image/index.js +300 -0
- package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
- package/dist/plugins/jsx/LexicalJsxNode.js +102 -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 +688 -0
- package/dist/plugins/jsx/index.js +78 -0
- package/dist/plugins/link/AutoLinkPlugin.d.ts +9 -0
- package/dist/plugins/link/AutoLinkPlugin.js +18 -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 +92 -0
- package/dist/plugins/link/index.js +33 -0
- package/dist/plugins/link-dialog/LinkDialog.d.ts +16 -0
- package/dist/plugins/link-dialog/LinkDialog.js +148 -0
- package/dist/plugins/link-dialog/index.d.ts +595 -0
- package/dist/plugins/link-dialog/index.js +260 -0
- package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
- package/dist/plugins/lists/LexicalListItemVisitor.js +23 -0
- package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
- package/dist/plugins/lists/LexicalListVisitor.js +13 -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 +20 -0
- package/dist/plugins/lists/index.d.ts +613 -0
- package/dist/plugins/lists/index.js +119 -0
- package/dist/plugins/markdown-shortcut/index.d.ts +71 -0
- package/dist/plugins/markdown-shortcut/index.js +90 -0
- package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
- package/dist/plugins/quote/LexicalQuoteVisitor.js +12 -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 +417 -0
- package/dist/plugins/quote/index.js +26 -0
- package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
- package/dist/plugins/sandpack/SandpackEditor.js +37 -0
- package/dist/plugins/sandpack/index.d.ts +951 -0
- package/dist/plugins/sandpack/index.js +93 -0
- package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
- package/dist/plugins/sandpack/useCodeMirrorRef.js +96 -0
- 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/plugins/table/TableEditor.js +388 -0
- package/dist/plugins/table/TableNode.d.ts +52 -0
- package/dist/plugins/table/TableNode.js +152 -0
- package/dist/plugins/table/index.d.ts +614 -0
- package/dist/plugins/table/index.js +69 -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 +603 -0
- package/dist/plugins/thematic-break/index.js +39 -0
- package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +6 -0
- package/dist/plugins/toolbar/components/BlockTypeSelect.js +54 -0
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +5 -0
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +33 -0
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +6 -0
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +7 -0
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
- package/dist/plugins/toolbar/components/CodeToggle.d.ts +6 -0
- package/dist/plugins/toolbar/components/CodeToggle.js +19 -0
- package/dist/plugins/toolbar/components/CreateLink.d.ts +6 -0
- package/dist/plugins/toolbar/components/CreateLink.js +20 -0
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +18 -0
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +25 -0
- package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
- package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +7 -0
- package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
- package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertFrontmatter.js +24 -0
- package/dist/plugins/toolbar/components/InsertImage.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertImage.js +14 -0
- package/dist/plugins/toolbar/components/InsertSandpack.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
- package/dist/plugins/toolbar/components/InsertTable.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertTable.js +20 -0
- package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +7 -0
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
- package/dist/plugins/toolbar/components/ListsToggle.d.ts +7 -0
- package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
- package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +7 -0
- package/dist/plugins/toolbar/components/ShowSandpackInfo.js +31 -0
- package/dist/plugins/toolbar/components/UndoRedo.d.ts +5 -0
- package/dist/plugins/toolbar/components/UndoRedo.js +58 -0
- package/dist/plugins/toolbar/index.d.ts +492 -0
- package/dist/plugins/toolbar/index.js +40 -0
- package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
- package/dist/plugins/toolbar/primitives/DialogButton.js +114 -0
- package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +8 -0
- package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
- package/dist/plugins/toolbar/primitives/select.d.ts +50 -0
- package/dist/plugins/toolbar/primitives/select.js +55 -0
- package/dist/plugins/toolbar/primitives/toolbar.d.ts +163 -0
- package/dist/plugins/toolbar/primitives/toolbar.js +115 -0
- package/dist/style.css +1715 -0
- package/dist/styles/globals.css.js +4 -0
- package/dist/styles/lexical-theme.module.css.js +62 -0
- package/dist/styles/lexicalTheme.d.ts +2 -0
- package/dist/styles/lexicalTheme.js +31 -0
- package/dist/styles/ui.module.css.js +308 -0
- package/dist/utils/detectMac.d.ts +3 -0
- package/dist/utils/detectMac.js +13 -0
- package/dist/utils/fp.d.ts +47 -0
- package/dist/utils/fp.js +14 -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 +62 -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 +435 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { $addUpdateTag, $getNodeByKey, createEditor, $getRoot, BLUR_COMMAND, COMMAND_PRIORITY_EDITOR, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_HIGH, KEY_BACKSPACE_COMMAND, COMMAND_PRIORITY_CRITICAL } from "lexical";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
import { corePluginHooks, NESTED_EDITOR_UPDATED_COMMAND } from "./index.js";
|
|
4
|
+
import { ContentEditable } from "@lexical/react/LexicalContentEditable.js";
|
|
5
|
+
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary.js";
|
|
6
|
+
import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer.js";
|
|
7
|
+
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin.js";
|
|
8
|
+
import { lexicalTheme } from "../../styles/lexicalTheme.js";
|
|
9
|
+
import { exportLexicalTreeToMdast } from "../../exportMarkdownFromLexical.js";
|
|
10
|
+
import { importMdastTreeToLexical } from "../../importMarkdownToLexical.js";
|
|
11
|
+
import styles from "../../styles/ui.module.css.js";
|
|
12
|
+
import { SharedHistoryPlugin } from "./SharedHistoryPlugin.js";
|
|
13
|
+
import { mergeRegister } from "@lexical/utils";
|
|
14
|
+
import { isPartOftheEditorUI } from "../../utils/isPartOftheEditorUI.js";
|
|
15
|
+
const NestedEditorsContext = React__default.createContext(void 0);
|
|
16
|
+
function useNestedEditorContext() {
|
|
17
|
+
const context = React__default.useContext(NestedEditorsContext);
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error("useNestedEditor must be used within a NestedEditorsProvider");
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
23
|
+
function useMdastNodeUpdater() {
|
|
24
|
+
const { parentEditor, mdastNode, lexicalNode } = useNestedEditorContext();
|
|
25
|
+
return function updateMdastNode(node) {
|
|
26
|
+
parentEditor.update(() => {
|
|
27
|
+
$addUpdateTag("history-push");
|
|
28
|
+
const currentNode = $getNodeByKey(lexicalNode.getKey());
|
|
29
|
+
if (currentNode) {
|
|
30
|
+
currentNode.setMdastNode({ ...mdastNode, ...node });
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function useLexicalNodeRemove() {
|
|
36
|
+
const { parentEditor, lexicalNode } = useNestedEditorContext();
|
|
37
|
+
return () => {
|
|
38
|
+
parentEditor.update(() => {
|
|
39
|
+
const node = $getNodeByKey(lexicalNode.getKey());
|
|
40
|
+
node.selectNext();
|
|
41
|
+
node.remove();
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const NestedLexicalEditor = function(props) {
|
|
46
|
+
const { getContent, getUpdatedMdastNode, contentEditableProps, block = false } = props;
|
|
47
|
+
const { mdastNode, lexicalNode, focusEmitter } = useNestedEditorContext();
|
|
48
|
+
const updateMdastNode = useMdastNodeUpdater();
|
|
49
|
+
const removeNode = useLexicalNodeRemove();
|
|
50
|
+
const content = getContent(mdastNode);
|
|
51
|
+
const [rootEditor] = corePluginHooks.useEmitterValues("rootEditor");
|
|
52
|
+
const [importVisitors, exportVisitors, usedLexicalNodes, jsxComponentDescriptors, jsxIsAvailable, nestedEditorChildren] = corePluginHooks.useEmitterValues(
|
|
53
|
+
"importVisitors",
|
|
54
|
+
"exportVisitors",
|
|
55
|
+
"usedLexicalNodes",
|
|
56
|
+
"jsxComponentDescriptors",
|
|
57
|
+
"jsxIsAvailable",
|
|
58
|
+
"nestedEditorChildren"
|
|
59
|
+
);
|
|
60
|
+
const setEditorInFocus = corePluginHooks.usePublisher("editorInFocus");
|
|
61
|
+
const [editor] = React__default.useState(() => {
|
|
62
|
+
const editor2 = createEditor({
|
|
63
|
+
nodes: usedLexicalNodes,
|
|
64
|
+
theme: lexicalTheme
|
|
65
|
+
});
|
|
66
|
+
return editor2;
|
|
67
|
+
});
|
|
68
|
+
React__default.useEffect(() => {
|
|
69
|
+
focusEmitter == null ? void 0 : focusEmitter.subscribe(() => {
|
|
70
|
+
editor.focus();
|
|
71
|
+
});
|
|
72
|
+
}, [editor, focusEmitter]);
|
|
73
|
+
React__default.useEffect(() => {
|
|
74
|
+
editor.update(() => {
|
|
75
|
+
$getRoot().clear();
|
|
76
|
+
let theContent = content;
|
|
77
|
+
if (block) {
|
|
78
|
+
if (theContent.length === 0) {
|
|
79
|
+
theContent = [{ type: "paragraph", children: [] }];
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
theContent = [{ type: "paragraph", children: content }];
|
|
83
|
+
}
|
|
84
|
+
importMdastTreeToLexical({
|
|
85
|
+
root: $getRoot(),
|
|
86
|
+
mdastRoot: {
|
|
87
|
+
type: "root",
|
|
88
|
+
children: theContent
|
|
89
|
+
},
|
|
90
|
+
visitors: importVisitors
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}, [editor, block, importVisitors]);
|
|
94
|
+
React__default.useEffect(() => {
|
|
95
|
+
function updateParentNode() {
|
|
96
|
+
editor.getEditorState().read(() => {
|
|
97
|
+
const mdast = exportLexicalTreeToMdast({
|
|
98
|
+
root: $getRoot(),
|
|
99
|
+
visitors: exportVisitors,
|
|
100
|
+
jsxComponentDescriptors,
|
|
101
|
+
jsxIsAvailable
|
|
102
|
+
});
|
|
103
|
+
const content2 = block ? mdast.children : mdast.children[0].children;
|
|
104
|
+
updateMdastNode(getUpdatedMdastNode(structuredClone(mdastNode), content2));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return mergeRegister(
|
|
108
|
+
editor.registerCommand(
|
|
109
|
+
BLUR_COMMAND,
|
|
110
|
+
(payload) => {
|
|
111
|
+
const relatedTarget = payload.relatedTarget;
|
|
112
|
+
if (isPartOftheEditorUI(relatedTarget, rootEditor.getRootElement())) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
updateParentNode();
|
|
116
|
+
setEditorInFocus(null);
|
|
117
|
+
return true;
|
|
118
|
+
},
|
|
119
|
+
COMMAND_PRIORITY_EDITOR
|
|
120
|
+
),
|
|
121
|
+
// triggered by codemirror
|
|
122
|
+
editor.registerCommand(
|
|
123
|
+
NESTED_EDITOR_UPDATED_COMMAND,
|
|
124
|
+
() => {
|
|
125
|
+
updateParentNode();
|
|
126
|
+
return true;
|
|
127
|
+
},
|
|
128
|
+
COMMAND_PRIORITY_EDITOR
|
|
129
|
+
),
|
|
130
|
+
editor.registerCommand(
|
|
131
|
+
SELECTION_CHANGE_COMMAND,
|
|
132
|
+
() => {
|
|
133
|
+
setEditorInFocus({ editorType: "lexical", rootNode: lexicalNode });
|
|
134
|
+
return false;
|
|
135
|
+
},
|
|
136
|
+
COMMAND_PRIORITY_HIGH
|
|
137
|
+
),
|
|
138
|
+
editor.registerCommand(
|
|
139
|
+
KEY_BACKSPACE_COMMAND,
|
|
140
|
+
(_, editor2) => {
|
|
141
|
+
const editorElement = editor2.getRootElement();
|
|
142
|
+
if ((editorElement == null ? void 0 : editorElement.innerText) === "\n") {
|
|
143
|
+
removeNode();
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
},
|
|
148
|
+
COMMAND_PRIORITY_CRITICAL
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
}, [
|
|
152
|
+
block,
|
|
153
|
+
editor,
|
|
154
|
+
exportVisitors,
|
|
155
|
+
getUpdatedMdastNode,
|
|
156
|
+
jsxComponentDescriptors,
|
|
157
|
+
jsxIsAvailable,
|
|
158
|
+
lexicalNode,
|
|
159
|
+
mdastNode,
|
|
160
|
+
removeNode,
|
|
161
|
+
setEditorInFocus,
|
|
162
|
+
updateMdastNode,
|
|
163
|
+
rootEditor
|
|
164
|
+
]);
|
|
165
|
+
return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor }, /* @__PURE__ */ React__default.createElement(
|
|
166
|
+
RichTextPlugin,
|
|
167
|
+
{
|
|
168
|
+
contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { ...contentEditableProps, className: styles.nestedEditor }),
|
|
169
|
+
placeholder: null,
|
|
170
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
171
|
+
}
|
|
172
|
+
), /* @__PURE__ */ React__default.createElement(SharedHistoryPlugin, null), nestedEditorChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })));
|
|
173
|
+
};
|
|
174
|
+
export {
|
|
175
|
+
NestedEditorsContext,
|
|
176
|
+
NestedLexicalEditor,
|
|
177
|
+
useLexicalNodeRemove,
|
|
178
|
+
useMdastNodeUpdater,
|
|
179
|
+
useNestedEditorContext
|
|
180
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The properties of the {@link PropertyPopover} React component.
|
|
4
|
+
*/
|
|
5
|
+
export interface PropertyPopoverProps {
|
|
6
|
+
/**
|
|
7
|
+
* The properties to edit. The key is the name of the property, and the value is the initial value.
|
|
8
|
+
*/
|
|
9
|
+
properties: Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Triggered when the user edits the property values.
|
|
12
|
+
*/
|
|
13
|
+
onChange: (values: Record<string, string>) => void;
|
|
14
|
+
/**
|
|
15
|
+
* The title to display in the popover.
|
|
16
|
+
*/
|
|
17
|
+
title: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A React component that can be used in custom editors to edit the properties of the node.
|
|
21
|
+
* Displays a simple, static key/value editing UI in a popover.
|
|
22
|
+
*/
|
|
23
|
+
export declare const PropertyPopover: React.FC<PropertyPopoverProps>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as RadixPopover from "@radix-ui/react-popover";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
import { useForm } from "react-hook-form";
|
|
4
|
+
import styles from "../../styles/ui.module.css.js";
|
|
5
|
+
import { PopoverPortal, PopoverContent } from "./ui/PopoverUtils.js";
|
|
6
|
+
import { corePluginHooks } from "./index.js";
|
|
7
|
+
const PropertyPopover = ({ title, properties, onChange }) => {
|
|
8
|
+
const [open, setOpen] = React__default.useState(false);
|
|
9
|
+
const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
|
|
10
|
+
const { register, handleSubmit, reset } = useForm({ defaultValues: properties });
|
|
11
|
+
return /* @__PURE__ */ React__default.createElement(RadixPopover.Root, { open, onOpenChange: (v) => setOpen(v) }, /* @__PURE__ */ React__default.createElement(RadixPopover.Trigger, { className: styles.iconButton }, /* @__PURE__ */ React__default.createElement("div", null, iconComponentFor("settings"))), /* @__PURE__ */ React__default.createElement(PopoverPortal, null, /* @__PURE__ */ React__default.createElement(PopoverContent, null, /* @__PURE__ */ React__default.createElement(
|
|
12
|
+
"form",
|
|
13
|
+
{
|
|
14
|
+
onSubmit: (e) => {
|
|
15
|
+
void handleSubmit(onChange)(e);
|
|
16
|
+
setOpen(false);
|
|
17
|
+
e.preventDefault();
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
/* @__PURE__ */ React__default.createElement("h3", { className: styles.propertyPanelTitle }, title, " Attributes"),
|
|
22
|
+
/* @__PURE__ */ React__default.createElement("table", { className: styles.propertyEditorTable }, /* @__PURE__ */ React__default.createElement("thead", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", { className: styles.readOnlyColumnCell }, "Attribute"), /* @__PURE__ */ React__default.createElement("th", null, "Value"))), /* @__PURE__ */ React__default.createElement("tbody", null, Object.keys(properties).map((propName) => /* @__PURE__ */ React__default.createElement("tr", { key: propName }, /* @__PURE__ */ React__default.createElement("th", { className: styles.readOnlyColumnCell }, " ", propName, " "), /* @__PURE__ */ React__default.createElement("td", null, /* @__PURE__ */ React__default.createElement("input", { ...register(propName), className: styles.propertyEditorInput }))))), /* @__PURE__ */ React__default.createElement("tfoot", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("td", { colSpan: 2 }, /* @__PURE__ */ React__default.createElement("div", { className: styles.buttonsFooter }, /* @__PURE__ */ React__default.createElement("button", { type: "submit", className: styles.primaryButton }, "Save"), /* @__PURE__ */ React__default.createElement(
|
|
23
|
+
"button",
|
|
24
|
+
{
|
|
25
|
+
type: "reset",
|
|
26
|
+
className: styles.secondaryButton,
|
|
27
|
+
onClick: (e) => {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
reset(properties);
|
|
30
|
+
setOpen(false);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"Cancel"
|
|
34
|
+
))))))
|
|
35
|
+
))));
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
PropertyPopover
|
|
39
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin.js";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
import { corePluginHooks } from "./index.js";
|
|
4
|
+
const SharedHistoryPlugin = () => {
|
|
5
|
+
const [historyState] = corePluginHooks.useEmitterValues("historyState");
|
|
6
|
+
return /* @__PURE__ */ React__default.createElement(HistoryPlugin, { externalHistoryState: historyState });
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
SharedHistoryPlugin
|
|
10
|
+
};
|