@haklex/rich-editor 0.69.0 → 0.69.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{theme-DH4xzxU-.js → ColorSchemeContext-DLWz8vFw.js} +1349 -92
- package/dist/{thumbhash-GjK8OYAb.js → LinkCardRenderer-D4mQbUQo.js} +109 -31
- package/dist/NestedEditorPluginsContext-DKFdozOE.js +8 -0
- package/dist/{ExtraNodesContext-xQ2RNsqH.js → RendererConfigProvider-BPYO0Ip0.js} +37 -7
- package/dist/{RubyRenderer-8HMSMaZz.js → RubyRenderer-BuFWY87e.js} +2 -1
- package/dist/SpoilerNode-D7Tgdo2K.js +82 -0
- package/dist/{VirtualizationPlugin-nD_x-4yR.js → VirtualizationPlugin-CkNi6FW2.js} +85 -53
- package/dist/{VirtualizationPlugin-Bqv4MkJH.js → VirtualizationPlugin-DbAHlGBL.js} +358 -172
- package/dist/{VirtualizedEditor-uWe43zaI.js → VirtualizedEditor-D099IYqN.js} +54 -41
- package/dist/block-id-state-DfN32rR_.js +5 -0
- package/dist/command-registry-entry.d.ts.map +1 -1
- package/dist/commands/registry.d.ts +2 -2
- package/dist/commands/registry.d.ts.map +1 -1
- package/dist/commands-entry.d.ts +1 -4
- package/dist/commands-entry.d.ts.map +1 -1
- package/dist/commands-entry.mjs +2 -2
- package/dist/components/ContentEditable.css.d.ts.map +1 -1
- package/dist/components/ContentEditable.d.ts +1 -1
- package/dist/components/ContentEditable.d.ts.map +1 -1
- package/dist/components/CorePlugins.d.ts +1 -1
- package/dist/components/CorePlugins.d.ts.map +1 -1
- package/dist/components/EditorSurfaceHost.d.ts +2 -2
- package/dist/components/EditorSurfaceHost.d.ts.map +1 -1
- package/dist/components/LinkFavicon.d.ts +1 -1
- package/dist/components/LinkFavicon.d.ts.map +1 -1
- package/dist/components/RendererWrapper.d.ts +5 -16
- package/dist/components/RendererWrapper.d.ts.map +1 -1
- package/dist/components/RichEditor.d.ts +2 -2
- package/dist/components/RichEditor.d.ts.map +1 -1
- package/dist/components/RichEditorShell.d.ts +7 -7
- package/dist/components/RichEditorShell.d.ts.map +1 -1
- package/dist/components/VirtualizationFromProps.d.ts +2 -2
- package/dist/components/VirtualizationFromProps.d.ts.map +1 -1
- package/dist/components/decorators/AlertEditDecorator.d.ts +3 -3
- package/dist/components/decorators/AlertEditDecorator.d.ts.map +1 -1
- package/dist/components/decorators/BannerEditDecorator.d.ts +3 -3
- package/dist/components/decorators/BannerEditDecorator.d.ts.map +1 -1
- package/dist/components/decorators/CodeBlockEditDecorator.d.ts +1 -1
- package/dist/components/decorators/CodeBlockEditDecorator.d.ts.map +1 -1
- package/dist/components/decorators/GridEditDecorator.d.ts +2 -2
- package/dist/components/decorators/GridEditDecorator.d.ts.map +1 -1
- package/dist/components/decorators/NestedEditorCorePlugins.d.ts +1 -1
- package/dist/components/decorators/NestedEditorCorePlugins.d.ts.map +1 -1
- package/dist/components/decorators/gridAutoFocus.d.ts +1 -1
- package/dist/components/decorators/gridAutoFocus.d.ts.map +1 -1
- package/dist/components/decorators/useNestedEditorSync.d.ts +1 -1
- package/dist/components/decorators/useNestedEditorSync.d.ts.map +1 -1
- package/dist/components/renderer-decoration.d.ts +13 -0
- package/dist/components/renderer-decoration.d.ts.map +1 -0
- package/dist/components/renderers/AlertRenderer.d.ts +2 -2
- package/dist/components/renderers/AlertRenderer.d.ts.map +1 -1
- package/dist/components/renderers/AlertStaticDecorator.d.ts +3 -3
- package/dist/components/renderers/AlertStaticDecorator.d.ts.map +1 -1
- package/dist/components/renderers/BannerRenderer.d.ts +2 -2
- package/dist/components/renderers/BannerRenderer.d.ts.map +1 -1
- package/dist/components/renderers/BannerStaticDecorator.d.ts +3 -3
- package/dist/components/renderers/BannerStaticDecorator.d.ts.map +1 -1
- package/dist/components/renderers/CodeBlockRenderer.d.ts +1 -1
- package/dist/components/renderers/CodeBlockRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FileRenderer.d.ts +1 -4
- package/dist/components/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteRenderer.d.ts +1 -1
- package/dist/components/renderers/FootnoteRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteSectionEditRenderer.d.ts +1 -1
- package/dist/components/renderers/FootnoteSectionEditRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteSectionRenderer.d.ts +1 -1
- package/dist/components/renderers/FootnoteSectionRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteStaticRenderer.d.ts +1 -1
- package/dist/components/renderers/FootnoteStaticRenderer.d.ts.map +1 -1
- package/dist/components/renderers/GridStaticDecorator.d.ts +2 -2
- package/dist/components/renderers/GridStaticDecorator.d.ts.map +1 -1
- package/dist/components/renderers/ImageRenderer.d.ts +2 -2
- package/dist/components/renderers/ImageRenderer.d.ts.map +1 -1
- package/dist/components/renderers/KaTeXRenderer.d.ts +1 -1
- package/dist/components/renderers/KaTeXRenderer.d.ts.map +1 -1
- package/dist/components/renderers/LinkCardRenderer.d.ts +1 -1
- package/dist/components/renderers/LinkCardRenderer.d.ts.map +1 -1
- package/dist/components/renderers/MentionRenderer.d.ts +1 -1
- package/dist/components/renderers/MentionRenderer.d.ts.map +1 -1
- package/dist/components/renderers/MermaidRenderer.d.ts +1 -1
- package/dist/components/renderers/MermaidRenderer.d.ts.map +1 -1
- package/dist/components/renderers/RubyRenderer.d.ts +2 -2
- package/dist/components/renderers/RubyRenderer.d.ts.map +1 -1
- package/dist/components/renderers/TagRenderer.d.ts +1 -2
- package/dist/components/renderers/TagRenderer.d.ts.map +1 -1
- package/dist/components/renderers/VideoRenderer.d.ts +1 -1
- package/dist/components/renderers/VideoRenderer.d.ts.map +1 -1
- package/dist/components/utils.d.ts +1 -1
- package/dist/components/utils.d.ts.map +1 -1
- package/dist/config-edit.d.ts +1 -1
- package/dist/config-edit.d.ts.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/context/ColorSchemeContext.d.ts +1 -5
- package/dist/context/ColorSchemeContext.d.ts.map +1 -1
- package/dist/context/ColorSchemeProvider.d.ts +7 -0
- package/dist/context/ColorSchemeProvider.d.ts.map +1 -0
- package/dist/context/EditorBlockContext.d.ts +2 -2
- package/dist/context/EditorBlockContext.d.ts.map +1 -1
- package/dist/context/EditorSurface.d.ts +19 -0
- package/dist/context/EditorSurface.d.ts.map +1 -0
- package/dist/context/EditorSurfaceContext.d.ts +7 -22
- package/dist/context/EditorSurfaceContext.d.ts.map +1 -1
- package/dist/context/ExtraNodesContext.d.ts +2 -6
- package/dist/context/ExtraNodesContext.d.ts.map +1 -1
- package/dist/context/ExtraNodesProvider.d.ts +7 -0
- package/dist/context/ExtraNodesProvider.d.ts.map +1 -0
- package/dist/context/FileUploadContext.d.ts +2 -6
- package/dist/context/FileUploadContext.d.ts.map +1 -1
- package/dist/context/FileUploadProvider.d.ts +7 -0
- package/dist/context/FileUploadProvider.d.ts.map +1 -0
- package/dist/context/FootnoteDefinitionsContext.d.ts +1 -4
- package/dist/context/FootnoteDefinitionsContext.d.ts.map +1 -1
- package/dist/context/FootnoteDefinitionsProvider.d.ts +6 -0
- package/dist/context/FootnoteDefinitionsProvider.d.ts.map +1 -0
- package/dist/context/ImagePreprocessContext.d.ts +2 -4
- package/dist/context/ImagePreprocessContext.d.ts.map +1 -1
- package/dist/context/ImagePreprocessProvider.d.ts +5 -0
- package/dist/context/ImagePreprocessProvider.d.ts.map +1 -0
- package/dist/context/ImageUploadContext.d.ts +2 -6
- package/dist/context/ImageUploadContext.d.ts.map +1 -1
- package/dist/context/ImageUploadProvider.d.ts +7 -0
- package/dist/context/ImageUploadProvider.d.ts.map +1 -0
- package/dist/context/NestedContentRendererContext.d.ts +4 -4
- package/dist/context/NestedContentRendererContext.d.ts.map +1 -1
- package/dist/context/NestedEditorPluginsContext.d.ts +5 -2
- package/dist/context/NestedEditorPluginsContext.d.ts.map +1 -1
- package/dist/context/NestedEditorPluginsProvider.d.ts +3 -0
- package/dist/context/NestedEditorPluginsProvider.d.ts.map +1 -0
- package/dist/context/RendererConfigContext.d.ts +9 -4
- package/dist/context/RendererConfigContext.d.ts.map +1 -1
- package/dist/context/RendererConfigProvider.d.ts +3 -0
- package/dist/context/RendererConfigProvider.d.ts.map +1 -0
- package/dist/context/TextSelectionContext.d.ts +2 -5
- package/dist/context/TextSelectionContext.d.ts.map +1 -1
- package/dist/context/TextSelectionStoreProvider.d.ts +5 -0
- package/dist/context/TextSelectionStoreProvider.d.ts.map +1 -0
- package/dist/context/VideoUploadContext.d.ts +2 -6
- package/dist/context/VideoUploadContext.d.ts.map +1 -1
- package/dist/context/VideoUploadProvider.d.ts +7 -0
- package/dist/context/VideoUploadProvider.d.ts.map +1 -0
- package/dist/{grid.css-DJWKdYpz.js → grid.css-DAMDDTZh.js} +2 -1
- package/dist/index.d.ts +15 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +34 -22
- package/dist/insert-commands-CtLGoIz0.js +9 -0
- package/dist/{katex.css-9crOcnIa.js → katex.css-DJbW49pH.js} +1 -1
- package/dist/{node-registry-DRd8ZbeC.js → node-registry-PtbiwsVu.js} +416 -42
- package/dist/node-registry.d.ts +1 -1
- package/dist/node-registry.d.ts.map +1 -1
- package/dist/nodes/AlertQuoteEditNode.d.ts +4 -4
- package/dist/nodes/AlertQuoteEditNode.d.ts.map +1 -1
- package/dist/nodes/AlertQuoteNode.d.ts +3 -2
- package/dist/nodes/AlertQuoteNode.d.ts.map +1 -1
- package/dist/nodes/BannerEditNode.d.ts +4 -4
- package/dist/nodes/BannerEditNode.d.ts.map +1 -1
- package/dist/nodes/BannerNode.d.ts +3 -2
- package/dist/nodes/BannerNode.d.ts.map +1 -1
- package/dist/nodes/CodeBlockEditNode.d.ts +6 -6
- package/dist/nodes/CodeBlockEditNode.d.ts.map +1 -1
- package/dist/nodes/CodeBlockNode.d.ts +4 -3
- package/dist/nodes/CodeBlockNode.d.ts.map +1 -1
- package/dist/nodes/CommentNode.d.ts +3 -2
- package/dist/nodes/CommentNode.d.ts.map +1 -1
- package/dist/nodes/DetailsNode.d.ts +4 -3
- package/dist/nodes/DetailsNode.d.ts.map +1 -1
- package/dist/nodes/FileNode.d.ts +4 -3
- package/dist/nodes/FileNode.d.ts.map +1 -1
- package/dist/nodes/FootnoteNode.d.ts +3 -2
- package/dist/nodes/FootnoteNode.d.ts.map +1 -1
- package/dist/nodes/FootnoteSectionEditNode.d.ts +2 -2
- package/dist/nodes/FootnoteSectionEditNode.d.ts.map +1 -1
- package/dist/nodes/FootnoteSectionNode.d.ts +3 -2
- package/dist/nodes/FootnoteSectionNode.d.ts.map +1 -1
- package/dist/nodes/GridContainerNode.d.ts +3 -2
- package/dist/nodes/GridContainerNode.d.ts.map +1 -1
- package/dist/nodes/GridEditNode.d.ts +4 -4
- package/dist/nodes/GridEditNode.d.ts.map +1 -1
- package/dist/nodes/ImageNode.d.ts +5 -4
- package/dist/nodes/ImageNode.d.ts.map +1 -1
- package/dist/nodes/KaTeXBlockNode.d.ts +4 -3
- package/dist/nodes/KaTeXBlockNode.d.ts.map +1 -1
- package/dist/nodes/KaTeXInlineNode.d.ts +3 -2
- package/dist/nodes/KaTeXInlineNode.d.ts.map +1 -1
- package/dist/nodes/LinkCardNode.d.ts +4 -3
- package/dist/nodes/LinkCardNode.d.ts.map +1 -1
- package/dist/nodes/MentionNode.d.ts +4 -3
- package/dist/nodes/MentionNode.d.ts.map +1 -1
- package/dist/nodes/MermaidNode.d.ts +4 -3
- package/dist/nodes/MermaidNode.d.ts.map +1 -1
- package/dist/nodes/RichQuoteNode.d.ts +2 -2
- package/dist/nodes/RichQuoteNode.d.ts.map +1 -1
- package/dist/nodes/RubyNode.d.ts +2 -1
- package/dist/nodes/RubyNode.d.ts.map +1 -1
- package/dist/nodes/SpoilerNode.d.ts +2 -1
- package/dist/nodes/SpoilerNode.d.ts.map +1 -1
- package/dist/nodes/TagNode.d.ts +3 -2
- package/dist/nodes/TagNode.d.ts.map +1 -1
- package/dist/nodes/VideoNode.d.ts +4 -3
- package/dist/nodes/VideoNode.d.ts.map +1 -1
- package/dist/nodes/shared.d.ts +1 -1
- package/dist/nodes/shared.d.ts.map +1 -1
- package/dist/nodes-entry.d.ts.map +1 -1
- package/dist/nodes-entry.mjs +2 -4
- package/dist/{normalizeSerializedEditorState-VaI73T09.js → normalizeSerializedEditorState-CNUAQd3l.js} +16 -1
- package/dist/plugins/AlertPlugin.d.ts +0 -2
- package/dist/plugins/AlertPlugin.d.ts.map +1 -1
- package/dist/plugins/AutoFocusPlugin.d.ts.map +1 -1
- package/dist/plugins/AutoLinkPlugin.d.ts +1 -1
- package/dist/plugins/AutoLinkPlugin.d.ts.map +1 -1
- package/dist/plugins/BlockExitPlugin.d.ts +0 -2
- package/dist/plugins/BlockExitPlugin.d.ts.map +1 -1
- package/dist/plugins/BlockIdPlugin.d.ts +0 -1
- package/dist/plugins/BlockIdPlugin.d.ts.map +1 -1
- package/dist/plugins/ClickBelowPlugin.d.ts +0 -2
- package/dist/plugins/ClickBelowPlugin.d.ts.map +1 -1
- package/dist/plugins/EditorRefPlugin.d.ts +1 -1
- package/dist/plugins/EditorRefPlugin.d.ts.map +1 -1
- package/dist/plugins/FileUploadPlugin.d.ts +1 -1
- package/dist/plugins/FileUploadPlugin.d.ts.map +1 -1
- package/dist/plugins/FootnotePlugin.d.ts +1 -1
- package/dist/plugins/FootnotePlugin.d.ts.map +1 -1
- package/dist/plugins/HorizontalRulePlugin.d.ts.map +1 -1
- package/dist/plugins/ImageDialog.d.ts +2 -2
- package/dist/plugins/ImageDialog.d.ts.map +1 -1
- package/dist/plugins/ImageDialogReview.d.ts +2 -2
- package/dist/plugins/ImageDialogReview.d.ts.map +1 -1
- package/dist/plugins/ImageDialogSource.d.ts +1 -1
- package/dist/plugins/ImageDialogSource.d.ts.map +1 -1
- package/dist/plugins/ImagePlugin.d.ts +0 -3
- package/dist/plugins/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/ImageUploadPlugin.d.ts +1 -13
- package/dist/plugins/ImageUploadPlugin.d.ts.map +1 -1
- package/dist/plugins/InlineDndPlugin.d.ts +1 -3
- package/dist/plugins/InlineDndPlugin.d.ts.map +1 -1
- package/dist/plugins/KaTeXPlugin.d.ts +0 -2
- package/dist/plugins/KaTeXPlugin.d.ts.map +1 -1
- package/dist/plugins/LinkFaviconPlugin.d.ts.map +1 -1
- package/dist/plugins/MarkdownPastePlugin.d.ts.map +1 -1
- package/dist/plugins/MarkdownShortcutsPlugin.d.ts +1 -1
- package/dist/plugins/MarkdownShortcutsPlugin.d.ts.map +1 -1
- package/dist/plugins/MermaidPlugin.d.ts +0 -1
- package/dist/plugins/MermaidPlugin.d.ts.map +1 -1
- package/dist/plugins/OnChangePlugin.d.ts +1 -1
- package/dist/plugins/OnChangePlugin.d.ts.map +1 -1
- package/dist/plugins/PasteLinkPlugin.d.ts.map +1 -1
- package/dist/plugins/SubmitShortcutPlugin.d.ts.map +1 -1
- package/dist/plugins/TextSelectionPlugin.d.ts.map +1 -1
- package/dist/plugins/VideoUploadPlugin.d.ts.map +1 -1
- package/dist/plugins/VirtualizationPlugin.d.ts.map +1 -1
- package/dist/plugins/block-exit-commands.d.ts +3 -0
- package/dist/plugins/block-exit-commands.d.ts.map +1 -0
- package/dist/plugins/block-id-state.d.ts +2 -0
- package/dist/plugins/block-id-state.d.ts.map +1 -0
- package/dist/plugins/click-below-command.d.ts +3 -0
- package/dist/plugins/click-below-command.d.ts.map +1 -0
- package/dist/plugins/file-upload-command.d.ts +1 -1
- package/dist/plugins/file-upload-command.d.ts.map +1 -1
- package/dist/plugins/file-upload-store.d.ts +1 -1
- package/dist/plugins/file-upload-store.d.ts.map +1 -1
- package/dist/plugins/image-dialog-model.d.ts +1 -1
- package/dist/plugins/image-dialog-model.d.ts.map +1 -1
- package/dist/plugins/image-dialog.css.d.ts.map +1 -1
- package/dist/plugins/image-upload-command.d.ts +1 -1
- package/dist/plugins/image-upload-command.d.ts.map +1 -1
- package/dist/plugins/image-upload-fn.d.ts +14 -0
- package/dist/plugins/image-upload-fn.d.ts.map +1 -0
- package/dist/plugins/image-upload-toast.d.ts.map +1 -1
- package/dist/plugins/image-upload.css.d.ts.map +1 -1
- package/dist/plugins/inline-dnd-move.d.ts +4 -0
- package/dist/plugins/inline-dnd-move.d.ts.map +1 -0
- package/dist/plugins/inline-dnd-shared.d.ts.map +1 -1
- package/dist/plugins/inline-dnd.css.d.ts.map +1 -1
- package/dist/plugins/insert-commands.d.ts +9 -0
- package/dist/plugins/insert-commands.d.ts.map +1 -0
- package/dist/plugins/insertion-cursor.d.ts +1 -1
- package/dist/plugins/insertion-cursor.d.ts.map +1 -1
- package/dist/plugins/present-image-dialog.d.ts +1 -1
- package/dist/plugins/present-image-dialog.d.ts.map +1 -1
- package/dist/plugins/text-selection.css.d.ts.map +1 -1
- package/dist/plugins-entry.d.ts +15 -8
- package/dist/plugins-entry.d.ts.map +1 -1
- package/dist/plugins-entry.mjs +5 -6
- package/dist/recycler-entry.d.ts.map +1 -1
- package/dist/renderers-entry.d.ts +4 -2
- package/dist/renderers-entry.d.ts.map +1 -1
- package/dist/renderers-entry.mjs +5 -5
- package/dist/{utils-E6qVk-NR.js → shared.css-DRoqE_U-.js} +1 -24
- package/dist/static-entry.d.ts +12 -6
- package/dist/static-entry.d.ts.map +1 -1
- package/dist/static-entry.mjs +10 -9
- package/dist/styles/article.css.d.ts.map +1 -1
- package/dist/styles/chat.css.d.ts.map +1 -1
- package/dist/styles/comment.css.d.ts.map +1 -1
- package/dist/styles/details.css.d.ts +5 -5
- package/dist/styles/details.css.d.ts.map +1 -1
- package/dist/styles/grid.css.d.ts +10 -10
- package/dist/styles/grid.css.d.ts.map +1 -1
- package/dist/styles/index.d.ts +3 -0
- package/dist/styles/index.d.ts.map +1 -1
- package/dist/styles/katex.css.d.ts +3 -3
- package/dist/styles/katex.css.d.ts.map +1 -1
- package/dist/styles/note.css.d.ts.map +1 -1
- package/dist/styles/shared.css.d.ts +54 -54
- package/dist/styles/shared.css.d.ts.map +1 -1
- package/dist/styles/theme.d.ts +1 -1
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles-entry.d.ts.map +1 -1
- package/dist/styles-entry.mjs +4 -3
- package/dist/transformers/alert.d.ts +1 -1
- package/dist/transformers/alert.d.ts.map +1 -1
- package/dist/transformers/code-block.d.ts +1 -1
- package/dist/transformers/code-block.d.ts.map +1 -1
- package/dist/transformers/comment.d.ts +1 -1
- package/dist/transformers/comment.d.ts.map +1 -1
- package/dist/transformers/container.d.ts +1 -1
- package/dist/transformers/container.d.ts.map +1 -1
- package/dist/transformers/footnote.d.ts +1 -1
- package/dist/transformers/footnote.d.ts.map +1 -1
- package/dist/transformers/grid-container.d.ts +1 -1
- package/dist/transformers/grid-container.d.ts.map +1 -1
- package/dist/transformers/horizontal-rule.d.ts +1 -1
- package/dist/transformers/horizontal-rule.d.ts.map +1 -1
- package/dist/transformers/index.d.ts +1 -1
- package/dist/transformers/index.d.ts.map +1 -1
- package/dist/transformers/insert.d.ts.map +1 -1
- package/dist/transformers/katex.d.ts +1 -1
- package/dist/transformers/katex.d.ts.map +1 -1
- package/dist/transformers/mention.d.ts +1 -1
- package/dist/transformers/mention.d.ts.map +1 -1
- package/dist/transformers/quote.d.ts +1 -1
- package/dist/transformers/quote.d.ts.map +1 -1
- package/dist/transformers/rich-blocks.d.ts.map +1 -1
- package/dist/transformers/ruby.d.ts +1 -1
- package/dist/transformers/ruby.d.ts.map +1 -1
- package/dist/transformers/spoiler.d.ts +1 -1
- package/dist/transformers/spoiler.d.ts.map +1 -1
- package/dist/transformers/superscript-subscript.d.ts.map +1 -1
- package/dist/transformers/table.d.ts +1 -1
- package/dist/transformers/table.d.ts.map +1 -1
- package/dist/types/renderer-config.d.ts +15 -15
- package/dist/types/renderer-config.d.ts.map +1 -1
- package/dist/types/renderer-keys.d.ts +14 -14
- package/dist/types/renderer-keys.d.ts.map +1 -1
- package/dist/types/slash-menu.d.ts +2 -2
- package/dist/types/slash-menu.d.ts.map +1 -1
- package/dist/types.d.ts +5 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/codeBlockSelectionIntent.d.ts +1 -0
- package/dist/utils/codeBlockSelectionIntent.d.ts.map +1 -1
- package/dist/utils/collect-command-items.d.ts +2 -2
- package/dist/utils/collect-command-items.d.ts.map +1 -1
- package/dist/utils/comment-anchor.d.ts +1 -1
- package/dist/utils/comment-anchor.d.ts.map +1 -1
- package/dist/utils/extractTextContent.d.ts +1 -1
- package/dist/utils/extractTextContent.d.ts.map +1 -1
- package/dist/utils/favicon.d.ts.map +1 -1
- package/dist/utils/file-meta.d.ts +4 -0
- package/dist/utils/file-meta.d.ts.map +1 -0
- package/dist/utils/getRegisteredNodeKlass.d.ts +1 -1
- package/dist/utils/getRegisteredNodeKlass.d.ts.map +1 -1
- package/dist/utils/image-display-size.d.ts.map +1 -1
- package/dist/utils/image-insertion.d.ts +1 -1
- package/dist/utils/image-insertion.d.ts.map +1 -1
- package/dist/utils/image-preprocess.d.ts +1 -1
- package/dist/utils/image-preprocess.d.ts.map +1 -1
- package/dist/utils/katex-defaults.d.ts.map +1 -1
- package/dist/utils/lucide-dom.d.ts.map +1 -1
- package/dist/utils/nested-editor-sync.d.ts +1 -1
- package/dist/utils/nested-editor-sync.d.ts.map +1 -1
- package/dist/utils/normalizeSerializedEditorState.d.ts +1 -1
- package/dist/utils/normalizeSerializedEditorState.d.ts.map +1 -1
- package/dist/utils/occurrence-keys.d.ts +7 -0
- package/dist/utils/occurrence-keys.d.ts.map +1 -0
- package/dist/utils/tag-color.d.ts.map +1 -1
- package/dist/utils/text-selection-constants.d.ts.map +1 -1
- package/dist/utils/text-selection.d.ts +1 -1
- package/dist/utils/text-selection.d.ts.map +1 -1
- package/dist/utils/thumbhash.d.ts.map +1 -1
- package/dist/utils/toggle-spoiler.d.ts +1 -1
- package/dist/utils/toggle-spoiler.d.ts.map +1 -1
- package/dist/utils-i78C9io3.js +26 -0
- package/dist/virtualization/VirtualizationPlugin.d.ts +2 -2
- package/dist/virtualization/VirtualizationPlugin.d.ts.map +1 -1
- package/dist/virtualization/VirtualizedEditor.d.ts +3 -3
- package/dist/virtualization/VirtualizedEditor.d.ts.map +1 -1
- package/dist/virtualization/blocks.d.ts +3 -3
- package/dist/virtualization/blocks.d.ts.map +1 -1
- package/dist/virtualization/controller.d.ts +8 -4
- package/dist/virtualization/controller.d.ts.map +1 -1
- package/dist/virtualization/document.d.ts +1 -1
- package/dist/virtualization/document.d.ts.map +1 -1
- package/dist/virtualization/layout.d.ts +1 -1
- package/dist/virtualization/layout.d.ts.map +1 -1
- package/dist/virtualization/preserve.d.ts.map +1 -1
- package/dist/virtualization/style.css.d.ts.map +1 -1
- package/dist/virtualization/sync.d.ts +2 -2
- package/dist/virtualization/sync.d.ts.map +1 -1
- package/dist/virtualization/types.d.ts +2 -2
- package/dist/virtualization/types.d.ts.map +1 -1
- package/dist/virtualization/viewport.d.ts +1 -1
- package/dist/virtualization/viewport.d.ts.map +1 -1
- package/dist/virtualization-entry.d.ts.map +1 -1
- package/dist/virtualization-entry.mjs +1 -1
- package/package.json +4 -6
- package/dist/AlertQuoteEditNode-DFg-xOND.js +0 -372
- package/dist/BlockIdPlugin-Cwv8aV9g.js +0 -106
- package/dist/ColorSchemeContext-Dc_HebHd.js +0 -1336
- package/dist/LinkCardRenderer-BT8P5aJC.js +0 -100
- package/dist/MermaidPlugin-D0Z2_YAe.js +0 -71
- package/dist/NestedEditorPluginsContext-D78UZkmx.js +0 -16
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { c as setCodeBlockCursorIntent, o as $createCodeBlockEditNode, s as $createBannerEditNode, t as getResolvedEditNodes } from "./node-registry-
|
|
1
|
+
import { c as $createAlertQuoteEditNode, h as setCodeBlockCursorIntent, m as PasteLinkPlugin, o as $createCodeBlockEditNode, s as $createBannerEditNode, t as getResolvedEditNodes } from "./node-registry-PtbiwsVu.js";
|
|
2
2
|
import { n as useEditorBlock } from "./EditorBlockContext-DytAx9Tg.js";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import "./
|
|
10
|
-
import {
|
|
4
|
+
import { $ as $isFootnoteSectionNode, A as KaTeXInlineNode, At as INLINE_DRAG_MIME, N as KaTeXBlockNode, O as $createKaTeXInlineNode, P as $createImageNode, Q as $createFootnoteSectionNode, R as $withAdaptiveImageDisplayWidth, S as $createMentionNode, Y as $isGridContainerNode, ct as DetailsNode, et as FootnoteSectionNode, ft as CommentNode, h as RubyNode, it as $isFileNode, j as $createKaTeXBlockNode, kt as INLINE_DRAG_ATTR, lt as $createCommentNode, mt as CodeBlockNode, nt as FootnoteNode, ot as fileExtFromName, p as $createRubyNode, rt as $createFileNode, s as $createVideoNode, st as $createDetailsNode, tt as $createFootnoteNode, ut as $createCommentPlaceholderNode, vt as BannerNode, w as MentionNode, wt as AlertQuoteNode, y as $createMermaidNode } from "./ColorSchemeContext-DLWz8vFw.js";
|
|
5
|
+
import { n as computeImageMeta } from "./LinkCardRenderer-D4mQbUQo.js";
|
|
6
|
+
import { a as OPEN_FILE_PICKER_COMMAND, i as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND, o as extractTextContent, r as SpoilerNode, t as $createSpoilerNode } from "./SpoilerNode-D7Tgdo2K.js";
|
|
7
|
+
import { i as probeFavicon, n as FootnoteDefinitionsProvider, r as getHostname, t as normalizeSerializedEditorState } from "./normalizeSerializedEditorState-CNUAQd3l.js";
|
|
8
|
+
import "./VirtualizationPlugin-CkNi6FW2.js";
|
|
9
|
+
import { a as INSERT_MERMAID_COMMAND, i as INSERT_KATEX_INLINE_COMMAND, n as INSERT_IMAGE_COMMAND, r as INSERT_KATEX_BLOCK_COMMAND, t as INSERT_ALERT_COMMAND } from "./insert-commands-CtLGoIz0.js";
|
|
10
|
+
import { t as blockIdState } from "./block-id-state-DfN32rR_.js";
|
|
11
11
|
import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin";
|
|
12
12
|
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
13
13
|
import { ListPlugin } from "@lexical/react/LexicalListPlugin";
|
|
@@ -15,9 +15,9 @@ import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin
|
|
|
15
15
|
import { TablePlugin } from "@lexical/react/LexicalTablePlugin";
|
|
16
16
|
import { AutoLinkNode, LinkNode, createLinkMatcherWithRegExp, registerAutoLink } from "@lexical/link";
|
|
17
17
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
18
|
-
import { createContext, use, useCallback, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
18
|
+
import { createContext, createElement, use, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
19
19
|
import { $createQuoteNode, $isQuoteNode, DRAG_DROP_PASTE, QuoteNode } from "@lexical/rich-text";
|
|
20
|
-
import { $addUpdateTag, $createLineBreakNode, $createNodeSelection, $createParagraphNode, $createRangeSelection, $createTextNode, $exportNodeJSON, $getNodeByKey, $getRoot, $getSelection, $getState, $insertNodes, $isDecoratorNode, $isElementNode, $isLineBreakNode, $isNodeSelection, $isParagraphNode, $isRangeSelection, $isRootNode, $isTextNode, $nodesOfType, $parseSerializedNode, $setSelection, BLUR_COMMAND, CLICK_COMMAND, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, HISTORY_MERGE_TAG, IS_CODE, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, KEY_SPACE_COMMAND, PASTE_COMMAND, SELECTION_CHANGE_COMMAND, SKIP_COLLAB_TAG, TextNode, createEditor } from "lexical";
|
|
20
|
+
import { $addUpdateTag, $createLineBreakNode, $createNodeSelection, $createParagraphNode, $createRangeSelection, $createTextNode, $exportNodeJSON, $getNodeByKey, $getRoot, $getSelection, $getState, $insertNodes, $isDecoratorNode, $isElementNode, $isLineBreakNode, $isNodeSelection, $isParagraphNode, $isRangeSelection, $isRootNode, $isTextNode, $nodesOfType, $parseSerializedNode, $setSelection, $setState, BLUR_COMMAND, CLICK_COMMAND, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, HISTORY_MERGE_TAG, IS_CODE, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, KEY_SPACE_COMMAND, PASTE_COMMAND, SELECTION_CHANGE_COMMAND, SKIP_COLLAB_TAG, TextNode, createEditor } from "lexical";
|
|
21
21
|
import { $createHorizontalRuleNode, HorizontalRuleNode, INSERT_HORIZONTAL_RULE_COMMAND } from "@lexical/extension";
|
|
22
22
|
import { CODE_BLOCK_NODE_TRANSFORMER, COMMENT_TRANSFORMER, CONTAINER_TRANSFORMER, FOOTNOTE_SECTION_TRANSFORMER, FOOTNOTE_TRANSFORMER, GIT_ALERT_TRANSFORMER, HORIZONTAL_RULE_BLOCK_TRANSFORMER, IMAGE_BLOCK_TRANSFORMER, INSERT_TRANSFORMER, KATEX_BLOCK_TRANSFORMER, KATEX_INLINE_TRANSFORMER, LINK_CARD_BLOCK_TRANSFORMER, MENTION_TRANSFORMER, MERMAID_BLOCK_TRANSFORMER, RUBY_TRANSFORMER, SPOILER_TRANSFORMER, SUBSCRIPT_TRANSFORMER, SUPERSCRIPT_TRANSFORMER, TABLE_BLOCK_TRANSFORMER, VIDEO_BLOCK_TRANSFORMER } from "@haklex/rich-headless/transformers";
|
|
23
23
|
import { createPortal } from "react-dom";
|
|
@@ -27,6 +27,7 @@ import { $createTableCellNode, $createTableNode, $createTableRowNode, TableCellH
|
|
|
27
27
|
import { Pencil, Plus, Upload, X } from "lucide-react";
|
|
28
28
|
import { ActionButton, AnimatedCheckbox, Field, Kbd, TextInput, confirmDiscardChanges, presentDialog, toast, updateToast } from "@haklex/rich-editor-ui";
|
|
29
29
|
import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
30
|
+
import { nanoid } from "nanoid";
|
|
30
31
|
import { usePortalTheme } from "@haklex/rich-style-token";
|
|
31
32
|
//#region src/plugins/AutoLinkPlugin.tsx
|
|
32
33
|
var DEFAULT_MATCHERS = [createLinkMatcherWithRegExp(/https?:\/\/(?:www\.)?[\w#%+.:=@~-]{1,256}\.[A-Za-z]{2}[\w#%&()+./:=?@~-]*/), createLinkMatcherWithRegExp(/(?:[\w%+.-]+@[\d.a-z-]+\.[a-z]{2,})/i, (text) => `mailto:${text}`)];
|
|
@@ -42,7 +43,7 @@ function AutoLinkPlugin({ matchers }) {
|
|
|
42
43
|
return null;
|
|
43
44
|
}
|
|
44
45
|
//#endregion
|
|
45
|
-
//#region src/plugins/
|
|
46
|
+
//#region src/plugins/block-exit-commands.ts
|
|
46
47
|
var INLINE_CODE_EXIT_CARET = "";
|
|
47
48
|
function selectDecoratorNode(node, cursorPlacement = "start") {
|
|
48
49
|
if (node.getType() === "code-block") setCodeBlockCursorIntent(node.getKey(), cursorPlacement);
|
|
@@ -98,13 +99,6 @@ function exitInlineCodeAtLineEnd(selection) {
|
|
|
98
99
|
selection.setStyle(anchorNode.getStyle());
|
|
99
100
|
return anchorNode;
|
|
100
101
|
}
|
|
101
|
-
function BlockExitPlugin() {
|
|
102
|
-
const [editor] = useLexicalComposerContext();
|
|
103
|
-
useEffect(() => {
|
|
104
|
-
return registerBlockExitCommands(editor);
|
|
105
|
-
}, [editor]);
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
102
|
function registerBlockExitCommands(editor) {
|
|
109
103
|
let virtualParagraphKey = null;
|
|
110
104
|
let inlineCodeExitCaretKey = null;
|
|
@@ -421,14 +415,16 @@ function registerBlockExitCommands(editor) {
|
|
|
421
415
|
};
|
|
422
416
|
}
|
|
423
417
|
//#endregion
|
|
424
|
-
//#region src/plugins/
|
|
425
|
-
function
|
|
418
|
+
//#region src/plugins/BlockExitPlugin.tsx
|
|
419
|
+
function BlockExitPlugin() {
|
|
426
420
|
const [editor] = useLexicalComposerContext();
|
|
427
421
|
useEffect(() => {
|
|
428
|
-
return
|
|
422
|
+
return registerBlockExitCommands(editor);
|
|
429
423
|
}, [editor]);
|
|
430
424
|
return null;
|
|
431
425
|
}
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/plugins/click-below-command.ts
|
|
432
428
|
function registerClickBelowCommand(editor) {
|
|
433
429
|
return editor.registerCommand(CLICK_COMMAND, (event) => {
|
|
434
430
|
const rootElement = editor.getRootElement();
|
|
@@ -451,6 +447,15 @@ function registerClickBelowCommand(editor) {
|
|
|
451
447
|
}, COMMAND_PRIORITY_LOW);
|
|
452
448
|
}
|
|
453
449
|
//#endregion
|
|
450
|
+
//#region src/plugins/ClickBelowPlugin.tsx
|
|
451
|
+
function ClickBelowPlugin() {
|
|
452
|
+
const [editor] = useLexicalComposerContext();
|
|
453
|
+
useEffect(() => {
|
|
454
|
+
return registerClickBelowCommand(editor);
|
|
455
|
+
}, [editor]);
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
//#endregion
|
|
454
459
|
//#region src/transformers/horizontal-rule.ts
|
|
455
460
|
var HORIZONTAL_RULE_REGEX = /^(---|\*\*\*|___)\s?$/;
|
|
456
461
|
var HORIZONTAL_RULE_BLOCK_TRANSFORMER$1 = {
|
|
@@ -511,6 +516,27 @@ function HorizontalRulePlugin() {
|
|
|
511
516
|
var dropCaret = "_224tt30";
|
|
512
517
|
var draggingSource = "_224tt31";
|
|
513
518
|
//#endregion
|
|
519
|
+
//#region src/plugins/inline-dnd-move.ts
|
|
520
|
+
function $insertAtDOMRange(node, range) {
|
|
521
|
+
const selection = $createRangeSelection();
|
|
522
|
+
selection.applyDOMRange(range);
|
|
523
|
+
$setSelection(selection);
|
|
524
|
+
selection.insertNodes([node]);
|
|
525
|
+
}
|
|
526
|
+
function moveInlineNodeBetweenEditors(source, key, target, range) {
|
|
527
|
+
const json = source.read(() => {
|
|
528
|
+
const node = $getNodeByKey(key);
|
|
529
|
+
return node ? $exportNodeJSON(node) : null;
|
|
530
|
+
});
|
|
531
|
+
if (!json) return false;
|
|
532
|
+
target.update(() => $insertAtDOMRange($parseSerializedNode(json), range), { discrete: true });
|
|
533
|
+
source.update(() => $getNodeByKey(key)?.remove(), {
|
|
534
|
+
discrete: true,
|
|
535
|
+
tag: "history-merge"
|
|
536
|
+
});
|
|
537
|
+
return true;
|
|
538
|
+
}
|
|
539
|
+
//#endregion
|
|
514
540
|
//#region src/plugins/InlineDndPlugin.tsx
|
|
515
541
|
var activeInlineDrag = null;
|
|
516
542
|
function caretRangeAtPoint(x, y) {
|
|
@@ -555,25 +581,6 @@ function caretRect(range) {
|
|
|
555
581
|
const el = container instanceof Element ? container : container.parentElement;
|
|
556
582
|
return el ? el.getBoundingClientRect() : null;
|
|
557
583
|
}
|
|
558
|
-
function $insertAtDOMRange(node, range) {
|
|
559
|
-
const selection = $createRangeSelection();
|
|
560
|
-
selection.applyDOMRange(range);
|
|
561
|
-
$setSelection(selection);
|
|
562
|
-
selection.insertNodes([node]);
|
|
563
|
-
}
|
|
564
|
-
function moveInlineNodeBetweenEditors(source, key, target, range) {
|
|
565
|
-
const json = source.read(() => {
|
|
566
|
-
const node = $getNodeByKey(key);
|
|
567
|
-
return node ? $exportNodeJSON(node) : null;
|
|
568
|
-
});
|
|
569
|
-
if (!json) return false;
|
|
570
|
-
target.update(() => $insertAtDOMRange($parseSerializedNode(json), range), { discrete: true });
|
|
571
|
-
source.update(() => $getNodeByKey(key)?.remove(), {
|
|
572
|
-
discrete: true,
|
|
573
|
-
tag: "history-merge"
|
|
574
|
-
});
|
|
575
|
-
return true;
|
|
576
|
-
}
|
|
577
584
|
function InlineDndPlugin() {
|
|
578
585
|
const [editor] = useLexicalComposerContext();
|
|
579
586
|
const documentBlocks = useEditorBlock()?.documentBlocks;
|
|
@@ -1148,20 +1155,27 @@ function CorePlugins() {
|
|
|
1148
1155
|
] });
|
|
1149
1156
|
}
|
|
1150
1157
|
//#endregion
|
|
1151
|
-
//#region src/context/FileUploadContext.
|
|
1158
|
+
//#region src/context/FileUploadContext.ts
|
|
1152
1159
|
var FileUploadContext = createContext(null);
|
|
1160
|
+
function useFileUpload() {
|
|
1161
|
+
return use(FileUploadContext);
|
|
1162
|
+
}
|
|
1163
|
+
//#endregion
|
|
1164
|
+
//#region src/context/FileUploadProvider.tsx
|
|
1153
1165
|
function FileUploadProvider({ upload, children }) {
|
|
1154
|
-
return /* @__PURE__ */ jsx(FileUploadContext
|
|
1166
|
+
return /* @__PURE__ */ jsx(FileUploadContext, {
|
|
1155
1167
|
value: upload,
|
|
1156
1168
|
children
|
|
1157
1169
|
});
|
|
1158
1170
|
}
|
|
1159
|
-
function useFileUpload() {
|
|
1160
|
-
return use(FileUploadContext);
|
|
1161
|
-
}
|
|
1162
1171
|
//#endregion
|
|
1163
|
-
//#region src/context/ImagePreprocessContext.
|
|
1172
|
+
//#region src/context/ImagePreprocessContext.ts
|
|
1164
1173
|
var ImagePreprocessContext = createContext(null);
|
|
1174
|
+
function useImagePreprocess() {
|
|
1175
|
+
return use(ImagePreprocessContext);
|
|
1176
|
+
}
|
|
1177
|
+
//#endregion
|
|
1178
|
+
//#region src/context/ImagePreprocessProvider.tsx
|
|
1165
1179
|
function ImagePreprocessProvider({ children }) {
|
|
1166
1180
|
const ref = useRef(null);
|
|
1167
1181
|
const value = useMemo(() => ({
|
|
@@ -1173,37 +1187,150 @@ function ImagePreprocessProvider({ children }) {
|
|
|
1173
1187
|
};
|
|
1174
1188
|
}
|
|
1175
1189
|
}), []);
|
|
1176
|
-
return /* @__PURE__ */ jsx(ImagePreprocessContext
|
|
1190
|
+
return /* @__PURE__ */ jsx(ImagePreprocessContext, {
|
|
1177
1191
|
value,
|
|
1178
1192
|
children
|
|
1179
1193
|
});
|
|
1180
1194
|
}
|
|
1181
|
-
function useImagePreprocess() {
|
|
1182
|
-
return use(ImagePreprocessContext);
|
|
1183
|
-
}
|
|
1184
1195
|
//#endregion
|
|
1185
|
-
//#region src/context/ImageUploadContext.
|
|
1196
|
+
//#region src/context/ImageUploadContext.ts
|
|
1186
1197
|
var ImageUploadContext = createContext(null);
|
|
1198
|
+
function useImageUpload() {
|
|
1199
|
+
return use(ImageUploadContext);
|
|
1200
|
+
}
|
|
1201
|
+
//#endregion
|
|
1202
|
+
//#region src/context/ImageUploadProvider.tsx
|
|
1187
1203
|
function ImageUploadProvider({ upload, children }) {
|
|
1188
|
-
return /* @__PURE__ */ jsx(ImageUploadContext
|
|
1204
|
+
return /* @__PURE__ */ jsx(ImageUploadContext, {
|
|
1189
1205
|
value: upload,
|
|
1190
1206
|
children
|
|
1191
1207
|
});
|
|
1192
1208
|
}
|
|
1193
|
-
function useImageUpload() {
|
|
1194
|
-
return use(ImageUploadContext);
|
|
1195
|
-
}
|
|
1196
1209
|
//#endregion
|
|
1197
|
-
//#region src/context/VideoUploadContext.
|
|
1210
|
+
//#region src/context/VideoUploadContext.ts
|
|
1198
1211
|
var VideoUploadContext = createContext(null);
|
|
1212
|
+
function useVideoUpload() {
|
|
1213
|
+
return use(VideoUploadContext);
|
|
1214
|
+
}
|
|
1215
|
+
//#endregion
|
|
1216
|
+
//#region src/context/VideoUploadProvider.tsx
|
|
1199
1217
|
function VideoUploadProvider({ upload, children }) {
|
|
1200
|
-
return /* @__PURE__ */ jsx(VideoUploadContext
|
|
1218
|
+
return /* @__PURE__ */ jsx(VideoUploadContext, {
|
|
1201
1219
|
value: upload,
|
|
1202
1220
|
children
|
|
1203
1221
|
});
|
|
1204
1222
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1223
|
+
//#endregion
|
|
1224
|
+
//#region src/plugins/AlertPlugin.tsx
|
|
1225
|
+
function AlertPlugin() {
|
|
1226
|
+
const [editor] = useLexicalComposerContext();
|
|
1227
|
+
useEffect(() => {
|
|
1228
|
+
return editor.registerCommand(INSERT_ALERT_COMMAND, (alertType) => {
|
|
1229
|
+
$insertNodes([$createAlertQuoteEditNode(alertType)]);
|
|
1230
|
+
return true;
|
|
1231
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
1232
|
+
}, [editor]);
|
|
1233
|
+
return null;
|
|
1234
|
+
}
|
|
1235
|
+
//#endregion
|
|
1236
|
+
//#region src/plugins/BlockIdPlugin.tsx
|
|
1237
|
+
var NORMALIZATION_TAG = "block-id-normalization";
|
|
1238
|
+
function buildPreviousIdIndex(editorState) {
|
|
1239
|
+
return editorState.read(() => {
|
|
1240
|
+
const map = /* @__PURE__ */ new Map();
|
|
1241
|
+
for (const child of $getRoot().getChildren()) {
|
|
1242
|
+
const id = $getState(child, blockIdState);
|
|
1243
|
+
if (!id) continue;
|
|
1244
|
+
const set = map.get(id) ?? /* @__PURE__ */ new Set();
|
|
1245
|
+
set.add(child.getKey());
|
|
1246
|
+
map.set(id, set);
|
|
1247
|
+
}
|
|
1248
|
+
return map;
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
function collectRootChildren(editorState) {
|
|
1252
|
+
return editorState.read(() => $getRoot().getChildren().map((child) => $getState(child, blockIdState)));
|
|
1253
|
+
}
|
|
1254
|
+
function hasDuplicateOrMissingId(children) {
|
|
1255
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1256
|
+
for (const id of children) {
|
|
1257
|
+
if (!id || seen.has(id)) return true;
|
|
1258
|
+
seen.add(id);
|
|
1259
|
+
}
|
|
1260
|
+
return false;
|
|
1261
|
+
}
|
|
1262
|
+
function generateBlockId(used) {
|
|
1263
|
+
while (true) {
|
|
1264
|
+
const id = nanoid(8);
|
|
1265
|
+
if (!used.has(id)) return id;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
function pickKeeperKey(nodes, previousKeys) {
|
|
1269
|
+
if (!nodes.length) return null;
|
|
1270
|
+
if (previousKeys?.size) {
|
|
1271
|
+
for (const node of nodes) if (previousKeys.has(node.getKey())) return node.getKey();
|
|
1272
|
+
}
|
|
1273
|
+
return nodes[0]?.getKey() ?? null;
|
|
1274
|
+
}
|
|
1275
|
+
function normalizeRootBlockIds(editor, previousIdIndex) {
|
|
1276
|
+
editor.update(() => {
|
|
1277
|
+
$addUpdateTag("history-merge");
|
|
1278
|
+
const children = $getRoot().getChildren();
|
|
1279
|
+
const groupedById = /* @__PURE__ */ new Map();
|
|
1280
|
+
for (const child of children) {
|
|
1281
|
+
const id = $getState(child, blockIdState);
|
|
1282
|
+
if (!id) continue;
|
|
1283
|
+
const bucket = groupedById.get(id) ?? [];
|
|
1284
|
+
bucket.push(child);
|
|
1285
|
+
groupedById.set(id, bucket);
|
|
1286
|
+
}
|
|
1287
|
+
const keeperById = /* @__PURE__ */ new Map();
|
|
1288
|
+
for (const [id, nodes] of groupedById) {
|
|
1289
|
+
if (nodes.length <= 1) continue;
|
|
1290
|
+
const keeperKey = pickKeeperKey(nodes, previousIdIndex.get(id));
|
|
1291
|
+
if (keeperKey) keeperById.set(id, keeperKey);
|
|
1292
|
+
}
|
|
1293
|
+
const used = /* @__PURE__ */ new Set();
|
|
1294
|
+
for (const child of children) {
|
|
1295
|
+
let id = $getState(child, blockIdState);
|
|
1296
|
+
const keeperKey = id ? keeperById.get(id) : null;
|
|
1297
|
+
if (!id || used.has(id) || keeperKey !== void 0 && child.getKey() !== keeperKey) {
|
|
1298
|
+
id = generateBlockId(used);
|
|
1299
|
+
$setState(child, blockIdState, id);
|
|
1300
|
+
}
|
|
1301
|
+
used.add(id);
|
|
1302
|
+
}
|
|
1303
|
+
}, { tag: NORMALIZATION_TAG });
|
|
1304
|
+
}
|
|
1305
|
+
function syncBlockIdAttributes(editor) {
|
|
1306
|
+
editor.getEditorState().read(() => {
|
|
1307
|
+
for (const child of $getRoot().getChildren()) {
|
|
1308
|
+
const id = $getState(child, blockIdState);
|
|
1309
|
+
if (!id) continue;
|
|
1310
|
+
const dom = editor.getElementByKey(child.getKey());
|
|
1311
|
+
if (dom && dom.getAttribute("data-block-id") !== id) dom.setAttribute("data-block-id", id);
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
function BlockIdPlugin() {
|
|
1316
|
+
const [editor] = useLexicalComposerContext();
|
|
1317
|
+
useEffect(() => {
|
|
1318
|
+
if (hasDuplicateOrMissingId(collectRootChildren(editor.getEditorState()))) normalizeRootBlockIds(editor, /* @__PURE__ */ new Map());
|
|
1319
|
+
syncBlockIdAttributes(editor);
|
|
1320
|
+
return editor.registerUpdateListener(({ tags, editorState, prevEditorState }) => {
|
|
1321
|
+
if (tags.has(NORMALIZATION_TAG)) {
|
|
1322
|
+
syncBlockIdAttributes(editor);
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
if (!hasDuplicateOrMissingId(collectRootChildren(editorState))) {
|
|
1326
|
+
syncBlockIdAttributes(editor);
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
const previousIdIndex = buildPreviousIdIndex(prevEditorState);
|
|
1330
|
+
normalizeRootBlockIds(editor, previousIdIndex);
|
|
1331
|
+
});
|
|
1332
|
+
}, [editor]);
|
|
1333
|
+
return null;
|
|
1207
1334
|
}
|
|
1208
1335
|
//#endregion
|
|
1209
1336
|
//#region src/plugins/file-upload-store.ts
|
|
@@ -1240,10 +1367,12 @@ function isMediaFile(file) {
|
|
|
1240
1367
|
function FileUploadPlugin({ onUpload }) {
|
|
1241
1368
|
const block = useEditorBlock();
|
|
1242
1369
|
const blockRef = useRef(block);
|
|
1243
|
-
blockRef.current = block;
|
|
1244
1370
|
const [editor] = useLexicalComposerContext();
|
|
1245
1371
|
const uploadRef = useRef(onUpload);
|
|
1246
|
-
|
|
1372
|
+
useLayoutEffect(() => {
|
|
1373
|
+
blockRef.current = block;
|
|
1374
|
+
uploadRef.current = onUpload;
|
|
1375
|
+
});
|
|
1247
1376
|
const targetEditorRef = useRef(editor);
|
|
1248
1377
|
const fileInputRef = useRef(null);
|
|
1249
1378
|
const uploadFile = useCallback((file, target) => {
|
|
@@ -1342,17 +1471,6 @@ function FileUploadPlugin({ onUpload }) {
|
|
|
1342
1471
|
});
|
|
1343
1472
|
}
|
|
1344
1473
|
//#endregion
|
|
1345
|
-
//#region src/utils/image-preprocess.ts
|
|
1346
|
-
async function resolvePreprocessTargets(files, source, preprocess) {
|
|
1347
|
-
if (!preprocess || files.length === 0) return files;
|
|
1348
|
-
try {
|
|
1349
|
-
return await preprocess(files, { source }) ?? [];
|
|
1350
|
-
} catch (err) {
|
|
1351
|
-
console.error("[ImageUploadPlugin] preprocess failed, uploading originals", err);
|
|
1352
|
-
return files;
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
//#endregion
|
|
1356
1474
|
//#region src/plugins/image-dialog-model.ts
|
|
1357
1475
|
var IMAGE_FORMATS_HINT = "PNG, JPG, GIF, WebP, AVIF";
|
|
1358
1476
|
var UNSAFE_URL_RE = /^(?:javascript\s*:|vbscript\s*:|data\s*:(?!image\/))/i;
|
|
@@ -1450,6 +1568,49 @@ function getImageEditor(scope) {
|
|
|
1450
1568
|
return (scope && editors.get(scope)) ?? null;
|
|
1451
1569
|
}
|
|
1452
1570
|
//#endregion
|
|
1571
|
+
//#region src/plugins/image-upload-fn.ts
|
|
1572
|
+
function uploadImageFile(upload, file) {
|
|
1573
|
+
return keepsOriginal(file) ? upload(file, { keepOriginal: true }) : upload(file);
|
|
1574
|
+
}
|
|
1575
|
+
function readAsDataUrl(file) {
|
|
1576
|
+
return new Promise((resolve, reject) => {
|
|
1577
|
+
const reader = new FileReader();
|
|
1578
|
+
reader.onload = () => resolve(String(reader.result));
|
|
1579
|
+
reader.onerror = () => reject(reader.error ?? /* @__PURE__ */ new Error("File read failed"));
|
|
1580
|
+
reader.readAsDataURL(file);
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
async function defaultImageUpload(file) {
|
|
1584
|
+
return {
|
|
1585
|
+
src: await readAsDataUrl(file),
|
|
1586
|
+
altText: file.name
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1589
|
+
//#endregion
|
|
1590
|
+
//#region src/plugins/ImagePlugin.tsx
|
|
1591
|
+
function ImagePlugin() {
|
|
1592
|
+
const [editor] = useLexicalComposerContext();
|
|
1593
|
+
useEffect(() => {
|
|
1594
|
+
return editor.registerCommand(INSERT_IMAGE_COMMAND, (payload) => {
|
|
1595
|
+
const imageNode = $createImageNode($withAdaptiveImageDisplayWidth(payload), { autoOpenOnMount: !payload.src });
|
|
1596
|
+
$insertNodes([imageNode]);
|
|
1597
|
+
return true;
|
|
1598
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
1599
|
+
}, [editor]);
|
|
1600
|
+
return null;
|
|
1601
|
+
}
|
|
1602
|
+
//#endregion
|
|
1603
|
+
//#region src/utils/image-preprocess.ts
|
|
1604
|
+
async function resolvePreprocessTargets(files, source, preprocess) {
|
|
1605
|
+
if (!preprocess || files.length === 0) return files;
|
|
1606
|
+
try {
|
|
1607
|
+
return await preprocess(files, { source }) ?? [];
|
|
1608
|
+
} catch (err) {
|
|
1609
|
+
console.error("[ImageUploadPlugin] preprocess failed, uploading originals", err);
|
|
1610
|
+
return files;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
//#endregion
|
|
1453
1614
|
//#region src/plugins/image-upload.css.ts
|
|
1454
1615
|
var draggingWrapperClass = "rich-image-upload-dragging";
|
|
1455
1616
|
//#endregion
|
|
@@ -1594,12 +1755,11 @@ var meta = "dtt1x7o dtt1x74";
|
|
|
1594
1755
|
//#region src/plugins/ImageDialogReview.tsx
|
|
1595
1756
|
function useFileImageInfo(file) {
|
|
1596
1757
|
const [info, setInfo] = useState(null);
|
|
1597
|
-
const [
|
|
1758
|
+
const [failedFile, setFailedFile] = useState(null);
|
|
1598
1759
|
useEffect(() => {
|
|
1599
1760
|
if (typeof URL.createObjectURL !== "function") return;
|
|
1600
1761
|
const url = URL.createObjectURL(file);
|
|
1601
1762
|
let active = true;
|
|
1602
|
-
setFailed(false);
|
|
1603
1763
|
const image = new Image();
|
|
1604
1764
|
image.onload = () => {
|
|
1605
1765
|
if (active) setInfo({
|
|
@@ -1609,7 +1769,7 @@ function useFileImageInfo(file) {
|
|
|
1609
1769
|
});
|
|
1610
1770
|
};
|
|
1611
1771
|
image.onerror = () => {
|
|
1612
|
-
if (active)
|
|
1772
|
+
if (active) setFailedFile(file);
|
|
1613
1773
|
};
|
|
1614
1774
|
image.src = url;
|
|
1615
1775
|
return () => {
|
|
@@ -1618,7 +1778,7 @@ function useFileImageInfo(file) {
|
|
|
1618
1778
|
};
|
|
1619
1779
|
}, [file]);
|
|
1620
1780
|
return {
|
|
1621
|
-
failed,
|
|
1781
|
+
failed: failedFile === file,
|
|
1622
1782
|
info
|
|
1623
1783
|
};
|
|
1624
1784
|
}
|
|
@@ -1769,33 +1929,29 @@ function hasImageData$1(dataTransfer) {
|
|
|
1769
1929
|
return [...dataTransfer.items].some((item) => item.type.startsWith("image/"));
|
|
1770
1930
|
}
|
|
1771
1931
|
function useUrlPreview(url) {
|
|
1772
|
-
const [
|
|
1932
|
+
const [result, setResult] = useState(null);
|
|
1933
|
+
const trimmed = url.trim();
|
|
1934
|
+
const valid = trimmed !== "" && isSafeImageUrl(trimmed);
|
|
1773
1935
|
useEffect(() => {
|
|
1774
|
-
|
|
1775
|
-
if (!trimmed) {
|
|
1776
|
-
setState({ status: "idle" });
|
|
1777
|
-
return;
|
|
1778
|
-
}
|
|
1779
|
-
if (!isSafeImageUrl(trimmed)) {
|
|
1780
|
-
setState({
|
|
1781
|
-
message: "Unsupported URL scheme",
|
|
1782
|
-
status: "error"
|
|
1783
|
-
});
|
|
1784
|
-
return;
|
|
1785
|
-
}
|
|
1786
|
-
setState({ status: "loading" });
|
|
1936
|
+
if (!valid) return;
|
|
1787
1937
|
let active = true;
|
|
1788
1938
|
const timer = setTimeout(() => {
|
|
1789
1939
|
loadImageByUrl(trimmed).then(({ height, width }) => {
|
|
1790
|
-
if (active)
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1940
|
+
if (active) setResult({
|
|
1941
|
+
url,
|
|
1942
|
+
state: {
|
|
1943
|
+
height,
|
|
1944
|
+
status: "loaded",
|
|
1945
|
+
width
|
|
1946
|
+
}
|
|
1794
1947
|
});
|
|
1795
1948
|
}, () => {
|
|
1796
|
-
if (active)
|
|
1797
|
-
|
|
1798
|
-
|
|
1949
|
+
if (active) setResult({
|
|
1950
|
+
url,
|
|
1951
|
+
state: {
|
|
1952
|
+
message: "Could not load this image URL",
|
|
1953
|
+
status: "error"
|
|
1954
|
+
}
|
|
1799
1955
|
});
|
|
1800
1956
|
});
|
|
1801
1957
|
}, PREVIEW_DEBOUNCE_MS);
|
|
@@ -1803,8 +1959,17 @@ function useUrlPreview(url) {
|
|
|
1803
1959
|
active = false;
|
|
1804
1960
|
clearTimeout(timer);
|
|
1805
1961
|
};
|
|
1806
|
-
}, [
|
|
1807
|
-
|
|
1962
|
+
}, [
|
|
1963
|
+
trimmed,
|
|
1964
|
+
url,
|
|
1965
|
+
valid
|
|
1966
|
+
]);
|
|
1967
|
+
if (!trimmed) return { status: "idle" };
|
|
1968
|
+
if (!valid) return {
|
|
1969
|
+
message: "Unsupported URL scheme",
|
|
1970
|
+
status: "error"
|
|
1971
|
+
};
|
|
1972
|
+
return result?.url === url ? result.state : { status: "loading" };
|
|
1808
1973
|
}
|
|
1809
1974
|
function ImageDialogSource({ allowUrl, onAddUrl, onPickFiles, onReceiveFiles }) {
|
|
1810
1975
|
const urlId = useId();
|
|
@@ -1952,7 +2117,7 @@ function ImageDialog({ allowUrl = true, editor = null, initialFiles, mode = "ins
|
|
|
1952
2117
|
const [inserting, setInserting] = useState(false);
|
|
1953
2118
|
const [keepOriginal$1, setKeepOriginal] = useState(false);
|
|
1954
2119
|
const fileInputRef = useRef(null);
|
|
1955
|
-
const
|
|
2120
|
+
const detectionsRef = useRef(/* @__PURE__ */ new Map());
|
|
1956
2121
|
const privacy = editor?.privacy;
|
|
1957
2122
|
const copy = imageDialogCopy(mode, step === "review" ? rows.length : 1);
|
|
1958
2123
|
const dirty = rows.some((row) => row.kind === "file" && row.current !== row.original) || !startedWithFiles && rows.length > 0;
|
|
@@ -1965,9 +2130,9 @@ function ImageDialog({ allowUrl = true, editor = null, initialFiles, mode = "ins
|
|
|
1965
2130
|
useEffect(() => {
|
|
1966
2131
|
if (!privacy) return;
|
|
1967
2132
|
for (const row of rows) {
|
|
1968
|
-
if (row.kind !== "file" ||
|
|
2133
|
+
if (row.kind !== "file" || detectionsRef.current.has(row.id)) continue;
|
|
1969
2134
|
const detection = privacy.detectGps(row.original).catch(() => null);
|
|
1970
|
-
|
|
2135
|
+
detectionsRef.current.set(row.id, detection);
|
|
1971
2136
|
detection.then((gps) => {
|
|
1972
2137
|
setRows((current) => withGps(current, /* @__PURE__ */ new Map([[row.id, gps]])));
|
|
1973
2138
|
});
|
|
@@ -2016,8 +2181,8 @@ function ImageDialog({ allowUrl = true, editor = null, initialFiles, mode = "ins
|
|
|
2016
2181
|
const insert = async () => {
|
|
2017
2182
|
if (inserting || blocked || rows.length === 0) return;
|
|
2018
2183
|
setInserting(true);
|
|
2019
|
-
const ids = [...
|
|
2020
|
-
const found = await Promise.all(ids.map((id) =>
|
|
2184
|
+
const ids = [...detectionsRef.current.keys()];
|
|
2185
|
+
const found = await Promise.all(ids.map((id) => detectionsRef.current.get(id)));
|
|
2021
2186
|
const merged = withGps(rows, new Map(ids.map((id, index) => [id, found[index]])));
|
|
2022
2187
|
const result = await finalizeRows(merged, privacy?.stripGps);
|
|
2023
2188
|
setInserting(false);
|
|
@@ -2128,7 +2293,7 @@ function ImageDialog({ allowUrl = true, editor = null, initialFiles, mode = "ins
|
|
|
2128
2293
|
});
|
|
2129
2294
|
}
|
|
2130
2295
|
//#endregion
|
|
2131
|
-
//#region src/plugins/present-image-dialog.
|
|
2296
|
+
//#region src/plugins/present-image-dialog.ts
|
|
2132
2297
|
function createTitleStore(initial) {
|
|
2133
2298
|
let value = initial;
|
|
2134
2299
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -2170,9 +2335,9 @@ function presentImageDialog({ allowUrl = true, editor = null, files, mode = "ins
|
|
|
2170
2335
|
portalClassName,
|
|
2171
2336
|
sheet: "auto",
|
|
2172
2337
|
theme,
|
|
2173
|
-
title:
|
|
2338
|
+
title: createElement(DialogTitleText, { store: title }),
|
|
2174
2339
|
width: 520,
|
|
2175
|
-
content: ({ dismiss, requestDismiss }) =>
|
|
2340
|
+
content: ({ dismiss, requestDismiss }) => createElement(ImageDialog, {
|
|
2176
2341
|
allowUrl,
|
|
2177
2342
|
editor,
|
|
2178
2343
|
initialFiles: files,
|
|
@@ -2190,41 +2355,26 @@ function presentImageDialog({ allowUrl = true, editor = null, files, mode = "ins
|
|
|
2190
2355
|
}
|
|
2191
2356
|
//#endregion
|
|
2192
2357
|
//#region src/plugins/ImageUploadPlugin.tsx
|
|
2193
|
-
function uploadImageFile(upload, file) {
|
|
2194
|
-
return keepsOriginal(file) ? upload(file, { keepOriginal: true }) : upload(file);
|
|
2195
|
-
}
|
|
2196
2358
|
function hasImageData(dataTransfer) {
|
|
2197
2359
|
if (!dataTransfer) return false;
|
|
2198
2360
|
if ([...dataTransfer.files].some(isImageFile)) return true;
|
|
2199
2361
|
return [...dataTransfer.items].some((item) => item.type.startsWith("image/"));
|
|
2200
2362
|
}
|
|
2201
|
-
function readAsDataUrl(file) {
|
|
2202
|
-
return new Promise((resolve, reject) => {
|
|
2203
|
-
const reader = new FileReader();
|
|
2204
|
-
reader.onload = () => resolve(String(reader.result));
|
|
2205
|
-
reader.onerror = () => reject(reader.error ?? /* @__PURE__ */ new Error("File read failed"));
|
|
2206
|
-
reader.readAsDataURL(file);
|
|
2207
|
-
});
|
|
2208
|
-
}
|
|
2209
|
-
async function defaultImageUpload(file) {
|
|
2210
|
-
return {
|
|
2211
|
-
src: await readAsDataUrl(file),
|
|
2212
|
-
altText: file.name
|
|
2213
|
-
};
|
|
2214
|
-
}
|
|
2215
2363
|
function ImageUploadPlugin({ onUpload }) {
|
|
2216
2364
|
const block = useEditorBlock();
|
|
2217
2365
|
const blockRef = useRef(block);
|
|
2218
|
-
blockRef.current = block;
|
|
2219
2366
|
const [editor] = useLexicalComposerContext();
|
|
2220
2367
|
const uploadRef = useRef(onUpload);
|
|
2221
|
-
uploadRef.current = onUpload;
|
|
2222
2368
|
const preprocessContext = useImagePreprocess();
|
|
2223
2369
|
const preprocessContextRef = useRef(preprocessContext);
|
|
2224
|
-
preprocessContextRef.current = preprocessContext;
|
|
2225
2370
|
const portalTheme = usePortalTheme();
|
|
2226
2371
|
const portalThemeRef = useRef(portalTheme);
|
|
2227
|
-
|
|
2372
|
+
useLayoutEffect(() => {
|
|
2373
|
+
blockRef.current = block;
|
|
2374
|
+
uploadRef.current = onUpload;
|
|
2375
|
+
preprocessContextRef.current = preprocessContext;
|
|
2376
|
+
portalThemeRef.current = portalTheme;
|
|
2377
|
+
});
|
|
2228
2378
|
const uploadAndInsert = useCallback(async (file, target, cursor, after) => {
|
|
2229
2379
|
const release = blockRef.current?.retain();
|
|
2230
2380
|
try {
|
|
@@ -2361,6 +2511,28 @@ function ImageUploadPlugin({ onUpload }) {
|
|
|
2361
2511
|
return null;
|
|
2362
2512
|
}
|
|
2363
2513
|
//#endregion
|
|
2514
|
+
//#region src/plugins/KaTeXPlugin.tsx
|
|
2515
|
+
function KaTeXPlugin() {
|
|
2516
|
+
const [editor] = useLexicalComposerContext();
|
|
2517
|
+
useEffect(() => {
|
|
2518
|
+
const unregisterInline = editor.registerCommand(INSERT_KATEX_INLINE_COMMAND, (equation) => {
|
|
2519
|
+
const node = $createKaTeXInlineNode(equation, { autoOpenOnMount: !equation.trim() });
|
|
2520
|
+
$insertNodes([node]);
|
|
2521
|
+
return true;
|
|
2522
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
2523
|
+
const unregisterBlock = editor.registerCommand(INSERT_KATEX_BLOCK_COMMAND, (equation) => {
|
|
2524
|
+
const node = $createKaTeXBlockNode(equation, { autoOpenOnMount: !equation.trim() });
|
|
2525
|
+
$insertNodes([node]);
|
|
2526
|
+
return true;
|
|
2527
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
2528
|
+
return () => {
|
|
2529
|
+
unregisterInline();
|
|
2530
|
+
unregisterBlock();
|
|
2531
|
+
};
|
|
2532
|
+
}, [editor]);
|
|
2533
|
+
return null;
|
|
2534
|
+
}
|
|
2535
|
+
//#endregion
|
|
2364
2536
|
//#region src/plugins/LinkFaviconPlugin.tsx
|
|
2365
2537
|
function applyFavicon(dom, href) {
|
|
2366
2538
|
if (dom.dataset.faviconHref === href) return;
|
|
@@ -2396,7 +2568,20 @@ function LinkFaviconPlugin() {
|
|
|
2396
2568
|
return null;
|
|
2397
2569
|
}
|
|
2398
2570
|
//#endregion
|
|
2399
|
-
//#region src/
|
|
2571
|
+
//#region src/plugins/MermaidPlugin.tsx
|
|
2572
|
+
function MermaidPlugin() {
|
|
2573
|
+
const [editor] = useLexicalComposerContext();
|
|
2574
|
+
useEffect(() => {
|
|
2575
|
+
return editor.registerCommand(INSERT_MERMAID_COMMAND, (diagram) => {
|
|
2576
|
+
const node = $createMermaidNode(diagram);
|
|
2577
|
+
$insertNodes([node]);
|
|
2578
|
+
return true;
|
|
2579
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
2580
|
+
}, [editor]);
|
|
2581
|
+
return null;
|
|
2582
|
+
}
|
|
2583
|
+
//#endregion
|
|
2584
|
+
//#region src/context/TextSelectionContext.ts
|
|
2400
2585
|
function areSnapshotsEqual(a, b) {
|
|
2401
2586
|
if (a === b) return true;
|
|
2402
2587
|
if (!a || !b) return false;
|
|
@@ -2435,14 +2620,6 @@ function createTextSelectionStore(initialState = { snapshot: null }) {
|
|
|
2435
2620
|
};
|
|
2436
2621
|
}
|
|
2437
2622
|
var TextSelectionStoreContext = createContext(null);
|
|
2438
|
-
function TextSelectionStoreProvider({ children }) {
|
|
2439
|
-
const storeRef = useRef(null);
|
|
2440
|
-
if (!storeRef.current) storeRef.current = createTextSelectionStore();
|
|
2441
|
-
return /* @__PURE__ */ jsx(TextSelectionStoreContext.Provider, {
|
|
2442
|
-
value: storeRef.current,
|
|
2443
|
-
children
|
|
2444
|
-
});
|
|
2445
|
-
}
|
|
2446
2623
|
function useTextSelectionStore() {
|
|
2447
2624
|
const store = use(TextSelectionStoreContext);
|
|
2448
2625
|
if (!store) throw new Error("useTextSelectionStore must be used within TextSelectionStoreProvider");
|
|
@@ -3036,41 +3213,46 @@ var ERROR_TOAST_DURATION = 6e3;
|
|
|
3036
3213
|
function VideoUploadPlugin({ onUpload }) {
|
|
3037
3214
|
const block = useEditorBlock();
|
|
3038
3215
|
const blockRef = useRef(block);
|
|
3039
|
-
blockRef.current = block;
|
|
3040
3216
|
const [editor] = useLexicalComposerContext();
|
|
3041
3217
|
const uploadRef = useRef(onUpload);
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
} });
|
|
3053
|
-
editor.update(() => {
|
|
3054
|
-
$insertAtCursor(cursor, [$createVideoNode({ src: result.src })]);
|
|
3055
|
-
});
|
|
3056
|
-
updateToast(id, {
|
|
3057
|
-
title: "Video uploaded",
|
|
3058
|
-
tone: "success"
|
|
3059
|
-
});
|
|
3060
|
-
} catch (err) {
|
|
3061
|
-
console.error("[VideoUploadPlugin]", err);
|
|
3062
|
-
updateToast(id, {
|
|
3063
|
-
action: {
|
|
3064
|
-
label: "Retry",
|
|
3065
|
-
onClick: () => void uploadVideo(file, cursor)
|
|
3066
|
-
},
|
|
3067
|
-
duration: ERROR_TOAST_DURATION,
|
|
3068
|
-
title: "Video upload failed",
|
|
3069
|
-
tone: "error"
|
|
3218
|
+
useLayoutEffect(() => {
|
|
3219
|
+
blockRef.current = block;
|
|
3220
|
+
uploadRef.current = onUpload;
|
|
3221
|
+
});
|
|
3222
|
+
const uploadVideo = useCallback((file, cursor) => {
|
|
3223
|
+
const run = async () => {
|
|
3224
|
+
const release = blockRef.current?.retain();
|
|
3225
|
+
const id = toast({
|
|
3226
|
+
title: "Uploading video…",
|
|
3227
|
+
tone: "loading"
|
|
3070
3228
|
});
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3229
|
+
try {
|
|
3230
|
+
const result = await uploadRef.current(file, { onProgress: (percent) => {
|
|
3231
|
+
updateToast(id, { title: `Uploading video… ${Math.round(percent)}%` });
|
|
3232
|
+
} });
|
|
3233
|
+
editor.update(() => {
|
|
3234
|
+
$insertAtCursor(cursor, [$createVideoNode({ src: result.src })]);
|
|
3235
|
+
});
|
|
3236
|
+
updateToast(id, {
|
|
3237
|
+
title: "Video uploaded",
|
|
3238
|
+
tone: "success"
|
|
3239
|
+
});
|
|
3240
|
+
} catch (err) {
|
|
3241
|
+
console.error("[VideoUploadPlugin]", err);
|
|
3242
|
+
updateToast(id, {
|
|
3243
|
+
action: {
|
|
3244
|
+
label: "Retry",
|
|
3245
|
+
onClick: () => void run()
|
|
3246
|
+
},
|
|
3247
|
+
duration: ERROR_TOAST_DURATION,
|
|
3248
|
+
title: "Video upload failed",
|
|
3249
|
+
tone: "error"
|
|
3250
|
+
});
|
|
3251
|
+
} finally {
|
|
3252
|
+
queueMicrotask(() => release?.());
|
|
3253
|
+
}
|
|
3254
|
+
};
|
|
3255
|
+
return run();
|
|
3074
3256
|
}, [editor]);
|
|
3075
3257
|
const handleFiles = useCallback((files) => {
|
|
3076
3258
|
const videos = files.filter(isVideoFile);
|
|
@@ -3133,7 +3315,9 @@ function VideoUploadPlugin({ onUpload }) {
|
|
|
3133
3315
|
function EditorRefPlugin({ onEditorReady }) {
|
|
3134
3316
|
const [editor] = useLexicalComposerContext();
|
|
3135
3317
|
const callbackRef = useRef(onEditorReady);
|
|
3136
|
-
|
|
3318
|
+
useLayoutEffect(() => {
|
|
3319
|
+
callbackRef.current = onEditorReady;
|
|
3320
|
+
});
|
|
3137
3321
|
useEffect(() => {
|
|
3138
3322
|
callbackRef.current?.(editor);
|
|
3139
3323
|
return () => callbackRef.current?.(null);
|
|
@@ -3233,7 +3417,9 @@ function OnChangePlugin({ onChange, debounceMs }) {
|
|
|
3233
3417
|
const [editor] = useLexicalComposerContext();
|
|
3234
3418
|
const timerRef = useRef(void 0);
|
|
3235
3419
|
const onChangeRef = useRef(onChange);
|
|
3236
|
-
|
|
3420
|
+
useLayoutEffect(() => {
|
|
3421
|
+
onChangeRef.current = onChange;
|
|
3422
|
+
});
|
|
3237
3423
|
useEffect(() => {
|
|
3238
3424
|
const unregister = editor.registerUpdateListener(({ editorState }) => {
|
|
3239
3425
|
const fn = onChangeRef.current;
|
|
@@ -3282,4 +3468,4 @@ function AutoFocusPlugin() {
|
|
|
3282
3468
|
return null;
|
|
3283
3469
|
}
|
|
3284
3470
|
//#endregion
|
|
3285
|
-
export {
|
|
3471
|
+
export { CorePlugins as $, presentImageDialog as A, FileUploadPlugin as B, createTextSelectionStore as C, LinkFaviconPlugin as D, MermaidPlugin as E, uploadImageFile as F, VideoUploadProvider as G, useFileUploadEntry as H, getImageEditor as I, useImageUpload as J, useVideoUpload as K, keepsOriginal as L, resolvePreprocessTargets as M, ImagePlugin as N, KaTeXPlugin as O, defaultImageUpload as P, useFileUpload as Q, markKeepOriginal as R, TextSelectionStoreContext as S, useTextSelectionStore as T, BlockIdPlugin as U, setFileUploadEntry as V, AlertPlugin as W, useImagePreprocess as X, ImagePreprocessProvider as Y, FileUploadProvider as Z, $getRootBlock as _, EditorRefPlugin as a, ClickBelowPlugin as at, buildBlockAnchor as b, $captureTextSelection as c, AutoLinkPlugin as ct, createDOMRangeFromTextSelection as d, MarkdownShortcutsPlugin as et, findDOMPointByTextOffset as f, TEXT_SELECTION_HIGHLIGHT_NAME as g, getTextOffsetFromDOMPoint as h, FootnotePlugin as i, HorizontalRulePlugin as it, ImageDialog as j, ImageUploadPlugin as k, $captureTextSelectionFromRangeSelection as l, getDOMRectFromTextSelection as m, SubmitShortcutPlugin as n, ALL_TRANSFORMERS as nt, VideoUploadPlugin as o, registerClickBelowCommand as ot, getBlockElementById as p, ImageUploadProvider as q, OnChangePlugin as r, InlineDndPlugin as rt, TextSelectionPlugin as s, BlockExitPlugin as st, AutoFocusPlugin as t, MarkdownPastePlugin as tt, $restoreTextSelection as u, $getTextOffsetInBlock as v, useTextSelectionSnapshot as w, buildRangeAnchor as x, $resolveSelectionPoint as y, registerImageEditor as z };
|