@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,62 @@
|
|
|
1
|
+
import { coreSystem } from "../core/index.js";
|
|
2
|
+
import { codeBlockSystem } from "../codeblock/index.js";
|
|
3
|
+
import { CodeMirrorEditor } from "./CodeMirrorEditor.js";
|
|
4
|
+
import { system } from "../../gurx/realmFactory.js";
|
|
5
|
+
import { realmPlugin } from "../../gurx/react.js";
|
|
6
|
+
const defaultCodeBlockLanguages = {
|
|
7
|
+
js: "JavaScript",
|
|
8
|
+
ts: "TypeScript",
|
|
9
|
+
tsx: "TypeScript (React)",
|
|
10
|
+
jsx: "JavaScript (React)",
|
|
11
|
+
css: "CSS"
|
|
12
|
+
};
|
|
13
|
+
const codeMirrorSystem = system(
|
|
14
|
+
(r, [, { insertCodeBlock }]) => {
|
|
15
|
+
const codeBlockLanguages = r.node(defaultCodeBlockLanguages);
|
|
16
|
+
const insertCodeMirror = r.node();
|
|
17
|
+
r.link(
|
|
18
|
+
r.pipe(
|
|
19
|
+
insertCodeMirror,
|
|
20
|
+
r.o.map(({ language, code }) => {
|
|
21
|
+
return {
|
|
22
|
+
code,
|
|
23
|
+
language,
|
|
24
|
+
meta: ""
|
|
25
|
+
};
|
|
26
|
+
})
|
|
27
|
+
),
|
|
28
|
+
insertCodeBlock
|
|
29
|
+
);
|
|
30
|
+
return {
|
|
31
|
+
codeBlockLanguages,
|
|
32
|
+
insertCodeMirror
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
[coreSystem, codeBlockSystem]
|
|
36
|
+
);
|
|
37
|
+
const [
|
|
38
|
+
/** @internal */
|
|
39
|
+
codeMirrorPlugin,
|
|
40
|
+
/** @internal */
|
|
41
|
+
codeMirrorHooks
|
|
42
|
+
] = realmPlugin({
|
|
43
|
+
id: "codemirror",
|
|
44
|
+
systemSpec: codeMirrorSystem,
|
|
45
|
+
applyParamsToSystem(r, params) {
|
|
46
|
+
r.pubKey("codeBlockLanguages", params.codeBlockLanguages);
|
|
47
|
+
},
|
|
48
|
+
init(r, { codeBlockLanguages }) {
|
|
49
|
+
r.pubKey("appendCodeBlockEditorDescriptor", {
|
|
50
|
+
match(language, meta) {
|
|
51
|
+
return codeBlockLanguages.hasOwnProperty(language) && meta === "";
|
|
52
|
+
},
|
|
53
|
+
priority: 1,
|
|
54
|
+
Editor: CodeMirrorEditor
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
export {
|
|
59
|
+
codeMirrorHooks,
|
|
60
|
+
codeMirrorPlugin,
|
|
61
|
+
codeMirrorSystem
|
|
62
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DOMConversionMap, DOMExportOutput, ElementNode, LexicalEditor, LexicalNode, NodeKey, SerializedElementNode, Spread } from 'lexical';
|
|
2
|
+
import { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
|
|
3
|
+
import { MDX_NODE_TYPES, htmlTags } from './MdastHTMLNode';
|
|
4
|
+
export type KnownHTMLTagType = (typeof htmlTags)[number];
|
|
5
|
+
declare const TYPE_NAME: "generic-html";
|
|
6
|
+
export type SerializedGenericHTMLNode = Spread<{
|
|
7
|
+
tag: KnownHTMLTagType;
|
|
8
|
+
type: typeof TYPE_NAME;
|
|
9
|
+
mdxType: MdxNodeType;
|
|
10
|
+
attributes: MdxJsxAttribute[];
|
|
11
|
+
version: 1;
|
|
12
|
+
}, SerializedElementNode>;
|
|
13
|
+
type MdxNodeType = (typeof MDX_NODE_TYPES)[number];
|
|
14
|
+
export declare class GenericHTMLNode extends ElementNode {
|
|
15
|
+
/** @internal */
|
|
16
|
+
__tag: KnownHTMLTagType;
|
|
17
|
+
__nodeType: MdxNodeType;
|
|
18
|
+
__attributes: MdxJsxAttribute[];
|
|
19
|
+
static getType(): string;
|
|
20
|
+
static clone(node: GenericHTMLNode): GenericHTMLNode;
|
|
21
|
+
constructor(tag: KnownHTMLTagType, type: MdxNodeType, attributes: MdxJsxAttribute[], key?: NodeKey);
|
|
22
|
+
getTag(): KnownHTMLTagType;
|
|
23
|
+
getNodeType(): MdxNodeType;
|
|
24
|
+
getAttributes(): MdxJsxAttribute[];
|
|
25
|
+
updateAttributes(attributes: MdxJsxAttribute[]): void;
|
|
26
|
+
getStyle(): string;
|
|
27
|
+
createDOM(): HTMLElement;
|
|
28
|
+
updateDOM(): boolean;
|
|
29
|
+
static importDOM(): DOMConversionMap | null;
|
|
30
|
+
exportDOM(editor: LexicalEditor): DOMExportOutput;
|
|
31
|
+
static importJSON(serializedNode: SerializedGenericHTMLNode): GenericHTMLNode;
|
|
32
|
+
exportJSON(): SerializedGenericHTMLNode;
|
|
33
|
+
extractWithChild(): boolean;
|
|
34
|
+
isInline(): boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare function $createGenericHTMLNode(tag: KnownHTMLTagType, type: MdxNodeType, attributes: MdxJsxAttribute[]): GenericHTMLNode;
|
|
37
|
+
export declare function $isGenericHTMLNode(node: LexicalNode | null | undefined): node is GenericHTMLNode;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { ElementNode, $applyNodeReplacement } from "lexical";
|
|
8
|
+
const TYPE_NAME = "generic-html";
|
|
9
|
+
class GenericHTMLNode extends ElementNode {
|
|
10
|
+
constructor(tag, type, attributes, key) {
|
|
11
|
+
super(key);
|
|
12
|
+
/** @internal */
|
|
13
|
+
__publicField(this, "__tag");
|
|
14
|
+
__publicField(this, "__nodeType");
|
|
15
|
+
__publicField(this, "__attributes");
|
|
16
|
+
this.__tag = tag;
|
|
17
|
+
this.__nodeType = type;
|
|
18
|
+
this.__attributes = attributes;
|
|
19
|
+
}
|
|
20
|
+
static getType() {
|
|
21
|
+
return TYPE_NAME;
|
|
22
|
+
}
|
|
23
|
+
static clone(node) {
|
|
24
|
+
return new GenericHTMLNode(node.__tag, node.__nodeType, node.__attributes, node.__key);
|
|
25
|
+
}
|
|
26
|
+
getTag() {
|
|
27
|
+
return this.__tag;
|
|
28
|
+
}
|
|
29
|
+
getNodeType() {
|
|
30
|
+
return this.__nodeType;
|
|
31
|
+
}
|
|
32
|
+
getAttributes() {
|
|
33
|
+
return this.__attributes;
|
|
34
|
+
}
|
|
35
|
+
updateAttributes(attributes) {
|
|
36
|
+
const self = this.getWritable();
|
|
37
|
+
self.__attributes = attributes;
|
|
38
|
+
}
|
|
39
|
+
getStyle() {
|
|
40
|
+
var _a;
|
|
41
|
+
return (_a = this.__attributes.find((attribute) => attribute.name === "style")) == null ? void 0 : _a.value;
|
|
42
|
+
}
|
|
43
|
+
// View
|
|
44
|
+
createDOM() {
|
|
45
|
+
const tag = this.__tag;
|
|
46
|
+
const element = document.createElement(tag);
|
|
47
|
+
this.__attributes.forEach((attribute) => {
|
|
48
|
+
element.setAttribute(attribute.name, attribute.value);
|
|
49
|
+
});
|
|
50
|
+
return element;
|
|
51
|
+
}
|
|
52
|
+
updateDOM() {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
static importDOM() {
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
exportDOM(editor) {
|
|
59
|
+
const { element } = super.exportDOM(editor);
|
|
60
|
+
return {
|
|
61
|
+
element
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
static importJSON(serializedNode) {
|
|
65
|
+
const node = $createGenericHTMLNode(serializedNode.tag, serializedNode.mdxType, serializedNode.attributes);
|
|
66
|
+
node.setFormat(serializedNode.format);
|
|
67
|
+
node.setIndent(serializedNode.indent);
|
|
68
|
+
node.setDirection(serializedNode.direction);
|
|
69
|
+
return node;
|
|
70
|
+
}
|
|
71
|
+
exportJSON() {
|
|
72
|
+
return {
|
|
73
|
+
...super.exportJSON(),
|
|
74
|
+
tag: this.getTag(),
|
|
75
|
+
attributes: this.__attributes,
|
|
76
|
+
mdxType: this.__nodeType,
|
|
77
|
+
type: TYPE_NAME,
|
|
78
|
+
version: 1
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/*
|
|
82
|
+
// Mutation
|
|
83
|
+
insertNewAfter(selection?: RangeSelection, restoreSelection = true): ParagraphNode | GenericHTMLNode {
|
|
84
|
+
const anchorOffet = selection ? selection.anchor.offset : 0
|
|
85
|
+
const newElement =
|
|
86
|
+
anchorOffet > 0 && anchorOffet < this.getTextContentSize() ? $createHeadingNode(this.getTag()) : $createParagraphNode()
|
|
87
|
+
const direction = this.getDirection()
|
|
88
|
+
newElement.setDirection(direction)
|
|
89
|
+
this.insertAfter(newElement, restoreSelection)
|
|
90
|
+
return newElement
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
collapseAtStart(): true {
|
|
94
|
+
const newElement = !this.isEmpty() ? $createHeadingNode(this.getTag()) : $createParagraphNode()
|
|
95
|
+
const children = this.getChildren()
|
|
96
|
+
children.forEach((child) => newElement.append(child))
|
|
97
|
+
this.replace(newElement)
|
|
98
|
+
return true
|
|
99
|
+
}*/
|
|
100
|
+
extractWithChild() {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
isInline() {
|
|
104
|
+
return this.__nodeType === "mdxJsxTextElement";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function $createGenericHTMLNode(tag, type, attributes) {
|
|
108
|
+
return $applyNodeReplacement(new GenericHTMLNode(tag, type, attributes));
|
|
109
|
+
}
|
|
110
|
+
function $isGenericHTMLNode(node) {
|
|
111
|
+
return node instanceof GenericHTMLNode;
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
$createGenericHTMLNode,
|
|
115
|
+
$isGenericHTMLNode,
|
|
116
|
+
GenericHTMLNode
|
|
117
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type IconKey = 'add_column' | 'add_photo' | 'add_row' | 'arrow_drop_down' | 'check' | 'check_small' | 'close' | 'code' | 'content_copy' | 'delete_big' | 'delete_small' | 'sandpack' | 'difference' | 'edit' | 'admonition' | 'extension' | 'format_align_center' | 'format_align_left' | 'format_align_right' | 'format_bold' | 'format_italic' | 'format_list_bulleted' | 'format_list_checked' | 'format_list_numbered' | 'format_underlined' | 'frame_source' | 'frontmatter' | 'horizontal_rule' | 'insert_col_left' | 'insert_col_right' | 'insert_row_above' | 'insert_row_below' | 'link' | 'link_off' | 'markdown' | 'more_horiz' | 'more_vert' | 'open_in_new' | 'redo' | 'rich_text' | 'settings' | 'table' | 'undo';
|
|
3
|
+
declare const Icon: React.FC<{
|
|
4
|
+
name: IconKey;
|
|
5
|
+
}>;
|
|
6
|
+
export default Icon;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
import SvgAddColumn from "../../icons/add_column.svg.js";
|
|
3
|
+
import SvgAddPhoto from "../../icons/add_photo.svg.js";
|
|
4
|
+
import SvgAddRow from "../../icons/add_row.svg.js";
|
|
5
|
+
import SvgArrowDropDown from "../../icons/arrow_drop_down.svg.js";
|
|
6
|
+
import SvgCheck from "../../icons/check.svg.js";
|
|
7
|
+
import SvgCheckSmall from "../../icons/check_small.svg.js";
|
|
8
|
+
import SvgClose from "../../icons/close.svg.js";
|
|
9
|
+
import SvgCode from "../../icons/code.svg.js";
|
|
10
|
+
import SvgContentCopy from "../../icons/content_copy.svg.js";
|
|
11
|
+
import SvgDeleteBig from "../../icons/delete_big.svg.js";
|
|
12
|
+
import SvgDeleteSmall from "../../icons/delete_small.svg.js";
|
|
13
|
+
import SvgSandpack from "../../icons/sandpack.svg.js";
|
|
14
|
+
import SvgDifference from "../../icons/difference.svg.js";
|
|
15
|
+
import SvgEdit from "../../icons/edit.svg.js";
|
|
16
|
+
import SvgAdmonition from "../../icons/admonition.svg.js";
|
|
17
|
+
import SvgExtension from "../../icons/extension.svg.js";
|
|
18
|
+
import SvgFormatAlignCenter from "../../icons/format_align_center.svg.js";
|
|
19
|
+
import SvgFormatAlignLeft from "../../icons/format_align_left.svg.js";
|
|
20
|
+
import SvgFormatAlignRight from "../../icons/format_align_right.svg.js";
|
|
21
|
+
import SvgFormatBold from "../../icons/format_bold.svg.js";
|
|
22
|
+
import SvgFormatItalic from "../../icons/format_italic.svg.js";
|
|
23
|
+
import SvgFormatListBulleted from "../../icons/format_list_bulleted.svg.js";
|
|
24
|
+
import SvgFormatListChecked from "../../icons/format_list_checked.svg.js";
|
|
25
|
+
import SvgFormatListNumbered from "../../icons/format_list_numbered.svg.js";
|
|
26
|
+
import SvgFormatUnderlined from "../../icons/format_underlined.svg.js";
|
|
27
|
+
import SvgFrameSource from "../../icons/frame_source.svg.js";
|
|
28
|
+
import SvgFrontmatter from "../../icons/frontmatter.svg.js";
|
|
29
|
+
import SvgHorizontalRule from "../../icons/horizontal_rule.svg.js";
|
|
30
|
+
import SvgInsertColLeft from "../../icons/insert_col_left.svg.js";
|
|
31
|
+
import SvgInsertColRight from "../../icons/insert_col_right.svg.js";
|
|
32
|
+
import SvgInsertRowAbove from "../../icons/insert_row_above.svg.js";
|
|
33
|
+
import SvgInsertRowBelow from "../../icons/insert_row_below.svg.js";
|
|
34
|
+
import SvgLink from "../../icons/link.svg.js";
|
|
35
|
+
import SvgLinkOff from "../../icons/link_off.svg.js";
|
|
36
|
+
import SvgMarkdown from "../../icons/markdown.svg.js";
|
|
37
|
+
import SvgMoreHoriz from "../../icons/more_horiz.svg.js";
|
|
38
|
+
import SvgMoreVert from "../../icons/more_vert.svg.js";
|
|
39
|
+
import SvgOpenInNew from "../../icons/open_in_new.svg.js";
|
|
40
|
+
import SvgRedo from "../../icons/redo.svg.js";
|
|
41
|
+
import SvgRichText from "../../icons/rich_text.svg.js";
|
|
42
|
+
import SvgSettings from "../../icons/settings.svg.js";
|
|
43
|
+
import SvgTable from "../../icons/table.svg.js";
|
|
44
|
+
import SvgUndo from "../../icons/undo.svg.js";
|
|
45
|
+
const IconMap = {
|
|
46
|
+
add_column: SvgAddColumn,
|
|
47
|
+
add_photo: SvgAddPhoto,
|
|
48
|
+
add_row: SvgAddRow,
|
|
49
|
+
arrow_drop_down: SvgArrowDropDown,
|
|
50
|
+
check: SvgCheck,
|
|
51
|
+
check_small: SvgCheckSmall,
|
|
52
|
+
close: SvgClose,
|
|
53
|
+
code: SvgCode,
|
|
54
|
+
content_copy: SvgContentCopy,
|
|
55
|
+
delete_big: SvgDeleteBig,
|
|
56
|
+
delete_small: SvgDeleteSmall,
|
|
57
|
+
sandpack: SvgSandpack,
|
|
58
|
+
difference: SvgDifference,
|
|
59
|
+
edit: SvgEdit,
|
|
60
|
+
admonition: SvgAdmonition,
|
|
61
|
+
extension: SvgExtension,
|
|
62
|
+
format_align_center: SvgFormatAlignCenter,
|
|
63
|
+
format_align_left: SvgFormatAlignLeft,
|
|
64
|
+
format_align_right: SvgFormatAlignRight,
|
|
65
|
+
format_bold: SvgFormatBold,
|
|
66
|
+
format_italic: SvgFormatItalic,
|
|
67
|
+
format_list_bulleted: SvgFormatListBulleted,
|
|
68
|
+
format_list_checked: SvgFormatListChecked,
|
|
69
|
+
format_list_numbered: SvgFormatListNumbered,
|
|
70
|
+
format_underlined: SvgFormatUnderlined,
|
|
71
|
+
frame_source: SvgFrameSource,
|
|
72
|
+
frontmatter: SvgFrontmatter,
|
|
73
|
+
horizontal_rule: SvgHorizontalRule,
|
|
74
|
+
insert_col_left: SvgInsertColLeft,
|
|
75
|
+
insert_col_right: SvgInsertColRight,
|
|
76
|
+
insert_row_above: SvgInsertRowAbove,
|
|
77
|
+
insert_row_below: SvgInsertRowBelow,
|
|
78
|
+
link: SvgLink,
|
|
79
|
+
link_off: SvgLinkOff,
|
|
80
|
+
markdown: SvgMarkdown,
|
|
81
|
+
more_horiz: SvgMoreHoriz,
|
|
82
|
+
more_vert: SvgMoreVert,
|
|
83
|
+
open_in_new: SvgOpenInNew,
|
|
84
|
+
redo: SvgRedo,
|
|
85
|
+
rich_text: SvgRichText,
|
|
86
|
+
settings: SvgSettings,
|
|
87
|
+
table: SvgTable,
|
|
88
|
+
undo: SvgUndo
|
|
89
|
+
};
|
|
90
|
+
const Icon = ({ name }) => {
|
|
91
|
+
const IconComponent = IconMap[name];
|
|
92
|
+
return /* @__PURE__ */ React__default.createElement(IconComponent, null);
|
|
93
|
+
};
|
|
94
|
+
export {
|
|
95
|
+
Icon as default
|
|
96
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
2
|
+
import { GenericHTMLNode } from './GenericHTMLNode';
|
|
3
|
+
import { LexicalExportVisitor } from '../../exportMarkdownFromLexical';
|
|
4
|
+
export declare const LexicalGenericHTMLVisitor: LexicalExportVisitor<GenericHTMLNode, MdxJsxFlowElement | MdxJsxTextElement>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { $isGenericHTMLNode } from "./GenericHTMLNode.js";
|
|
2
|
+
const LexicalGenericHTMLVisitor = {
|
|
3
|
+
testLexicalNode: $isGenericHTMLNode,
|
|
4
|
+
visitLexicalNode({ actions, lexicalNode }) {
|
|
5
|
+
actions.addAndStepInto("mdxJsxTextElement", {
|
|
6
|
+
name: lexicalNode.getTag(),
|
|
7
|
+
type: lexicalNode.getNodeType(),
|
|
8
|
+
attributes: lexicalNode.getAttributes()
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
priority: -100
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
LexicalGenericHTMLVisitor
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { $isLineBreakNode } from "lexical";
|
|
2
|
+
const LexicalLinebreakVisitor = {
|
|
3
|
+
testLexicalNode: $isLineBreakNode,
|
|
4
|
+
visitLexicalNode: ({ mdastParent, actions }) => {
|
|
5
|
+
actions.appendToParent(mdastParent, { type: "text", value: "\n" });
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
LexicalLinebreakVisitor
|
|
10
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TextNode } from 'lexical';
|
|
2
|
+
import * as Mdast from 'mdast';
|
|
3
|
+
import { LexicalExportVisitor } from '../../exportMarkdownFromLexical';
|
|
4
|
+
export declare function isMdastText(mdastNode: Mdast.Content): mdastNode is Mdast.Text;
|
|
5
|
+
export declare const LexicalTextVisitor: LexicalExportVisitor<TextNode, Mdast.Text>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { $isTextNode } from "lexical";
|
|
2
|
+
import { IS_CODE, IS_ITALIC, IS_BOLD, IS_UNDERLINE } from "../../FormatConstants.js";
|
|
3
|
+
function isMdastText(mdastNode) {
|
|
4
|
+
return mdastNode.type === "text";
|
|
5
|
+
}
|
|
6
|
+
const JOINABLE_TAGS = ["u", "span"];
|
|
7
|
+
const LexicalTextVisitor = {
|
|
8
|
+
shouldJoin: (prevNode, currentNode) => {
|
|
9
|
+
if (["text", "emphasis", "strong"].includes(prevNode.type)) {
|
|
10
|
+
return prevNode.type === currentNode.type;
|
|
11
|
+
}
|
|
12
|
+
if (prevNode.type === "mdxJsxTextElement" && currentNode.type === "mdxJsxTextElement" && JOINABLE_TAGS.includes(currentNode.name)) {
|
|
13
|
+
const currentMdxNode = currentNode;
|
|
14
|
+
return prevNode.name === currentMdxNode.name && JSON.stringify(prevNode.attributes) === JSON.stringify(currentMdxNode.attributes);
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
},
|
|
18
|
+
join(prevNode, currentNode) {
|
|
19
|
+
if (isMdastText(prevNode) && isMdastText(currentNode)) {
|
|
20
|
+
return {
|
|
21
|
+
type: "text",
|
|
22
|
+
value: prevNode.value + currentNode.value
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
return {
|
|
26
|
+
...prevNode,
|
|
27
|
+
children: [...prevNode.children, ...currentNode.children]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
testLexicalNode: $isTextNode,
|
|
32
|
+
visitLexicalNode: ({ lexicalNode, mdastParent, actions }) => {
|
|
33
|
+
const previousSibling = lexicalNode.getPreviousSibling();
|
|
34
|
+
const prevFormat = $isTextNode(previousSibling) ? previousSibling.getFormat() : 0;
|
|
35
|
+
const textContent = lexicalNode.getTextContent();
|
|
36
|
+
const format = lexicalNode.getFormat() ?? 0;
|
|
37
|
+
const style = lexicalNode.getStyle();
|
|
38
|
+
if (format & IS_CODE) {
|
|
39
|
+
actions.addAndStepInto("inlineCode", {
|
|
40
|
+
value: textContent
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let localParentNode = mdastParent;
|
|
45
|
+
if (style) {
|
|
46
|
+
localParentNode = actions.appendToParent(localParentNode, {
|
|
47
|
+
type: "mdxJsxTextElement",
|
|
48
|
+
name: "span",
|
|
49
|
+
children: [],
|
|
50
|
+
attributes: [{ type: "mdxJsxAttribute", name: "style", value: style }]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (prevFormat & format & IS_ITALIC) {
|
|
54
|
+
localParentNode = actions.appendToParent(localParentNode, {
|
|
55
|
+
type: "emphasis",
|
|
56
|
+
children: []
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (prevFormat & format & IS_BOLD) {
|
|
60
|
+
localParentNode = actions.appendToParent(localParentNode, {
|
|
61
|
+
type: "strong",
|
|
62
|
+
children: []
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (prevFormat & format & IS_UNDERLINE) {
|
|
66
|
+
localParentNode = actions.appendToParent(localParentNode, {
|
|
67
|
+
type: "mdxJsxTextElement",
|
|
68
|
+
name: "u",
|
|
69
|
+
children: [],
|
|
70
|
+
attributes: []
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (format & IS_ITALIC && !(prevFormat & IS_ITALIC)) {
|
|
74
|
+
localParentNode = actions.appendToParent(localParentNode, {
|
|
75
|
+
type: "emphasis",
|
|
76
|
+
children: []
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (format & IS_BOLD && !(prevFormat & IS_BOLD)) {
|
|
80
|
+
localParentNode = actions.appendToParent(localParentNode, {
|
|
81
|
+
type: "strong",
|
|
82
|
+
children: []
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (format & IS_UNDERLINE && !(prevFormat & IS_UNDERLINE)) {
|
|
86
|
+
localParentNode = actions.appendToParent(localParentNode, {
|
|
87
|
+
type: "mdxJsxTextElement",
|
|
88
|
+
name: "u",
|
|
89
|
+
children: [],
|
|
90
|
+
attributes: []
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
actions.appendToParent(localParentNode, {
|
|
94
|
+
type: "text",
|
|
95
|
+
value: textContent
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
export {
|
|
100
|
+
LexicalTextVisitor,
|
|
101
|
+
isMdastText
|
|
102
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IS_UNDERLINE, IS_ITALIC, IS_BOLD } from "../../FormatConstants.js";
|
|
2
|
+
function isOpeningUnderlineNode(node) {
|
|
3
|
+
return node.type === "html" && node.value === "<u>";
|
|
4
|
+
}
|
|
5
|
+
function isClosingUnderlineNode(node) {
|
|
6
|
+
return node.type === "html" && node.value === "</u>";
|
|
7
|
+
}
|
|
8
|
+
function isJsxUnderlineNode(node) {
|
|
9
|
+
return node.type === "mdxJsxTextElement" && node.name === "u";
|
|
10
|
+
}
|
|
11
|
+
const MdastFormattingVisitor = {
|
|
12
|
+
testNode(mdastNode) {
|
|
13
|
+
return mdastNode.type === "emphasis" || mdastNode.type === "strong" || isJsxUnderlineNode(mdastNode) || isOpeningUnderlineNode(mdastNode) || isClosingUnderlineNode(mdastNode);
|
|
14
|
+
},
|
|
15
|
+
visitNode({ mdastNode, lexicalParent, actions, mdastParent }) {
|
|
16
|
+
if (isOpeningUnderlineNode(mdastNode)) {
|
|
17
|
+
actions.addFormatting(IS_UNDERLINE, mdastParent);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (isClosingUnderlineNode(mdastNode)) {
|
|
21
|
+
actions.removeFormatting(IS_UNDERLINE, mdastParent);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (mdastNode.type === "emphasis") {
|
|
25
|
+
actions.addFormatting(IS_ITALIC);
|
|
26
|
+
} else if (mdastNode.type === "strong") {
|
|
27
|
+
actions.addFormatting(IS_BOLD);
|
|
28
|
+
} else if (isJsxUnderlineNode(mdastNode)) {
|
|
29
|
+
actions.addFormatting(IS_UNDERLINE);
|
|
30
|
+
}
|
|
31
|
+
actions.visitChildren(mdastNode, lexicalParent);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
MdastFormattingVisitor
|
|
36
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Mdast from 'mdast';
|
|
2
|
+
import { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
3
|
+
interface MdastBlockHTMLNode extends MdxJsxFlowElement {
|
|
4
|
+
name: (typeof htmlTags)[number];
|
|
5
|
+
}
|
|
6
|
+
interface MdastInlineHTMLNode extends MdxJsxTextElement {
|
|
7
|
+
name: (typeof htmlTags)[number];
|
|
8
|
+
}
|
|
9
|
+
export type MdastHTMLNode = MdastBlockHTMLNode | MdastInlineHTMLNode;
|
|
10
|
+
export declare const MDX_NODE_TYPES: readonly ["mdxJsxTextElement", "mdxJsxFlowElement"];
|
|
11
|
+
export declare function isMdastHTMLNode(node: Mdast.Parent | Mdast.Content | Mdast.Root): node is MdastHTMLNode;
|
|
12
|
+
export declare const htmlTags: readonly ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "input", "ins", "kbd", "label", "legend", "li", "link", "main", "map", "mark", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr"];
|
|
13
|
+
export {};
|