@lobehub/editor 4.15.1 → 4.15.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/es/_virtual/_rolldown/runtime.js +28 -0
- package/es/codemirror/components/CopyButton.d.ts +7 -0
- package/es/codemirror/components/CopyButton.js +24 -0
- package/es/codemirror/components/LanguageSelect.d.ts +7 -0
- package/es/codemirror/components/LanguageSelect.js +59 -0
- package/es/codemirror/components/MoreOptions.d.ts +7 -0
- package/es/codemirror/components/MoreOptions.js +66 -0
- package/es/codemirror/components/Toolbar.d.ts +7 -0
- package/es/codemirror/components/Toolbar.js +51 -0
- package/es/codemirror/components/style.js +7 -0
- package/es/codemirror/constants.d.ts +6 -0
- package/es/codemirror/constants.js +512 -0
- package/es/codemirror/loader.d.ts +61 -0
- package/es/codemirror/loader.js +77 -0
- package/es/codemirror/style.d.ts +4 -0
- package/es/codemirror/style.js +82 -0
- package/es/codemirror/theme.d.ts +132 -0
- package/es/codemirror/theme.js +75 -0
- package/es/codemirror/types.d.ts +53 -0
- package/es/codemirror.d.ts +9 -263
- package/es/codemirror.js +8 -1
- package/es/common/canUseDOM.js +11 -0
- package/es/common/sys.js +27 -0
- package/es/const/hotkey.js +100 -0
- package/es/editor-kernel/data-source.d.ts +15 -0
- package/es/editor-kernel/data-source.js +15 -0
- package/es/editor-kernel/event.d.ts +7 -0
- package/es/editor-kernel/event.js +19 -0
- package/es/editor-kernel/index.d.ts +5 -0
- package/es/editor-kernel/index.js +17 -0
- package/es/editor-kernel/inode/helper.js +87 -0
- package/es/editor-kernel/inode/i-element-node.d.ts +6 -0
- package/es/editor-kernel/inode/i-node.d.ts +6 -0
- package/es/editor-kernel/inode/index.d.ts +4 -0
- package/es/editor-kernel/inode/paragraph-node.d.ts +1 -0
- package/es/editor-kernel/inode/root-node.d.ts +9 -0
- package/es/editor-kernel/inode/text-node.d.ts +9 -0
- package/es/editor-kernel/kernel.d.ts +122 -0
- package/es/editor-kernel/kernel.js +661 -0
- package/es/editor-kernel/plugin.js +59 -0
- package/es/editor-kernel/react/LexicalErrorBoundary.d.ts +13 -0
- package/es/editor-kernel/react/LexicalErrorBoundary.js +19 -0
- package/es/editor-kernel/react/PortalAnchor.js +12 -0
- package/es/editor-kernel/react/PortalContainer.d.ts +14 -0
- package/es/editor-kernel/react/PortalContainer.js +25 -0
- package/es/editor-kernel/react/index.d.ts +5 -0
- package/es/editor-kernel/react/react-context.d.ts +11 -0
- package/es/editor-kernel/react/react-context.js +21 -0
- package/es/editor-kernel/react/react-editor.d.ts +16 -0
- package/es/editor-kernel/react/react-editor.js +32 -0
- package/es/editor-kernel/react/useAnchor.js +17 -0
- package/es/editor-kernel/react/useDecorators.js +54 -0
- package/es/editor-kernel/react/useEditable.js +25 -0
- package/es/editor-kernel/react/useLexicalEditor.d.ts +6 -0
- package/es/editor-kernel/react/useLexicalEditor.js +23 -0
- package/es/editor-kernel/react/useLexicalNodeSelection.js +86 -0
- package/es/editor-kernel/react/useTranslation.js +9 -0
- package/es/editor-kernel/utils.d.ts +46 -0
- package/es/editor-kernel/utils.js +138 -0
- package/es/headless/extract-media-from-editor-state.d.ts +22 -0
- package/es/headless/extract-media-from-editor-state.js +49 -0
- package/es/headless/index.d.ts +69 -0
- package/es/headless/index.js +189 -0
- package/es/headless/plugins/codeblock.js +82 -0
- package/es/headless.js +3 -20139
- package/es/index.d.ts +112 -3059
- package/es/index.js +100 -8484
- package/es/locale/index.d.ts +61 -0
- package/es/locale/index.js +62 -0
- package/es/node_modules/.pnpm/@types_mdast@4.0.4/node_modules/@types/mdast/index.d.ts +953 -0
- package/es/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts +83 -0
- package/es/plugins/auto-complete/index.d.ts +2 -0
- package/es/plugins/auto-complete/node/placeholderNode.js +89 -0
- package/es/plugins/auto-complete/plugin/index.d.ts +31 -0
- package/es/plugins/auto-complete/plugin/index.js +395 -0
- package/es/plugins/auto-complete/react/ReactAutoCompletePlugin.d.ts +7 -0
- package/es/plugins/auto-complete/react/ReactAutoCompletePlugin.js +60 -0
- package/es/plugins/auto-complete/react/index.d.ts +1 -0
- package/es/plugins/auto-complete/react/style.js +12 -0
- package/es/plugins/auto-complete/react/type.d.ts +25 -0
- package/es/plugins/block/command/index.d.ts +13 -0
- package/es/plugins/block/command/index.js +161 -0
- package/es/plugins/block/index.d.ts +5 -0
- package/es/plugins/block/plugin/index.d.ts +9 -0
- package/es/plugins/block/plugin/index.js +86 -0
- package/es/plugins/block/react/ReactBlockPlugin.d.ts +18 -0
- package/es/plugins/block/react/ReactBlockPlugin.js +457 -0
- package/es/plugins/block/react/core/runtime-context.js +19 -0
- package/es/plugins/block/react/core/types.d.ts +6 -0
- package/es/plugins/block/react/drag/drag-session.js +264 -0
- package/es/plugins/block/react/drag/drag-utils.js +95 -0
- package/es/plugins/block/react/index.d.ts +2 -0
- package/es/plugins/block/react/style.js +66 -0
- package/es/plugins/block/service/i-block-menu-service.d.ts +44 -0
- package/es/plugins/block/service/i-block-menu-service.js +43 -0
- package/es/plugins/block/service/index.d.ts +1 -0
- package/es/plugins/code/command/index.d.ts +7 -0
- package/es/plugins/code/command/index.js +30 -0
- package/es/plugins/code/index.d.ts +3 -0
- package/es/plugins/code/node/code.js +91 -0
- package/es/plugins/code/plugin/index.d.ts +9 -0
- package/es/plugins/code/plugin/index.js +74 -0
- package/es/plugins/code/plugin/registry.js +33 -0
- package/es/plugins/code/react/CodeReactPlugin.d.ts +7 -0
- package/es/plugins/code/react/CodeReactPlugin.js +27 -0
- package/es/plugins/code/react/index.d.ts +1 -0
- package/es/plugins/code/react/style.js +21 -0
- package/es/plugins/code/react/type.d.ts +7 -0
- package/es/plugins/codeblock/command/index.d.ts +8 -0
- package/es/plugins/codeblock/command/index.js +40 -0
- package/es/plugins/codeblock/index.d.ts +6 -0
- package/es/plugins/codeblock/index.js +5 -0
- package/es/plugins/codeblock/plugin/CodeHighlighterShiki.js +415 -0
- package/es/plugins/codeblock/plugin/FacadeShiki.js +193 -0
- package/es/plugins/codeblock/plugin/index.d.ts +16 -0
- package/es/plugins/codeblock/plugin/index.js +157 -0
- package/es/plugins/codeblock/plugin/invariant.js +14 -0
- package/es/plugins/codeblock/react/ReactCodeblockPlugin.d.ts +7 -0
- package/es/plugins/codeblock/react/ReactCodeblockPlugin.js +27 -0
- package/es/plugins/codeblock/react/index.d.ts +2 -0
- package/es/plugins/codeblock/react/style.js +58 -0
- package/es/plugins/codeblock/react/type.d.ts +8 -0
- package/es/plugins/codeblock/utils/language.js +9 -0
- package/es/plugins/codemirror-block/command/index.d.ts +13 -0
- package/es/plugins/codemirror-block/command/index.js +67 -0
- package/es/plugins/codemirror-block/index.d.ts +3 -0
- package/es/plugins/codemirror-block/lib/mode.js +8 -0
- package/es/plugins/codemirror-block/node/CodeMirrorNode.d.ts +48 -0
- package/es/plugins/codemirror-block/node/CodeMirrorNode.js +205 -0
- package/es/plugins/codemirror-block/plugin/index.d.ts +12 -0
- package/es/plugins/codemirror-block/plugin/index.js +80 -0
- package/es/plugins/codemirror-block/react/CodemirrorNode.js +219 -0
- package/es/plugins/codemirror-block/react/ReactCodemirrorNode.d.ts +7 -0
- package/es/plugins/codemirror-block/react/ReactCodemirrorNode.js +26 -0
- package/es/plugins/codemirror-block/react/index.d.ts +1 -0
- package/es/plugins/codemirror-block/react/type.d.ts +6 -0
- package/es/plugins/common/command/index.d.ts +11 -0
- package/es/plugins/common/command/index.js +24 -0
- package/es/plugins/common/data-source/json-data-source.js +133 -0
- package/es/plugins/common/data-source/text-data-source.js +32 -0
- package/es/plugins/common/index.d.ts +6 -0
- package/es/plugins/common/node/ElementDOMSlot.js +30 -0
- package/es/plugins/common/node/cursor.d.ts +16 -0
- package/es/plugins/common/node/cursor.js +189 -0
- package/es/plugins/common/plugin/index.d.ts +43 -0
- package/es/plugins/common/plugin/index.js +338 -0
- package/es/plugins/common/plugin/mdReader.js +62 -0
- package/es/plugins/common/plugin/paste-handler.d.ts +11 -0
- package/es/plugins/common/plugin/paste-handler.js +61 -0
- package/es/plugins/common/plugin/register.js +306 -0
- package/es/plugins/common/react/Placeholder/index.js +65 -0
- package/es/plugins/common/react/Placeholder/style.js +22 -0
- package/es/plugins/common/react/ReactEditorContent.d.ts +7 -0
- package/es/plugins/common/react/ReactEditorContent.js +8 -0
- package/es/plugins/common/react/ReactPlainText.d.ts +7 -0
- package/es/plugins/common/react/ReactPlainText.js +192 -0
- package/es/plugins/common/react/index.d.ts +3 -0
- package/es/plugins/common/react/style.js +206 -0
- package/es/plugins/common/react/type.d.ts +94 -0
- package/es/plugins/common/utils/index.js +135 -0
- package/es/plugins/content-blocks/data-source/content-blocks-data-source.d.ts +15 -0
- package/es/plugins/content-blocks/data-source/content-blocks-data-source.js +21 -0
- package/es/plugins/content-blocks/index.d.ts +6 -0
- package/es/plugins/content-blocks/plugin/index.d.ts +10 -0
- package/es/plugins/content-blocks/plugin/index.js +24 -0
- package/es/plugins/content-blocks/types.d.ts +33 -0
- package/es/plugins/content-blocks/types.js +4 -0
- package/es/plugins/content-blocks/utils/extract-media-lists.d.ts +7 -0
- package/es/plugins/content-blocks/utils/extract-media-lists.js +32 -0
- package/es/plugins/content-blocks/utils/extract.d.ts +8 -0
- package/es/plugins/content-blocks/utils/extract.js +188 -0
- package/es/plugins/file/command/index.d.ts +9 -0
- package/es/plugins/file/command/index.js +31 -0
- package/es/plugins/file/index.d.ts +4 -0
- package/es/plugins/file/node/FileNode.d.ts +38 -0
- package/es/plugins/file/node/FileNode.js +106 -0
- package/es/plugins/file/plugin/index.d.ts +18 -0
- package/es/plugins/file/plugin/index.js +103 -0
- package/es/plugins/file/react/ReactFilePlugin.d.ts +7 -0
- package/es/plugins/file/react/ReactFilePlugin.js +35 -0
- package/es/plugins/file/react/components/ReactFile.js +50 -0
- package/es/plugins/file/react/index.d.ts +2 -0
- package/es/plugins/file/react/style.js +32 -0
- package/es/plugins/file/react/type.d.ts +17 -0
- package/es/plugins/file/utils/index.js +29 -0
- package/es/plugins/hr/command/index.d.ts +7 -0
- package/es/plugins/hr/command/index.js +14 -0
- package/es/plugins/hr/index.d.ts +4 -0
- package/es/plugins/hr/node/HorizontalRuleNode.d.ts +18 -0
- package/es/plugins/hr/node/HorizontalRuleNode.js +59 -0
- package/es/plugins/hr/plugin/index.d.ts +12 -0
- package/es/plugins/hr/plugin/index.js +60 -0
- package/es/plugins/hr/react/ReactHRPlugin.d.ts +7 -0
- package/es/plugins/hr/react/ReactHRPlugin.js +28 -0
- package/es/plugins/hr/react/components/HRNode.js +36 -0
- package/es/plugins/hr/react/index.d.ts +2 -0
- package/es/plugins/hr/react/style.js +32 -0
- package/es/plugins/hr/react/type.d.ts +6 -0
- package/es/plugins/image/command/index.d.ts +12 -0
- package/es/plugins/image/command/index.js +53 -0
- package/es/plugins/image/index.d.ts +4 -0
- package/es/plugins/image/node/basie-image-node.d.ts +33 -0
- package/es/plugins/image/node/basie-image-node.js +68 -0
- package/es/plugins/image/node/block-image-node.d.ts +43 -0
- package/es/plugins/image/node/block-image-node.js +137 -0
- package/es/plugins/image/node/image-node.d.ts +41 -0
- package/es/plugins/image/node/image-node.js +128 -0
- package/es/plugins/image/plugin/index.d.ts +24 -0
- package/es/plugins/image/plugin/index.js +183 -0
- package/es/plugins/image/react/ReactImagePlugin.d.ts +7 -0
- package/es/plugins/image/react/ReactImagePlugin.js +41 -0
- package/es/plugins/image/react/components/BrokenImage.js +16 -0
- package/es/plugins/image/react/components/Image.js +190 -0
- package/es/plugins/image/react/components/ImageEditPopover.js +160 -0
- package/es/plugins/image/react/components/LazyImage.js +73 -0
- package/es/plugins/image/react/components/ResizeHandle.js +62 -0
- package/es/plugins/image/react/components/style.js +135 -0
- package/es/plugins/image/react/components/useSupenseImage.js +22 -0
- package/es/plugins/image/react/index.d.ts +2 -0
- package/es/plugins/image/react/style.js +31 -0
- package/es/plugins/image/react/type.d.ts +23 -0
- package/es/plugins/inode/index.d.ts +3 -0
- package/es/plugins/inode/plugin/index.d.ts +19 -0
- package/es/plugins/inode/plugin/index.js +23 -0
- package/es/plugins/inode/react/index.d.ts +6 -0
- package/es/plugins/inode/react/index.js +15 -0
- package/es/plugins/inode/service/index.d.ts +17 -0
- package/es/plugins/inode/service/index.js +22 -0
- package/es/plugins/link/command/index.d.ts +10 -0
- package/es/plugins/link/command/index.js +33 -0
- package/es/plugins/link/index.d.ts +5 -0
- package/es/plugins/link/node/LinkNode.d.ts +10 -0
- package/es/plugins/link/node/LinkNode.js +448 -0
- package/es/plugins/link/plugin/index.d.ts +16 -0
- package/es/plugins/link/plugin/index.js +106 -0
- package/es/plugins/link/plugin/registry.js +82 -0
- package/es/plugins/link/react/ReactLinkPlugin.d.ts +7 -0
- package/es/plugins/link/react/ReactLinkPlugin.js +50 -0
- package/es/plugins/link/react/components/LinkEdit.js +204 -0
- package/es/plugins/link/react/components/LinkToolbar.js +148 -0
- package/es/plugins/link/react/index.d.ts +2 -0
- package/es/plugins/link/react/style.js +34 -0
- package/es/plugins/link/react/type.d.ts +14 -0
- package/es/plugins/link/service/i-link-service.d.ts +10 -0
- package/es/plugins/link/service/i-link-service.js +19 -0
- package/es/plugins/link/utils/index.js +45 -0
- package/es/plugins/link-highlight/command/index.d.ts +8 -0
- package/es/plugins/link-highlight/command/index.js +30 -0
- package/es/plugins/link-highlight/index.d.ts +3 -0
- package/es/plugins/link-highlight/node/link-highlight.js +80 -0
- package/es/plugins/link-highlight/plugin/index.d.ts +18 -0
- package/es/plugins/link-highlight/plugin/index.js +109 -0
- package/es/plugins/link-highlight/plugin/registry.js +33 -0
- package/es/plugins/link-highlight/react/ReactLinkHighlightPlugin.d.ts +7 -0
- package/es/plugins/link-highlight/react/ReactLinkHighlightPlugin.js +29 -0
- package/es/plugins/link-highlight/react/index.d.ts +1 -0
- package/es/plugins/link-highlight/react/style.js +14 -0
- package/es/plugins/link-highlight/react/type.d.ts +16 -0
- package/es/plugins/list/command/index.d.ts +3 -0
- package/es/plugins/list/command/index.js +3 -0
- package/es/plugins/list/index.d.ts +5 -0
- package/es/plugins/list/plugin/checkList.d.ts +6 -0
- package/es/plugins/list/plugin/checkList.js +140 -0
- package/es/plugins/list/plugin/index.d.ts +9 -0
- package/es/plugins/list/plugin/index.js +195 -0
- package/es/plugins/list/plugin/registry.js +68 -0
- package/es/plugins/list/react/ReactListPlugin.d.ts +7 -0
- package/es/plugins/list/react/ReactListPlugin.js +21 -0
- package/es/plugins/list/react/index.d.ts +2 -0
- package/es/plugins/list/react/style.js +123 -0
- package/es/plugins/list/react/type.d.ts +7 -0
- package/es/plugins/list/utils/index.js +58 -0
- package/es/plugins/litexml/command/diffCommand.d.ts +17 -0
- package/es/plugins/litexml/command/diffCommand.js +97 -0
- package/es/plugins/litexml/command/index.d.ts +38 -0
- package/es/plugins/litexml/command/index.js +333 -0
- package/es/plugins/litexml/data-source/litexml-data-source.d.ts +65 -0
- package/es/plugins/litexml/data-source/litexml-data-source.js +286 -0
- package/es/plugins/litexml/index.d.ts +7 -0
- package/es/plugins/litexml/node/DiffNode.d.ts +29 -0
- package/es/plugins/litexml/node/DiffNode.js +95 -0
- package/es/plugins/litexml/plugin/index.d.ts +24 -0
- package/es/plugins/litexml/plugin/index.js +100 -0
- package/es/plugins/litexml/react/DiffNodeToolbar/index.js +60 -0
- package/es/plugins/litexml/react/DiffNodeToolbar/style.js +24 -0
- package/es/plugins/litexml/react/hooks/useHasDiffNode.d.ts +7 -0
- package/es/plugins/litexml/react/hooks/useHasDiffNode.js +35 -0
- package/es/plugins/litexml/react/index.d.ts +6 -0
- package/es/plugins/litexml/react/index.js +26 -0
- package/es/plugins/litexml/react/style.js +124 -0
- package/es/plugins/litexml/service/litexml-service.d.ts +93 -0
- package/es/plugins/litexml/service/litexml-service.js +42 -0
- package/es/plugins/litexml/utils/index.js +59 -0
- package/es/plugins/markdown/command/index.d.ts +14 -0
- package/es/plugins/markdown/command/index.js +74 -0
- package/es/plugins/markdown/data-source/markdown/parse.d.ts +14 -0
- package/es/plugins/markdown/data-source/markdown/parse.js +195 -0
- package/es/plugins/markdown/data-source/markdown-data-source.js +148 -0
- package/es/plugins/markdown/data-source/markdown-writer-context.js +40 -0
- package/es/plugins/markdown/index.d.ts +7 -0
- package/es/plugins/markdown/plugin/index.d.ts +22 -0
- package/es/plugins/markdown/plugin/index.js +285 -0
- package/es/plugins/markdown/react/index.d.ts +6 -0
- package/es/plugins/markdown/react/index.js +31 -0
- package/es/plugins/markdown/service/shortcut.d.ts +57 -0
- package/es/plugins/markdown/service/shortcut.js +101 -0
- package/es/plugins/markdown/service/transformers.d.ts +61 -0
- package/es/plugins/markdown/service/transformers.js +119 -0
- package/es/plugins/markdown/utils/detectLanguage.d.ts +22 -0
- package/es/plugins/markdown/utils/detectLanguage.js +251 -0
- package/es/plugins/markdown/utils/index.d.ts +11 -0
- package/es/plugins/markdown/utils/index.js +143 -0
- package/es/plugins/markdown/utils/logger.js +6 -0
- package/es/plugins/math/command/index.d.ts +9 -0
- package/es/plugins/math/command/index.js +38 -0
- package/es/plugins/math/index.d.ts +3 -0
- package/es/plugins/math/node/index.d.ts +44 -0
- package/es/plugins/math/node/index.js +161 -0
- package/es/plugins/math/plugin/index.d.ts +15 -0
- package/es/plugins/math/plugin/index.js +119 -0
- package/es/plugins/math/react/components/MathEditor.js +198 -0
- package/es/plugins/math/react/components/MathEditorContainer.js +101 -0
- package/es/plugins/math/react/components/MathEditorContent.js +133 -0
- package/es/plugins/math/react/components/MathInline.js +86 -0
- package/es/plugins/math/react/components/Placeholder.js +24 -0
- package/es/plugins/math/react/index.d.ts +7 -0
- package/es/plugins/math/react/index.js +35 -0
- package/es/plugins/math/react/style.js +96 -0
- package/es/plugins/math/react/type.d.ts +17 -0
- package/es/plugins/math/utils/index.js +23 -0
- package/es/plugins/mention/command/index.d.ts +10 -0
- package/es/plugins/mention/command/index.js +18 -0
- package/es/plugins/mention/index.d.ts +5 -0
- package/es/plugins/mention/node/MentionNode.d.ts +28 -0
- package/es/plugins/mention/node/MentionNode.js +86 -0
- package/es/plugins/mention/plugin/index.d.ts +18 -0
- package/es/plugins/mention/plugin/index.js +63 -0
- package/es/plugins/mention/plugin/register.js +30 -0
- package/es/plugins/mention/react/ReactMentionPlugin.d.ts +7 -0
- package/es/plugins/mention/react/ReactMentionPlugin.js +36 -0
- package/es/plugins/mention/react/components/Mention.js +33 -0
- package/es/plugins/mention/react/index.d.ts +2 -0
- package/es/plugins/mention/react/style.js +34 -0
- package/es/plugins/mention/react/type.d.ts +12 -0
- package/es/plugins/slash/index.d.ts +6 -0
- package/es/plugins/slash/plugin/index.d.ts +27 -0
- package/es/plugins/slash/plugin/index.js +160 -0
- package/es/plugins/slash/react/ReactSlashOption.d.ts +7 -0
- package/es/plugins/slash/react/ReactSlashOption.js +8 -0
- package/es/plugins/slash/react/ReactSlashPlugin.d.ts +7 -0
- package/es/plugins/slash/react/ReactSlashPlugin.js +190 -0
- package/es/plugins/slash/react/components/DefaultSlashMenu.js +168 -0
- package/es/plugins/slash/react/components/SlashMenu.d.ts +11 -0
- package/es/plugins/slash/react/components/SlashMenu.js +40 -0
- package/es/plugins/slash/react/index.d.ts +4 -0
- package/es/plugins/slash/react/type.d.ts +114 -0
- package/es/plugins/slash/react/utils.js +18 -0
- package/es/plugins/slash/service/i-slash-service.d.ts +50 -0
- package/es/plugins/slash/service/i-slash-service.js +55 -0
- package/es/plugins/slash/utils/utils.d.ts +1 -0
- package/es/plugins/slash/utils/utils.js +97 -0
- package/es/plugins/table/command/index.d.ts +17 -0
- package/es/plugins/table/command/index.js +57 -0
- package/es/plugins/table/index.d.ts +3 -0
- package/es/plugins/table/node/index.js +18 -0
- package/es/plugins/table/plugin/index.d.ts +8 -0
- package/es/plugins/table/plugin/index.js +172 -0
- package/es/plugins/table/react/TableActionMenu/ActionMenu.js +220 -0
- package/es/plugins/table/react/TableActionMenu/index.js +128 -0
- package/es/plugins/table/react/TableActionMenu/style.js +20 -0
- package/es/plugins/table/react/TableActionMenu/utils.js +34 -0
- package/es/plugins/table/react/TableHoverActions/index.js +147 -0
- package/es/plugins/table/react/TableHoverActions/style.js +14 -0
- package/es/plugins/table/react/TableHoverActions/utils.js +32 -0
- package/es/plugins/table/react/TableResize/index.js +253 -0
- package/es/plugins/table/react/TableResize/style.js +16 -0
- package/es/plugins/table/react/TableResize/utils.js +9 -0
- package/es/plugins/table/react/index.d.ts +7 -0
- package/es/plugins/table/react/index.js +49 -0
- package/es/plugins/table/react/style.js +63 -0
- package/es/plugins/table/react/type.d.ts +8 -0
- package/es/plugins/table/utils/index.js +48 -0
- package/es/plugins/toolbar/command/index.d.ts +12 -0
- package/es/plugins/toolbar/command/index.js +17 -0
- package/es/plugins/toolbar/index.d.ts +2 -0
- package/es/plugins/toolbar/react/index.d.ts +7 -0
- package/es/plugins/toolbar/react/index.js +109 -0
- package/es/plugins/toolbar/react/style.js +55 -0
- package/es/plugins/toolbar/react/type.d.ts +9 -0
- package/es/plugins/toolbar/utils/getDOMRangeRect.js +20 -0
- package/es/plugins/toolbar/utils/setFloatingElemPosition.js +50 -0
- package/es/plugins/upload/index.d.ts +2 -0
- package/es/plugins/upload/plugin/index.d.ts +6 -0
- package/es/plugins/upload/plugin/index.js +47 -0
- package/es/plugins/upload/service/i-upload-service.d.ts +13 -0
- package/es/plugins/upload/service/i-upload-service.js +30 -0
- package/es/plugins/upload/utils/index.js +15 -0
- package/es/plugins/virtual-block/index.d.ts +2 -0
- package/es/plugins/virtual-block/plugin/index.d.ts +8 -0
- package/es/plugins/virtual-block/plugin/index.js +19 -0
- package/es/plugins/virtual-block/plugin/register.js +150 -0
- package/es/plugins/virtual-block/react/ReactVirtualBlock.d.ts +6 -0
- package/es/plugins/virtual-block/react/ReactVirtualBlock.js +15 -0
- package/es/plugins/virtual-block/react/index.d.ts +1 -0
- package/es/react/ChatInput/ChatInput.d.ts +7 -0
- package/es/react/ChatInput/ChatInput.js +91 -0
- package/es/react/ChatInput/index.d.ts +2 -0
- package/es/react/ChatInput/style.js +115 -0
- package/es/react/ChatInput/type.d.ts +32 -0
- package/es/react/ChatInputActionBar/ChatInputActionBar.d.ts +7 -0
- package/es/react/ChatInputActionBar/ChatInputActionBar.js +22 -0
- package/es/react/ChatInputActionBar/index.d.ts +2 -0
- package/es/react/ChatInputActionBar/style.js +7 -0
- package/es/react/ChatInputActionBar/type.d.ts +10 -0
- package/es/react/ChatInputActions/ChatInputActions.d.ts +7 -0
- package/es/react/ChatInputActions/ChatInputActions.js +65 -0
- package/es/react/ChatInputActions/components/ActionItem.js +46 -0
- package/es/react/ChatInputActions/components/ActionRender.js +45 -0
- package/es/react/ChatInputActions/components/CollapsedActions.js +60 -0
- package/es/react/ChatInputActions/components/useDisplayActionCount.js +45 -0
- package/es/react/ChatInputActions/index.d.ts +2 -0
- package/es/react/ChatInputActions/style.js +20 -0
- package/es/react/ChatInputActions/type.d.ts +36 -0
- package/es/react/CodeLanguageSelect/CodeLanguageSelect.d.ts +7 -0
- package/es/react/CodeLanguageSelect/CodeLanguageSelect.js +67 -0
- package/es/react/CodeLanguageSelect/index.d.ts +2 -0
- package/es/react/CodeLanguageSelect/style.js +7 -0
- package/es/react/CodeLanguageSelect/type.d.ts +6 -0
- package/es/react/Editor/Editor.js +108 -0
- package/es/react/Editor/index.d.ts +16 -0
- package/es/react/Editor/index.js +11 -0
- package/es/react/Editor/type.d.ts +64 -0
- package/es/react/Editor/utils.d.ts +6 -0
- package/es/react/Editor/utils.js +6 -0
- package/es/react/EditorProvider/index.d.ts +28 -0
- package/es/react/EditorProvider/index.js +18 -0
- package/es/react/FloatActions/FloatActions.d.ts +7 -0
- package/es/react/FloatActions/FloatActions.js +34 -0
- package/es/react/FloatActions/components/ActionItem.js +46 -0
- package/es/react/FloatActions/components/ActionRender.js +45 -0
- package/es/react/FloatActions/components/CollapsedActions.js +60 -0
- package/es/react/FloatActions/index.d.ts +2 -0
- package/es/react/FloatActions/style.js +19 -0
- package/es/react/FloatActions/type.d.ts +33 -0
- package/es/react/FloatMenu/FloatMenu.d.ts +7 -0
- package/es/react/FloatMenu/FloatMenu.js +32 -0
- package/es/react/FloatMenu/index.d.ts +2 -0
- package/es/react/FloatMenu/style.js +28 -0
- package/es/react/FloatMenu/type.d.ts +25 -0
- package/es/react/SendButton/SendButton.d.ts +7 -0
- package/es/react/SendButton/SendButton.js +107 -0
- package/es/react/SendButton/components/SendIcon.js +23 -0
- package/es/react/SendButton/components/StopIcon.js +56 -0
- package/es/react/SendButton/index.d.ts +2 -0
- package/es/react/SendButton/style.js +68 -0
- package/es/react/SendButton/type.d.ts +12 -0
- package/es/react/SlashMenu/SlashMenu.d.ts +7 -0
- package/es/react/SlashMenu/SlashMenu.js +40 -0
- package/es/react/SlashMenu/index.d.ts +2 -0
- package/es/react/SlashMenu/type.d.ts +17 -0
- package/es/react/hooks/useEditor.d.ts +5 -0
- package/es/react/hooks/useEditor.js +8 -0
- package/es/react/hooks/useEditorState/index.d.ts +71 -0
- package/es/react/hooks/useEditorState/index.js +347 -0
- package/es/react/hooks/useEditorState/utils.js +28 -0
- package/es/react/hooks/useSize.js +61 -0
- package/es/react.d.ts +22 -334
- package/es/react.js +13 -1573
- package/es/renderer/LexicalDiff.d.ts +41 -0
- package/es/renderer/LexicalDiff.js +96 -0
- package/es/renderer/LexicalRenderer.d.ts +16 -0
- package/es/renderer/LexicalRenderer.js +48 -0
- package/es/renderer/diff/compute.js +396 -0
- package/es/renderer/diff/style.d.ts +4 -0
- package/es/renderer/diff/style.js +104 -0
- package/es/renderer/diff/types.d.ts +32 -0
- package/es/renderer/engine/render-builtin-node.js +196 -0
- package/es/renderer/engine/render-text-node.js +33 -0
- package/es/renderer/engine/render-tree.js +35 -0
- package/es/renderer/engine/shiki.d.ts +4 -0
- package/es/renderer/engine/shiki.js +24 -0
- package/es/renderer/engine/utils.js +16 -0
- package/es/renderer/nodes/index.d.ts +6 -0
- package/es/renderer/nodes/index.js +44 -0
- package/es/renderer/renderers/codeblock.js +21 -0
- package/es/renderer/renderers/file.js +29 -0
- package/es/renderer/renderers/horizontalrule.js +29 -0
- package/es/renderer/renderers/image.js +35 -0
- package/es/renderer/renderers/index.d.ts +6 -0
- package/es/renderer/renderers/index.js +21 -0
- package/es/renderer/renderers/math.js +19 -0
- package/es/renderer/renderers/mention.js +15 -0
- package/es/renderer/renderers/mermaid.js +17 -0
- package/es/renderer/style.js +52 -0
- package/es/renderer/types.d.ts +29 -0
- package/es/renderer.d.ts +8 -114
- package/es/renderer.js +5 -1153
- package/es/types/hotkey.d.ts +76 -0
- package/es/types/hotkey.js +65 -0
- package/es/types/index.d.ts +2 -0
- package/es/types/kernel.d.ts +359 -0
- package/es/types/locale.d.ts +11 -0
- package/es/utils/cx.js +4 -0
- package/es/utils/debug.d.ts +425 -0
- package/es/{debug-CIvbNHJu.js → utils/debug.js} +3 -35
- package/es/utils/hotkey/isHotkeyMatch.js +17 -0
- package/es/utils/hotkey/parseHotkeys.js +53 -0
- package/es/utils/hotkey/registerHotkey.d.ts +18 -0
- package/es/utils/hotkey/registerHotkey.js +35 -0
- package/es/utils/scrollIntoView.d.ts +8 -0
- package/es/utils/scrollIntoView.js +29 -0
- package/es/utils/updatePosition.js +26 -0
- package/es/utils/url.d.ts +18 -0
- package/es/utils/url.js +34 -0
- package/package.json +4 -1
- package/es/ReactSlashPlugin-BiVy_Iwf.js +0 -23072
- package/es/codemirror-3POv7f__.js +0 -923
- package/es/index-DHGp94p0.d.ts +0 -916
- package/es/style-DADgHVA1.js +0 -2889
- package/es/style-DMdPzCo-.js +0 -999
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
//#region src/plugins/markdown/utils/detectLanguage.ts
|
|
2
|
+
const LANGUAGE_PATTERNS = {
|
|
3
|
+
bash: {
|
|
4
|
+
optional: [
|
|
5
|
+
/\|\||&&/,
|
|
6
|
+
/echo\s+/,
|
|
7
|
+
/if\s+\[/
|
|
8
|
+
],
|
|
9
|
+
required: [/^#!\/bin\/(ba)?sh/, /\${?\w+}?/],
|
|
10
|
+
weight: 7
|
|
11
|
+
},
|
|
12
|
+
csharp: {
|
|
13
|
+
optional: [
|
|
14
|
+
/\[.*]/,
|
|
15
|
+
/async\s+Task/,
|
|
16
|
+
/var\s+\w+\s*=/
|
|
17
|
+
],
|
|
18
|
+
required: [/(public|private|protected)\s+(class|interface|namespace)/, /using\s+\w+/],
|
|
19
|
+
weight: 8
|
|
20
|
+
},
|
|
21
|
+
css: {
|
|
22
|
+
optional: [/@media|@import|@keyframes/, /!important/],
|
|
23
|
+
required: [/[#.]?[\w-]+\s*{/, /:\s*[\w#%-]+;/],
|
|
24
|
+
weight: 8
|
|
25
|
+
},
|
|
26
|
+
dockerfile: {
|
|
27
|
+
required: [/^FROM\s+/, /^(RUN|CMD|COPY|ADD|WORKDIR|ENV|EXPOSE)\s+/m],
|
|
28
|
+
weight: 10
|
|
29
|
+
},
|
|
30
|
+
go: {
|
|
31
|
+
optional: [
|
|
32
|
+
/import\s+\(/,
|
|
33
|
+
/:=/,
|
|
34
|
+
/defer|goroutine/
|
|
35
|
+
],
|
|
36
|
+
required: [/package\s+\w+/, /func\s+\w+/],
|
|
37
|
+
weight: 8
|
|
38
|
+
},
|
|
39
|
+
graphql: {
|
|
40
|
+
optional: [/fragment\s+/, /on\s+\w+/],
|
|
41
|
+
required: [/(query|mutation|subscription)\s+/, /{[\S\s]*}/],
|
|
42
|
+
weight: 8
|
|
43
|
+
},
|
|
44
|
+
html: {
|
|
45
|
+
optional: [/<\/\w+>/, /class=|id=/],
|
|
46
|
+
required: [/<(html|head|body|div|span|p|a|img|script|style|link|meta)/i],
|
|
47
|
+
weight: 9
|
|
48
|
+
},
|
|
49
|
+
ini: {
|
|
50
|
+
exclude: [/^\s*</, /{.*}/],
|
|
51
|
+
required: [/^\[.*]$/m, /\w+\s*=\s*/],
|
|
52
|
+
weight: 6
|
|
53
|
+
},
|
|
54
|
+
java: {
|
|
55
|
+
optional: [
|
|
56
|
+
/@Override|@Autowired/,
|
|
57
|
+
/extends|implements/,
|
|
58
|
+
/System\.out/
|
|
59
|
+
],
|
|
60
|
+
required: [/(public|private|protected)\s+(class|interface|static)/, /\w+\s+\w+\s*\([^)]*\)\s*{/],
|
|
61
|
+
weight: 8
|
|
62
|
+
},
|
|
63
|
+
javascript: {
|
|
64
|
+
exclude: [
|
|
65
|
+
/^\s*</,
|
|
66
|
+
/interface\s+\w+/,
|
|
67
|
+
/:\s*\w+\s*[;=]/
|
|
68
|
+
],
|
|
69
|
+
optional: [
|
|
70
|
+
/=>\s*{/,
|
|
71
|
+
/console\.(log|error|warn)/,
|
|
72
|
+
/\.then\(/,
|
|
73
|
+
/require\(/
|
|
74
|
+
],
|
|
75
|
+
required: [/(function|const|let|var|class|import|export|async|await)\s/],
|
|
76
|
+
weight: 7
|
|
77
|
+
},
|
|
78
|
+
json: {
|
|
79
|
+
optional: [/"[^"]*"\s*:/, /:\s*["'[{]/],
|
|
80
|
+
required: [/^\s*[[{]/, /[\]}]\s*$/],
|
|
81
|
+
weight: 10
|
|
82
|
+
},
|
|
83
|
+
jsx: {
|
|
84
|
+
exclude: [/^\s*<!DOCTYPE/, /^\s*<html/],
|
|
85
|
+
optional: [
|
|
86
|
+
/className=/,
|
|
87
|
+
/{.*}/,
|
|
88
|
+
/import.*from/
|
|
89
|
+
],
|
|
90
|
+
required: [/<\w+[^>]*>/, /(const|function|class)\s+\w+/],
|
|
91
|
+
weight: 8
|
|
92
|
+
},
|
|
93
|
+
makefile: {
|
|
94
|
+
optional: [/\$\(.*\)/, /\.PHONY/],
|
|
95
|
+
required: [/^[\w-]+:\s*/, /^\t/m],
|
|
96
|
+
weight: 7
|
|
97
|
+
},
|
|
98
|
+
markdown: {
|
|
99
|
+
optional: [
|
|
100
|
+
/```/,
|
|
101
|
+
/\*\*.*\*\*/,
|
|
102
|
+
/^\s*[*+-]\s+/m
|
|
103
|
+
],
|
|
104
|
+
required: [/^#{1,6}\s+/, /\[.*]\(.*\)/],
|
|
105
|
+
weight: 6
|
|
106
|
+
},
|
|
107
|
+
php: {
|
|
108
|
+
optional: [
|
|
109
|
+
/function\s+\w+/,
|
|
110
|
+
/class\s+\w+/,
|
|
111
|
+
/echo|print/
|
|
112
|
+
],
|
|
113
|
+
required: [/<\?php/, /\$\w+/],
|
|
114
|
+
weight: 10
|
|
115
|
+
},
|
|
116
|
+
powershell: {
|
|
117
|
+
optional: [
|
|
118
|
+
/\|\s*Where/,
|
|
119
|
+
/\|\s*Select/,
|
|
120
|
+
/param\(/
|
|
121
|
+
],
|
|
122
|
+
required: [/\$\w+/, /(Get|Set|New|Remove)-\w+/],
|
|
123
|
+
weight: 8
|
|
124
|
+
},
|
|
125
|
+
python: {
|
|
126
|
+
optional: [
|
|
127
|
+
/if __name__|print\(/,
|
|
128
|
+
/self\.|lambda/,
|
|
129
|
+
/@\w+\s*$/m
|
|
130
|
+
],
|
|
131
|
+
required: [/(def|class|import|from)\s+\w+/, /:\s*$/m],
|
|
132
|
+
weight: 8
|
|
133
|
+
},
|
|
134
|
+
ruby: {
|
|
135
|
+
optional: [
|
|
136
|
+
/do\s*\|.*\|/,
|
|
137
|
+
/puts|require/,
|
|
138
|
+
/:\w+\s*=>/
|
|
139
|
+
],
|
|
140
|
+
required: [/(def|class|module|end)\s/, /@\w+/],
|
|
141
|
+
weight: 7
|
|
142
|
+
},
|
|
143
|
+
rust: {
|
|
144
|
+
optional: [
|
|
145
|
+
/::\w+/,
|
|
146
|
+
/&mut|&str/,
|
|
147
|
+
/#\[derive\(/
|
|
148
|
+
],
|
|
149
|
+
required: [/(fn|struct|impl|trait|use)\s+/, /let\s+(mut\s+)?\w+/],
|
|
150
|
+
weight: 8
|
|
151
|
+
},
|
|
152
|
+
scss: {
|
|
153
|
+
optional: [/@mixin|@include|@extend/, /#{.*}/],
|
|
154
|
+
required: [/\$[\w-]+\s*:/, /[&@]\w+/],
|
|
155
|
+
weight: 8
|
|
156
|
+
},
|
|
157
|
+
sql: {
|
|
158
|
+
optional: [/from|where|join|group by|order by/i, /\*/],
|
|
159
|
+
required: [/(select|insert|update|delete|create|alter|drop)\s+/i],
|
|
160
|
+
weight: 9
|
|
161
|
+
},
|
|
162
|
+
toml: {
|
|
163
|
+
optional: [/\[\[.*]]/, /"""[\S\s]*"""/],
|
|
164
|
+
required: [/^\[.*]$/m, /\w+\s*=\s*[\w"']/],
|
|
165
|
+
weight: 8
|
|
166
|
+
},
|
|
167
|
+
tsx: {
|
|
168
|
+
optional: [
|
|
169
|
+
/:\s*React\./,
|
|
170
|
+
/:\s*FC</,
|
|
171
|
+
/useState|useEffect/
|
|
172
|
+
],
|
|
173
|
+
required: [/<\w+[^>]*>/, /interface|type\s+\w+/],
|
|
174
|
+
weight: 9
|
|
175
|
+
},
|
|
176
|
+
typescript: {
|
|
177
|
+
optional: [
|
|
178
|
+
/<\w+>/,
|
|
179
|
+
/as\s+\w+/,
|
|
180
|
+
/implements|extends/
|
|
181
|
+
],
|
|
182
|
+
required: [/(interface|type|enum)\s+\w+/, /:\s*\w+(\[]|<.+>)?\s*[);=]/],
|
|
183
|
+
weight: 8
|
|
184
|
+
},
|
|
185
|
+
xml: {
|
|
186
|
+
optional: [/<\/\w+>/, /xmlns/],
|
|
187
|
+
required: [/<\?xml|<\w+[^>]*>/],
|
|
188
|
+
weight: 9
|
|
189
|
+
},
|
|
190
|
+
yaml: {
|
|
191
|
+
exclude: [/^\s*[[\]{]/],
|
|
192
|
+
required: [/^[\s-]*\w+:\s*/, /^[\s-]*-\s+/m],
|
|
193
|
+
weight: 8
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Detect the programming language of a code snippet
|
|
198
|
+
* @param code - The code snippet to analyze
|
|
199
|
+
* @returns Language detection result with confidence score
|
|
200
|
+
*/
|
|
201
|
+
function detectLanguage(code) {
|
|
202
|
+
if (!code || code.trim().length === 0) return null;
|
|
203
|
+
const trimmed = code.trim();
|
|
204
|
+
const scores = {};
|
|
205
|
+
for (const [language, pattern] of Object.entries(LANGUAGE_PATTERNS)) {
|
|
206
|
+
let score = 0;
|
|
207
|
+
const baseWeight = pattern.weight || 5;
|
|
208
|
+
if (pattern.exclude) {
|
|
209
|
+
if (pattern.exclude.some((regex) => regex.test(trimmed))) continue;
|
|
210
|
+
}
|
|
211
|
+
if (pattern.required) {
|
|
212
|
+
if (!pattern.required.every((regex) => regex.test(trimmed))) continue;
|
|
213
|
+
score += baseWeight * 2;
|
|
214
|
+
}
|
|
215
|
+
if (pattern.optional) {
|
|
216
|
+
const matchedOptional = pattern.optional.filter((regex) => regex.test(trimmed)).length;
|
|
217
|
+
score += matchedOptional * baseWeight;
|
|
218
|
+
}
|
|
219
|
+
if (score > 0) scores[language] = score;
|
|
220
|
+
}
|
|
221
|
+
const entries = Object.entries(scores);
|
|
222
|
+
if (entries.length === 0) return null;
|
|
223
|
+
entries.sort((a, b) => b[1] - a[1]);
|
|
224
|
+
const [topLanguage, topScore] = entries[0];
|
|
225
|
+
const maxPossibleScore = (LANGUAGE_PATTERNS[topLanguage].weight || 5) * 5;
|
|
226
|
+
const confidence = Math.min(100, Math.round(topScore / maxPossibleScore * 100));
|
|
227
|
+
if (confidence < 30) return null;
|
|
228
|
+
return {
|
|
229
|
+
confidence,
|
|
230
|
+
language: topLanguage
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Simple detection for common formats with high confidence
|
|
235
|
+
* Falls back to detectLanguage for more complex detection
|
|
236
|
+
*/
|
|
237
|
+
function detectCodeLanguage(code) {
|
|
238
|
+
const trimmed = code.trim();
|
|
239
|
+
if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) try {
|
|
240
|
+
JSON.parse(trimmed);
|
|
241
|
+
return "json";
|
|
242
|
+
} catch {}
|
|
243
|
+
if (/^\s*(select|insert|update|delete|create|alter|drop)\s+/i.test(code)) return "sql";
|
|
244
|
+
if (/^<\?xml/i.test(code)) return "xml";
|
|
245
|
+
if (/^FROM\s+|^RUN\s+|^CMD\s+/m.test(code)) return "dockerfile";
|
|
246
|
+
if (/<\?php/.test(code)) return "php";
|
|
247
|
+
const result = detectLanguage(code);
|
|
248
|
+
return result && result.confidence > 50 ? result.language : null;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
export { detectCodeLanguage, detectLanguage };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseSelection, LexicalEditor, LexicalNode, TextNode } from "lexical";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/markdown/utils/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a character is a punctuation character.
|
|
6
|
+
* @param char The character to check.
|
|
7
|
+
* @returns True if the character is a punctuation character, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
declare function isPunctuationChar(char: string): boolean;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { isPunctuationChar };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { $caretFromPoint, $getCaretRange, $getChildCaret, $getRoot, $isElementNode, $isRangeSelection, $isTextNode, $isTextPointCaret, $parseSerializedNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND } from "lexical";
|
|
2
|
+
//#region src/plugins/markdown/utils/index.ts
|
|
3
|
+
/**
|
|
4
|
+
* Returns true if the node can contain transformable markdown.
|
|
5
|
+
* Code nodes cannot contain transformable markdown.
|
|
6
|
+
* For example, `code **bold**` should not be transformed to
|
|
7
|
+
* <code>code <strong>bold</strong></code>.
|
|
8
|
+
*/
|
|
9
|
+
function canContainTransformableMarkdown(node) {
|
|
10
|
+
return $isTextNode(node) && !node.hasFormat("code");
|
|
11
|
+
}
|
|
12
|
+
function isEqualSubString(stringA, aStart, stringB, bStart, length) {
|
|
13
|
+
for (let i = 0; i < length; i++) if (stringA[aStart + i] !== stringB[bStart + i]) return false;
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
const PUNCTUATION_OR_SPACE = /[!-/:-@[-`{-~\s]/;
|
|
17
|
+
function getOpenTagStartIndex(string, maxIndex, tag) {
|
|
18
|
+
const tagLength = tag.length;
|
|
19
|
+
for (let i = maxIndex; i >= tagLength; i--) {
|
|
20
|
+
const startIndex = i - tagLength;
|
|
21
|
+
if (isEqualSubString(string, startIndex, tag, 0, tagLength) && string[startIndex + tagLength] !== " ") return startIndex;
|
|
22
|
+
}
|
|
23
|
+
return -1;
|
|
24
|
+
}
|
|
25
|
+
function indexBy(list, callback) {
|
|
26
|
+
const index = {};
|
|
27
|
+
for (const item of list) {
|
|
28
|
+
const key = callback(item);
|
|
29
|
+
if (!key) continue;
|
|
30
|
+
if (index[key]) index[key].push(item);
|
|
31
|
+
else index[key] = [item];
|
|
32
|
+
}
|
|
33
|
+
return index;
|
|
34
|
+
}
|
|
35
|
+
let Punctuation = /[!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~\u00A1\u2010-\u2027-]/;
|
|
36
|
+
try {
|
|
37
|
+
Punctuation = /* @__PURE__ */ new RegExp("[\\p{Pc}|\\p{Pd}|\\p{Pe}|\\p{Pf}|\\p{Pi}|\\p{Po}|\\p{Ps}]", "u");
|
|
38
|
+
} catch {}
|
|
39
|
+
/**
|
|
40
|
+
* Checks if a character is a punctuation character.
|
|
41
|
+
* @param char The character to check.
|
|
42
|
+
* @returns True if the character is a punctuation character, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
function isPunctuationChar(char) {
|
|
45
|
+
return Punctuation.test(char);
|
|
46
|
+
}
|
|
47
|
+
function $updateSelectionOnInsert(selection) {
|
|
48
|
+
if ($isRangeSelection(selection) && selection.isCollapsed()) {
|
|
49
|
+
const anchor = selection.anchor;
|
|
50
|
+
let nodeToInspect = null;
|
|
51
|
+
const anchorCaret = $caretFromPoint(anchor, "previous");
|
|
52
|
+
if (anchorCaret) if ($isTextPointCaret(anchorCaret)) nodeToInspect = anchorCaret.origin;
|
|
53
|
+
else {
|
|
54
|
+
const range = $getCaretRange(anchorCaret, $getChildCaret($getRoot(), "next").getFlipped());
|
|
55
|
+
for (const caret of range) if ($isTextNode(caret.origin)) {
|
|
56
|
+
nodeToInspect = caret.origin;
|
|
57
|
+
break;
|
|
58
|
+
} else if ($isElementNode(caret.origin) && !caret.origin.isInline()) break;
|
|
59
|
+
}
|
|
60
|
+
if (nodeToInspect && $isTextNode(nodeToInspect)) {
|
|
61
|
+
const newFormat = nodeToInspect.getFormat();
|
|
62
|
+
const newStyle = nodeToInspect.getStyle();
|
|
63
|
+
if (selection.format !== newFormat || selection.style !== newStyle) {
|
|
64
|
+
selection.format = newFormat;
|
|
65
|
+
selection.style = newStyle;
|
|
66
|
+
selection.dirty = true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Inserts Lexical nodes into the editor using different strategies depending on
|
|
73
|
+
* some simple selection-based heuristics. If you're looking for a generic way to
|
|
74
|
+
* to insert nodes into the editor at a specific selection point, you probably want
|
|
75
|
+
* {@link lexical.$insertNodes}
|
|
76
|
+
*
|
|
77
|
+
* @param editor LexicalEditor instance to insert the nodes into.
|
|
78
|
+
* @param nodes The nodes to insert.
|
|
79
|
+
* @param selection The selection to insert the nodes into.
|
|
80
|
+
*/
|
|
81
|
+
function $insertGeneratedNodes(editor, nodes, selection) {
|
|
82
|
+
if (!editor.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, {
|
|
83
|
+
nodes,
|
|
84
|
+
selection
|
|
85
|
+
})) {
|
|
86
|
+
selection.insertNodes(nodes);
|
|
87
|
+
$updateSelectionOnInsert(selection);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Creates an object containing all the styles and their values provided in the CSS string.
|
|
92
|
+
* @param css - The CSS string of styles and their values.
|
|
93
|
+
* @returns The styleObject containing all the styles and their values.
|
|
94
|
+
*/
|
|
95
|
+
function getStyleObjectFromRawCSS(css) {
|
|
96
|
+
const styleObject = {};
|
|
97
|
+
if (!css) return styleObject;
|
|
98
|
+
const styles = css.split(";");
|
|
99
|
+
for (const style of styles) if (style !== "") {
|
|
100
|
+
const [key, value] = style.split(/:([^]+)/);
|
|
101
|
+
if (key && value) styleObject[key.trim()] = value.trim();
|
|
102
|
+
}
|
|
103
|
+
return styleObject;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
107
|
+
*
|
|
108
|
+
* This source code is licensed under the MIT license found in the
|
|
109
|
+
* LICENSE file in the root directory of this source tree.
|
|
110
|
+
*
|
|
111
|
+
*/
|
|
112
|
+
const CSS_TO_STYLES = /* @__PURE__ */ new Map();
|
|
113
|
+
/**
|
|
114
|
+
* Gets the TextNode's style object and adds the styles to the CSS.
|
|
115
|
+
* @param node - The TextNode to add styles to.
|
|
116
|
+
*/
|
|
117
|
+
function $addNodeStyle(node) {
|
|
118
|
+
const CSSText = node.getStyle();
|
|
119
|
+
const styles = getStyleObjectFromRawCSS(CSSText);
|
|
120
|
+
CSS_TO_STYLES.set(CSSText, styles);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* This method takes an array of objects conforming to the BaseSerializedNode interface and returns
|
|
124
|
+
* an Array containing instances of the corresponding LexicalNode classes registered on the editor.
|
|
125
|
+
* Normally, you'd get an Array of BaseSerialized nodes from {@link $generateJSONFromSelectedNodes}
|
|
126
|
+
*
|
|
127
|
+
* @param serializedNodes an Array of objects conforming to the BaseSerializedNode interface.
|
|
128
|
+
* @returns an Array of Lexical Node objects.
|
|
129
|
+
*/
|
|
130
|
+
function $generateNodesFromSerializedNodes(serializedNodes) {
|
|
131
|
+
const nodes = [];
|
|
132
|
+
for (const serializedNode of serializedNodes) {
|
|
133
|
+
const node = $parseSerializedNode(serializedNode);
|
|
134
|
+
if ($isTextNode(node)) $addNodeStyle(node);
|
|
135
|
+
nodes.push(node);
|
|
136
|
+
}
|
|
137
|
+
return nodes;
|
|
138
|
+
}
|
|
139
|
+
function insertIRootNode(editor, root, selection) {
|
|
140
|
+
$insertGeneratedNodes(editor, $generateNodesFromSerializedNodes(root.children), selection);
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { $generateNodesFromSerializedNodes, $insertGeneratedNodes, PUNCTUATION_OR_SPACE, canContainTransformableMarkdown, getOpenTagStartIndex, indexBy, insertIRootNode, isEqualSubString, isPunctuationChar };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _$lexical from "lexical";
|
|
2
|
+
import { LexicalEditor } from "lexical";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/math/command/index.d.ts
|
|
5
|
+
declare const INSERT_MATH_COMMAND: _$lexical.LexicalCommand<{
|
|
6
|
+
code: string;
|
|
7
|
+
}>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { INSERT_MATH_COMMAND };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { $createMathInlineNode } from "../node/index.js";
|
|
2
|
+
import { $createParagraphNode, $getNodeByKey, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_HIGH, createCommand } from "lexical";
|
|
3
|
+
import { $wrapNodeInElement, mergeRegister } from "@lexical/utils";
|
|
4
|
+
//#region src/plugins/math/command/index.ts
|
|
5
|
+
const INSERT_MATH_COMMAND = createCommand("INSERT_MATH_COMMAND");
|
|
6
|
+
const UPDATE_MATH_COMMAND = createCommand("UPDATE_MATH_COMMAND");
|
|
7
|
+
const SELECT_MATH_SIDE_COMMAND = createCommand("SELECT_MATH_SIDE_COMMAND");
|
|
8
|
+
function registerMathCommand(editor) {
|
|
9
|
+
return mergeRegister(editor.registerCommand(INSERT_MATH_COMMAND, (payload) => {
|
|
10
|
+
const { code } = payload;
|
|
11
|
+
editor.update(() => {
|
|
12
|
+
const mathNode = $createMathInlineNode(code);
|
|
13
|
+
$insertNodes([mathNode]);
|
|
14
|
+
if ($isRootOrShadowRoot(mathNode.getParentOrThrow())) $wrapNodeInElement(mathNode, $createParagraphNode).selectEnd();
|
|
15
|
+
});
|
|
16
|
+
return true;
|
|
17
|
+
}, COMMAND_PRIORITY_HIGH), editor.registerCommand(UPDATE_MATH_COMMAND, (payload) => {
|
|
18
|
+
const { code, key } = payload;
|
|
19
|
+
editor.update(() => {
|
|
20
|
+
const mathCode = $getNodeByKey(key);
|
|
21
|
+
if (mathCode) {
|
|
22
|
+
mathCode.updateCode(code);
|
|
23
|
+
mathCode.selectNext();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return true;
|
|
27
|
+
}, COMMAND_PRIORITY_HIGH), editor.registerCommand(SELECT_MATH_SIDE_COMMAND, (payload) => {
|
|
28
|
+
const { key, prev } = payload;
|
|
29
|
+
editor.update(() => {
|
|
30
|
+
const mathNode = $getNodeByKey(key);
|
|
31
|
+
if (mathNode) if (prev) mathNode.selectPrevious();
|
|
32
|
+
else mathNode.selectNext();
|
|
33
|
+
});
|
|
34
|
+
return true;
|
|
35
|
+
}, COMMAND_PRIORITY_HIGH));
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { INSERT_MATH_COMMAND, SELECT_MATH_SIDE_COMMAND, UPDATE_MATH_COMMAND, registerMathCommand };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DOMConversionMap, DOMExportOutput, DecoratorNode, EditorConfig, LexicalEditor, LexicalNode, LexicalUpdateJSON, SerializedLexicalNode, Spread } from "lexical";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/math/node/index.d.ts
|
|
4
|
+
type SerializedMathInlineNode = Spread<{
|
|
5
|
+
code: string;
|
|
6
|
+
}, SerializedLexicalNode>;
|
|
7
|
+
declare class MathInlineNode extends DecoratorNode<unknown> {
|
|
8
|
+
static getType(): string;
|
|
9
|
+
static clone(node: MathInlineNode): MathInlineNode;
|
|
10
|
+
static importJSON(serializedNode: SerializedMathInlineNode): MathInlineNode;
|
|
11
|
+
static importDOM(): DOMConversionMap | null;
|
|
12
|
+
__code: string;
|
|
13
|
+
constructor(code?: string, key?: string);
|
|
14
|
+
get code(): string;
|
|
15
|
+
updateCode(newCode: string): void;
|
|
16
|
+
exportDOM(): DOMExportOutput;
|
|
17
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
18
|
+
exportJSON(): SerializedMathInlineNode;
|
|
19
|
+
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedMathInlineNode>): this;
|
|
20
|
+
getTextContent(): string;
|
|
21
|
+
isInline(): boolean;
|
|
22
|
+
updateDOM(): boolean;
|
|
23
|
+
decorate(editor: LexicalEditor): unknown;
|
|
24
|
+
}
|
|
25
|
+
declare class MathBlockNode extends DecoratorNode<unknown> {
|
|
26
|
+
static getType(): string;
|
|
27
|
+
static clone(node: MathBlockNode): MathBlockNode;
|
|
28
|
+
static importJSON(serializedNode: SerializedMathInlineNode): MathBlockNode;
|
|
29
|
+
static importDOM(): DOMConversionMap | null;
|
|
30
|
+
__code: string;
|
|
31
|
+
constructor(code?: string, key?: string);
|
|
32
|
+
get code(): string;
|
|
33
|
+
updateCode(newCode: string): void;
|
|
34
|
+
exportDOM(): DOMExportOutput;
|
|
35
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
36
|
+
exportJSON(): SerializedMathInlineNode;
|
|
37
|
+
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedMathInlineNode>): this;
|
|
38
|
+
getTextContent(): string;
|
|
39
|
+
isInline(): boolean;
|
|
40
|
+
updateDOM(): boolean;
|
|
41
|
+
decorate(editor: LexicalEditor): unknown;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { MathBlockNode, MathInlineNode };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { getKernelFromEditor } from "../../../editor-kernel/utils.js";
|
|
2
|
+
import { $applyNodeReplacement, DecoratorNode } from "lexical";
|
|
3
|
+
import { addClassNamesToElement } from "@lexical/utils";
|
|
4
|
+
//#region src/plugins/math/node/index.ts
|
|
5
|
+
var MathInlineNode = class MathInlineNode extends DecoratorNode {
|
|
6
|
+
static getType() {
|
|
7
|
+
return "math";
|
|
8
|
+
}
|
|
9
|
+
static clone(node) {
|
|
10
|
+
return new MathInlineNode(node.__code, node.__key);
|
|
11
|
+
}
|
|
12
|
+
static importJSON(serializedNode) {
|
|
13
|
+
return $createMathInlineNode().updateFromJSON(serializedNode);
|
|
14
|
+
}
|
|
15
|
+
static importDOM() {
|
|
16
|
+
return { span: (node) => {
|
|
17
|
+
if (node.classList.contains("math-inline")) return {
|
|
18
|
+
conversion: $convertMathInlineElement,
|
|
19
|
+
priority: 0
|
|
20
|
+
};
|
|
21
|
+
return null;
|
|
22
|
+
} };
|
|
23
|
+
}
|
|
24
|
+
constructor(code = "", key) {
|
|
25
|
+
super(key);
|
|
26
|
+
this.__code = code;
|
|
27
|
+
}
|
|
28
|
+
get code() {
|
|
29
|
+
return this.__code;
|
|
30
|
+
}
|
|
31
|
+
updateCode(newCode) {
|
|
32
|
+
const writer = this.getWritable();
|
|
33
|
+
writer.__code = newCode;
|
|
34
|
+
}
|
|
35
|
+
exportDOM() {
|
|
36
|
+
const span = document.createElement("span");
|
|
37
|
+
span.className = "math-inline";
|
|
38
|
+
return { element: span };
|
|
39
|
+
}
|
|
40
|
+
createDOM(config) {
|
|
41
|
+
const element = document.createElement("span");
|
|
42
|
+
addClassNamesToElement(element, config.theme.mathInline);
|
|
43
|
+
return element;
|
|
44
|
+
}
|
|
45
|
+
exportJSON() {
|
|
46
|
+
return {
|
|
47
|
+
...super.exportJSON(),
|
|
48
|
+
code: this.__code
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
updateFromJSON(serializedNode) {
|
|
52
|
+
const node = super.updateFromJSON(serializedNode);
|
|
53
|
+
this.__code = serializedNode.code || "";
|
|
54
|
+
return node;
|
|
55
|
+
}
|
|
56
|
+
getTextContent() {
|
|
57
|
+
return `$${this.code}$`;
|
|
58
|
+
}
|
|
59
|
+
isInline() {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
updateDOM() {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
decorate(editor) {
|
|
66
|
+
const decorator = getKernelFromEditor(editor)?.getDecorator(MathInlineNode.getType());
|
|
67
|
+
if (!decorator) return null;
|
|
68
|
+
if (typeof decorator === "function") return decorator(this, editor);
|
|
69
|
+
return {
|
|
70
|
+
queryDOM: decorator.queryDOM,
|
|
71
|
+
render: decorator.render(this, editor)
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var MathBlockNode = class MathBlockNode extends DecoratorNode {
|
|
76
|
+
static getType() {
|
|
77
|
+
return "mathBlock";
|
|
78
|
+
}
|
|
79
|
+
static clone(node) {
|
|
80
|
+
return new MathBlockNode(node.__code, node.__key);
|
|
81
|
+
}
|
|
82
|
+
static importJSON(serializedNode) {
|
|
83
|
+
return $createMathBlockNode().updateFromJSON(serializedNode);
|
|
84
|
+
}
|
|
85
|
+
static importDOM() {
|
|
86
|
+
return { div: (node) => {
|
|
87
|
+
if (node.classList.contains("math-block")) return {
|
|
88
|
+
conversion: $convertMathBlockElement,
|
|
89
|
+
priority: 0
|
|
90
|
+
};
|
|
91
|
+
return null;
|
|
92
|
+
} };
|
|
93
|
+
}
|
|
94
|
+
constructor(code = "", key) {
|
|
95
|
+
super(key);
|
|
96
|
+
this.__code = code;
|
|
97
|
+
}
|
|
98
|
+
get code() {
|
|
99
|
+
return this.__code;
|
|
100
|
+
}
|
|
101
|
+
updateCode(newCode) {
|
|
102
|
+
const writer = this.getWritable();
|
|
103
|
+
writer.__code = newCode;
|
|
104
|
+
}
|
|
105
|
+
exportDOM() {
|
|
106
|
+
const div = document.createElement("div");
|
|
107
|
+
div.className = "math-block";
|
|
108
|
+
return { element: div };
|
|
109
|
+
}
|
|
110
|
+
createDOM(config) {
|
|
111
|
+
const element = document.createElement("div");
|
|
112
|
+
addClassNamesToElement(element, config.theme.mathBlock);
|
|
113
|
+
return element;
|
|
114
|
+
}
|
|
115
|
+
exportJSON() {
|
|
116
|
+
return {
|
|
117
|
+
...super.exportJSON(),
|
|
118
|
+
code: this.__code
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
updateFromJSON(serializedNode) {
|
|
122
|
+
const node = super.updateFromJSON(serializedNode);
|
|
123
|
+
this.__code = serializedNode.code || "";
|
|
124
|
+
return node;
|
|
125
|
+
}
|
|
126
|
+
getTextContent() {
|
|
127
|
+
return `$$\n${this.code}\n$$\n`;
|
|
128
|
+
}
|
|
129
|
+
isInline() {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
updateDOM() {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
decorate(editor) {
|
|
136
|
+
const decorator = getKernelFromEditor(editor)?.getDecorator(MathBlockNode.getType());
|
|
137
|
+
if (!decorator) return null;
|
|
138
|
+
if (typeof decorator === "function") return decorator(this, editor);
|
|
139
|
+
return {
|
|
140
|
+
queryDOM: decorator.queryDOM,
|
|
141
|
+
render: decorator.render(this, editor)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
function $createMathInlineNode(code = "") {
|
|
146
|
+
return $applyNodeReplacement(new MathInlineNode(code));
|
|
147
|
+
}
|
|
148
|
+
function $createMathBlockNode(code = "") {
|
|
149
|
+
return $applyNodeReplacement(new MathBlockNode(code));
|
|
150
|
+
}
|
|
151
|
+
function $convertMathInlineElement() {
|
|
152
|
+
return { node: $createMathInlineNode() };
|
|
153
|
+
}
|
|
154
|
+
function $convertMathBlockElement() {
|
|
155
|
+
return { node: $createMathBlockNode() };
|
|
156
|
+
}
|
|
157
|
+
function $isMathNode(node) {
|
|
158
|
+
return node instanceof MathInlineNode || node instanceof MathBlockNode;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
export { $createMathBlockNode, $createMathInlineNode, $isMathNode, MathBlockNode, MathInlineNode };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IEditorPluginConstructor } from "../../../types/kernel.js";
|
|
2
|
+
import { MathBlockNode, MathInlineNode } from "../node/index.js";
|
|
3
|
+
import { LexicalEditor } from "lexical";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/math/plugin/index.d.ts
|
|
6
|
+
interface MathPluginOptions {
|
|
7
|
+
decorator: (node: MathInlineNode | MathBlockNode, editor: LexicalEditor) => unknown;
|
|
8
|
+
theme?: {
|
|
9
|
+
mathBlock?: string;
|
|
10
|
+
mathInline?: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
declare const MathPlugin: IEditorPluginConstructor<MathPluginOptions>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { MathPlugin };
|