@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
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { RefObject, ComponentType, ReactNode } from 'react';
|
|
2
|
+
import type { LexicalVisitor } from '../../exportMarkdownFromLexical';
|
|
3
|
+
import type { Options } from 'mdast-util-to-markdown';
|
|
4
|
+
import type { Config } from 'mdast-util-from-markdown/lib';
|
|
5
|
+
import type { Extension } from 'micromark-util-types';
|
|
6
|
+
import type { Content } from 'mdast';
|
|
7
|
+
import type { MdastImportVisitor } from '../../importMarkdownToLexical';
|
|
8
|
+
import type { EditorSubscription, EditorInFocus, BlockType } from '../core';
|
|
9
|
+
import type { InitialEditorStateType } from '@lexical/react/LexicalComposer';
|
|
10
|
+
import type { JsxComponentDescriptor } from '../jsx';
|
|
11
|
+
import type { HistoryState } from '@lexical/history';
|
|
12
|
+
import type { LexicalEditor, RangeSelection, Klass, LexicalNode, TextFormatType, ElementNode, DecoratorNode } from 'lexical';
|
|
13
|
+
import type { SystemSpec, Realm, RealmNode, PluginConstructor } from '../../gurx';
|
|
14
|
+
/// <reference types="react" />
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare const headingsSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
19
|
+
activeEditor: RealmNode<LexicalEditor | null>;
|
|
20
|
+
inFocus: RealmNode<boolean>;
|
|
21
|
+
historyState: RealmNode<HistoryState>;
|
|
22
|
+
currentSelection: RealmNode<RangeSelection | null>;
|
|
23
|
+
jsxIsAvailable: RealmNode<boolean>;
|
|
24
|
+
jsxComponentDescriptors: RealmNode<JsxComponentDescriptor[]>;
|
|
25
|
+
initialRootEditorState: RealmNode<InitialEditorStateType>;
|
|
26
|
+
rootEditor: RealmNode<LexicalEditor | null>;
|
|
27
|
+
createRootEditorSubscription: RealmNode<EditorSubscription>;
|
|
28
|
+
createActiveEditorSubscription: RealmNode<EditorSubscription>;
|
|
29
|
+
importVisitors: RealmNode<MdastImportVisitor<Content>[]>;
|
|
30
|
+
syntaxExtensions: RealmNode<Extension[]>;
|
|
31
|
+
mdastExtensions: RealmNode<(Partial<Config> | Partial<Config>[])[] | null | undefined>;
|
|
32
|
+
usedLexicalNodes: RealmNode<Klass<LexicalNode>[]>;
|
|
33
|
+
addImportVisitor: RealmNode<MdastImportVisitor<Content>>;
|
|
34
|
+
addLexicalNode: RealmNode<Klass<LexicalNode>>;
|
|
35
|
+
addSyntaxExtension: RealmNode<Extension>;
|
|
36
|
+
addMdastExtension: RealmNode<Partial<Config> | Partial<Config>[]>;
|
|
37
|
+
toMarkdownExtensions: RealmNode<Options[]>;
|
|
38
|
+
toMarkdownOptions: RealmNode<Options>;
|
|
39
|
+
addToMarkdownExtension: RealmNode<Options>;
|
|
40
|
+
addExportVisitor: RealmNode<LexicalVisitor>;
|
|
41
|
+
exportVisitors: RealmNode<LexicalVisitor[]>;
|
|
42
|
+
initialMarkdown: RealmNode<string>;
|
|
43
|
+
setMarkdown: RealmNode<string>;
|
|
44
|
+
markdown: RealmNode<string>;
|
|
45
|
+
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
46
|
+
contentEditableClassName: RealmNode<string>;
|
|
47
|
+
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
48
|
+
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
49
|
+
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
50
|
+
addTopAreaChild: RealmNode<ComponentType<{}>>;
|
|
51
|
+
nestedEditorChildren: RealmNode<ComponentType<{}>[]>;
|
|
52
|
+
addNestedEditorChild: RealmNode<ComponentType<{}>>;
|
|
53
|
+
editorWrappers: RealmNode<ComponentType<{
|
|
54
|
+
children: ReactNode;
|
|
55
|
+
}>[]>;
|
|
56
|
+
addEditorWrapper: RealmNode<ComponentType<{
|
|
57
|
+
children: ReactNode;
|
|
58
|
+
}>>;
|
|
59
|
+
currentFormat: RealmNode<number>;
|
|
60
|
+
editorInFocus: RealmNode<EditorInFocus | null>;
|
|
61
|
+
applyFormat: RealmNode<TextFormatType>;
|
|
62
|
+
currentBlockType: RealmNode<BlockType>;
|
|
63
|
+
applyBlockType: RealmNode<BlockType>;
|
|
64
|
+
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
65
|
+
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
66
|
+
}>], (_: Realm) => {}>;
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export declare const headingsPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
71
|
+
activeEditor: RealmNode<LexicalEditor | null>;
|
|
72
|
+
inFocus: RealmNode<boolean>;
|
|
73
|
+
historyState: RealmNode<HistoryState>;
|
|
74
|
+
currentSelection: RealmNode<RangeSelection | null>;
|
|
75
|
+
jsxIsAvailable: RealmNode<boolean>;
|
|
76
|
+
jsxComponentDescriptors: RealmNode<JsxComponentDescriptor[]>;
|
|
77
|
+
initialRootEditorState: RealmNode<InitialEditorStateType>;
|
|
78
|
+
rootEditor: RealmNode<LexicalEditor | null>;
|
|
79
|
+
createRootEditorSubscription: RealmNode<EditorSubscription>;
|
|
80
|
+
createActiveEditorSubscription: RealmNode<EditorSubscription>;
|
|
81
|
+
importVisitors: RealmNode<MdastImportVisitor<Content>[]>;
|
|
82
|
+
syntaxExtensions: RealmNode<Extension[]>;
|
|
83
|
+
mdastExtensions: RealmNode<(Partial<Config> | Partial<Config>[])[] | null | undefined>;
|
|
84
|
+
usedLexicalNodes: RealmNode<Klass<LexicalNode>[]>;
|
|
85
|
+
addImportVisitor: RealmNode<MdastImportVisitor<Content>>;
|
|
86
|
+
addLexicalNode: RealmNode<Klass<LexicalNode>>;
|
|
87
|
+
addSyntaxExtension: RealmNode<Extension>;
|
|
88
|
+
addMdastExtension: RealmNode<Partial<Config> | Partial<Config>[]>;
|
|
89
|
+
toMarkdownExtensions: RealmNode<Options[]>;
|
|
90
|
+
toMarkdownOptions: RealmNode<Options>;
|
|
91
|
+
addToMarkdownExtension: RealmNode<Options>;
|
|
92
|
+
addExportVisitor: RealmNode<LexicalVisitor>;
|
|
93
|
+
exportVisitors: RealmNode<LexicalVisitor[]>;
|
|
94
|
+
initialMarkdown: RealmNode<string>;
|
|
95
|
+
setMarkdown: RealmNode<string>;
|
|
96
|
+
markdown: RealmNode<string>;
|
|
97
|
+
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
98
|
+
contentEditableClassName: RealmNode<string>;
|
|
99
|
+
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
100
|
+
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
101
|
+
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
102
|
+
addTopAreaChild: RealmNode<ComponentType<{}>>;
|
|
103
|
+
nestedEditorChildren: RealmNode<ComponentType<{}>[]>;
|
|
104
|
+
addNestedEditorChild: RealmNode<ComponentType<{}>>;
|
|
105
|
+
editorWrappers: RealmNode<ComponentType<{
|
|
106
|
+
children: ReactNode;
|
|
107
|
+
}>[]>;
|
|
108
|
+
addEditorWrapper: RealmNode<ComponentType<{
|
|
109
|
+
children: ReactNode;
|
|
110
|
+
}>>;
|
|
111
|
+
currentFormat: RealmNode<number>;
|
|
112
|
+
editorInFocus: RealmNode<EditorInFocus | null>;
|
|
113
|
+
applyFormat: RealmNode<TextFormatType>;
|
|
114
|
+
currentBlockType: RealmNode<BlockType>;
|
|
115
|
+
applyBlockType: RealmNode<BlockType>;
|
|
116
|
+
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
117
|
+
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
118
|
+
}>], (_: Realm) => {}>, object>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { coreSystem } from "../core/index.js";
|
|
2
|
+
import { MdastHeadingVisitor } from "./MdastHeadingVisitor.js";
|
|
3
|
+
import { HeadingNode } from "@lexical/rich-text";
|
|
4
|
+
import { LexicalHeadingVisitor } from "./LexicalHeadingVisitor.js";
|
|
5
|
+
import { system } from "../../gurx/realmFactory.js";
|
|
6
|
+
import { realmPlugin } from "../../gurx/react.js";
|
|
7
|
+
const headingsSystem = system((_) => ({}), [coreSystem]);
|
|
8
|
+
const [headingsPlugin] = realmPlugin({
|
|
9
|
+
id: "headings",
|
|
10
|
+
systemSpec: headingsSystem,
|
|
11
|
+
init: (realm) => {
|
|
12
|
+
realm.pubKey("addImportVisitor", MdastHeadingVisitor);
|
|
13
|
+
realm.pubKey("addLexicalNode", HeadingNode);
|
|
14
|
+
realm.pubKey("addExportVisitor", LexicalHeadingVisitor);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
headingsPlugin,
|
|
19
|
+
headingsSystem
|
|
20
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface ImageEditorProps {
|
|
3
|
+
nodeKey: string;
|
|
4
|
+
src: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
width: number | 'inherit';
|
|
7
|
+
height: number | 'inherit';
|
|
8
|
+
}
|
|
9
|
+
export declare function ImageEditor({ src, title, nodeKey, width, height }: ImageEditorProps): JSX.Element;
|
|
@@ -1,46 +1,12 @@
|
|
|
1
|
-
import React__default
|
|
1
|
+
import React__default from "react";
|
|
2
2
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
3
3
|
import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection";
|
|
4
4
|
import { mergeRegister } from "@lexical/utils";
|
|
5
5
|
import { $isNodeSelection, $getSelection, $getNodeByKey, $setSelection, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_LOW, CLICK_COMMAND, DRAGSTART_COMMAND, KEY_DELETE_COMMAND, KEY_BACKSPACE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND } from "lexical";
|
|
6
|
-
import
|
|
6
|
+
import styles from "../../styles/ui.module.css.js";
|
|
7
7
|
import classNames from "classnames";
|
|
8
|
-
import "
|
|
9
|
-
import "
|
|
10
|
-
import "@lexical/react/LexicalErrorBoundary";
|
|
11
|
-
import "@lexical/react/LexicalHorizontalRulePlugin";
|
|
12
|
-
import "@lexical/react/LexicalLinkPlugin";
|
|
13
|
-
import "@lexical/react/LexicalListPlugin";
|
|
14
|
-
import "@lexical/react/LexicalRichTextPlugin";
|
|
15
|
-
import "@lexical/react/LexicalTabIndentationPlugin";
|
|
16
|
-
import "@lexical/code";
|
|
17
|
-
import "@lexical/link";
|
|
18
|
-
import "@lexical/list";
|
|
19
|
-
import "@lexical/react/LexicalHorizontalRuleNode";
|
|
20
|
-
import "@lexical/rich-text";
|
|
21
|
-
import "mdast-util-directive";
|
|
22
|
-
import "mdast-util-from-markdown";
|
|
23
|
-
import "mdast-util-frontmatter";
|
|
24
|
-
import "mdast-util-gfm-table";
|
|
25
|
-
import "mdast-util-mdx";
|
|
26
|
-
import "micromark-extension-directive";
|
|
27
|
-
import "micromark-extension-frontmatter";
|
|
28
|
-
import "micromark-extension-gfm-table";
|
|
29
|
-
import "micromark-extension-mdxjs";
|
|
30
|
-
import "@lexical/selection";
|
|
31
|
-
import "@lexical/react/LexicalHistoryPlugin";
|
|
32
|
-
import "mdast-util-to-markdown";
|
|
33
|
-
import "@radix-ui/react-popover";
|
|
34
|
-
import "@radix-ui/react-tooltip";
|
|
35
|
-
import "downshift";
|
|
36
|
-
import "@lexical/markdown";
|
|
37
|
-
import "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
38
|
-
import "react-diff-view";
|
|
39
|
-
import "unidiff";
|
|
40
|
-
import "@radix-ui/react-toolbar";
|
|
41
|
-
import "@radix-ui/react-select";
|
|
42
|
-
import "@radix-ui/react-dialog";
|
|
43
|
-
import "@lexical/react/LexicalNestedComposer";
|
|
8
|
+
import { $isImageNode } from "./ImageNode.js";
|
|
9
|
+
import ImageResizer from "./ImageResizer.js";
|
|
44
10
|
const imageCache = /* @__PURE__ */ new Set();
|
|
45
11
|
function useSuspenseImage(src) {
|
|
46
12
|
if (!imageCache.has(src)) {
|
|
@@ -58,19 +24,22 @@ function LazyImage({
|
|
|
58
24
|
title,
|
|
59
25
|
className,
|
|
60
26
|
imageRef,
|
|
61
|
-
src
|
|
27
|
+
src,
|
|
28
|
+
width,
|
|
29
|
+
height
|
|
62
30
|
}) {
|
|
63
31
|
useSuspenseImage(src);
|
|
64
|
-
return /* @__PURE__ */ React__default.createElement("img", { className: className || void 0, src, title, ref: imageRef, draggable: "false" });
|
|
32
|
+
return /* @__PURE__ */ React__default.createElement("img", { className: className || void 0, src, title, ref: imageRef, draggable: "false", width, height });
|
|
65
33
|
}
|
|
66
|
-
function ImageEditor({ src, title, nodeKey }) {
|
|
67
|
-
const imageRef = useRef(null);
|
|
68
|
-
const buttonRef = useRef(null);
|
|
34
|
+
function ImageEditor({ src, title, nodeKey, width, height }) {
|
|
35
|
+
const imageRef = React__default.useRef(null);
|
|
36
|
+
const buttonRef = React__default.useRef(null);
|
|
69
37
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
70
38
|
const [editor] = useLexicalComposerContext();
|
|
71
|
-
const [selection, setSelection] = useState(null);
|
|
72
|
-
const activeEditorRef = useRef(null);
|
|
73
|
-
const
|
|
39
|
+
const [selection, setSelection] = React__default.useState(null);
|
|
40
|
+
const activeEditorRef = React__default.useRef(null);
|
|
41
|
+
const [isResizing, setIsResizing] = React__default.useState(false);
|
|
42
|
+
const onDelete = React__default.useCallback(
|
|
74
43
|
(payload) => {
|
|
75
44
|
if (isSelected && $isNodeSelection($getSelection())) {
|
|
76
45
|
const event = payload;
|
|
@@ -84,7 +53,7 @@ function ImageEditor({ src, title, nodeKey }) {
|
|
|
84
53
|
},
|
|
85
54
|
[isSelected, nodeKey]
|
|
86
55
|
);
|
|
87
|
-
const onEnter = useCallback(
|
|
56
|
+
const onEnter = React__default.useCallback(
|
|
88
57
|
(event) => {
|
|
89
58
|
const latestSelection = $getSelection();
|
|
90
59
|
const buttonElem = buttonRef.current;
|
|
@@ -99,7 +68,7 @@ function ImageEditor({ src, title, nodeKey }) {
|
|
|
99
68
|
},
|
|
100
69
|
[isSelected]
|
|
101
70
|
);
|
|
102
|
-
const onEscape = useCallback(
|
|
71
|
+
const onEscape = React__default.useCallback(
|
|
103
72
|
(event) => {
|
|
104
73
|
if (buttonRef.current === event.target) {
|
|
105
74
|
$setSelection(null);
|
|
@@ -116,7 +85,7 @@ function ImageEditor({ src, title, nodeKey }) {
|
|
|
116
85
|
},
|
|
117
86
|
[editor, setSelected]
|
|
118
87
|
);
|
|
119
|
-
useEffect(() => {
|
|
88
|
+
React__default.useEffect(() => {
|
|
120
89
|
let isMounted = true;
|
|
121
90
|
const unregister = mergeRegister(
|
|
122
91
|
editor.registerUpdateListener(({ editorState }) => {
|
|
@@ -136,6 +105,9 @@ function ImageEditor({ src, title, nodeKey }) {
|
|
|
136
105
|
CLICK_COMMAND,
|
|
137
106
|
(payload) => {
|
|
138
107
|
const event = payload;
|
|
108
|
+
if (isResizing) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
139
111
|
if (event.target === imageRef.current) {
|
|
140
112
|
if (event.shiftKey) {
|
|
141
113
|
setSelected(!isSelected);
|
|
@@ -169,12 +141,28 @@ function ImageEditor({ src, title, nodeKey }) {
|
|
|
169
141
|
isMounted = false;
|
|
170
142
|
unregister();
|
|
171
143
|
};
|
|
172
|
-
}, [clearSelection, editor, isSelected, nodeKey, onDelete, onEnter, onEscape, setSelected]);
|
|
144
|
+
}, [clearSelection, editor, isResizing, isSelected, nodeKey, onDelete, onEnter, onEscape, setSelected]);
|
|
145
|
+
const onResizeEnd = (nextWidth, nextHeight) => {
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
setIsResizing(false);
|
|
148
|
+
}, 200);
|
|
149
|
+
editor.update(() => {
|
|
150
|
+
const node = $getNodeByKey(nodeKey);
|
|
151
|
+
if ($isImageNode(node)) {
|
|
152
|
+
node.setWidthAndHeight(nextWidth, nextHeight);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
const onResizeStart = () => {
|
|
157
|
+
setIsResizing(true);
|
|
158
|
+
};
|
|
173
159
|
const draggable = $isNodeSelection(selection);
|
|
174
160
|
const isFocused = isSelected;
|
|
175
|
-
return /* @__PURE__ */ React__default.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React__default.createElement(
|
|
161
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: null }, /* @__PURE__ */ React__default.createElement("div", { className: styles.imageWrapper, "data-editor-block-type": "image" }, /* @__PURE__ */ React__default.createElement("div", { draggable }, /* @__PURE__ */ React__default.createElement(
|
|
176
162
|
LazyImage,
|
|
177
163
|
{
|
|
164
|
+
width,
|
|
165
|
+
height,
|
|
178
166
|
className: classNames({
|
|
179
167
|
[styles.focusedImage]: isFocused
|
|
180
168
|
}),
|
|
@@ -182,7 +170,7 @@ function ImageEditor({ src, title, nodeKey }) {
|
|
|
182
170
|
title: title || "",
|
|
183
171
|
imageRef
|
|
184
172
|
}
|
|
185
|
-
))));
|
|
173
|
+
)), draggable && isFocused && /* @__PURE__ */ React__default.createElement(ImageResizer, { editor, imageRef, onResizeStart, onResizeEnd })));
|
|
186
174
|
}
|
|
187
175
|
export {
|
|
188
176
|
ImageEditor
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
3
|
+
import { DecoratorNode } from 'lexical';
|
|
4
|
+
/**
|
|
5
|
+
* A serialized representation of an {@link ImageNode}.
|
|
6
|
+
*/
|
|
7
|
+
export type SerializedImageNode = Spread<{
|
|
8
|
+
altText: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
width?: number;
|
|
11
|
+
height?: number;
|
|
12
|
+
src: string;
|
|
13
|
+
type: 'image';
|
|
14
|
+
version: 1;
|
|
15
|
+
}, SerializedLexicalNode>;
|
|
16
|
+
/**
|
|
17
|
+
* A lexical node that represents an image. Use {@link "$createImageNode"} to construct one.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ImageNode extends DecoratorNode<JSX.Element> {
|
|
20
|
+
__src: string;
|
|
21
|
+
__altText: string;
|
|
22
|
+
__title: string | undefined;
|
|
23
|
+
__width: 'inherit' | number;
|
|
24
|
+
__height: 'inherit' | number;
|
|
25
|
+
static getType(): string;
|
|
26
|
+
static clone(node: ImageNode): ImageNode;
|
|
27
|
+
static importJSON(serializedNode: SerializedImageNode): ImageNode;
|
|
28
|
+
exportDOM(): DOMExportOutput;
|
|
29
|
+
static importDOM(): DOMConversionMap | null;
|
|
30
|
+
constructor(src: string, altText: string, title: string | undefined, width?: 'inherit' | number, height?: 'inherit' | number, key?: NodeKey);
|
|
31
|
+
exportJSON(): SerializedImageNode;
|
|
32
|
+
setWidthAndHeight(width: 'inherit' | number, height: 'inherit' | number): void;
|
|
33
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
34
|
+
updateDOM(): false;
|
|
35
|
+
getSrc(): string;
|
|
36
|
+
getAltText(): string;
|
|
37
|
+
getTitle(): string | undefined;
|
|
38
|
+
getHeight(): 'inherit' | number;
|
|
39
|
+
getWidth(): 'inherit' | number;
|
|
40
|
+
hasExplicitDimensions(): boolean;
|
|
41
|
+
setTitle(title: string | undefined): void;
|
|
42
|
+
decorate(_parentEditor: LexicalEditor): JSX.Element;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The payload to create an {@link ImageNode}.
|
|
46
|
+
*/
|
|
47
|
+
export interface CreateImageNodeOptions {
|
|
48
|
+
altText: string;
|
|
49
|
+
width?: number;
|
|
50
|
+
height?: number;
|
|
51
|
+
title?: string;
|
|
52
|
+
key?: NodeKey;
|
|
53
|
+
src: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates an {@link ImageNode}.
|
|
57
|
+
* @param options - The payload to create an image. The keys map to the img tag attributes.
|
|
58
|
+
*/
|
|
59
|
+
export declare function $createImageNode(options: CreateImageNodeOptions): ImageNode;
|
|
60
|
+
/**
|
|
61
|
+
* Retruns true if the node is an {@link ImageNode}.
|
|
62
|
+
*/
|
|
63
|
+
export declare function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode;
|
|
@@ -0,0 +1,136 @@
|
|
|
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 React__default from "react";
|
|
8
|
+
import { DecoratorNode } from "lexical";
|
|
9
|
+
import { ImageEditor } from "./ImageEditor.js";
|
|
10
|
+
function convertImageElement(domNode) {
|
|
11
|
+
if (domNode instanceof HTMLImageElement) {
|
|
12
|
+
const { alt: altText, src, title, width, height } = domNode;
|
|
13
|
+
const node = $createImageNode({ altText, src, title, width, height });
|
|
14
|
+
return { node };
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
class ImageNode extends DecoratorNode {
|
|
19
|
+
constructor(src, altText, title, width, height, key) {
|
|
20
|
+
super(key);
|
|
21
|
+
__publicField(this, "__src");
|
|
22
|
+
__publicField(this, "__altText");
|
|
23
|
+
__publicField(this, "__title");
|
|
24
|
+
__publicField(this, "__width");
|
|
25
|
+
__publicField(this, "__height");
|
|
26
|
+
this.__src = src;
|
|
27
|
+
this.__title = title;
|
|
28
|
+
this.__altText = altText;
|
|
29
|
+
this.__width = width || "inherit";
|
|
30
|
+
this.__height = height || "inherit";
|
|
31
|
+
}
|
|
32
|
+
static getType() {
|
|
33
|
+
return "image";
|
|
34
|
+
}
|
|
35
|
+
static clone(node) {
|
|
36
|
+
return new ImageNode(node.__src, node.__altText, node.__title, node.__width, node.__height, node.__key);
|
|
37
|
+
}
|
|
38
|
+
static importJSON(serializedNode) {
|
|
39
|
+
const { altText, title, src, width, height } = serializedNode;
|
|
40
|
+
const node = $createImageNode({
|
|
41
|
+
altText,
|
|
42
|
+
title,
|
|
43
|
+
src,
|
|
44
|
+
height,
|
|
45
|
+
width
|
|
46
|
+
});
|
|
47
|
+
return node;
|
|
48
|
+
}
|
|
49
|
+
exportDOM() {
|
|
50
|
+
const element = document.createElement("img");
|
|
51
|
+
element.setAttribute("src", this.__src);
|
|
52
|
+
element.setAttribute("alt", this.__altText);
|
|
53
|
+
if (this.__title) {
|
|
54
|
+
element.setAttribute("title", this.__title);
|
|
55
|
+
}
|
|
56
|
+
if (this.__width) {
|
|
57
|
+
element.setAttribute("width", this.__width.toString());
|
|
58
|
+
}
|
|
59
|
+
if (this.__height) {
|
|
60
|
+
element.setAttribute("height", this.__height.toString());
|
|
61
|
+
}
|
|
62
|
+
return { element };
|
|
63
|
+
}
|
|
64
|
+
static importDOM() {
|
|
65
|
+
return {
|
|
66
|
+
img: () => ({
|
|
67
|
+
conversion: convertImageElement,
|
|
68
|
+
priority: 0
|
|
69
|
+
})
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
exportJSON() {
|
|
73
|
+
return {
|
|
74
|
+
altText: this.getAltText(),
|
|
75
|
+
title: this.getTitle(),
|
|
76
|
+
height: this.__height === "inherit" ? 0 : this.__height,
|
|
77
|
+
width: this.__width === "inherit" ? 0 : this.__width,
|
|
78
|
+
src: this.getSrc(),
|
|
79
|
+
type: "image",
|
|
80
|
+
version: 1
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
setWidthAndHeight(width, height) {
|
|
84
|
+
const writable = this.getWritable();
|
|
85
|
+
writable.__width = width;
|
|
86
|
+
writable.__height = height;
|
|
87
|
+
}
|
|
88
|
+
createDOM(config) {
|
|
89
|
+
const span = document.createElement("span");
|
|
90
|
+
const theme = config.theme;
|
|
91
|
+
const className = theme.image;
|
|
92
|
+
if (className !== void 0) {
|
|
93
|
+
span.className = className;
|
|
94
|
+
}
|
|
95
|
+
return span;
|
|
96
|
+
}
|
|
97
|
+
updateDOM() {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
getSrc() {
|
|
101
|
+
return this.__src;
|
|
102
|
+
}
|
|
103
|
+
getAltText() {
|
|
104
|
+
return this.__altText;
|
|
105
|
+
}
|
|
106
|
+
getTitle() {
|
|
107
|
+
return this.__title;
|
|
108
|
+
}
|
|
109
|
+
getHeight() {
|
|
110
|
+
return this.__height;
|
|
111
|
+
}
|
|
112
|
+
getWidth() {
|
|
113
|
+
return this.__width;
|
|
114
|
+
}
|
|
115
|
+
hasExplicitDimensions() {
|
|
116
|
+
return this.__width !== "inherit" || this.__height !== "inherit";
|
|
117
|
+
}
|
|
118
|
+
setTitle(title) {
|
|
119
|
+
this.getWritable().__title = title;
|
|
120
|
+
}
|
|
121
|
+
decorate(_parentEditor) {
|
|
122
|
+
return /* @__PURE__ */ React__default.createElement(ImageEditor, { src: this.getSrc(), title: this.getTitle(), nodeKey: this.getKey(), width: this.__width, height: this.__height });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function $createImageNode(options) {
|
|
126
|
+
const { altText, title, src, key, width, height } = options;
|
|
127
|
+
return new ImageNode(src, altText, title, width, height, key);
|
|
128
|
+
}
|
|
129
|
+
function $isImageNode(node) {
|
|
130
|
+
return node instanceof ImageNode;
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
$createImageNode,
|
|
134
|
+
$isImageNode,
|
|
135
|
+
ImageNode
|
|
136
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
/// <reference types="react" />
|
|
9
|
+
import type { LexicalEditor } from 'lexical';
|
|
10
|
+
export default function ImageResizer({ onResizeStart, onResizeEnd, imageRef, maxWidth, editor }: {
|
|
11
|
+
editor: LexicalEditor;
|
|
12
|
+
imageRef: {
|
|
13
|
+
current: null | HTMLElement;
|
|
14
|
+
};
|
|
15
|
+
maxWidth?: number;
|
|
16
|
+
onResizeEnd: (width: 'inherit' | number, height: 'inherit' | number) => void;
|
|
17
|
+
onResizeStart: () => void;
|
|
18
|
+
}): JSX.Element;
|