@mdxeditor/editor 0.10.0 → 0.11.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/README.md +4 -3
- package/dist/FormatConstants.d.ts +9 -0
- package/dist/FormatConstants.js +10 -0
- package/dist/MDXEditor.d.ts +60 -0
- package/dist/MDXEditor.js +105 -0
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +17 -0
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.js +29 -0
- package/dist/directive-editors/GenericDirectiveEditor.d.ts +8 -0
- package/dist/directive-editors/GenericDirectiveEditor.js +32 -0
- package/dist/exportMarkdownFromLexical.d.ts +114 -0
- package/dist/exportMarkdownFromLexical.js +199 -0
- package/dist/gurx/index.d.ts +3 -0
- package/dist/gurx/react.d.ts +121 -0
- package/dist/gurx/react.js +112 -0
- package/dist/gurx/realm.d.ts +133 -0
- package/dist/gurx/realm.js +491 -0
- package/dist/gurx/realmFactory.d.ts +58 -0
- package/dist/gurx/realmFactory.js +28 -0
- package/dist/icons/add_column.svg.js +8 -0
- package/dist/icons/add_photo.svg.js +8 -0
- package/dist/icons/add_row.svg.js +8 -0
- package/dist/icons/arrow_drop_down.svg.js +8 -0
- package/dist/icons/arrow_right.svg.js +8 -0
- package/dist/icons/check.svg.js +8 -0
- package/dist/icons/close.svg.js +8 -0
- package/dist/icons/code.svg.js +8 -0
- package/dist/icons/content_copy.svg.js +8 -0
- package/dist/icons/delete.svg.js +8 -0
- package/dist/icons/delete_small.svg.js +8 -0
- package/dist/icons/deployed_code.svg.js +8 -0
- package/dist/icons/difference.svg.js +8 -0
- package/dist/icons/edit.svg.js +8 -0
- package/dist/icons/emergency_home.svg.js +8 -0
- package/dist/icons/format_align_center.svg.js +8 -0
- package/dist/icons/format_align_left.svg.js +8 -0
- package/dist/icons/format_align_right.svg.js +8 -0
- package/dist/icons/format_bold.svg.js +8 -0
- package/dist/icons/format_italic.svg.js +8 -0
- package/dist/icons/format_list_bulleted.svg.js +8 -0
- package/dist/icons/format_list_numbered.svg.js +8 -0
- package/dist/icons/format_underlined.svg.js +8 -0
- package/dist/icons/frame_source.svg.js +8 -0
- package/dist/icons/frontmatter.svg.js +8 -0
- package/dist/icons/horizontal_rule.svg.js +8 -0
- package/dist/icons/insert_col_left.svg.js +8 -0
- package/dist/icons/insert_col_right.svg.js +8 -0
- package/dist/icons/insert_row_above.svg.js +8 -0
- package/dist/icons/insert_row_below.svg.js +8 -0
- package/dist/icons/link.svg.js +8 -0
- package/dist/icons/link_off.svg.js +8 -0
- package/dist/icons/markdown.svg.js +8 -0
- package/dist/icons/more_horiz.svg.js +8 -0
- package/dist/icons/open_in_new.svg.js +8 -0
- package/dist/icons/redo.svg.js +8 -0
- package/dist/icons/rich_text.svg.js +8 -0
- package/dist/icons/settings.svg.js +8 -0
- package/dist/icons/table.svg.js +8 -0
- package/dist/icons/undo.svg.js +8 -0
- package/dist/importMarkdownToLexical.d.ts +84 -0
- package/dist/importMarkdownToLexical.js +65 -0
- package/dist/index.d.ts +49 -1105
- package/dist/index.js +140 -72
- package/dist/jsx-editors/GenericJsxEditor.d.ts +8 -0
- package/dist/jsx-editors/GenericJsxEditor.js +56 -0
- package/dist/node_modules/react-diff-view/style/index.css.js +4 -0
- package/dist/plugins/codeblock/CodeBlockNode.d.ts +99 -0
- package/dist/plugins/codeblock/CodeBlockNode.js +155 -0
- package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
- package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
- package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
- package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
- package/dist/plugins/codeblock/index.d.ts +617 -0
- package/dist/plugins/codeblock/index.js +73 -0
- package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
- package/dist/plugins/codemirror/CodeMirrorEditor.js +33 -0
- package/dist/plugins/codemirror/index.d.ts +800 -0
- package/dist/plugins/codemirror/index.js +62 -0
- package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
- package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
- package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalRootVisitor.js +10 -0
- package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
- package/dist/plugins/core/LexicalTextVisitor.js +85 -0
- package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
- package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
- package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastInlineCodeVisitor.js +11 -0
- package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
- package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastRootVisitor.js +9 -0
- package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastTextVisitor.js +10 -0
- package/dist/plugins/core/NestedLexicalEditor.d.ts +96 -0
- package/dist/plugins/core/NestedLexicalEditor.js +181 -0
- package/dist/plugins/core/PropertyPopover.d.ts +23 -0
- package/dist/plugins/core/PropertyPopover.js +36 -0
- package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
- package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
- package/dist/plugins/core/index.d.ts +423 -0
- package/dist/plugins/core/index.js +346 -0
- package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
- package/dist/plugins/core/ui/PopoverUtils.js +17 -0
- package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
- package/dist/plugins/diff-source/DiffSourceWrapper.js +11 -0
- package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
- package/dist/plugins/diff-source/DiffViewer.js +18 -0
- package/dist/plugins/diff-source/SourceEditor.d.ts +2 -0
- package/dist/plugins/diff-source/SourceEditor.js +27 -0
- package/dist/plugins/diff-source/index.d.ts +544 -0
- package/dist/plugins/diff-source/index.js +55 -0
- package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
- package/dist/plugins/directives/DirectiveNode.js +92 -0
- package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
- package/dist/plugins/directives/DirectiveVisitor.js +10 -0
- package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
- package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
- package/dist/plugins/directives/index.d.ts +603 -0
- package/dist/plugins/directives/index.js +53 -0
- package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
- package/dist/plugins/frontmatter/FrontmatterEditor.js +69 -0
- package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
- package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
- package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
- package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
- package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
- package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
- package/dist/plugins/frontmatter/index.d.ts +523 -0
- package/dist/plugins/frontmatter/index.js +53 -0
- package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
- package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
- package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
- package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
- package/dist/plugins/headings/index.d.ts +118 -0
- package/dist/plugins/headings/index.js +20 -0
- package/dist/plugins/image/ImageEditor.d.ts +9 -0
- package/dist/{ImageEditor-3725ebef.js → plugins/image/ImageEditor.js} +40 -52
- package/dist/plugins/image/ImageNode.d.ts +63 -0
- package/dist/plugins/image/ImageNode.js +136 -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 +36 -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 +557 -0
- package/dist/plugins/image/index.js +246 -0
- package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
- package/dist/plugins/jsx/LexicalJsxNode.js +102 -0
- package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
- package/dist/plugins/jsx/LexicalJsxVisitor.js +12 -0
- package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
- package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
- package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
- package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
- package/dist/plugins/jsx/index.d.ts +599 -0
- package/dist/plugins/jsx/index.js +59 -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 +68 -0
- package/dist/plugins/link/index.js +22 -0
- package/dist/plugins/link-dialog/LinkDialog.d.ts +12 -0
- package/dist/plugins/link-dialog/LinkDialog.js +174 -0
- package/dist/plugins/link-dialog/index.d.ts +508 -0
- package/dist/plugins/link-dialog/index.js +242 -0
- package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
- package/dist/plugins/lists/LexicalListItemVisitor.js +22 -0
- package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
- package/dist/plugins/lists/LexicalListVisitor.js +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 +18 -0
- package/dist/plugins/lists/index.d.ts +533 -0
- package/dist/plugins/lists/index.js +111 -0
- package/dist/plugins/markdown-shortcut/index.d.ts +63 -0
- package/dist/plugins/markdown-shortcut/index.js +34 -0
- package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
- package/dist/plugins/quote/LexicalQuoteVisitor.js +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 +361 -0
- package/dist/plugins/quote/index.js +26 -0
- package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
- package/dist/plugins/sandpack/SandpackEditor.js +35 -0
- package/dist/plugins/sandpack/index.d.ts +839 -0
- package/dist/plugins/sandpack/index.js +93 -0
- package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
- package/dist/{useCodeMirrorRef-0def7994.js → plugins/sandpack/useCodeMirrorRef.js} +22 -10
- package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
- package/dist/plugins/table/LexicalTableVisitor.js +10 -0
- package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
- package/dist/plugins/table/MdastTableVisitor.js +10 -0
- package/dist/plugins/table/TableEditor.d.ts +21 -0
- package/dist/plugins/table/TableEditor.js +384 -0
- package/dist/plugins/table/TableNode.d.ts +52 -0
- package/dist/plugins/table/TableNode.js +147 -0
- package/dist/plugins/table/index.d.ts +523 -0
- package/dist/plugins/table/index.js +59 -0
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
- package/dist/plugins/thematic-break/index.d.ts +523 -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 +52 -0
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +5 -0
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +35 -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 +20 -0
- package/dist/plugins/toolbar/components/CreateLink.d.ts +6 -0
- package/dist/plugins/toolbar/components/CreateLink.js +11 -0
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +18 -0
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +27 -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 +11 -0
- package/dist/plugins/toolbar/components/InsertImage.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertImage.js +23 -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 +32 -0
- package/dist/plugins/toolbar/components/UndoRedo.d.ts +5 -0
- package/dist/plugins/toolbar/components/UndoRedo.js +59 -0
- package/dist/plugins/toolbar/index.d.ts +428 -0
- package/dist/plugins/toolbar/index.js +39 -0
- package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
- package/dist/plugins/toolbar/primitives/DialogButton.js +115 -0
- package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +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 +44 -0
- package/dist/plugins/toolbar/primitives/toolbar.d.ts +160 -0
- package/dist/plugins/toolbar/primitives/toolbar.js +111 -0
- package/dist/style.css +556 -249
- package/dist/styles/globals.css.js +4 -0
- package/dist/styles/lexical-theme.module.css.js +53 -0
- package/dist/styles/lexicalTheme.d.ts +2 -0
- package/dist/styles/lexicalTheme.js +28 -0
- package/dist/styles/ui.module.css.js +254 -0
- package/dist/utils/detectMac.d.ts +2 -0
- package/dist/utils/detectMac.js +6 -0
- package/dist/utils/fp.d.ts +47 -0
- package/dist/utils/fp.js +10 -0
- package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
- package/dist/utils/isPartOftheEditorUI.js +12 -0
- package/dist/utils/lexicalHelpers.d.ts +11 -0
- package/dist/utils/lexicalHelpers.js +49 -0
- package/dist/utils/uuid4.d.ts +1 -0
- package/dist/utils/uuid4.js +10 -0
- package/dist/utils/voidEmitter.d.ts +14 -0
- package/dist/utils/voidEmitter.js +15 -0
- package/package.json +246 -14
- package/dist/CodeBlockEditor-6488d3ea.cjs +0 -1
- package/dist/CodeBlockEditor-884743e8.js +0 -79
- package/dist/FrontmatterEditor-435d0430.js +0 -118
- package/dist/FrontmatterEditor-95b69d31.cjs +0 -1
- package/dist/ImageEditor-43997418.cjs +0 -1
- package/dist/JsxEditor-1b8aa6c6.cjs +0 -1
- package/dist/JsxEditor-b2e4afc2.js +0 -108
- package/dist/LeafDirectiveEditor-792cbb83.js +0 -59
- package/dist/LeafDirectiveEditor-c0daefa4.cjs +0 -1
- package/dist/SandpackEditor-56a51f80.js +0 -100
- package/dist/SandpackEditor-a09311db.cjs +0 -1
- package/dist/SourceEditor-1fc83319.cjs +0 -1
- package/dist/SourceEditor-32f2b4d8.js +0 -64
- package/dist/TableEditor-616848bc.cjs +0 -1
- package/dist/TableEditor-777ac58a.js +0 -426
- package/dist/index-51585eed.cjs +0 -1
- package/dist/index-d34aa66b.js +0 -4361
- package/dist/index.cjs +0 -1
- package/dist/useCodeMirrorRef-8f68c999.cjs +0 -1
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
2
|
-
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
|
|
3
|
-
import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
|
|
4
|
-
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
5
|
-
import { $createParagraphNode, createEditor, KEY_TAB_COMMAND, COMMAND_PRIORITY_CRITICAL, KEY_ENTER_COMMAND, BLUR_COMMAND, $getRoot } from "lexical";
|
|
6
|
-
import * as React from "react";
|
|
7
|
-
import React__default, { useEffect } from "react";
|
|
8
|
-
import { s as styles, u as useEmitterValues, t as theme, i as importMdastTreeToLexical, S as SharedHistoryPlugin, e as exportLexicalTreeToMdast } from "./index-d34aa66b.js";
|
|
9
|
-
import { toHast } from "mdast-util-to-hast";
|
|
10
|
-
import { raw } from "hast-util-raw";
|
|
11
|
-
import { sanitize } from "hast-util-sanitize";
|
|
12
|
-
import { toHtml } from "hast-util-to-html";
|
|
13
|
-
import * as RadixPopover from "@radix-ui/react-popover";
|
|
14
|
-
import classNames from "classnames";
|
|
15
|
-
import * as RadixToolbar from "@radix-ui/react-toolbar";
|
|
16
|
-
import "@lexical/react/LexicalComposer";
|
|
17
|
-
import "@lexical/react/LexicalHorizontalRulePlugin";
|
|
18
|
-
import "@lexical/react/LexicalLinkPlugin";
|
|
19
|
-
import "@lexical/react/LexicalListPlugin";
|
|
20
|
-
import "@lexical/react/LexicalTabIndentationPlugin";
|
|
21
|
-
import "@lexical/code";
|
|
22
|
-
import "@lexical/link";
|
|
23
|
-
import "@lexical/list";
|
|
24
|
-
import "@lexical/react/LexicalHorizontalRuleNode";
|
|
25
|
-
import "@lexical/rich-text";
|
|
26
|
-
import "mdast-util-directive";
|
|
27
|
-
import "mdast-util-from-markdown";
|
|
28
|
-
import "mdast-util-frontmatter";
|
|
29
|
-
import "mdast-util-gfm-table";
|
|
30
|
-
import "mdast-util-mdx";
|
|
31
|
-
import "micromark-extension-directive";
|
|
32
|
-
import "micromark-extension-frontmatter";
|
|
33
|
-
import "micromark-extension-gfm-table";
|
|
34
|
-
import "micromark-extension-mdxjs";
|
|
35
|
-
import "@lexical/utils";
|
|
36
|
-
import "@lexical/react/LexicalComposerContext";
|
|
37
|
-
import "@lexical/selection";
|
|
38
|
-
import "@lexical/react/LexicalHistoryPlugin";
|
|
39
|
-
import "mdast-util-to-markdown";
|
|
40
|
-
import "@radix-ui/react-tooltip";
|
|
41
|
-
import "downshift";
|
|
42
|
-
import "@lexical/markdown";
|
|
43
|
-
import "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
44
|
-
import "react-diff-view";
|
|
45
|
-
import "unidiff";
|
|
46
|
-
import "@radix-ui/react-select";
|
|
47
|
-
import "@radix-ui/react-dialog";
|
|
48
|
-
const MarkdownAstRenderer = (props) => {
|
|
49
|
-
const root = { type: "root", children: props.mdastChildren };
|
|
50
|
-
const hast = raw(toHast(root, { allowDangerousHtml: true }));
|
|
51
|
-
const safeHast = sanitize(hast);
|
|
52
|
-
const html = toHtml(safeHast);
|
|
53
|
-
return /* @__PURE__ */ React__default.createElement("span", { dangerouslySetInnerHTML: { __html: html || " " } });
|
|
54
|
-
};
|
|
55
|
-
const SvgMoreHoriz = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
56
|
-
maskType: "alpha"
|
|
57
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M6 14c-.55 0-1.02-.196-1.412-.588A1.926 1.926 0 0 1 4 12c0-.55.196-1.02.588-1.412A1.926 1.926 0 0 1 6 10c.55 0 1.02.196 1.412.588.392.391.588.862.588 1.412 0 .55-.196 1.02-.588 1.412A1.926 1.926 0 0 1 6 14Zm6 0c-.55 0-1.02-.196-1.412-.588A1.926 1.926 0 0 1 10 12c0-.55.196-1.02.588-1.412A1.926 1.926 0 0 1 12 10c.55 0 1.02.196 1.412.588.392.391.588.862.588 1.412 0 .55-.196 1.02-.588 1.412A1.926 1.926 0 0 1 12 14Zm6 0c-.55 0-1.02-.196-1.413-.588A1.926 1.926 0 0 1 16 12c0-.55.196-1.02.587-1.412A1.926 1.926 0 0 1 18 10c.55 0 1.02.196 1.413.588.391.391.587.862.587 1.412 0 .55-.196 1.02-.587 1.412A1.926 1.926 0 0 1 18 14Z" })));
|
|
58
|
-
const MoreHorizIcon = SvgMoreHoriz;
|
|
59
|
-
const SvgFormatAlignLeft = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
60
|
-
maskType: "alpha"
|
|
61
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3 17v-1.5h14V17H3Zm0-3.125v-1.5h10v1.5H3Zm0-3.125v-1.5h14v1.5H3Zm0-3.125v-1.5h10v1.5H3ZM3 4.5V3h14v1.5H3Z" })));
|
|
62
|
-
const AlignLeftIcon = SvgFormatAlignLeft;
|
|
63
|
-
const SvgFormatAlignCenter = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
64
|
-
maskType: "alpha"
|
|
65
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3 17v-1.5h14V17H3Zm3-3.125v-1.5h8v1.5H6ZM3 10.75v-1.5h14v1.5H3Zm3-3.125v-1.5h8v1.5H6ZM3 4.5V3h14v1.5H3Z" })));
|
|
66
|
-
const AlignCenterIcon = SvgFormatAlignCenter;
|
|
67
|
-
const SvgFormatAlignRight = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
68
|
-
maskType: "alpha"
|
|
69
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3 17v-1.5h14V17H3Zm4-3.125v-1.5h10v1.5H7ZM3 10.75v-1.5h14v1.5H3Zm4-3.125v-1.5h10v1.5H7ZM3 4.5V3h14v1.5H3Z" })));
|
|
70
|
-
const AlignRightIcon = SvgFormatAlignRight;
|
|
71
|
-
const SvgInsertColLeft = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
72
|
-
maskType: "alpha"
|
|
73
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 20h20v20H0z", transform: "rotate(-90 0 20)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M15.75 4.5H13v2.75h-1.5V4.5H8.75V3h2.75V.25H13V3h2.75v1.5ZM13 17H5V3h2.25v1.5H6.5v11h5V8.75H13V17Z" })));
|
|
74
|
-
const InsertColLeftIcon = SvgInsertColLeft;
|
|
75
|
-
const SvgInsertColRight = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
76
|
-
maskType: "alpha"
|
|
77
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z", transform: "matrix(0 -1 -1 0 20 20)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M4.25 4.5H7v2.75h1.5V4.5h2.75V3H8.5V.25H7V3H4.25v1.5ZM7 17h8V3h-2.25v1.5h.75v11h-5V8.75H7V17Z" })));
|
|
78
|
-
const InsertColRightIcon = SvgInsertColRight;
|
|
79
|
-
const SvgDeleteSmall = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
80
|
-
maskType: "alpha"
|
|
81
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M6.5 17a1.45 1.45 0 0 1-1.06-.44A1.445 1.445 0 0 1 5 15.5v-10H4V4h4V3h4v1h4v1.5h-1v9.991c0 .423-.147.78-.44 1.072A1.45 1.45 0 0 1 13.5 17h-7Zm7-11.5h-7v10h7v-10ZM8 14h1.5V7H8v7Zm2.5 0H12V7h-1.5v7Z" })));
|
|
82
|
-
const DeleteSmallIcon = SvgDeleteSmall;
|
|
83
|
-
const SvgInsertRowAbove = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
84
|
-
maskType: "alpha"
|
|
85
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z", transform: "matrix(-1 0 0 1 20 0)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M4.5 16.75V14h2.75v-1.5H4.5V9.75H3v2.75H.25V14H3v2.75h1.5ZM17 14V6H3v2.25h1.5V7.5h11v5H8.75V14H17Z" })));
|
|
86
|
-
const InsertRowAboveIcon = SvgInsertRowAbove;
|
|
87
|
-
const SvgInsertRowBelow = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
88
|
-
maskType: "alpha"
|
|
89
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M20 20h20v20H20z", transform: "rotate(180 20 20)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M4.5 3.25V6h2.75v1.5H4.5v2.75H3V7.5H.25V6H3V3.25h1.5ZM17 6v8H3v-2.25h1.5v.75h11v-5H8.75V6H17Z" })));
|
|
90
|
-
const InsertRowBelowIcon = SvgInsertRowBelow;
|
|
91
|
-
const SvgAddRow = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
92
|
-
maskType: "alpha"
|
|
93
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M20 20h20v20H20z", transform: "rotate(180 20 20)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M10.5 3.25V6h2.75v1.5H10.5v2.75H9V7.5H6.25V6H9V3.25h1.5ZM17 6v8H3V6h2.5v1.5h-1v5h11v-5H14V6h3Z" })));
|
|
94
|
-
const AddRowIcon = SvgAddRow;
|
|
95
|
-
const SvgAddColumn = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
96
|
-
maskType: "alpha"
|
|
97
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z", transform: "matrix(0 -1 -1 0 20 20)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3.25 10.5H6v2.75h1.5V10.5h2.75V9H7.5V6.25H6V9H3.25v1.5ZM6 17h8V3H6v2.5h1.5v-1h5v11h-5V14H6v3Z" })));
|
|
98
|
-
const AddColumnIcon = SvgAddColumn;
|
|
99
|
-
const AlignToTailwindClassMap = {
|
|
100
|
-
center: styles.centeredCell,
|
|
101
|
-
left: styles.leftAlignedCell,
|
|
102
|
-
right: styles.rightAlignedCell
|
|
103
|
-
};
|
|
104
|
-
const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
|
|
105
|
-
const [activeCell, setActiveCell] = React__default.useState(null);
|
|
106
|
-
const setActiveCellWithBoundaries = React__default.useCallback(
|
|
107
|
-
(cell) => {
|
|
108
|
-
const colCount = lexicalTable.getColCount();
|
|
109
|
-
if (cell === null) {
|
|
110
|
-
setActiveCell(null);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
let [colIndex, rowIndex] = cell;
|
|
114
|
-
if (colIndex > colCount - 1) {
|
|
115
|
-
colIndex = 0;
|
|
116
|
-
rowIndex++;
|
|
117
|
-
}
|
|
118
|
-
if (colIndex < 0) {
|
|
119
|
-
colIndex = colCount - 1;
|
|
120
|
-
rowIndex -= 1;
|
|
121
|
-
}
|
|
122
|
-
if (rowIndex > lexicalTable.getRowCount() - 1) {
|
|
123
|
-
setActiveCell(null);
|
|
124
|
-
parentEditor.update(() => {
|
|
125
|
-
const nextSibling = lexicalTable.getLatest().getNextSibling();
|
|
126
|
-
if (nextSibling) {
|
|
127
|
-
lexicalTable.getLatest().selectNext();
|
|
128
|
-
} else {
|
|
129
|
-
const newParagraph = $createParagraphNode();
|
|
130
|
-
lexicalTable.insertAfter(newParagraph);
|
|
131
|
-
newParagraph.select();
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (rowIndex < 0) {
|
|
137
|
-
setActiveCell(null);
|
|
138
|
-
parentEditor.update(() => {
|
|
139
|
-
lexicalTable.getLatest().selectPrevious();
|
|
140
|
-
});
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
setActiveCell([colIndex, rowIndex]);
|
|
144
|
-
},
|
|
145
|
-
[lexicalTable, parentEditor]
|
|
146
|
-
);
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
lexicalTable.focusEmitter.subscribe(setActiveCellWithBoundaries);
|
|
149
|
-
}, [lexicalTable, setActiveCellWithBoundaries]);
|
|
150
|
-
const addRowToBottom = React__default.useCallback(() => {
|
|
151
|
-
parentEditor.update(() => {
|
|
152
|
-
lexicalTable.addRowToBottom();
|
|
153
|
-
setActiveCell([0, lexicalTable.getRowCount()]);
|
|
154
|
-
});
|
|
155
|
-
}, [parentEditor, lexicalTable]);
|
|
156
|
-
const addColumnToRight = React__default.useCallback(() => {
|
|
157
|
-
parentEditor.update(() => {
|
|
158
|
-
lexicalTable.addColumnToRight();
|
|
159
|
-
setActiveCell([lexicalTable.getColCount(), 0]);
|
|
160
|
-
});
|
|
161
|
-
}, [parentEditor, lexicalTable]);
|
|
162
|
-
const [highlightedCoordinates, setHighlightedCoordinates] = React__default.useState([-1, -1]);
|
|
163
|
-
const onTableMouseOver = React__default.useCallback((e) => {
|
|
164
|
-
let tableCell = e.target;
|
|
165
|
-
while (tableCell && !["TH", "TD"].includes(tableCell.tagName)) {
|
|
166
|
-
if (tableCell === e.currentTarget) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
tableCell = tableCell.parentElement;
|
|
170
|
-
}
|
|
171
|
-
if (tableCell === null) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const tableRow = tableCell.parentElement;
|
|
175
|
-
const tableContainer = tableRow.parentElement;
|
|
176
|
-
const colIndex = tableContainer.tagName === "TFOOT" ? -1 : Array.from(tableRow.children).indexOf(tableCell);
|
|
177
|
-
const rowIndex = tableCell.tagName === "TH" ? -1 : Array.from(tableRow.parentElement.children).indexOf(tableRow);
|
|
178
|
-
setHighlightedCoordinates([colIndex, rowIndex]);
|
|
179
|
-
}, []);
|
|
180
|
-
return /* @__PURE__ */ React__default.createElement("table", { className: styles.tableEditor, onMouseOver: onTableMouseOver, onMouseLeave: () => setHighlightedCoordinates([-1, -1]) }, /* @__PURE__ */ React__default.createElement("colgroup", null, /* @__PURE__ */ React__default.createElement("col", null), Array.from({ length: mdastNode.children[0].children.length }, (_, colIndex) => {
|
|
181
|
-
const align = mdastNode.align || [];
|
|
182
|
-
const currentColumnAlign = align[colIndex] || "left";
|
|
183
|
-
const className = AlignToTailwindClassMap[currentColumnAlign];
|
|
184
|
-
return /* @__PURE__ */ React__default.createElement("col", { key: colIndex, className });
|
|
185
|
-
}), /* @__PURE__ */ React__default.createElement("col", null)), /* @__PURE__ */ React__default.createElement("thead", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", { className: styles.tableToolsColumn, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(
|
|
186
|
-
"button",
|
|
187
|
-
{
|
|
188
|
-
className: styles.iconButton,
|
|
189
|
-
title: "Delete table",
|
|
190
|
-
onClick: () => {
|
|
191
|
-
parentEditor.update(() => {
|
|
192
|
-
lexicalTable.selectNext();
|
|
193
|
-
lexicalTable.remove();
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
/* @__PURE__ */ React__default.createElement(DeleteSmallIcon, null)
|
|
198
|
-
)), Array.from({ length: mdastNode.children[0].children.length }, (_, colIndex) => {
|
|
199
|
-
return /* @__PURE__ */ React__default.createElement("th", { key: colIndex, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(
|
|
200
|
-
ColumnEditor,
|
|
201
|
-
{
|
|
202
|
-
...{
|
|
203
|
-
setActiveCellWithBoundaries,
|
|
204
|
-
parentEditor,
|
|
205
|
-
colIndex,
|
|
206
|
-
highlightedCoordinates,
|
|
207
|
-
lexicalTable,
|
|
208
|
-
align: (mdastNode.align || [])[colIndex]
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
));
|
|
212
|
-
}), /* @__PURE__ */ React__default.createElement("th", { className: styles.tableToolsColumn }))), /* @__PURE__ */ React__default.createElement("tbody", null, mdastNode.children.map((row, rowIndex) => {
|
|
213
|
-
return /* @__PURE__ */ React__default.createElement("tr", { key: rowIndex }, /* @__PURE__ */ React__default.createElement("td", { className: styles.toolCell, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(RowEditor, { ...{ setActiveCellWithBoundaries, parentEditor, rowIndex, highlightedCoordinates, lexicalTable } })), row.children.map((mdastCell, colIndex) => {
|
|
214
|
-
var _a;
|
|
215
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
216
|
-
Cell,
|
|
217
|
-
{
|
|
218
|
-
align: (_a = mdastNode.align) == null ? void 0 : _a[colIndex],
|
|
219
|
-
key: colIndex,
|
|
220
|
-
contents: mdastCell.children,
|
|
221
|
-
...{ rowIndex, colIndex, lexicalTable, parentEditor, activeCellTuple: [activeCell, setActiveCellWithBoundaries] }
|
|
222
|
-
}
|
|
223
|
-
);
|
|
224
|
-
}), rowIndex === 0 && /* @__PURE__ */ React__default.createElement("th", { rowSpan: lexicalTable.getRowCount(), "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement("button", { className: styles.addColumnButton, onClick: addColumnToRight }, /* @__PURE__ */ React__default.createElement(AddColumnIcon, null))));
|
|
225
|
-
})), /* @__PURE__ */ React__default.createElement("tfoot", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", null), /* @__PURE__ */ React__default.createElement("th", { colSpan: lexicalTable.getColCount() }, /* @__PURE__ */ React__default.createElement("button", { className: styles.addRowButton, onClick: addRowToBottom }, /* @__PURE__ */ React__default.createElement(AddRowIcon, null))), /* @__PURE__ */ React__default.createElement("th", null))));
|
|
226
|
-
};
|
|
227
|
-
const Cell = ({ align, ...props }) => {
|
|
228
|
-
const [activeCell, setActiveCell] = props.activeCellTuple;
|
|
229
|
-
const isActive = activeCell && activeCell[0] === props.colIndex && activeCell[1] === props.rowIndex;
|
|
230
|
-
const className = AlignToTailwindClassMap[align || "left"];
|
|
231
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
232
|
-
"td",
|
|
233
|
-
{
|
|
234
|
-
className,
|
|
235
|
-
"data-active": isActive,
|
|
236
|
-
onClick: () => {
|
|
237
|
-
setActiveCell([props.colIndex, props.rowIndex]);
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
isActive ? /* @__PURE__ */ React__default.createElement(CellEditor, { ...props }) : /* @__PURE__ */ React__default.createElement(MarkdownAstRenderer, { mdastChildren: props.contents })
|
|
241
|
-
);
|
|
242
|
-
};
|
|
243
|
-
const CellEditor = ({ activeCellTuple, parentEditor, lexicalTable, contents, colIndex, rowIndex }) => {
|
|
244
|
-
const [markdownParseOptions, lexicalConvertOptions, jsxComponentDescriptors, lexicalNodes] = useEmitterValues(
|
|
245
|
-
"markdownParseOptions",
|
|
246
|
-
"lexicalConvertOptions",
|
|
247
|
-
"jsxComponentDescriptors",
|
|
248
|
-
"lexicalNodes"
|
|
249
|
-
);
|
|
250
|
-
const [editor] = React__default.useState(() => {
|
|
251
|
-
let disposed = false;
|
|
252
|
-
const editor2 = createEditor({
|
|
253
|
-
nodes: lexicalNodes,
|
|
254
|
-
theme
|
|
255
|
-
});
|
|
256
|
-
function saveAndDispose(nextCell) {
|
|
257
|
-
if (disposed) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
disposed = true;
|
|
261
|
-
editor2.getEditorState().read(() => {
|
|
262
|
-
const mdast = exportLexicalTreeToMdast({
|
|
263
|
-
root: $getRoot(),
|
|
264
|
-
jsxComponentDescriptors,
|
|
265
|
-
...lexicalConvertOptions
|
|
266
|
-
});
|
|
267
|
-
parentEditor.update(() => {
|
|
268
|
-
lexicalTable.updateCellContents(colIndex, rowIndex, mdast.children[0].children);
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
activeCellTuple[1](nextCell);
|
|
272
|
-
}
|
|
273
|
-
editor2.registerCommand(
|
|
274
|
-
KEY_TAB_COMMAND,
|
|
275
|
-
(payload) => {
|
|
276
|
-
payload.preventDefault();
|
|
277
|
-
const nextCell = payload.shiftKey ? [colIndex - 1, rowIndex] : [colIndex + 1, rowIndex];
|
|
278
|
-
saveAndDispose(nextCell);
|
|
279
|
-
return true;
|
|
280
|
-
},
|
|
281
|
-
COMMAND_PRIORITY_CRITICAL
|
|
282
|
-
);
|
|
283
|
-
editor2.registerCommand(
|
|
284
|
-
KEY_ENTER_COMMAND,
|
|
285
|
-
(payload) => {
|
|
286
|
-
payload == null ? void 0 : payload.preventDefault();
|
|
287
|
-
const nextCell = (payload == null ? void 0 : payload.shiftKey) ? [colIndex, rowIndex - 1] : [colIndex, rowIndex + 1];
|
|
288
|
-
saveAndDispose(nextCell);
|
|
289
|
-
return true;
|
|
290
|
-
},
|
|
291
|
-
COMMAND_PRIORITY_CRITICAL
|
|
292
|
-
);
|
|
293
|
-
editor2.registerCommand(
|
|
294
|
-
BLUR_COMMAND,
|
|
295
|
-
(payload) => {
|
|
296
|
-
const relatedTarget = payload.relatedTarget;
|
|
297
|
-
if ((relatedTarget == null ? void 0 : relatedTarget.dataset["editorDialog"]) !== void 0 || (relatedTarget == null ? void 0 : relatedTarget.dataset["toolbarItem"]) !== void 0) {
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
300
|
-
saveAndDispose(null);
|
|
301
|
-
return true;
|
|
302
|
-
},
|
|
303
|
-
COMMAND_PRIORITY_CRITICAL
|
|
304
|
-
);
|
|
305
|
-
editor2.registerRootListener((element) => {
|
|
306
|
-
if (element) {
|
|
307
|
-
editor2.focus();
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
editor2.update(() => {
|
|
311
|
-
importMdastTreeToLexical({
|
|
312
|
-
root: $getRoot(),
|
|
313
|
-
mdastRoot: { type: "root", children: [{ type: "paragraph", children: contents }] },
|
|
314
|
-
visitors: markdownParseOptions.visitors
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
return editor2;
|
|
318
|
-
});
|
|
319
|
-
return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor }, /* @__PURE__ */ React__default.createElement(RichTextPlugin, { contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { autoFocus: true }), placeholder: /* @__PURE__ */ React__default.createElement("div", null), ErrorBoundary: LexicalErrorBoundary }), /* @__PURE__ */ React__default.createElement(SharedHistoryPlugin, null));
|
|
320
|
-
};
|
|
321
|
-
const ColumnEditor = ({
|
|
322
|
-
parentEditor,
|
|
323
|
-
highlightedCoordinates,
|
|
324
|
-
align,
|
|
325
|
-
lexicalTable,
|
|
326
|
-
colIndex,
|
|
327
|
-
setActiveCellWithBoundaries
|
|
328
|
-
}) => {
|
|
329
|
-
const [editorRootElementRef] = useEmitterValues("editorRootElementRef");
|
|
330
|
-
const insertColumnAt = React__default.useCallback(
|
|
331
|
-
(colIndex2) => {
|
|
332
|
-
parentEditor.update(() => {
|
|
333
|
-
lexicalTable.insertColumnAt(colIndex2);
|
|
334
|
-
});
|
|
335
|
-
setActiveCellWithBoundaries([colIndex2, 0]);
|
|
336
|
-
},
|
|
337
|
-
[parentEditor, lexicalTable, setActiveCellWithBoundaries]
|
|
338
|
-
);
|
|
339
|
-
const deleteColumnAt = React__default.useCallback(
|
|
340
|
-
(colIndex2) => {
|
|
341
|
-
parentEditor.update(() => {
|
|
342
|
-
lexicalTable.deleteColumnAt(colIndex2);
|
|
343
|
-
});
|
|
344
|
-
},
|
|
345
|
-
[parentEditor, lexicalTable]
|
|
346
|
-
);
|
|
347
|
-
const setColumnAlign = React__default.useCallback(
|
|
348
|
-
(colIndex2, align2) => {
|
|
349
|
-
parentEditor.update(() => {
|
|
350
|
-
lexicalTable.setColumnAlign(colIndex2, align2);
|
|
351
|
-
});
|
|
352
|
-
},
|
|
353
|
-
[parentEditor, lexicalTable]
|
|
354
|
-
);
|
|
355
|
-
return /* @__PURE__ */ React__default.createElement(RadixPopover.Root, null, /* @__PURE__ */ React__default.createElement(
|
|
356
|
-
RadixPopover.PopoverTrigger,
|
|
357
|
-
{
|
|
358
|
-
className: styles.tableColumnEditorTrigger,
|
|
359
|
-
"data-active": highlightedCoordinates[0] === colIndex + 1,
|
|
360
|
-
title: "Column menu"
|
|
361
|
-
},
|
|
362
|
-
/* @__PURE__ */ React__default.createElement(MoreHorizIcon, null)
|
|
363
|
-
), /* @__PURE__ */ React__default.createElement(RadixPopover.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(
|
|
364
|
-
RadixPopover.PopoverContent,
|
|
365
|
-
{
|
|
366
|
-
className: classNames(styles.tableColumnEditorPopoverContent),
|
|
367
|
-
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
368
|
-
sideOffset: 5,
|
|
369
|
-
side: "top"
|
|
370
|
-
},
|
|
371
|
-
/* @__PURE__ */ React__default.createElement(RadixToolbar.Root, { className: styles.tableColumnEditorToolbar }, /* @__PURE__ */ React__default.createElement(
|
|
372
|
-
RadixToolbar.ToggleGroup,
|
|
373
|
-
{
|
|
374
|
-
className: styles.toggleGroupRoot,
|
|
375
|
-
onValueChange: (value) => {
|
|
376
|
-
setColumnAlign(colIndex, value);
|
|
377
|
-
},
|
|
378
|
-
value: align || "left",
|
|
379
|
-
type: "single",
|
|
380
|
-
"aria-label": "Text alignment"
|
|
381
|
-
},
|
|
382
|
-
/* @__PURE__ */ React__default.createElement(RadixToolbar.ToggleItem, { value: "left", title: "Align left" }, /* @__PURE__ */ React__default.createElement(AlignLeftIcon, null)),
|
|
383
|
-
/* @__PURE__ */ React__default.createElement(RadixToolbar.ToggleItem, { value: "center", title: "Align center" }, /* @__PURE__ */ React__default.createElement(AlignCenterIcon, null)),
|
|
384
|
-
/* @__PURE__ */ React__default.createElement(RadixToolbar.ToggleItem, { value: "right", title: "Align right" }, /* @__PURE__ */ React__default.createElement(AlignRightIcon, null))
|
|
385
|
-
), /* @__PURE__ */ React__default.createElement(RadixToolbar.Separator, null), /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: insertColumnAt.bind(null, colIndex), title: "Insert a column to the left of this one" }, /* @__PURE__ */ React__default.createElement(InsertColLeftIcon, null)), /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: insertColumnAt.bind(null, colIndex + 1), title: "Insert a column to the right of this one" }, /* @__PURE__ */ React__default.createElement(InsertColRightIcon, null)), /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: deleteColumnAt.bind(null, colIndex), title: "Delete this column" }, /* @__PURE__ */ React__default.createElement(DeleteSmallIcon, null)))
|
|
386
|
-
)));
|
|
387
|
-
};
|
|
388
|
-
const RowEditor = ({
|
|
389
|
-
parentEditor,
|
|
390
|
-
highlightedCoordinates,
|
|
391
|
-
lexicalTable,
|
|
392
|
-
rowIndex,
|
|
393
|
-
setActiveCellWithBoundaries
|
|
394
|
-
}) => {
|
|
395
|
-
const [editorRootElementRef] = useEmitterValues("editorRootElementRef");
|
|
396
|
-
const insertRowAt = React__default.useCallback(
|
|
397
|
-
(rowIndex2) => {
|
|
398
|
-
parentEditor.update(() => {
|
|
399
|
-
lexicalTable.insertRowAt(rowIndex2);
|
|
400
|
-
});
|
|
401
|
-
setActiveCellWithBoundaries([0, rowIndex2]);
|
|
402
|
-
},
|
|
403
|
-
[parentEditor, lexicalTable, setActiveCellWithBoundaries]
|
|
404
|
-
);
|
|
405
|
-
const deleteRowAt = React__default.useCallback(
|
|
406
|
-
(rowIndex2) => {
|
|
407
|
-
parentEditor.update(() => {
|
|
408
|
-
lexicalTable.deleteRowAt(rowIndex2);
|
|
409
|
-
});
|
|
410
|
-
},
|
|
411
|
-
[parentEditor, lexicalTable]
|
|
412
|
-
);
|
|
413
|
-
return /* @__PURE__ */ React__default.createElement(RadixPopover.Root, null, /* @__PURE__ */ React__default.createElement(RadixPopover.PopoverTrigger, { className: styles.tableColumnEditorTrigger, "data-active": highlightedCoordinates[1] === rowIndex }, /* @__PURE__ */ React__default.createElement(MoreHorizIcon, null)), /* @__PURE__ */ React__default.createElement(RadixPopover.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(
|
|
414
|
-
RadixPopover.PopoverContent,
|
|
415
|
-
{
|
|
416
|
-
className: classNames(styles.tableColumnEditorPopoverContent),
|
|
417
|
-
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
418
|
-
sideOffset: 5,
|
|
419
|
-
side: "bottom"
|
|
420
|
-
},
|
|
421
|
-
/* @__PURE__ */ React__default.createElement(RadixToolbar.Root, { className: styles.tableColumnEditorToolbar }, /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: insertRowAt.bind(null, rowIndex), title: "Insert a row above this one" }, /* @__PURE__ */ React__default.createElement(InsertRowAboveIcon, null)), /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: insertRowAt.bind(null, rowIndex + 1), title: "Insert a row below this one" }, /* @__PURE__ */ React__default.createElement(InsertRowBelowIcon, null)), /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: deleteRowAt.bind(null, rowIndex), title: "Delete this row" }, /* @__PURE__ */ React__default.createElement(DeleteSmallIcon, null)))
|
|
422
|
-
)));
|
|
423
|
-
};
|
|
424
|
-
export {
|
|
425
|
-
TableEditor
|
|
426
|
-
};
|