@mdxeditor/editor 1.14.2 → 2.0.0
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/MDXEditor.js +20 -25
- package/dist/RealmWithPlugins.js +36 -0
- package/dist/directive-editors/GenericDirectiveEditor.js +7 -4
- package/dist/index.d.ts +2590 -62
- package/dist/index.js +138 -66
- package/dist/jsx-editors/GenericJsxEditor.js +12 -9
- package/dist/plugins/codeblock/CodeBlockNode.js +5 -5
- package/dist/plugins/codeblock/index.js +37 -63
- package/dist/plugins/codemirror/CodeMirrorEditor.js +3 -2
- package/dist/plugins/codemirror/index.js +28 -45
- package/dist/plugins/core/GenericHTMLNode.js +9 -1
- package/dist/plugins/core/MdastHTMLNode.js +0 -1
- package/dist/plugins/core/NestedLexicalEditor.js +11 -10
- package/dist/plugins/core/PropertyPopover.js +3 -2
- package/dist/plugins/core/SharedHistoryPlugin.js +3 -3
- package/dist/plugins/core/index.js +426 -385
- package/dist/plugins/core/ui/DownshiftAutoComplete.js +3 -2
- package/dist/plugins/core/ui/PopoverUtils.js +3 -2
- package/dist/plugins/diff-source/DiffSourceWrapper.js +3 -4
- package/dist/plugins/diff-source/DiffViewer.js +7 -7
- package/dist/plugins/diff-source/SourceEditor.js +6 -6
- package/dist/plugins/diff-source/index.js +17 -52
- package/dist/plugins/directives/DirectiveNode.js +28 -5
- package/dist/plugins/directives/index.js +36 -43
- package/dist/plugins/frontmatter/FrontmatterEditor.js +20 -16
- package/dist/plugins/frontmatter/index.js +51 -62
- package/dist/plugins/headings/index.js +43 -49
- package/dist/plugins/image/ImageDialog.js +11 -7
- package/dist/plugins/image/ImageEditor.js +10 -7
- package/dist/plugins/image/ImageNode.js +27 -5
- package/dist/plugins/image/index.js +65 -72
- package/dist/plugins/jsx/LexicalJsxNode.js +3 -2
- package/dist/plugins/jsx/index.js +48 -60
- package/dist/plugins/link/index.js +15 -20
- package/dist/plugins/link-dialog/LinkDialog.js +17 -16
- package/dist/plugins/link-dialog/index.js +194 -216
- package/dist/plugins/lists/MdastListItemVisitor.js +3 -2
- package/dist/plugins/lists/index.js +50 -65
- package/dist/plugins/markdown-shortcut/index.js +12 -15
- package/dist/plugins/quote/index.js +11 -19
- package/dist/plugins/sandpack/SandpackEditor.js +3 -2
- package/dist/plugins/sandpack/index.js +34 -50
- package/dist/plugins/sandpack/useCodeMirrorRef.js +7 -6
- package/dist/plugins/table/TableEditor.js +12 -13
- package/dist/plugins/table/TableNode.js +28 -0
- package/dist/plugins/table/index.js +32 -39
- package/dist/plugins/thematic-break/index.js +19 -32
- package/dist/plugins/toolbar/components/BlockTypeSelect.js +9 -8
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +4 -4
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +3 -2
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +5 -5
- package/dist/plugins/toolbar/components/CodeToggle.js +4 -3
- package/dist/plugins/toolbar/components/CreateLink.js +6 -4
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +5 -5
- package/dist/plugins/toolbar/components/InsertAdmonition.js +5 -3
- package/dist/plugins/toolbar/components/InsertCodeBlock.js +5 -3
- package/dist/plugins/toolbar/components/InsertFrontmatter.js +6 -5
- package/dist/plugins/toolbar/components/InsertImage.js +6 -5
- package/dist/plugins/toolbar/components/InsertSandpack.js +5 -4
- package/dist/plugins/toolbar/components/InsertTable.js +5 -3
- package/dist/plugins/toolbar/components/InsertThematicBreak.js +6 -4
- package/dist/plugins/toolbar/components/ListsToggle.js +5 -4
- package/dist/plugins/toolbar/components/ShowSandpackInfo.js +9 -4
- package/dist/plugins/toolbar/components/UndoRedo.js +3 -3
- package/dist/plugins/toolbar/index.js +15 -31
- package/dist/plugins/toolbar/primitives/DialogButton.js +23 -24
- package/dist/plugins/toolbar/primitives/TooltipWrap.js +3 -2
- package/dist/plugins/toolbar/primitives/select.js +5 -4
- package/dist/plugins/toolbar/primitives/toolbar.js +10 -4
- package/dist/style.css +937 -570
- package/dist/styles/globals.css.js +1 -4
- package/dist/styles/lexical-theme.module.css.js +25 -19
- package/dist/styles/ui.module.css.js +106 -103
- package/package.json +64 -317
- package/dist/FormatConstants.d.ts +0 -9
- package/dist/MDXEditor.d.ts +0 -103
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +0 -17
- package/dist/directive-editors/GenericDirectiveEditor.d.ts +0 -8
- package/dist/exportMarkdownFromLexical.d.ts +0 -138
- package/dist/gurx/index.d.ts +0 -3
- package/dist/gurx/react.d.ts +0 -152
- package/dist/gurx/react.js +0 -206
- package/dist/gurx/realm.d.ts +0 -148
- package/dist/gurx/realm.js +0 -489
- package/dist/gurx/realmFactory.d.ts +0 -79
- package/dist/gurx/realmFactory.js +0 -32
- package/dist/importMarkdownToLexical.d.ts +0 -101
- package/dist/jsx-editors/GenericJsxEditor.d.ts +0 -8
- package/dist/plugins/codeblock/CodeBlockNode.d.ts +0 -100
- package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +0 -4
- package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +0 -3
- package/dist/plugins/codeblock/index.d.ts +0 -787
- package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +0 -3
- package/dist/plugins/codemirror/index.d.ts +0 -1038
- package/dist/plugins/core/GenericHTMLNode.d.ts +0 -38
- package/dist/plugins/core/Icon.d.ts +0 -6
- package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalParagraphVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalRootVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalTextVisitor.d.ts +0 -5
- package/dist/plugins/core/MdastBreakVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastFormattingVisitor.d.ts +0 -4
- package/dist/plugins/core/MdastHTMLNode.d.ts +0 -13
- package/dist/plugins/core/MdastHTMLVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastParagraphVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastRootVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastTextVisitor.d.ts +0 -3
- package/dist/plugins/core/NestedLexicalEditor.d.ts +0 -92
- package/dist/plugins/core/PropertyPopover.d.ts +0 -23
- package/dist/plugins/core/SharedHistoryPlugin.d.ts +0 -2
- package/dist/plugins/core/index.d.ts +0 -583
- package/dist/plugins/core/ui/DownshiftAutoComplete.d.ts +0 -15
- package/dist/plugins/core/ui/PopoverUtils.d.ts +0 -4
- package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +0 -4
- package/dist/plugins/diff-source/DiffViewer.d.ts +0 -2
- package/dist/plugins/diff-source/SourceEditor.d.ts +0 -4
- package/dist/plugins/diff-source/index.d.ts +0 -725
- package/dist/plugins/directives/DirectiveNode.d.ts +0 -51
- package/dist/plugins/directives/DirectiveVisitor.d.ts +0 -4
- package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +0 -3
- package/dist/plugins/directives/index.d.ts +0 -773
- package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +0 -6
- package/dist/plugins/frontmatter/FrontmatterNode.d.ts +0 -35
- package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +0 -4
- package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +0 -3
- package/dist/plugins/frontmatter/index.d.ts +0 -717
- package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +0 -4
- package/dist/plugins/headings/MdastHeadingVisitor.d.ts +0 -3
- package/dist/plugins/headings/index.d.ts +0 -707
- package/dist/plugins/image/ImageDialog.d.ts +0 -2
- package/dist/plugins/image/ImageEditor.d.ts +0 -10
- package/dist/plugins/image/ImageNode.d.ts +0 -65
- package/dist/plugins/image/ImageResizer.d.ts +0 -18
- package/dist/plugins/image/LexicalImageVisitor.d.ts +0 -4
- package/dist/plugins/image/MdastImageVisitor.d.ts +0 -6
- package/dist/plugins/image/index.d.ts +0 -804
- package/dist/plugins/jsx/LexicalJsxNode.d.ts +0 -54
- package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +0 -4
- package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +0 -3
- package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +0 -3
- package/dist/plugins/jsx/index.d.ts +0 -779
- package/dist/plugins/link/AutoLinkPlugin.d.ts +0 -9
- package/dist/plugins/link/LexicalLinkVisitor.d.ts +0 -4
- package/dist/plugins/link/MdastLinkVisitor.d.ts +0 -3
- package/dist/plugins/link/index.d.ts +0 -101
- package/dist/plugins/link-dialog/LinkDialog.d.ts +0 -16
- package/dist/plugins/link-dialog/index.d.ts +0 -670
- package/dist/plugins/lists/LexicalListItemVisitor.d.ts +0 -4
- package/dist/plugins/lists/LexicalListVisitor.d.ts +0 -4
- package/dist/plugins/lists/MdastListItemVisitor.d.ts +0 -3
- package/dist/plugins/lists/MdastListVisitor.d.ts +0 -3
- package/dist/plugins/lists/index.d.ts +0 -703
- package/dist/plugins/markdown-shortcut/index.d.ts +0 -80
- package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +0 -4
- package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +0 -3
- package/dist/plugins/quote/index.d.ts +0 -480
- package/dist/plugins/sandpack/SandpackEditor.d.ts +0 -7
- package/dist/plugins/sandpack/index.d.ts +0 -1077
- package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +0 -4
- package/dist/plugins/table/LexicalTableVisitor.d.ts +0 -4
- package/dist/plugins/table/MdastTableVisitor.d.ts +0 -3
- package/dist/plugins/table/TableEditor.d.ts +0 -21
- package/dist/plugins/table/TableNode.d.ts +0 -52
- package/dist/plugins/table/index.d.ts +0 -704
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +0 -4
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +0 -3
- package/dist/plugins/thematic-break/index.d.ts +0 -693
- package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +0 -6
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +0 -5
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +0 -6
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +0 -7
- package/dist/plugins/toolbar/components/CodeToggle.d.ts +0 -6
- package/dist/plugins/toolbar/components/CreateLink.d.ts +0 -6
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +0 -18
- package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +0 -7
- package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertImage.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertSandpack.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertTable.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +0 -6
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +0 -7
- package/dist/plugins/toolbar/components/ListsToggle.d.ts +0 -7
- package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +0 -7
- package/dist/plugins/toolbar/components/UndoRedo.d.ts +0 -5
- package/dist/plugins/toolbar/index.d.ts +0 -564
- package/dist/plugins/toolbar/primitives/DialogButton.d.ts +0 -40
- package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +0 -8
- package/dist/plugins/toolbar/primitives/select.d.ts +0 -50
- package/dist/plugins/toolbar/primitives/toolbar.d.ts +0 -163
- package/dist/styles/lexicalTheme.d.ts +0 -2
- package/dist/utils/detectMac.d.ts +0 -3
- package/dist/utils/fp.d.ts +0 -47
- package/dist/utils/isPartOftheEditorUI.d.ts +0 -1
- package/dist/utils/lexicalHelpers.d.ts +0 -11
- package/dist/utils/makeHslTransparent.d.ts +0 -1
- package/dist/utils/mergeStyleAttributes.d.ts +0 -1
- package/dist/utils/uuid4.d.ts +0 -1
- package/dist/utils/voidEmitter.d.ts +0 -14
- package/dist/utils/whitespaceConversion.d.ts +0 -2
- package/dist/utils/whitespaceConversion.js +0 -9
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { currentSelection$, activeEditor$, rootEditor$, addActivePlugin$, addMdastExtension$, addSyntaxExtension$, addImportVisitor$, addLexicalNode$, addExportVisitor$, addToMarkdownExtension$, addComposerChild$, addNestedEditorChild$ } from "../core/index.js";
|
|
2
2
|
import { MdastListVisitor } from "./MdastListVisitor.js";
|
|
3
3
|
import { MdastListItemVisitor } from "./MdastListItemVisitor.js";
|
|
4
4
|
import { LexicalListVisitor } from "./LexicalListVisitor.js";
|
|
5
5
|
import { LexicalListItemVisitor } from "./LexicalListItemVisitor.js";
|
|
6
|
-
import { $isListNode, ListNode,
|
|
6
|
+
import { $isListNode, ListNode, ListItemNode, $getListDepth, $isListItemNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND, REMOVE_LIST_COMMAND } from "@lexical/list";
|
|
7
7
|
import { $isRootOrShadowRoot, INDENT_CONTENT_COMMAND, COMMAND_PRIORITY_CRITICAL, $getSelection, $isRangeSelection, $isElementNode } from "lexical";
|
|
8
8
|
import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin.js";
|
|
9
9
|
import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin.js";
|
|
@@ -11,75 +11,60 @@ import { ListPlugin } from "@lexical/react/LexicalListPlugin.js";
|
|
|
11
11
|
import { $findMatchingParent, $getNearestNodeOfType } from "@lexical/utils";
|
|
12
12
|
import { gfmTaskListItem } from "micromark-extension-gfm-task-list-item";
|
|
13
13
|
import { gfmTaskListItemFromMarkdown, gfmTaskListItemToMarkdown } from "mdast-util-gfm-task-list-item";
|
|
14
|
-
import {
|
|
15
|
-
import { realmPlugin } from "../../
|
|
14
|
+
import { Cell, withLatestFrom, Signal } from "@mdxeditor/gurx";
|
|
15
|
+
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
16
16
|
const ListTypeCommandMap = /* @__PURE__ */ new Map([
|
|
17
17
|
["number", INSERT_ORDERED_LIST_COMMAND],
|
|
18
18
|
["bullet", INSERT_UNORDERED_LIST_COMMAND],
|
|
19
19
|
["check", INSERT_CHECK_LIST_COMMAND],
|
|
20
20
|
["", REMOVE_LIST_COMMAND]
|
|
21
21
|
]);
|
|
22
|
-
const
|
|
23
|
-
(r, [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const currentListType$ = Cell("", (r) => {
|
|
23
|
+
r.sub(r.pipe(currentSelection$, withLatestFrom(activeEditor$)), ([selection, theEditor]) => {
|
|
24
|
+
if (!selection || !theEditor) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const anchorNode = selection.anchor.getNode();
|
|
28
|
+
let element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent(anchorNode, (e) => {
|
|
29
|
+
const parent = e.getParent();
|
|
30
|
+
return parent !== null && $isRootOrShadowRoot(parent);
|
|
28
31
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const elementKey = element.getKey();
|
|
42
|
-
const elementDOM = theEditor.getElementByKey(elementKey);
|
|
43
|
-
if (elementDOM !== null) {
|
|
44
|
-
if ($isListNode(element)) {
|
|
45
|
-
const parentList = $getNearestNodeOfType(anchorNode, ListNode);
|
|
46
|
-
const type = parentList ? parentList.getListType() : element.getListType();
|
|
47
|
-
r.pub(currentListType, type);
|
|
48
|
-
} else {
|
|
49
|
-
r.pub(currentListType, null);
|
|
50
|
-
}
|
|
32
|
+
if (element === null) {
|
|
33
|
+
element = anchorNode.getTopLevelElementOrThrow();
|
|
34
|
+
}
|
|
35
|
+
const elementKey = element.getKey();
|
|
36
|
+
const elementDOM = theEditor.getElementByKey(elementKey);
|
|
37
|
+
if (elementDOM !== null) {
|
|
38
|
+
if ($isListNode(element)) {
|
|
39
|
+
const parentList = $getNearestNodeOfType(anchorNode, ListNode);
|
|
40
|
+
const type = parentList ? parentList.getListType() : element.getListType();
|
|
41
|
+
r.pub(currentListType$, type);
|
|
42
|
+
} else {
|
|
43
|
+
r.pub(currentListType$, "");
|
|
51
44
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
] = realmPlugin({
|
|
63
|
-
id: "lists",
|
|
64
|
-
systemSpec: listsSystem,
|
|
65
|
-
init: (realm) => {
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
const applyListType$ = Signal((r) => {
|
|
49
|
+
r.sub(r.pipe(applyListType$, withLatestFrom(activeEditor$)), ([listType, theEditor]) => {
|
|
50
|
+
theEditor == null ? void 0 : theEditor.dispatchCommand(ListTypeCommandMap.get(listType), void 0);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
const listsPlugin = realmPlugin({
|
|
54
|
+
init(realm) {
|
|
66
55
|
var _a;
|
|
67
|
-
realm.
|
|
68
|
-
realm.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
realm.pubKey("addComposerChild", CheckListPlugin);
|
|
80
|
-
realm.pubKey("addNestedEditorChild", TabIndentationPlugin);
|
|
81
|
-
realm.pubKey("addNestedEditorChild", ListPlugin);
|
|
82
|
-
realm.pubKey("addNestedEditorChild", CheckListPlugin);
|
|
56
|
+
(_a = realm.getValue(rootEditor$)) == null ? void 0 : _a.registerCommand(INDENT_CONTENT_COMMAND, () => !isIndentPermitted(7), COMMAND_PRIORITY_CRITICAL);
|
|
57
|
+
realm.pubIn({
|
|
58
|
+
[addActivePlugin$]: "lists",
|
|
59
|
+
[addMdastExtension$]: gfmTaskListItemFromMarkdown(),
|
|
60
|
+
[addSyntaxExtension$]: gfmTaskListItem(),
|
|
61
|
+
[addImportVisitor$]: [MdastListVisitor, MdastListItemVisitor],
|
|
62
|
+
[addLexicalNode$]: [ListItemNode, ListNode],
|
|
63
|
+
[addExportVisitor$]: [LexicalListVisitor, LexicalListItemVisitor],
|
|
64
|
+
[addToMarkdownExtension$]: gfmTaskListItemToMarkdown(),
|
|
65
|
+
[addComposerChild$]: [TabIndentationPlugin, ListPlugin, CheckListPlugin],
|
|
66
|
+
[addNestedEditorChild$]: [TabIndentationPlugin, ListPlugin, CheckListPlugin]
|
|
67
|
+
});
|
|
83
68
|
}
|
|
84
69
|
});
|
|
85
70
|
function getElementNodesInSelection(selection) {
|
|
@@ -116,7 +101,7 @@ function isIndentPermitted(maxDepth) {
|
|
|
116
101
|
return totalDepth <= maxDepth;
|
|
117
102
|
}
|
|
118
103
|
export {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
104
|
+
applyListType$,
|
|
105
|
+
currentListType$,
|
|
106
|
+
listsPlugin
|
|
122
107
|
};
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
+
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
1
2
|
import { QUOTE, LINK, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST, CODE, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE } from "@lexical/markdown";
|
|
2
3
|
import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin.js";
|
|
4
|
+
import { HeadingNode, $isHeadingNode, $createHeadingNode } from "@lexical/rich-text";
|
|
3
5
|
import React__default from "react";
|
|
4
6
|
import { CodeBlockNode, $createCodeBlockNode } from "../codeblock/CodeBlockNode.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
dependencies: [],
|
|
12
|
-
systemSpec: system((_) => ({}), [coreSystem]),
|
|
13
|
-
init: (realm, _, pluginIds) => {
|
|
14
|
-
const allowedHeadingLevels = pluginIds.includes("headings") ? (
|
|
15
|
-
// @ts-expect-error we query the realm for the allowed heading levels
|
|
16
|
-
realm.getKeyValue("allowedHeadingLevels")
|
|
17
|
-
) : [];
|
|
7
|
+
import { activePlugins$, addComposerChild$, addNestedEditorChild$ } from "../core/index.js";
|
|
8
|
+
import { allowedHeadingLevels$ } from "../headings/index.js";
|
|
9
|
+
const markdownShortcutPlugin = realmPlugin({
|
|
10
|
+
init(realm) {
|
|
11
|
+
const pluginIds = realm.getValue(activePlugins$);
|
|
12
|
+
const allowedHeadingLevels = pluginIds.includes("headings") ? realm.getValue(allowedHeadingLevels$) : [];
|
|
18
13
|
const transformers = pickTransformersForActivePlugins(pluginIds, allowedHeadingLevels);
|
|
19
|
-
realm.
|
|
20
|
-
|
|
14
|
+
realm.pubIn({
|
|
15
|
+
[addComposerChild$]: () => /* @__PURE__ */ React__default.createElement(MarkdownShortcutPlugin, { transformers }),
|
|
16
|
+
[addNestedEditorChild$]: () => /* @__PURE__ */ React__default.createElement(MarkdownShortcutPlugin, { transformers })
|
|
17
|
+
});
|
|
21
18
|
}
|
|
22
19
|
});
|
|
23
20
|
const createBlockNode = (createNode) => {
|
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import { coreSystem } from "../core/index.js";
|
|
2
1
|
import { QuoteNode } from "@lexical/rich-text";
|
|
3
2
|
import { MdastBlockQuoteVisitor } from "./MdastBlockQuoteVisitor.js";
|
|
4
3
|
import { LexicalQuoteVisitor } from "./LexicalQuoteVisitor.js";
|
|
5
|
-
import { realmPlugin } from "../../
|
|
6
|
-
import {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return {};
|
|
16
|
-
}, [coreSystem]),
|
|
17
|
-
init: (realm) => {
|
|
18
|
-
realm.pubKey("addImportVisitor", MdastBlockQuoteVisitor);
|
|
19
|
-
realm.pubKey("addLexicalNode", QuoteNode);
|
|
20
|
-
realm.pubKey("addExportVisitor", LexicalQuoteVisitor);
|
|
4
|
+
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
5
|
+
import { addActivePlugin$, addImportVisitor$, addLexicalNode$, addExportVisitor$ } from "../core/index.js";
|
|
6
|
+
const quotePlugin = realmPlugin({
|
|
7
|
+
init(realm) {
|
|
8
|
+
realm.pubIn({
|
|
9
|
+
[addActivePlugin$]: "quote",
|
|
10
|
+
[addImportVisitor$]: MdastBlockQuoteVisitor,
|
|
11
|
+
[addLexicalNode$]: QuoteNode,
|
|
12
|
+
[addExportVisitor$]: LexicalQuoteVisitor
|
|
13
|
+
});
|
|
21
14
|
}
|
|
22
15
|
});
|
|
23
16
|
export {
|
|
24
|
-
quotePlugin
|
|
25
|
-
quotePluginHooks
|
|
17
|
+
quotePlugin
|
|
26
18
|
};
|
|
@@ -2,7 +2,8 @@ import React__default from "react";
|
|
|
2
2
|
import { useCodeMirrorRef } from "./useCodeMirrorRef.js";
|
|
3
3
|
import { SandpackProvider, SandpackLayout, SandpackCodeEditor, SandpackPreview, useSandpack } from "@codesandbox/sandpack-react";
|
|
4
4
|
import { useCodeBlockEditorContext } from "../codeblock/CodeBlockNode.js";
|
|
5
|
-
import {
|
|
5
|
+
import { readOnly$ } from "../core/index.js";
|
|
6
|
+
import { useCellValue } from "@mdxeditor/gurx";
|
|
6
7
|
const CodeUpdateEmitter = ({ onChange, snippetFileName }) => {
|
|
7
8
|
const { sandpack } = useSandpack();
|
|
8
9
|
onChange(sandpack.files[snippetFileName].code);
|
|
@@ -10,7 +11,7 @@ const CodeUpdateEmitter = ({ onChange, snippetFileName }) => {
|
|
|
10
11
|
};
|
|
11
12
|
const SandpackEditor = ({ nodeKey, code, focusEmitter, preset }) => {
|
|
12
13
|
const codeMirrorRef = useCodeMirrorRef(nodeKey, "sandpack", "jsx", focusEmitter);
|
|
13
|
-
const
|
|
14
|
+
const readOnly = useCellValue(readOnly$);
|
|
14
15
|
const { setCode } = useCodeBlockEditorContext();
|
|
15
16
|
return /* @__PURE__ */ React__default.createElement(
|
|
16
17
|
SandpackProvider,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { codeBlockSystem } from "../codeblock/index.js";
|
|
2
|
+
import { insertCodeBlock$, appendCodeBlockEditorDescriptor$ } from "../codeblock/index.js";
|
|
4
3
|
import { SandpackEditor } from "./SandpackEditor.js";
|
|
5
|
-
import {
|
|
6
|
-
import { realmPlugin } from "../../
|
|
4
|
+
import { Cell, Signal, withLatestFrom, map, useCellValue } from "@mdxeditor/gurx";
|
|
5
|
+
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
7
6
|
const defaultSnippetContent = `
|
|
8
7
|
export default function App() {
|
|
9
8
|
return (
|
|
@@ -29,54 +28,36 @@ const defaultSandpackConfig = {
|
|
|
29
28
|
}
|
|
30
29
|
]
|
|
31
30
|
};
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
sandpackConfig
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
[coreSystem, codeBlockSystem]
|
|
60
|
-
);
|
|
61
|
-
const [
|
|
62
|
-
/** @internal */
|
|
63
|
-
sandpackPlugin,
|
|
64
|
-
/** @internal */
|
|
65
|
-
sandpackPluginHooks
|
|
66
|
-
] = realmPlugin({
|
|
67
|
-
id: "sandpack",
|
|
68
|
-
systemSpec: sandpackSystem,
|
|
69
|
-
applyParamsToSystem(r, params) {
|
|
70
|
-
r.pubKey("sandpackConfig", params.sandpackConfig);
|
|
71
|
-
},
|
|
72
|
-
init(r) {
|
|
73
|
-
r.pubKey("appendCodeBlockEditorDescriptor", {
|
|
31
|
+
const sandpackConfig$ = Cell(defaultSandpackConfig);
|
|
32
|
+
const insertSandpack$ = Signal((r) => {
|
|
33
|
+
r.link(
|
|
34
|
+
r.pipe(
|
|
35
|
+
insertSandpack$,
|
|
36
|
+
withLatestFrom(sandpackConfig$),
|
|
37
|
+
map(([presetName, sandpackConfig]) => {
|
|
38
|
+
const preset = presetName ? sandpackConfig.presets.find((preset2) => preset2.name === presetName) : sandpackConfig.presets.find((preset2) => preset2.name == sandpackConfig.defaultPreset);
|
|
39
|
+
if (!preset) {
|
|
40
|
+
throw new Error(`No sandpack preset found with name ${presetName}`);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
code: preset.initialSnippetContent || "",
|
|
44
|
+
language: preset.snippetLanguage || "jsx",
|
|
45
|
+
meta: preset.meta
|
|
46
|
+
};
|
|
47
|
+
})
|
|
48
|
+
),
|
|
49
|
+
insertCodeBlock$
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
const sandpackPlugin = realmPlugin({
|
|
53
|
+
init(realm) {
|
|
54
|
+
realm.pub(appendCodeBlockEditorDescriptor$, {
|
|
74
55
|
match(_language, meta) {
|
|
75
56
|
return meta == null ? void 0 : meta.startsWith("live");
|
|
76
57
|
},
|
|
77
58
|
priority: 1,
|
|
78
59
|
Editor(props) {
|
|
79
|
-
const
|
|
60
|
+
const config = useCellValue(sandpackConfig$);
|
|
80
61
|
const preset = config.presets.find((preset2) => preset2.meta === props.meta);
|
|
81
62
|
if (!preset) {
|
|
82
63
|
throw new Error(`No sandpack preset found with ${props.meta}`);
|
|
@@ -84,10 +65,13 @@ const [
|
|
|
84
65
|
return /* @__PURE__ */ React__default.createElement(SandpackEditor, { ...props, preset });
|
|
85
66
|
}
|
|
86
67
|
});
|
|
68
|
+
},
|
|
69
|
+
update(realm, params) {
|
|
70
|
+
realm.pub(sandpackConfig$, params == null ? void 0 : params.sandpackConfig);
|
|
87
71
|
}
|
|
88
72
|
});
|
|
89
73
|
export {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
74
|
+
insertSandpack$,
|
|
75
|
+
sandpackConfig$,
|
|
76
|
+
sandpackPlugin
|
|
93
77
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { $getNodeByKey, $createParagraphNode } from "lexical";
|
|
2
2
|
import React__default from "react";
|
|
3
3
|
import { useCodeBlockEditorContext } from "../codeblock/CodeBlockNode.js";
|
|
4
|
-
import {
|
|
4
|
+
import { activeEditor$, editorInFocus$ } from "../core/index.js";
|
|
5
|
+
import { useCellValue, usePublisher } from "@mdxeditor/gurx";
|
|
5
6
|
function useCodeMirrorRef(nodeKey, editorType, language, focusEmitter) {
|
|
6
|
-
const
|
|
7
|
-
const setEditorInFocus =
|
|
7
|
+
const activeEditor = useCellValue(activeEditor$);
|
|
8
|
+
const setEditorInFocus = usePublisher(editorInFocus$);
|
|
8
9
|
const codeMirrorRef = React__default.useRef(null);
|
|
9
10
|
const { lexicalNode } = useCodeBlockEditorContext();
|
|
10
11
|
const atBottom = React__default.useRef(false);
|
|
@@ -27,7 +28,7 @@ function useCodeMirrorRef(nodeKey, editorType, language, focusEmitter) {
|
|
|
27
28
|
if (!atBottom.current) {
|
|
28
29
|
atBottom.current = true;
|
|
29
30
|
} else {
|
|
30
|
-
|
|
31
|
+
activeEditor == null ? void 0 : activeEditor.update(() => {
|
|
31
32
|
var _a2, _b2;
|
|
32
33
|
const node = $getNodeByKey(nodeKey);
|
|
33
34
|
const nextSibling = node.getNextSibling();
|
|
@@ -50,7 +51,7 @@ function useCodeMirrorRef(nodeKey, editorType, language, focusEmitter) {
|
|
|
50
51
|
if (!atTop.current) {
|
|
51
52
|
atTop.current = true;
|
|
52
53
|
} else {
|
|
53
|
-
|
|
54
|
+
activeEditor == null ? void 0 : activeEditor.update(() => {
|
|
54
55
|
var _a2, _b2;
|
|
55
56
|
const node = $getNodeByKey(nodeKey);
|
|
56
57
|
const previousSibling = node.getPreviousSibling();
|
|
@@ -67,7 +68,7 @@ function useCodeMirrorRef(nodeKey, editorType, language, focusEmitter) {
|
|
|
67
68
|
e.stopPropagation();
|
|
68
69
|
}
|
|
69
70
|
},
|
|
70
|
-
[
|
|
71
|
+
[activeEditor, nodeKey]
|
|
71
72
|
);
|
|
72
73
|
React__default.useEffect(() => {
|
|
73
74
|
const codeMirror = codeMirrorRef.current;
|
|
@@ -15,7 +15,8 @@ import classNames from "classnames";
|
|
|
15
15
|
import styles from "../../styles/ui.module.css.js";
|
|
16
16
|
import { isPartOftheEditorUI } from "../../utils/isPartOftheEditorUI.js";
|
|
17
17
|
import { uuidv4 } from "../../utils/uuid4.js";
|
|
18
|
-
import {
|
|
18
|
+
import { iconComponentFor$, readOnly$, importVisitors$, exportVisitors$, usedLexicalNodes$, jsxComponentDescriptors$, jsxIsAvailable$, rootEditor$, editorRootElementRef$ } from "../core/index.js";
|
|
19
|
+
import { useCellValues } from "@mdxeditor/gurx";
|
|
19
20
|
const AlignToTailwindClassMap = {
|
|
20
21
|
center: styles.centeredCell,
|
|
21
22
|
left: styles.leftAlignedCell,
|
|
@@ -23,7 +24,7 @@ const AlignToTailwindClassMap = {
|
|
|
23
24
|
};
|
|
24
25
|
const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
|
|
25
26
|
const [activeCell, setActiveCell] = React__default.useState(null);
|
|
26
|
-
const [iconComponentFor, readOnly] =
|
|
27
|
+
const [iconComponentFor, readOnly] = useCellValues(iconComponentFor$, readOnly$);
|
|
27
28
|
const getCellKey = React__default.useMemo(() => {
|
|
28
29
|
return (cell) => {
|
|
29
30
|
if (!cell.__cacheKey) {
|
|
@@ -187,13 +188,13 @@ const Cell = ({ align, ...props }) => {
|
|
|
187
188
|
);
|
|
188
189
|
};
|
|
189
190
|
const CellEditor = ({ focus, setActiveCell, parentEditor, lexicalTable, contents, colIndex, rowIndex }) => {
|
|
190
|
-
const [importVisitors, exportVisitors, usedLexicalNodes, jsxComponentDescriptors, jsxIsAvailable, rootEditor] =
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
const [importVisitors, exportVisitors, usedLexicalNodes, jsxComponentDescriptors, jsxIsAvailable, rootEditor] = useCellValues(
|
|
192
|
+
importVisitors$,
|
|
193
|
+
exportVisitors$,
|
|
194
|
+
usedLexicalNodes$,
|
|
195
|
+
jsxComponentDescriptors$,
|
|
196
|
+
jsxIsAvailable$,
|
|
197
|
+
rootEditor$
|
|
197
198
|
);
|
|
198
199
|
const [editor] = React__default.useState(() => {
|
|
199
200
|
const editor2 = createEditor({
|
|
@@ -283,8 +284,7 @@ const ColumnEditor = ({
|
|
|
283
284
|
colIndex,
|
|
284
285
|
setActiveCellWithBoundaries
|
|
285
286
|
}) => {
|
|
286
|
-
const [editorRootElementRef] =
|
|
287
|
-
const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
|
|
287
|
+
const [editorRootElementRef, iconComponentFor] = useCellValues(editorRootElementRef$, iconComponentFor$);
|
|
288
288
|
const insertColumnAt = React__default.useCallback(
|
|
289
289
|
(colIndex2) => {
|
|
290
290
|
parentEditor.update(() => {
|
|
@@ -351,8 +351,7 @@ const RowEditor = ({
|
|
|
351
351
|
rowIndex,
|
|
352
352
|
setActiveCellWithBoundaries
|
|
353
353
|
}) => {
|
|
354
|
-
const [editorRootElementRef] =
|
|
355
|
-
const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
|
|
354
|
+
const [editorRootElementRef, iconComponentFor] = useCellValues(editorRootElementRef$, iconComponentFor$);
|
|
356
355
|
const insertRowAt = React__default.useCallback(
|
|
357
356
|
(rowIndex2) => {
|
|
358
357
|
parentEditor.update(() => {
|
|
@@ -21,21 +21,31 @@ function coordinatesEmitter() {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
class TableNode extends DecoratorNode {
|
|
24
|
+
/**
|
|
25
|
+
* Constructs a new {@link TableNode} with the specified MDAST table node as the object to edit.
|
|
26
|
+
* See {@link https://github.com/micromark/micromark-extension-gfm-table | micromark/micromark-extension-gfm-table} for more information on the MDAST table node.
|
|
27
|
+
*/
|
|
24
28
|
constructor(mdastNode, key) {
|
|
25
29
|
super(key);
|
|
30
|
+
/** @internal */
|
|
26
31
|
__publicField(this, "__mdastNode");
|
|
32
|
+
/** @internal */
|
|
27
33
|
__publicField(this, "focusEmitter", coordinatesEmitter());
|
|
28
34
|
this.__mdastNode = mdastNode || { type: "table", children: [] };
|
|
29
35
|
}
|
|
36
|
+
/** @internal */
|
|
30
37
|
static getType() {
|
|
31
38
|
return "table";
|
|
32
39
|
}
|
|
40
|
+
/** @internal */
|
|
33
41
|
static clone(node) {
|
|
34
42
|
return new TableNode(structuredClone(node.__mdastNode), node.__key);
|
|
35
43
|
}
|
|
44
|
+
/** @internal */
|
|
36
45
|
static importJSON(serializedNode) {
|
|
37
46
|
return $createTableNode(serializedNode.mdastNode);
|
|
38
47
|
}
|
|
48
|
+
/** @internal */
|
|
39
49
|
exportJSON() {
|
|
40
50
|
return {
|
|
41
51
|
mdastNode: structuredClone(this.__mdastNode),
|
|
@@ -43,22 +53,34 @@ class TableNode extends DecoratorNode {
|
|
|
43
53
|
version: 1
|
|
44
54
|
};
|
|
45
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns the mdast node that this node is constructed from.
|
|
58
|
+
*/
|
|
46
59
|
getMdastNode() {
|
|
47
60
|
return this.__mdastNode;
|
|
48
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Returns the number of rows in the table.
|
|
64
|
+
*/
|
|
49
65
|
getRowCount() {
|
|
50
66
|
return this.__mdastNode.children.length;
|
|
51
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns the number of columns in the table.
|
|
70
|
+
*/
|
|
52
71
|
getColCount() {
|
|
53
72
|
var _a;
|
|
54
73
|
return ((_a = this.__mdastNode.children[0]) == null ? void 0 : _a.children.length) || 0;
|
|
55
74
|
}
|
|
75
|
+
/** @internal */
|
|
56
76
|
createDOM() {
|
|
57
77
|
return document.createElement("div");
|
|
58
78
|
}
|
|
79
|
+
/** @internal */
|
|
59
80
|
updateDOM() {
|
|
60
81
|
return false;
|
|
61
82
|
}
|
|
83
|
+
/** @internal */
|
|
62
84
|
updateCellContents(colIndex, rowIndex, children) {
|
|
63
85
|
const self = this.getWritable();
|
|
64
86
|
const table = self.__mdastNode;
|
|
@@ -129,12 +151,18 @@ class TableNode extends DecoratorNode {
|
|
|
129
151
|
}
|
|
130
152
|
table.align[colIndex] = align;
|
|
131
153
|
}
|
|
154
|
+
/** @internal */
|
|
132
155
|
decorate(parentEditor) {
|
|
133
156
|
return /* @__PURE__ */ React__default.createElement(TableEditor, { lexicalTable: this, mdastNode: this.__mdastNode, parentEditor });
|
|
134
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Focuses the table cell at the specified coordinates.
|
|
160
|
+
* Pass `undefined` to remove the focus.
|
|
161
|
+
*/
|
|
135
162
|
select(coords) {
|
|
136
163
|
this.focusEmitter.publish(coords || [0, 0]);
|
|
137
164
|
}
|
|
165
|
+
/** @internal */
|
|
138
166
|
isInline() {
|
|
139
167
|
return false;
|
|
140
168
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
2
|
+
import { Signal, map } from "@mdxeditor/gurx";
|
|
1
3
|
import { gfmTableFromMarkdown, gfmTableToMarkdown } from "mdast-util-gfm-table";
|
|
2
4
|
import { gfmTable } from "micromark-extension-gfm-table";
|
|
3
|
-
import {
|
|
5
|
+
import { insertDecoratorNode$, addMdastExtension$, addSyntaxExtension$, addImportVisitor$, addLexicalNode$, addExportVisitor$, addToMarkdownExtension$ } from "../core/index.js";
|
|
4
6
|
import { LexicalTableVisitor } from "./LexicalTableVisitor.js";
|
|
5
7
|
import { MdastTableVisitor } from "./MdastTableVisitor.js";
|
|
6
8
|
import { $createTableNode, TableNode } from "./TableNode.js";
|
|
7
|
-
import {
|
|
8
|
-
import { realmPlugin } from "../../gurx/react.js";
|
|
9
|
+
import { $isTableNode } from "./TableNode.js";
|
|
9
10
|
function seedTable(rows = 1, columns = 1) {
|
|
10
11
|
const table = {
|
|
11
12
|
type: "table",
|
|
@@ -27,43 +28,35 @@ function seedTable(rows = 1, columns = 1) {
|
|
|
27
28
|
}
|
|
28
29
|
return table;
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
-
(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
] = realmPlugin({
|
|
54
|
-
id: "table",
|
|
55
|
-
systemSpec: tableSystem,
|
|
56
|
-
init: (realm) => {
|
|
57
|
-
realm.pubKey("addMdastExtension", gfmTableFromMarkdown);
|
|
58
|
-
realm.pubKey("addSyntaxExtension", gfmTable);
|
|
59
|
-
realm.pubKey("addImportVisitor", MdastTableVisitor);
|
|
60
|
-
realm.pubKey("addLexicalNode", TableNode);
|
|
61
|
-
realm.pubKey("addExportVisitor", LexicalTableVisitor);
|
|
62
|
-
realm.pubKey("addToMarkdownExtension", gfmTableToMarkdown({ tableCellPadding: true, tablePipeAlign: true }));
|
|
31
|
+
const insertTable$ = Signal((r) => {
|
|
32
|
+
r.link(
|
|
33
|
+
r.pipe(
|
|
34
|
+
insertTable$,
|
|
35
|
+
map(({ rows, columns }) => {
|
|
36
|
+
return () => $createTableNode(seedTable(rows, columns));
|
|
37
|
+
})
|
|
38
|
+
),
|
|
39
|
+
insertDecoratorNode$
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
const tablePlugin = realmPlugin({
|
|
43
|
+
init(realm) {
|
|
44
|
+
realm.pubIn({
|
|
45
|
+
// import
|
|
46
|
+
[addMdastExtension$]: gfmTableFromMarkdown(),
|
|
47
|
+
[addSyntaxExtension$]: gfmTable(),
|
|
48
|
+
[addImportVisitor$]: MdastTableVisitor,
|
|
49
|
+
// export
|
|
50
|
+
[addLexicalNode$]: TableNode,
|
|
51
|
+
[addExportVisitor$]: LexicalTableVisitor,
|
|
52
|
+
[addToMarkdownExtension$]: gfmTableToMarkdown({ tableCellPadding: true, tablePipeAlign: true })
|
|
53
|
+
});
|
|
63
54
|
}
|
|
64
55
|
});
|
|
65
56
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
$createTableNode,
|
|
58
|
+
$isTableNode,
|
|
59
|
+
TableNode,
|
|
60
|
+
insertTable$,
|
|
61
|
+
tablePlugin
|
|
69
62
|
};
|