@mdxeditor/editor 0.0.1 → 0.0.5-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 +2 -2
- package/README.md +15 -75
- package/dist/FormatConstants.d.ts +9 -0
- package/dist/FormatConstants.js +10 -0
- package/dist/MDXEditor.d.ts +103 -0
- package/dist/MDXEditor.js +144 -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 +138 -0
- package/dist/exportMarkdownFromLexical.js +239 -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/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/extension.svg.js +7 -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 +5 -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/frame_source.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 +5 -0
- package/dist/icons/table.svg.js +5 -0
- package/dist/icons/undo.svg.js +5 -0
- package/dist/importMarkdownToLexical.d.ts +101 -0
- package/dist/importMarkdownToLexical.js +93 -0
- package/dist/index.d.ts +62 -726
- package/dist/index.js +207 -4501
- 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 +787 -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 +1038 -0
- package/dist/plugins/codemirror/index.js +62 -0
- package/dist/plugins/core/GenericHTMLNode.d.ts +38 -0
- package/dist/plugins/core/GenericHTMLNode.js +117 -0
- package/dist/plugins/core/Icon.d.ts +6 -0
- package/dist/plugins/core/Icon.js +96 -0
- package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.js +15 -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 +102 -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/MdastHTMLNode.d.ts +13 -0
- package/dist/plugins/core/MdastHTMLNode.js +122 -0
- package/dist/plugins/core/MdastHTMLVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastHTMLVisitor.js +12 -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 +185 -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 +583 -0
- package/dist/plugins/core/index.js +490 -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 +14 -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 +53 -0
- package/dist/plugins/diff-source/index.d.ts +725 -0
- package/dist/plugins/diff-source/index.js +56 -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 +773 -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 +717 -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 +707 -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 +804 -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 +24 -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 +779 -0
- package/dist/plugins/jsx/index.js +82 -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 +101 -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 +669 -0
- package/dist/plugins/link-dialog/index.js +254 -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 +703 -0
- package/dist/plugins/lists/index.js +122 -0
- package/dist/plugins/markdown-shortcut/index.d.ts +80 -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 +480 -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 +1077 -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 +704 -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 +693 -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 +564 -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 +1093 -288
- 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 +311 -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 +44 -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 +80 -0
- package/dist/utils/makeHslTransparent.d.ts +1 -0
- package/dist/utils/makeHslTransparent.js +6 -0
- package/dist/utils/mergeStyleAttributes.d.ts +1 -0
- package/dist/utils/mergeStyleAttributes.js +22 -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/dist/utils/whitespaceConversion.d.ts +2 -0
- package/dist/utils/whitespaceConversion.js +9 -0
- package/package.json +326 -39
- package/dist/index.cjs +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { mdxFromMarkdown, mdxToMarkdown } from "mdast-util-mdx";
|
|
2
|
+
import { mdxjs } from "micromark-extension-mdxjs";
|
|
3
|
+
import { coreSystem } from "../core/index.js";
|
|
4
|
+
import { $createLexicalJsxNode, LexicalJsxNode } from "./LexicalJsxNode.js";
|
|
5
|
+
import { LexicalJsxVisitor } from "./LexicalJsxVisitor.js";
|
|
6
|
+
import { MdastMdxJsEsmVisitor } from "./MdastMdxJsEsmVisitor.js";
|
|
7
|
+
import { MdastMdxJsxElementVisitor } from "./MdastMdxJsxElementVisitor.js";
|
|
8
|
+
import { system } from "../../gurx/realmFactory.js";
|
|
9
|
+
import { realmPlugin } from "../../gurx/react.js";
|
|
10
|
+
function isMdastJsxNode(node) {
|
|
11
|
+
return node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement";
|
|
12
|
+
}
|
|
13
|
+
function toMdastJsxAttributes(attributes) {
|
|
14
|
+
return Object.entries(attributes).map(([name, value]) => ({
|
|
15
|
+
type: "mdxJsxAttribute",
|
|
16
|
+
name,
|
|
17
|
+
value
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
const jsxSystem = system(
|
|
21
|
+
(r, [{ insertDecoratorNode }]) => {
|
|
22
|
+
const insertJsx = r.node();
|
|
23
|
+
r.link(
|
|
24
|
+
r.pipe(
|
|
25
|
+
insertJsx,
|
|
26
|
+
r.o.map(({ kind, name, children, props }) => {
|
|
27
|
+
return () => {
|
|
28
|
+
const attributes = toMdastJsxAttributes(props);
|
|
29
|
+
if (kind === "flow") {
|
|
30
|
+
return $createLexicalJsxNode({
|
|
31
|
+
type: "mdxJsxFlowElement",
|
|
32
|
+
name,
|
|
33
|
+
children: children ?? [],
|
|
34
|
+
attributes
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
return $createLexicalJsxNode({
|
|
38
|
+
type: "mdxJsxTextElement",
|
|
39
|
+
name,
|
|
40
|
+
children: children ?? [],
|
|
41
|
+
attributes
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
),
|
|
47
|
+
insertDecoratorNode
|
|
48
|
+
);
|
|
49
|
+
return {
|
|
50
|
+
insertJsx
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
[coreSystem]
|
|
54
|
+
);
|
|
55
|
+
const [
|
|
56
|
+
/** @internal */
|
|
57
|
+
jsxPlugin,
|
|
58
|
+
/** @internal */
|
|
59
|
+
jsxPluginHooks
|
|
60
|
+
] = realmPlugin({
|
|
61
|
+
id: "jsx",
|
|
62
|
+
systemSpec: jsxSystem,
|
|
63
|
+
applyParamsToSystem: (realm, params) => {
|
|
64
|
+
realm.pubKey("jsxComponentDescriptors", (params == null ? void 0 : params.jsxComponentDescriptors) || []);
|
|
65
|
+
},
|
|
66
|
+
init: (realm, _) => {
|
|
67
|
+
realm.pubKey("jsxIsAvailable", true);
|
|
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());
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
export {
|
|
78
|
+
isMdastJsxNode,
|
|
79
|
+
jsxPlugin,
|
|
80
|
+
jsxPluginHooks,
|
|
81
|
+
jsxSystem
|
|
82
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { FC } from 'react';
|
|
9
|
+
export declare const LexicalAutoLinkPlugin: FC;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createLinkMatcherWithRegExp, AutoLinkPlugin } from "@lexical/react/LexicalAutoLinkPlugin.js";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
const URL_REGEX = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
|
4
|
+
const EMAIL_REGEX = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
|
|
5
|
+
const MATCHERS = [
|
|
6
|
+
createLinkMatcherWithRegExp(URL_REGEX, (text) => {
|
|
7
|
+
return text.startsWith("http") ? text : `https://${text}`;
|
|
8
|
+
}),
|
|
9
|
+
createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => {
|
|
10
|
+
return `mailto:${text}`;
|
|
11
|
+
})
|
|
12
|
+
];
|
|
13
|
+
const LexicalAutoLinkPlugin = () => {
|
|
14
|
+
return /* @__PURE__ */ React__default.createElement(AutoLinkPlugin, { matchers: MATCHERS });
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
LexicalAutoLinkPlugin
|
|
18
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { $isLinkNode } from "@lexical/link";
|
|
2
|
+
const LexicalLinkVisitor = {
|
|
3
|
+
testLexicalNode: $isLinkNode,
|
|
4
|
+
visitLexicalNode: ({ lexicalNode, actions }) => {
|
|
5
|
+
actions.addAndStepInto("link", { url: lexicalNode.getURL(), title: lexicalNode.getTitle() });
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
LexicalLinkVisitor
|
|
10
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { $createLinkNode } from "@lexical/link";
|
|
2
|
+
const MdastLinkVisitor = {
|
|
3
|
+
testNode: "link",
|
|
4
|
+
visitNode({ mdastNode, actions }) {
|
|
5
|
+
actions.addAndStepInto(
|
|
6
|
+
$createLinkNode(mdastNode.url, {
|
|
7
|
+
title: mdastNode.title
|
|
8
|
+
})
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
MdastLinkVisitor
|
|
14
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { IconKey } from '../core/Icon';
|
|
2
|
+
import type { Options } from 'mdast-util-to-markdown';
|
|
3
|
+
import type { Config } from 'mdast-util-from-markdown/lib';
|
|
4
|
+
import type { Extension } from 'micromark-util-types';
|
|
5
|
+
import type { Content } from 'mdast';
|
|
6
|
+
import type { MdastImportVisitor, LexicalVisitor } from '../..';
|
|
7
|
+
import type { EditorSubscription, EditorInFocus, BlockType } from '../core';
|
|
8
|
+
import type { InitialEditorStateType } from '@lexical/react/LexicalComposer';
|
|
9
|
+
import type { JsxComponentDescriptor } from '../jsx';
|
|
10
|
+
import type { HistoryState } from '@lexical/history';
|
|
11
|
+
import type { LexicalEditor, RangeSelection, Klass, LexicalNode, TextFormatType, ElementNode, DecoratorNode } from 'lexical';
|
|
12
|
+
import type { PluginConstructor, SystemSpec, Realm, RealmNode } from '../../gurx';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { LinkPlugin as LexicalLinkPlugin } from '@lexical/react/LexicalLinkPlugin.js';
|
|
15
|
+
/**
|
|
16
|
+
* The parameters used to configure the link plugin
|
|
17
|
+
*/
|
|
18
|
+
interface LinkPluginParams {
|
|
19
|
+
/**
|
|
20
|
+
* An optional function to validate the URL of a link.
|
|
21
|
+
* By default, no validation is performed.
|
|
22
|
+
*/
|
|
23
|
+
validateUrl?: React.ComponentProps<typeof LexicalLinkPlugin>['validateUrl'];
|
|
24
|
+
/**
|
|
25
|
+
* Whether to disable the auto-linking of URLs and email addresses.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
disableAutoLink?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export declare const linkPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
34
|
+
activeEditor: RealmNode<LexicalEditor | null>;
|
|
35
|
+
inFocus: RealmNode<boolean>;
|
|
36
|
+
historyState: RealmNode<HistoryState>;
|
|
37
|
+
currentSelection: RealmNode<RangeSelection | null>;
|
|
38
|
+
jsxIsAvailable: RealmNode<boolean>;
|
|
39
|
+
jsxComponentDescriptors: RealmNode<JsxComponentDescriptor[]>;
|
|
40
|
+
initialRootEditorState: RealmNode<InitialEditorStateType>;
|
|
41
|
+
rootEditor: RealmNode<LexicalEditor | null>;
|
|
42
|
+
createRootEditorSubscription: RealmNode<EditorSubscription>;
|
|
43
|
+
createActiveEditorSubscription: RealmNode<EditorSubscription>;
|
|
44
|
+
importVisitors: RealmNode<MdastImportVisitor<Content>[]>;
|
|
45
|
+
syntaxExtensions: RealmNode<Extension[]>;
|
|
46
|
+
mdastExtensions: RealmNode<(Partial<Config> | Partial<Config>[])[] | null | undefined>;
|
|
47
|
+
usedLexicalNodes: RealmNode<Klass<LexicalNode>[]>;
|
|
48
|
+
addImportVisitor: RealmNode<MdastImportVisitor<Content>>;
|
|
49
|
+
addLexicalNode: RealmNode<Klass<LexicalNode>>;
|
|
50
|
+
addSyntaxExtension: RealmNode<Extension>;
|
|
51
|
+
addMdastExtension: RealmNode<Partial<Config> | Partial<Config>[]>;
|
|
52
|
+
toMarkdownExtensions: RealmNode<Options[]>;
|
|
53
|
+
toMarkdownOptions: RealmNode<Options>;
|
|
54
|
+
addToMarkdownExtension: RealmNode<Options>;
|
|
55
|
+
addExportVisitor: RealmNode<LexicalVisitor>;
|
|
56
|
+
exportVisitors: RealmNode<LexicalVisitor[]>;
|
|
57
|
+
initialMarkdown: RealmNode<string>;
|
|
58
|
+
setMarkdown: RealmNode<string>;
|
|
59
|
+
markdown: RealmNode<string>;
|
|
60
|
+
markdownSignal: RealmNode<string>;
|
|
61
|
+
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
62
|
+
contentEditableClassName: RealmNode<string>;
|
|
63
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
64
|
+
autoFocus: RealmNode<boolean | {
|
|
65
|
+
defaultSelection?: "rootStart" | "rootEnd" | undefined;
|
|
66
|
+
preventScroll?: boolean | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
readOnly: RealmNode<boolean>;
|
|
69
|
+
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
70
|
+
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
71
|
+
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
72
|
+
addTopAreaChild: RealmNode<React.ComponentType<{}>>;
|
|
73
|
+
nestedEditorChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
74
|
+
addNestedEditorChild: RealmNode<React.ComponentType<{}>>;
|
|
75
|
+
editorWrappers: RealmNode<React.ComponentType<{
|
|
76
|
+
children: React.ReactNode;
|
|
77
|
+
}>[]>;
|
|
78
|
+
addEditorWrapper: RealmNode<React.ComponentType<{
|
|
79
|
+
children: React.ReactNode;
|
|
80
|
+
}>>;
|
|
81
|
+
currentFormat: RealmNode<number>;
|
|
82
|
+
editorInFocus: RealmNode<EditorInFocus | null>;
|
|
83
|
+
applyFormat: RealmNode<TextFormatType>;
|
|
84
|
+
currentBlockType: RealmNode<BlockType>;
|
|
85
|
+
applyBlockType: RealmNode<BlockType>;
|
|
86
|
+
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
87
|
+
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
88
|
+
onBlur: RealmNode<FocusEvent>;
|
|
89
|
+
iconComponentFor: RealmNode<(name: IconKey) => React.ReactNode>;
|
|
90
|
+
markdownProcessingError: RealmNode<{
|
|
91
|
+
error: string;
|
|
92
|
+
source: string;
|
|
93
|
+
} | null>;
|
|
94
|
+
markdownErrorSignal: RealmNode<{
|
|
95
|
+
error: string;
|
|
96
|
+
source: string;
|
|
97
|
+
}>;
|
|
98
|
+
}>], (r: Realm) => {
|
|
99
|
+
disableAutoLink: RealmNode<boolean>;
|
|
100
|
+
}>, LinkPluginParams>;
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import { coreSystem } from "../core/index.js";
|
|
3
|
+
import { MdastLinkVisitor } from "./MdastLinkVisitor.js";
|
|
4
|
+
import { LexicalLinkVisitor } from "./LexicalLinkVisitor.js";
|
|
5
|
+
import { LinkNode, AutoLinkNode } from "@lexical/link";
|
|
6
|
+
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin.js";
|
|
7
|
+
import { LexicalAutoLinkPlugin } from "./AutoLinkPlugin.js";
|
|
8
|
+
import { system } from "../../gurx/realmFactory.js";
|
|
9
|
+
import { realmPlugin } from "../../gurx/react.js";
|
|
10
|
+
const linkSystem = system(
|
|
11
|
+
(r) => {
|
|
12
|
+
const disableAutoLink = r.node(false);
|
|
13
|
+
return { disableAutoLink };
|
|
14
|
+
},
|
|
15
|
+
[coreSystem]
|
|
16
|
+
);
|
|
17
|
+
const [linkPlugin] = realmPlugin({
|
|
18
|
+
id: "link",
|
|
19
|
+
systemSpec: linkSystem,
|
|
20
|
+
init: (realm, params) => {
|
|
21
|
+
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
|
+
const linkPluginProps = (params == null ? void 0 : params.validateUrl) ? { validateUrl: params.validateUrl } : {};
|
|
28
|
+
realm.pubKey("addComposerChild", () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(LinkPlugin, { ...linkPluginProps }), disableAutoLink ? null : /* @__PURE__ */ React__default.createElement(LexicalAutoLinkPlugin, null)));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export {
|
|
32
|
+
linkPlugin
|
|
33
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LexicalCommand } from 'lexical';
|
|
3
|
+
export declare const OPEN_LINK_DIALOG: LexicalCommand<undefined>;
|
|
4
|
+
interface LinkEditFormProps {
|
|
5
|
+
url: string;
|
|
6
|
+
title: string;
|
|
7
|
+
onSubmit: (link: {
|
|
8
|
+
url: string;
|
|
9
|
+
title: string;
|
|
10
|
+
}) => void;
|
|
11
|
+
onCancel: () => void;
|
|
12
|
+
linkAutocompleteSuggestions: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare function LinkEditForm({ url, title, onSubmit, onCancel, linkAutocompleteSuggestions }: LinkEditFormProps): React.JSX.Element;
|
|
15
|
+
export declare const LinkDialog: React.FC;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import * as RadixPopover from "@radix-ui/react-popover";
|
|
2
|
+
import * as Tooltip from "@radix-ui/react-tooltip";
|
|
3
|
+
import React__default from "react";
|
|
4
|
+
import { corePluginHooks } from "../core/index.js";
|
|
5
|
+
import { DownshiftAutoComplete } from "../core/ui/DownshiftAutoComplete.js";
|
|
6
|
+
import styles from "../../styles/ui.module.css.js";
|
|
7
|
+
import classNames from "classnames";
|
|
8
|
+
import { createCommand } from "lexical";
|
|
9
|
+
import { useForm } from "react-hook-form";
|
|
10
|
+
import { linkDialogPluginHooks } from "./index.js";
|
|
11
|
+
createCommand();
|
|
12
|
+
function LinkEditForm({ url, title, onSubmit, onCancel, linkAutocompleteSuggestions }) {
|
|
13
|
+
const {
|
|
14
|
+
register,
|
|
15
|
+
handleSubmit,
|
|
16
|
+
control,
|
|
17
|
+
setValue,
|
|
18
|
+
reset: _
|
|
19
|
+
} = useForm({
|
|
20
|
+
values: {
|
|
21
|
+
url,
|
|
22
|
+
title
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
26
|
+
"form",
|
|
27
|
+
{
|
|
28
|
+
onSubmit: (e) => {
|
|
29
|
+
void handleSubmit(onSubmit)(e);
|
|
30
|
+
e.stopPropagation();
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
},
|
|
33
|
+
onReset: (e) => {
|
|
34
|
+
e.stopPropagation();
|
|
35
|
+
onCancel();
|
|
36
|
+
},
|
|
37
|
+
className: classNames(styles.multiFieldForm, styles.linkDialogEditForm)
|
|
38
|
+
},
|
|
39
|
+
/* @__PURE__ */ React__default.createElement("div", { className: styles.formField }, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "link-url" }, "URL"), /* @__PURE__ */ React__default.createElement(
|
|
40
|
+
DownshiftAutoComplete,
|
|
41
|
+
{
|
|
42
|
+
register,
|
|
43
|
+
initialInputValue: url,
|
|
44
|
+
inputName: "url",
|
|
45
|
+
suggestions: linkAutocompleteSuggestions,
|
|
46
|
+
setValue,
|
|
47
|
+
control,
|
|
48
|
+
placeholder: "Select or paste an URL",
|
|
49
|
+
autofocus: true
|
|
50
|
+
}
|
|
51
|
+
)),
|
|
52
|
+
/* @__PURE__ */ React__default.createElement("div", { className: styles.formField }, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "link-title" }, "Title"), /* @__PURE__ */ React__default.createElement("input", { id: "link-title", className: styles.textInput, size: 40, ...register("title") })),
|
|
53
|
+
/* @__PURE__ */ React__default.createElement("div", { style: { display: "flex", justifyContent: "flex-end", gap: "var(--spacing-2)" } }, /* @__PURE__ */ React__default.createElement("button", { type: "submit", title: "Set URL", "aria-label": "Set URL", className: classNames(styles.primaryButton) }, "Save"), /* @__PURE__ */ React__default.createElement("button", { type: "reset", title: "Cancel change", "aria-label": "Cancel change", className: classNames(styles.secondaryButton) }, "Cancel"))
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
const LinkDialog = () => {
|
|
57
|
+
const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
|
|
58
|
+
const publishWindowChange = linkDialogPluginHooks.usePublisher("onWindowChange");
|
|
59
|
+
const [activeEditor] = corePluginHooks.useEmitterValues("activeEditor");
|
|
60
|
+
const [iconComponentFor] = corePluginHooks.useEmitterValues("iconComponentFor");
|
|
61
|
+
const [linkDialogState, linkAutocompleteSuggestions] = linkDialogPluginHooks.useEmitterValues(
|
|
62
|
+
"linkDialogState",
|
|
63
|
+
"linkAutocompleteSuggestions"
|
|
64
|
+
);
|
|
65
|
+
const updateLink = linkDialogPluginHooks.usePublisher("updateLink");
|
|
66
|
+
const cancelLinkEdit = linkDialogPluginHooks.usePublisher("cancelLinkEdit");
|
|
67
|
+
const switchFromPreviewToLinkEdit = linkDialogPluginHooks.usePublisher("switchFromPreviewToLinkEdit");
|
|
68
|
+
const removeLink = linkDialogPluginHooks.usePublisher("removeLink");
|
|
69
|
+
React__default.useEffect(() => {
|
|
70
|
+
const update = () => {
|
|
71
|
+
activeEditor == null ? void 0 : activeEditor.getEditorState().read(() => {
|
|
72
|
+
publishWindowChange(true);
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
window.addEventListener("resize", update);
|
|
76
|
+
window.addEventListener("scroll", update);
|
|
77
|
+
return () => {
|
|
78
|
+
window.removeEventListener("resize", update);
|
|
79
|
+
window.removeEventListener("scroll", update);
|
|
80
|
+
};
|
|
81
|
+
}, [activeEditor, publishWindowChange]);
|
|
82
|
+
const [copyUrlTooltipOpen, setCopyUrlTooltipOpen] = React__default.useState(false);
|
|
83
|
+
const theRect = linkDialogState == null ? void 0 : linkDialogState.rectangle;
|
|
84
|
+
const urlIsExternal = linkDialogState.type === "preview" && linkDialogState.url.startsWith("http");
|
|
85
|
+
return /* @__PURE__ */ React__default.createElement(RadixPopover.Root, { open: linkDialogState.type !== "inactive" }, /* @__PURE__ */ React__default.createElement(
|
|
86
|
+
RadixPopover.Anchor,
|
|
87
|
+
{
|
|
88
|
+
"data-visible": linkDialogState.type === "edit",
|
|
89
|
+
className: styles.linkDialogAnchor,
|
|
90
|
+
style: {
|
|
91
|
+
top: `${(theRect == null ? void 0 : theRect.top) ?? 0}px`,
|
|
92
|
+
left: `${(theRect == null ? void 0 : theRect.left) ?? 0}px`,
|
|
93
|
+
width: `${(theRect == null ? void 0 : theRect.width) ?? 0}px`,
|
|
94
|
+
height: `${(theRect == null ? void 0 : theRect.height) ?? 0}px`
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
), /* @__PURE__ */ React__default.createElement(RadixPopover.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(
|
|
98
|
+
RadixPopover.Content,
|
|
99
|
+
{
|
|
100
|
+
className: classNames(styles.linkDialogPopoverContent),
|
|
101
|
+
sideOffset: 5,
|
|
102
|
+
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
103
|
+
key: linkDialogState.linkNodeKey
|
|
104
|
+
},
|
|
105
|
+
linkDialogState.type === "edit" && /* @__PURE__ */ React__default.createElement(
|
|
106
|
+
LinkEditForm,
|
|
107
|
+
{
|
|
108
|
+
url: linkDialogState.url,
|
|
109
|
+
title: linkDialogState.title,
|
|
110
|
+
onSubmit: updateLink,
|
|
111
|
+
onCancel: cancelLinkEdit.bind(null, true),
|
|
112
|
+
linkAutocompleteSuggestions
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
linkDialogState.type === "preview" && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
116
|
+
"a",
|
|
117
|
+
{
|
|
118
|
+
className: styles.linkDialogPreviewAnchor,
|
|
119
|
+
href: linkDialogState.url,
|
|
120
|
+
...urlIsExternal ? { target: "_blank", rel: "noreferrer" } : {},
|
|
121
|
+
title: urlIsExternal ? `Open ${linkDialogState.url} in new window` : linkDialogState.url
|
|
122
|
+
},
|
|
123
|
+
/* @__PURE__ */ React__default.createElement("span", null, linkDialogState.url),
|
|
124
|
+
urlIsExternal && iconComponentFor("open_in_new")
|
|
125
|
+
), /* @__PURE__ */ React__default.createElement(ActionButton, { onClick: () => switchFromPreviewToLinkEdit(true), 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
|
+
ActionButton,
|
|
127
|
+
{
|
|
128
|
+
title: "Copy to clipboard",
|
|
129
|
+
"aria-label": "Copy link URL",
|
|
130
|
+
onClick: () => {
|
|
131
|
+
void window.navigator.clipboard.writeText(linkDialogState.url).then(() => {
|
|
132
|
+
setCopyUrlTooltipOpen(true);
|
|
133
|
+
setTimeout(() => setCopyUrlTooltipOpen(false), 1e3);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
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(true) }, iconComponentFor("link_off"))),
|
|
139
|
+
/* @__PURE__ */ React__default.createElement(RadixPopover.Arrow, { className: styles.popoverArrow })
|
|
140
|
+
)));
|
|
141
|
+
};
|
|
142
|
+
const ActionButton = React__default.forwardRef(({ className, ...props }, ref) => {
|
|
143
|
+
return /* @__PURE__ */ React__default.createElement("button", { className: classNames(styles.actionButton, className), ref, ...props });
|
|
144
|
+
});
|
|
145
|
+
export {
|
|
146
|
+
LinkDialog,
|
|
147
|
+
LinkEditForm
|
|
148
|
+
};
|