@mdxeditor/editor 1.14.3 → 2.0.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/MDXEditor.js +19 -25
- package/dist/RealmWithPlugins.js +38 -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 +433 -384
- 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 +12 -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/LexicalListItemVisitor.js +2 -1
- 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 +20 -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 +935 -571
- 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 +103 -103
- package/package.json +65 -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,12 +1,12 @@
|
|
|
1
1
|
import { mdxFromMarkdown, mdxToMarkdown } from "mdast-util-mdx";
|
|
2
2
|
import { mdxjs } from "micromark-extension-mdxjs";
|
|
3
|
-
import {
|
|
3
|
+
import { insertDecoratorNode$, jsxIsAvailable$, addMdastExtension$, addSyntaxExtension$, addImportVisitor$, addLexicalNode$, addExportVisitor$, addToMarkdownExtension$, jsxComponentDescriptors$ } from "../core/index.js";
|
|
4
4
|
import { $createLexicalJsxNode, LexicalJsxNode } from "./LexicalJsxNode.js";
|
|
5
5
|
import { LexicalJsxVisitor } from "./LexicalJsxVisitor.js";
|
|
6
6
|
import { MdastMdxJsEsmVisitor } from "./MdastMdxJsEsmVisitor.js";
|
|
7
7
|
import { MdastMdxJsxElementVisitor } from "./MdastMdxJsxElementVisitor.js";
|
|
8
|
-
import {
|
|
9
|
-
import { realmPlugin } from "../../
|
|
8
|
+
import { Signal, map } from "@mdxeditor/gurx";
|
|
9
|
+
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
10
10
|
function isMdastJsxNode(node) {
|
|
11
11
|
return node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement";
|
|
12
12
|
}
|
|
@@ -17,66 +17,54 @@ function toMdastJsxAttributes(attributes) {
|
|
|
17
17
|
value
|
|
18
18
|
}));
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
id: "jsx",
|
|
62
|
-
systemSpec: jsxSystem,
|
|
63
|
-
applyParamsToSystem: (realm, params) => {
|
|
64
|
-
realm.pubKey("jsxComponentDescriptors", (params == null ? void 0 : params.jsxComponentDescriptors) || []);
|
|
20
|
+
const insertJsx$ = Signal((r) => {
|
|
21
|
+
r.link(
|
|
22
|
+
r.pipe(
|
|
23
|
+
insertJsx$,
|
|
24
|
+
map(({ kind, name, children, props }) => {
|
|
25
|
+
return () => {
|
|
26
|
+
const attributes = toMdastJsxAttributes(props);
|
|
27
|
+
if (kind === "flow") {
|
|
28
|
+
return $createLexicalJsxNode({
|
|
29
|
+
type: "mdxJsxFlowElement",
|
|
30
|
+
name,
|
|
31
|
+
children: children ?? [],
|
|
32
|
+
attributes
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
return $createLexicalJsxNode({
|
|
36
|
+
type: "mdxJsxTextElement",
|
|
37
|
+
name,
|
|
38
|
+
children: children ?? [],
|
|
39
|
+
attributes
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
})
|
|
44
|
+
),
|
|
45
|
+
insertDecoratorNode$
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
const jsxPlugin = realmPlugin({
|
|
49
|
+
init: (realm) => {
|
|
50
|
+
realm.pubIn({
|
|
51
|
+
// import
|
|
52
|
+
[jsxIsAvailable$]: true,
|
|
53
|
+
[addMdastExtension$]: mdxFromMarkdown(),
|
|
54
|
+
[addSyntaxExtension$]: mdxjs(),
|
|
55
|
+
[addImportVisitor$]: [MdastMdxJsxElementVisitor, MdastMdxJsEsmVisitor],
|
|
56
|
+
// export
|
|
57
|
+
[addLexicalNode$]: LexicalJsxNode,
|
|
58
|
+
[addExportVisitor$]: LexicalJsxVisitor,
|
|
59
|
+
[addToMarkdownExtension$]: mdxToMarkdown()
|
|
60
|
+
});
|
|
65
61
|
},
|
|
66
|
-
|
|
67
|
-
realm.
|
|
68
|
-
realm.pubKey("addMdastExtension", mdxFromMarkdown());
|
|
69
|
-
realm.pubKey("addSyntaxExtension", mdxjs());
|
|
70
|
-
realm.pubKey("addImportVisitor", MdastMdxJsxElementVisitor);
|
|
71
|
-
realm.pubKey("addImportVisitor", MdastMdxJsEsmVisitor);
|
|
72
|
-
realm.pubKey("addLexicalNode", LexicalJsxNode);
|
|
73
|
-
realm.pubKey("addExportVisitor", LexicalJsxVisitor);
|
|
74
|
-
realm.pubKey("addToMarkdownExtension", mdxToMarkdown());
|
|
62
|
+
update(realm, params) {
|
|
63
|
+
realm.pub(jsxComponentDescriptors$, (params == null ? void 0 : params.jsxComponentDescriptors) || []);
|
|
75
64
|
}
|
|
76
65
|
});
|
|
77
66
|
export {
|
|
67
|
+
insertJsx$,
|
|
78
68
|
isMdastJsxNode,
|
|
79
|
-
jsxPlugin
|
|
80
|
-
jsxPluginHooks,
|
|
81
|
-
jsxSystem
|
|
69
|
+
jsxPlugin
|
|
82
70
|
};
|
|
@@ -1,33 +1,28 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import { coreSystem } from "../core/index.js";
|
|
3
2
|
import { MdastLinkVisitor } from "./MdastLinkVisitor.js";
|
|
4
3
|
import { LexicalLinkVisitor } from "./LexicalLinkVisitor.js";
|
|
5
4
|
import { LinkNode, AutoLinkNode } from "@lexical/link";
|
|
6
5
|
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin.js";
|
|
7
6
|
import { LexicalAutoLinkPlugin } from "./AutoLinkPlugin.js";
|
|
8
|
-
import {
|
|
9
|
-
import { realmPlugin } from "../../
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
[coreSystem]
|
|
16
|
-
);
|
|
17
|
-
const [linkPlugin] = realmPlugin({
|
|
18
|
-
id: "link",
|
|
19
|
-
systemSpec: linkSystem,
|
|
20
|
-
init: (realm, params) => {
|
|
7
|
+
import { Cell } from "@mdxeditor/gurx";
|
|
8
|
+
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
9
|
+
import { addActivePlugin$, addImportVisitor$, addLexicalNode$, addExportVisitor$, addComposerChild$ } from "../core/index.js";
|
|
10
|
+
const disableAutoLink$ = Cell(false);
|
|
11
|
+
const linkPlugin = realmPlugin({
|
|
12
|
+
init(realm, params) {
|
|
21
13
|
const disableAutoLink = Boolean(params == null ? void 0 : params.disableAutoLink);
|
|
22
|
-
realm.pubKey("addImportVisitor", MdastLinkVisitor);
|
|
23
|
-
realm.pubKey("addLexicalNode", LinkNode);
|
|
24
|
-
realm.pubKey("addLexicalNode", AutoLinkNode);
|
|
25
|
-
realm.pubKey("addExportVisitor", LexicalLinkVisitor);
|
|
26
|
-
realm.pubKey("disableAutoLink", disableAutoLink);
|
|
27
14
|
const linkPluginProps = (params == null ? void 0 : params.validateUrl) ? { validateUrl: params.validateUrl } : {};
|
|
28
|
-
realm.
|
|
15
|
+
realm.pubIn({
|
|
16
|
+
[addActivePlugin$]: "link",
|
|
17
|
+
[addImportVisitor$]: MdastLinkVisitor,
|
|
18
|
+
[addLexicalNode$]: [LinkNode, AutoLinkNode],
|
|
19
|
+
[addExportVisitor$]: LexicalLinkVisitor,
|
|
20
|
+
[disableAutoLink$]: disableAutoLink,
|
|
21
|
+
[addComposerChild$]: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(LinkPlugin, { ...linkPluginProps }), disableAutoLink ? null : /* @__PURE__ */ React__default.createElement(LexicalAutoLinkPlugin, null))
|
|
22
|
+
});
|
|
29
23
|
}
|
|
30
24
|
});
|
|
31
25
|
export {
|
|
26
|
+
disableAutoLink$,
|
|
32
27
|
linkPlugin
|
|
33
28
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as RadixPopover from "@radix-ui/react-popover";
|
|
2
2
|
import * as Tooltip from "@radix-ui/react-tooltip";
|
|
3
3
|
import React__default from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { editorRootElementRef$, activeEditor$, iconComponentFor$ } from "../core/index.js";
|
|
5
5
|
import { DownshiftAutoComplete } from "../core/ui/DownshiftAutoComplete.js";
|
|
6
6
|
import styles from "../../styles/ui.module.css.js";
|
|
7
7
|
import classNames from "classnames";
|
|
8
8
|
import { createCommand } from "lexical";
|
|
9
9
|
import { useForm } from "react-hook-form";
|
|
10
|
-
import {
|
|
10
|
+
import { linkDialogState$, linkAutocompleteSuggestions$, onWindowChange$, updateLink$, cancelLinkEdit$, switchFromPreviewToLinkEdit$, removeLink$ } from "./index.js";
|
|
11
|
+
import { useCellValues, usePublisher } from "@mdxeditor/gurx";
|
|
11
12
|
createCommand();
|
|
12
13
|
function LinkEditForm({ url, title, onSubmit, onCancel, linkAutocompleteSuggestions }) {
|
|
13
14
|
const {
|
|
@@ -54,18 +55,18 @@ function LinkEditForm({ url, title, onSubmit, onCancel, linkAutocompleteSuggesti
|
|
|
54
55
|
);
|
|
55
56
|
}
|
|
56
57
|
const LinkDialog = () => {
|
|
57
|
-
const [editorRootElementRef] =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"linkAutocompleteSuggestions"
|
|
58
|
+
const [editorRootElementRef, activeEditor, iconComponentFor, linkDialogState, linkAutocompleteSuggestions] = useCellValues(
|
|
59
|
+
editorRootElementRef$,
|
|
60
|
+
activeEditor$,
|
|
61
|
+
iconComponentFor$,
|
|
62
|
+
linkDialogState$,
|
|
63
|
+
linkAutocompleteSuggestions$
|
|
64
64
|
);
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const
|
|
65
|
+
const publishWindowChange = usePublisher(onWindowChange$);
|
|
66
|
+
const updateLink = usePublisher(updateLink$);
|
|
67
|
+
const cancelLinkEdit = usePublisher(cancelLinkEdit$);
|
|
68
|
+
const switchFromPreviewToLinkEdit = usePublisher(switchFromPreviewToLinkEdit$);
|
|
69
|
+
const removeLink = usePublisher(removeLink$);
|
|
69
70
|
React__default.useEffect(() => {
|
|
70
71
|
const update = () => {
|
|
71
72
|
activeEditor == null ? void 0 : activeEditor.getEditorState().read(() => {
|
|
@@ -108,7 +109,7 @@ const LinkDialog = () => {
|
|
|
108
109
|
url: linkDialogState.url,
|
|
109
110
|
title: linkDialogState.title,
|
|
110
111
|
onSubmit: updateLink,
|
|
111
|
-
onCancel: cancelLinkEdit.bind(null
|
|
112
|
+
onCancel: cancelLinkEdit.bind(null),
|
|
112
113
|
linkAutocompleteSuggestions
|
|
113
114
|
}
|
|
114
115
|
),
|
|
@@ -122,7 +123,7 @@ const LinkDialog = () => {
|
|
|
122
123
|
},
|
|
123
124
|
/* @__PURE__ */ React__default.createElement("span", null, linkDialogState.url),
|
|
124
125
|
urlIsExternal && iconComponentFor("open_in_new")
|
|
125
|
-
), /* @__PURE__ */ React__default.createElement(ActionButton, { onClick: () => switchFromPreviewToLinkEdit(
|
|
126
|
+
), /* @__PURE__ */ React__default.createElement(ActionButton, { onClick: () => switchFromPreviewToLinkEdit(), title: "Edit link URL", "aria-label": "Edit link URL" }, iconComponentFor("edit")), /* @__PURE__ */ React__default.createElement(Tooltip.Provider, null, /* @__PURE__ */ React__default.createElement(Tooltip.Root, { open: copyUrlTooltipOpen }, /* @__PURE__ */ React__default.createElement(Tooltip.Trigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
|
|
126
127
|
ActionButton,
|
|
127
128
|
{
|
|
128
129
|
title: "Copy to clipboard",
|
|
@@ -135,7 +136,7 @@ const LinkDialog = () => {
|
|
|
135
136
|
}
|
|
136
137
|
},
|
|
137
138
|
copyUrlTooltipOpen ? iconComponentFor("check") : iconComponentFor("content_copy")
|
|
138
|
-
)), /* @__PURE__ */ React__default.createElement(Tooltip.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Tooltip.Content, { className: classNames(styles.tooltipContent), sideOffset: 5 }, "Copied!", /* @__PURE__ */ React__default.createElement(Tooltip.Arrow, null))))), /* @__PURE__ */ React__default.createElement(ActionButton, { title: "Remove link", "aria-label": "Remove link", onClick: () => removeLink(
|
|
139
|
+
)), /* @__PURE__ */ React__default.createElement(Tooltip.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Tooltip.Content, { className: classNames(styles.tooltipContent), sideOffset: 5 }, "Copied!", /* @__PURE__ */ React__default.createElement(Tooltip.Arrow, null))))), /* @__PURE__ */ React__default.createElement(ActionButton, { title: "Remove link", "aria-label": "Remove link", onClick: () => removeLink() }, iconComponentFor("link_off"))),
|
|
139
140
|
/* @__PURE__ */ React__default.createElement(RadixPopover.Arrow, { className: styles.popoverArrow })
|
|
140
141
|
)));
|
|
141
142
|
};
|