@lobehub/editor 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +635 -0
- package/es/common/canUseDOM.d.ts +8 -0
- package/es/common/canUseDOM.js +9 -0
- package/es/common/sys.d.ts +17 -0
- package/es/common/sys.js +30 -0
- package/es/editor-kernel/data-source.d.ts +8 -0
- package/es/editor-kernel/data-source.js +30 -0
- package/es/editor-kernel/event.d.ts +3 -0
- package/es/editor-kernel/event.js +11 -0
- package/es/editor-kernel/index.d.ts +11 -0
- package/es/editor-kernel/index.js +14 -0
- package/es/editor-kernel/inode/helper.d.ts +11 -0
- package/es/editor-kernel/inode/helper.js +48 -0
- package/es/editor-kernel/inode/i-element-node.d.ts +5 -0
- package/es/editor-kernel/inode/i-element-node.js +1 -0
- package/es/editor-kernel/inode/i-node.d.ts +6 -0
- package/es/editor-kernel/inode/i-node.js +1 -0
- package/es/editor-kernel/inode/index.d.ts +5 -0
- package/es/editor-kernel/inode/index.js +5 -0
- package/es/editor-kernel/inode/paragraph-node.d.ts +6 -0
- package/es/editor-kernel/inode/paragraph-node.js +1 -0
- package/es/editor-kernel/inode/root-node.d.ts +7 -0
- package/es/editor-kernel/inode/root-node.js +1 -0
- package/es/editor-kernel/inode/text-node.d.ts +12 -0
- package/es/editor-kernel/inode/text-node.js +1 -0
- package/es/editor-kernel/kernel.d.ts +46 -0
- package/es/editor-kernel/kernel.js +273 -0
- package/es/editor-kernel/plugin.d.ts +7 -0
- package/es/editor-kernel/plugin.js +54 -0
- package/es/editor-kernel/react/LexicalErrorBoundary.d.ts +13 -0
- package/es/editor-kernel/react/LexicalErrorBoundary.js +26 -0
- package/es/editor-kernel/react/index.d.ts +5 -0
- package/es/editor-kernel/react/index.js +5 -0
- package/es/editor-kernel/react/react-context.d.ts +10 -0
- package/es/editor-kernel/react/react-context.js +25 -0
- package/es/editor-kernel/react/react-editor.d.ts +12 -0
- package/es/editor-kernel/react/react-editor.js +57 -0
- package/es/editor-kernel/react/useDecorators.d.ts +9 -0
- package/es/editor-kernel/react/useDecorators.js +69 -0
- package/es/editor-kernel/react/useLexicalEditor.d.ts +2 -0
- package/es/editor-kernel/react/useLexicalEditor.js +31 -0
- package/es/editor-kernel/react/useLexicalNodeSelection.d.ts +17 -0
- package/es/editor-kernel/react/useLexicalNodeSelection.js +99 -0
- package/es/editor-kernel/react/useToolbarState.d.ts +31 -0
- package/es/editor-kernel/react/useToolbarState.js +302 -0
- package/es/editor-kernel/react/useTranslation.d.ts +3 -0
- package/es/editor-kernel/react/useTranslation.js +19 -0
- package/es/editor-kernel/types.d.ts +189 -0
- package/es/editor-kernel/types.js +1 -0
- package/es/editor-kernel/utils.d.ts +25 -0
- package/es/editor-kernel/utils.js +69 -0
- package/es/index.d.ts +14 -0
- package/es/index.js +14 -0
- package/es/locale/index.d.ts +25 -0
- package/es/locale/index.js +24 -0
- package/es/plugins/codeblock/command/index.d.ts +20 -0
- package/es/plugins/codeblock/command/index.js +84 -0
- package/es/plugins/codeblock/index.d.ts +4 -0
- package/es/plugins/codeblock/index.js +4 -0
- package/es/plugins/codeblock/plugin/CodeHighlighterShiki.d.ts +24 -0
- package/es/plugins/codeblock/plugin/CodeHighlighterShiki.js +680 -0
- package/es/plugins/codeblock/plugin/FacadeShiki.d.ts +51 -0
- package/es/plugins/codeblock/plugin/FacadeShiki.js +348 -0
- package/es/plugins/codeblock/plugin/index.d.ts +18 -0
- package/es/plugins/codeblock/plugin/index.js +90 -0
- package/es/plugins/codeblock/plugin/invariant.d.ts +8 -0
- package/es/plugins/codeblock/plugin/invariant.js +17 -0
- package/es/plugins/codeblock/react/ReactCodeblockPlugin.d.ts +4 -0
- package/es/plugins/codeblock/react/ReactCodeblockPlugin.js +51 -0
- package/es/plugins/codeblock/react/index.d.ts +2 -0
- package/es/plugins/codeblock/react/index.js +1 -0
- package/es/plugins/codeblock/react/style.d.ts +6 -0
- package/es/plugins/codeblock/react/style.js +38 -0
- package/es/plugins/codeblock/react/type.d.ts +5 -0
- package/es/plugins/codeblock/react/type.js +1 -0
- package/es/plugins/codeblock/utils/language.d.ts +1 -0
- package/es/plugins/codeblock/utils/language.js +12 -0
- package/es/plugins/common/command/index.d.ts +7 -0
- package/es/plugins/common/command/index.js +31 -0
- package/es/plugins/common/data-source/json-data-source.d.ts +7 -0
- package/es/plugins/common/data-source/json-data-source.js +39 -0
- package/es/plugins/common/data-source/text-data-source.d.ts +6 -0
- package/es/plugins/common/data-source/text-data-source.js +54 -0
- package/es/plugins/common/index.d.ts +3 -0
- package/es/plugins/common/index.js +3 -0
- package/es/plugins/common/node/ElementDOMSlot.d.ts +5 -0
- package/es/plugins/common/node/ElementDOMSlot.js +59 -0
- package/es/plugins/common/node/LexicalLineBreakNode.d.ts +31 -0
- package/es/plugins/common/node/LexicalLineBreakNode.js +140 -0
- package/es/plugins/common/node/ParagraphNode.d.ts +7 -0
- package/es/plugins/common/node/ParagraphNode.js +47 -0
- package/es/plugins/common/plugin/index.d.ts +16 -0
- package/es/plugins/common/plugin/index.js +245 -0
- package/es/plugins/common/plugin/register.d.ts +4 -0
- package/es/plugins/common/plugin/register.js +230 -0
- package/es/plugins/common/react/Placeholder/index.d.ts +7 -0
- package/es/plugins/common/react/Placeholder/index.js +53 -0
- package/es/plugins/common/react/Placeholder/style.d.ts +4 -0
- package/es/plugins/common/react/Placeholder/style.js +12 -0
- package/es/plugins/common/react/ReactEditorContent.d.ts +4 -0
- package/es/plugins/common/react/ReactEditorContent.js +7 -0
- package/es/plugins/common/react/ReactPlainText.d.ts +4 -0
- package/es/plugins/common/react/ReactPlainText.js +100 -0
- package/es/plugins/common/react/index.d.ts +3 -0
- package/es/plugins/common/react/index.js +3 -0
- package/es/plugins/common/react/style.d.ts +18 -0
- package/es/plugins/common/react/style.js +38 -0
- package/es/plugins/common/react/type.d.ts +21 -0
- package/es/plugins/common/react/type.js +1 -0
- package/es/plugins/common/utils/index.d.ts +28 -0
- package/es/plugins/common/utils/index.js +96 -0
- package/es/plugins/file/command/index.d.ts +7 -0
- package/es/plugins/file/command/index.js +28 -0
- package/es/plugins/file/index.d.ts +3 -0
- package/es/plugins/file/index.js +3 -0
- package/es/plugins/file/node/FileNode.d.ts +36 -0
- package/es/plugins/file/node/FileNode.js +177 -0
- package/es/plugins/file/plugin/index.d.ts +14 -0
- package/es/plugins/file/plugin/index.js +116 -0
- package/es/plugins/file/react/ReactFilePlugin.d.ts +4 -0
- package/es/plugins/file/react/ReactFilePlugin.js +74 -0
- package/es/plugins/file/react/components/ReactFile.d.ts +10 -0
- package/es/plugins/file/react/components/ReactFile.js +65 -0
- package/es/plugins/file/react/index.d.ts +2 -0
- package/es/plugins/file/react/index.js +1 -0
- package/es/plugins/file/react/style.d.ts +3 -0
- package/es/plugins/file/react/style.js +11 -0
- package/es/plugins/file/react/type.d.ts +13 -0
- package/es/plugins/file/react/type.js +1 -0
- package/es/plugins/file/utils/index.d.ts +2 -0
- package/es/plugins/file/utils/index.js +45 -0
- package/es/plugins/hr/command/index.d.ts +3 -0
- package/es/plugins/hr/command/index.js +13 -0
- package/es/plugins/hr/index.d.ts +3 -0
- package/es/plugins/hr/index.js +3 -0
- package/es/plugins/hr/node/HorizontalRuleNode.d.ts +16 -0
- package/es/plugins/hr/node/HorizontalRuleNode.js +100 -0
- package/es/plugins/hr/plugin/index.d.ts +8 -0
- package/es/plugins/hr/plugin/index.js +70 -0
- package/es/plugins/hr/react/ReactHRPlugin.d.ts +4 -0
- package/es/plugins/hr/react/ReactHRPlugin.js +36 -0
- package/es/plugins/hr/react/components/HRNode.d.ts +10 -0
- package/es/plugins/hr/react/components/HRNode.js +45 -0
- package/es/plugins/hr/react/index.d.ts +2 -0
- package/es/plugins/hr/react/index.js +1 -0
- package/es/plugins/hr/react/style.d.ts +1 -0
- package/es/plugins/hr/react/style.js +8 -0
- package/es/plugins/hr/react/type.d.ts +3 -0
- package/es/plugins/hr/react/type.js +1 -0
- package/es/plugins/image/command/index.d.ts +8 -0
- package/es/plugins/image/command/index.js +46 -0
- package/es/plugins/image/index.d.ts +3 -0
- package/es/plugins/image/index.js +3 -0
- package/es/plugins/image/node/basie-image-node.d.ts +44 -0
- package/es/plugins/image/node/basie-image-node.js +151 -0
- package/es/plugins/image/node/image-node.d.ts +26 -0
- package/es/plugins/image/node/image-node.js +176 -0
- package/es/plugins/image/plugin/index.d.ts +13 -0
- package/es/plugins/image/plugin/index.js +74 -0
- package/es/plugins/image/react/ReactImagePlugin.d.ts +4 -0
- package/es/plugins/image/react/ReactImagePlugin.js +48 -0
- package/es/plugins/image/react/components/BrokenImage.d.ts +3 -0
- package/es/plugins/image/react/components/BrokenImage.js +18 -0
- package/es/plugins/image/react/components/Image.d.ts +7 -0
- package/es/plugins/image/react/components/Image.js +71 -0
- package/es/plugins/image/react/components/LazyImage.d.ts +8 -0
- package/es/plugins/image/react/components/LazyImage.js +99 -0
- package/es/plugins/image/react/components/useSupenseImage.d.ts +2 -0
- package/es/plugins/image/react/components/useSupenseImage.js +24 -0
- package/es/plugins/image/react/index.d.ts +2 -0
- package/es/plugins/image/react/index.js +1 -0
- package/es/plugins/image/react/style.d.ts +12 -0
- package/es/plugins/image/react/style.js +17 -0
- package/es/plugins/image/react/type.d.ts +6 -0
- package/es/plugins/image/react/type.js +1 -0
- package/es/plugins/link/command/index.d.ts +6 -0
- package/es/plugins/link/command/index.js +20 -0
- package/es/plugins/link/index.d.ts +3 -0
- package/es/plugins/link/index.js +3 -0
- package/es/plugins/link/node/LinkNode.d.ts +126 -0
- package/es/plugins/link/node/LinkNode.js +721 -0
- package/es/plugins/link/plugin/index.d.ts +8 -0
- package/es/plugins/link/plugin/index.js +94 -0
- package/es/plugins/link/react/ReactLinkPlugin.d.ts +4 -0
- package/es/plugins/link/react/ReactLinkPlugin.js +168 -0
- package/es/plugins/link/react/components/LinkEdit.d.ts +7 -0
- package/es/plugins/link/react/components/LinkEdit.js +138 -0
- package/es/plugins/link/react/components/Toolbar.d.ts +7 -0
- package/es/plugins/link/react/components/Toolbar.js +63 -0
- package/es/plugins/link/react/index.d.ts +2 -0
- package/es/plugins/link/react/index.js +1 -0
- package/es/plugins/link/react/style.d.ts +5 -0
- package/es/plugins/link/react/style.js +12 -0
- package/es/plugins/link/react/type.d.ts +9 -0
- package/es/plugins/link/react/type.js +1 -0
- package/es/plugins/link/utils/index.d.ts +4 -0
- package/es/plugins/link/utils/index.js +37 -0
- package/es/plugins/list/command/index.d.ts +1 -0
- package/es/plugins/list/command/index.js +1 -0
- package/es/plugins/list/index.d.ts +3 -0
- package/es/plugins/list/index.js +3 -0
- package/es/plugins/list/plugin/index.d.ts +5 -0
- package/es/plugins/list/plugin/index.js +193 -0
- package/es/plugins/list/react/ReactListPlugin.d.ts +4 -0
- package/es/plugins/list/react/ReactListPlugin.js +29 -0
- package/es/plugins/list/react/index.d.ts +2 -0
- package/es/plugins/list/react/index.js +1 -0
- package/es/plugins/list/react/style.d.ts +1 -0
- package/es/plugins/list/react/style.js +7 -0
- package/es/plugins/list/react/type.d.ts +3 -0
- package/es/plugins/list/react/type.js +1 -0
- package/es/plugins/list/utils/index.d.ts +5 -0
- package/es/plugins/list/utils/index.js +88 -0
- package/es/plugins/markdown/data-source/markdown-data-source.d.ts +10 -0
- package/es/plugins/markdown/data-source/markdown-data-source.js +64 -0
- package/es/plugins/markdown/data-source/markdown-writer-context.d.ts +12 -0
- package/es/plugins/markdown/data-source/markdown-writer-context.js +51 -0
- package/es/plugins/markdown/index.d.ts +2 -0
- package/es/plugins/markdown/index.js +2 -0
- package/es/plugins/markdown/plugin/index.d.ts +4 -0
- package/es/plugins/markdown/plugin/index.js +122 -0
- package/es/plugins/markdown/service/shortcut.d.ts +139 -0
- package/es/plugins/markdown/service/shortcut.js +401 -0
- package/es/plugins/markdown/utils/index.d.ts +12 -0
- package/es/plugins/markdown/utils/index.js +61 -0
- package/es/plugins/mention/command/index.d.ts +6 -0
- package/es/plugins/mention/command/index.js +19 -0
- package/es/plugins/mention/index.d.ts +3 -0
- package/es/plugins/mention/index.js +3 -0
- package/es/plugins/mention/node/MentionNode.d.ts +26 -0
- package/es/plugins/mention/node/MentionNode.js +143 -0
- package/es/plugins/mention/plugin/index.d.ts +11 -0
- package/es/plugins/mention/plugin/index.js +61 -0
- package/es/plugins/mention/plugin/register.d.ts +2 -0
- package/es/plugins/mention/plugin/register.js +46 -0
- package/es/plugins/mention/react/ReactMentionPlugin.d.ts +4 -0
- package/es/plugins/mention/react/ReactMentionPlugin.js +42 -0
- package/es/plugins/mention/react/components/Mention.d.ts +9 -0
- package/es/plugins/mention/react/components/Mention.js +39 -0
- package/es/plugins/mention/react/index.d.ts +2 -0
- package/es/plugins/mention/react/index.js +1 -0
- package/es/plugins/mention/react/style.d.ts +3 -0
- package/es/plugins/mention/react/style.js +11 -0
- package/es/plugins/mention/react/type.d.ts +8 -0
- package/es/plugins/mention/react/type.js +1 -0
- package/es/plugins/slash/index.d.ts +3 -0
- package/es/plugins/slash/index.js +3 -0
- package/es/plugins/slash/plugin/index.d.ts +23 -0
- package/es/plugins/slash/plugin/index.js +132 -0
- package/es/plugins/slash/react/ReactSlashOption.d.ts +4 -0
- package/es/plugins/slash/react/ReactSlashOption.js +7 -0
- package/es/plugins/slash/react/ReactSlashPlugin.d.ts +4 -0
- package/es/plugins/slash/react/ReactSlashPlugin.js +228 -0
- package/es/plugins/slash/react/components/SlashMenu.d.ts +8 -0
- package/es/plugins/slash/react/components/SlashMenu.js +72 -0
- package/es/plugins/slash/react/index.d.ts +4 -0
- package/es/plugins/slash/react/index.js +3 -0
- package/es/plugins/slash/react/style.d.ts +1 -0
- package/es/plugins/slash/react/style.js +9 -0
- package/es/plugins/slash/react/type.d.ts +82 -0
- package/es/plugins/slash/react/type.js +1 -0
- package/es/plugins/slash/react/utils.d.ts +5 -0
- package/es/plugins/slash/react/utils.js +20 -0
- package/es/plugins/slash/service/i-slash-service.d.ts +38 -0
- package/es/plugins/slash/service/i-slash-service.js +64 -0
- package/es/plugins/slash/utils/utils.d.ts +38 -0
- package/es/plugins/slash/utils/utils.js +192 -0
- package/es/plugins/table/command/index.d.ts +13 -0
- package/es/plugins/table/command/index.js +73 -0
- package/es/plugins/table/index.d.ts +3 -0
- package/es/plugins/table/index.js +3 -0
- package/es/plugins/table/node/index.d.ts +2 -0
- package/es/plugins/table/node/index.js +16 -0
- package/es/plugins/table/plugin/index.d.ts +5 -0
- package/es/plugins/table/plugin/index.js +85 -0
- package/es/plugins/table/react/TableActionMenu/index.d.ts +8 -0
- package/es/plugins/table/react/TableActionMenu/index.js +481 -0
- package/es/plugins/table/react/TableActionMenu/style.d.ts +1 -0
- package/es/plugins/table/react/TableActionMenu/style.js +7 -0
- package/es/plugins/table/react/TableActionMenu/utils.d.ts +9 -0
- package/es/plugins/table/react/TableActionMenu/utils.js +49 -0
- package/es/plugins/table/react/TableHoverActions/index.d.ts +7 -0
- package/es/plugins/table/react/TableHoverActions/index.js +268 -0
- package/es/plugins/table/react/TableHoverActions/style.d.ts +5 -0
- package/es/plugins/table/react/TableHoverActions/style.js +11 -0
- package/es/plugins/table/react/TableHoverActions/utils.d.ts +8 -0
- package/es/plugins/table/react/TableHoverActions/utils.js +43 -0
- package/es/plugins/table/react/TableResize/index.d.ts +10 -0
- package/es/plugins/table/react/TableResize/index.js +378 -0
- package/es/plugins/table/react/TableResize/style.d.ts +3 -0
- package/es/plugins/table/react/TableResize/style.js +10 -0
- package/es/plugins/table/react/TableResize/utils.d.ts +4 -0
- package/es/plugins/table/react/TableResize/utils.js +40 -0
- package/es/plugins/table/react/hooks.d.ts +1 -0
- package/es/plugins/table/react/hooks.js +22 -0
- package/es/plugins/table/react/index.d.ts +3 -0
- package/es/plugins/table/react/index.js +77 -0
- package/es/plugins/table/react/style.d.ts +1 -0
- package/es/plugins/table/react/style.js +8 -0
- package/es/plugins/table/react/type.d.ts +5 -0
- package/es/plugins/table/react/type.js +1 -0
- package/es/plugins/table/utils/index.d.ts +8 -0
- package/es/plugins/table/utils/index.js +83 -0
- package/es/plugins/upload/index.d.ts +3 -0
- package/es/plugins/upload/index.js +3 -0
- package/es/plugins/upload/plugin/index.d.ts +4 -0
- package/es/plugins/upload/plugin/index.js +82 -0
- package/es/plugins/upload/service/i-upload-service.d.ts +15 -0
- package/es/plugins/upload/service/i-upload-service.js +115 -0
- package/es/plugins/upload/utils/index.d.ts +1 -0
- package/es/plugins/upload/utils/index.js +20 -0
- package/es/react/ChatInput/ChatInput.d.ts +4 -0
- package/es/react/ChatInput/ChatInput.js +41 -0
- package/es/react/ChatInput/index.d.ts +2 -0
- package/es/react/ChatInput/index.js +2 -0
- package/es/react/ChatInput/style.d.ts +4 -0
- package/es/react/ChatInput/style.js +11 -0
- package/es/react/ChatInput/type.d.ts +10 -0
- package/es/react/ChatInput/type.js +1 -0
- package/es/react/ChatInputActionBar/ChatInputActionBar.d.ts +4 -0
- package/es/react/ChatInputActionBar/ChatInputActionBar.js +27 -0
- package/es/react/ChatInputActionBar/index.d.ts +2 -0
- package/es/react/ChatInputActionBar/index.js +2 -0
- package/es/react/ChatInputActionBar/style.d.ts +3 -0
- package/es/react/ChatInputActionBar/style.js +9 -0
- package/es/react/ChatInputActionBar/type.d.ts +7 -0
- package/es/react/ChatInputActionBar/type.js +1 -0
- package/es/react/ChatInputActions/ChatInputActions.d.ts +4 -0
- package/es/react/ChatInputActions/ChatInputActions.js +187 -0
- package/es/react/ChatInputActions/components/ChatInputActionsCollapse.d.ts +4 -0
- package/es/react/ChatInputActions/components/ChatInputActionsCollapse.js +97 -0
- package/es/react/ChatInputActions/index.d.ts +2 -0
- package/es/react/ChatInputActions/index.js +1 -0
- package/es/react/ChatInputActions/style.d.ts +4 -0
- package/es/react/ChatInputActions/style.js +10 -0
- package/es/react/ChatInputActions/type.d.ts +38 -0
- package/es/react/ChatInputActions/type.js +1 -0
- package/es/react/CodeLanguageSelect/CodeLanguageSelect.d.ts +4 -0
- package/es/react/CodeLanguageSelect/CodeLanguageSelect.js +96 -0
- package/es/react/CodeLanguageSelect/index.d.ts +2 -0
- package/es/react/CodeLanguageSelect/index.js +2 -0
- package/es/react/CodeLanguageSelect/style.d.ts +3 -0
- package/es/react/CodeLanguageSelect/style.js +9 -0
- package/es/react/CodeLanguageSelect/type.d.ts +2 -0
- package/es/react/CodeLanguageSelect/type.js +1 -0
- package/es/react/Editor/Editor.d.ts +4 -0
- package/es/react/Editor/Editor.js +78 -0
- package/es/react/Editor/index.d.ts +14 -0
- package/es/react/Editor/index.js +10 -0
- package/es/react/Editor/type.d.ts +24 -0
- package/es/react/Editor/type.js +1 -0
- package/es/react/Editor/useEditor.d.ts +3 -0
- package/es/react/Editor/useEditor.js +4 -0
- package/es/react/Editor/utils.d.ts +2 -0
- package/es/react/Editor/utils.js +3 -0
- package/es/react/EditorProvider/index.d.ts +20 -0
- package/es/react/EditorProvider/index.js +25 -0
- package/es/react/SendButton/SendButton.d.ts +4 -0
- package/es/react/SendButton/SendButton.js +77 -0
- package/es/react/SendButton/components/SendIcon.d.ts +6 -0
- package/es/react/SendButton/components/SendIcon.js +32 -0
- package/es/react/SendButton/components/StopIcon.d.ts +6 -0
- package/es/react/SendButton/components/StopIcon.js +61 -0
- package/es/react/SendButton/index.d.ts +2 -0
- package/es/react/SendButton/index.js +2 -0
- package/es/react/SendButton/style.d.ts +6 -0
- package/es/react/SendButton/style.js +15 -0
- package/es/react/SendButton/type.d.ts +6 -0
- package/es/react/SendButton/type.js +1 -0
- package/es/react/SlashMenu/SlashMenu.d.ts +4 -0
- package/es/react/SlashMenu/SlashMenu.js +68 -0
- package/es/react/SlashMenu/index.d.ts +2 -0
- package/es/react/SlashMenu/index.js +2 -0
- package/es/react/SlashMenu/style.d.ts +4 -0
- package/es/react/SlashMenu/style.js +11 -0
- package/es/react/SlashMenu/type.d.ts +8 -0
- package/es/react/SlashMenu/type.js +1 -0
- package/es/react/index.d.ts +8 -0
- package/es/react/index.js +8 -0
- package/es/types/global.d.ts +20 -0
- package/es/types/index.d.ts +2 -0
- package/es/types/index.js +2 -0
- package/es/types/kernel.d.ts +180 -0
- package/es/types/kernel.js +1 -0
- package/es/types/locale.d.ts +10 -0
- package/es/types/locale.js +1 -0
- package/package.json +66 -0
- package/patches/lexical+0.33.1.patch +88 -0
- package/react.d.ts +1 -0
- package/react.js +1 -0
- package/scripts/patch-lexical-package-json.js +20 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
var _excluded = ["fontSize", "headerMultiple", "lineHeight", "marginMultiple"];
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
17
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
18
|
+
import { Children, memo, useEffect, useLayoutEffect, useRef } from 'react';
|
|
19
|
+
import { LexicalErrorBoundary } from "../../../editor-kernel/react/LexicalErrorBoundary";
|
|
20
|
+
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
21
|
+
import { useDecorators } from "../../../editor-kernel/react/useDecorators";
|
|
22
|
+
import { MarkdownPlugin } from "../../markdown";
|
|
23
|
+
import { CommonPlugin } from "../plugin";
|
|
24
|
+
import Placeholder from "./Placeholder";
|
|
25
|
+
import { useStyles, useThemeStyles } from "./style";
|
|
26
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
var ReactPlainText = /*#__PURE__*/memo(function (_ref) {
|
|
29
|
+
var style = _ref.style,
|
|
30
|
+
children = _ref.children,
|
|
31
|
+
_ref$theme = _ref.theme,
|
|
32
|
+
theme = _ref$theme === void 0 ? {} : _ref$theme,
|
|
33
|
+
onChange = _ref.onChange,
|
|
34
|
+
className = _ref.className,
|
|
35
|
+
variant = _ref.variant;
|
|
36
|
+
var isChat = variant === 'chat';
|
|
37
|
+
var _theme$fontSize = theme.fontSize,
|
|
38
|
+
fontSize = _theme$fontSize === void 0 ? isChat ? 14 : 16 : _theme$fontSize,
|
|
39
|
+
_theme$headerMultiple = theme.headerMultiple,
|
|
40
|
+
headerMultiple = _theme$headerMultiple === void 0 ? isChat ? 0.25 : 1 : _theme$headerMultiple,
|
|
41
|
+
_theme$lineHeight = theme.lineHeight,
|
|
42
|
+
lineHeight = _theme$lineHeight === void 0 ? isChat ? 1.6 : 1.8 : _theme$lineHeight,
|
|
43
|
+
_theme$marginMultiple = theme.marginMultiple,
|
|
44
|
+
marginMultiple = _theme$marginMultiple === void 0 ? isChat ? 1 : 2 : _theme$marginMultiple,
|
|
45
|
+
restTheme = _objectWithoutProperties(theme, _excluded);
|
|
46
|
+
var editorContainerRef = useRef(null);
|
|
47
|
+
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
48
|
+
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
49
|
+
editor = _useLexicalComposerCo2[0];
|
|
50
|
+
var decorators = useDecorators(editor, LexicalErrorBoundary);
|
|
51
|
+
var _useThemeStyles = useThemeStyles(),
|
|
52
|
+
themeStyles = _useThemeStyles.styles;
|
|
53
|
+
var _useStyles = useStyles({
|
|
54
|
+
fontSize: fontSize,
|
|
55
|
+
headerMultiple: headerMultiple,
|
|
56
|
+
lineHeight: lineHeight,
|
|
57
|
+
marginMultiple: marginMultiple
|
|
58
|
+
}),
|
|
59
|
+
cx = _useStyles.cx,
|
|
60
|
+
styles = _useStyles.styles;
|
|
61
|
+
var _Children$only = Children.only(children),
|
|
62
|
+
_Children$only$props = _Children$only.props,
|
|
63
|
+
type = _Children$only$props.type,
|
|
64
|
+
content = _Children$only$props.content,
|
|
65
|
+
placeholder = _Children$only$props.placeholder;
|
|
66
|
+
useLayoutEffect(function () {
|
|
67
|
+
editor.registerPlugin(MarkdownPlugin);
|
|
68
|
+
editor.registerPlugin(CommonPlugin, {
|
|
69
|
+
theme: restTheme ? _objectSpread(_objectSpread({}, themeStyles), restTheme) : themeStyles
|
|
70
|
+
});
|
|
71
|
+
}, []);
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
var _editor$getLexicalEdi;
|
|
74
|
+
var container = editorContainerRef.current;
|
|
75
|
+
if (container) {
|
|
76
|
+
// Initialize the editor
|
|
77
|
+
editor.setRootElement(container);
|
|
78
|
+
}
|
|
79
|
+
editor.setDocument(type, content);
|
|
80
|
+
return (_editor$getLexicalEdi = editor.getLexicalEditor()) === null || _editor$getLexicalEdi === void 0 ? void 0 : _editor$getLexicalEdi.registerUpdateListener(function () {
|
|
81
|
+
onChange === null || onChange === void 0 || onChange(editor);
|
|
82
|
+
});
|
|
83
|
+
}, []);
|
|
84
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
85
|
+
className: cx(styles.root, styles.variant, className),
|
|
86
|
+
style: style,
|
|
87
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
88
|
+
contentEditable: true,
|
|
89
|
+
ref: editorContainerRef,
|
|
90
|
+
style: {
|
|
91
|
+
outline: 'none'
|
|
92
|
+
}
|
|
93
|
+
}), /*#__PURE__*/_jsx(Placeholder, {
|
|
94
|
+
style: style,
|
|
95
|
+
children: placeholder
|
|
96
|
+
}), decorators]
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
ReactPlainText.displayName = 'ReactPlainText';
|
|
100
|
+
export default ReactPlainText;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const useThemeStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
|
|
2
|
+
quote: string;
|
|
3
|
+
textBold: import("antd-style").SerializedStyles;
|
|
4
|
+
textCode: string;
|
|
5
|
+
textItalic: import("antd-style").SerializedStyles;
|
|
6
|
+
textStrikethrough: import("antd-style").SerializedStyles;
|
|
7
|
+
textUnderline: import("antd-style").SerializedStyles;
|
|
8
|
+
textUnderlineStrikethrough: import("antd-style").SerializedStyles;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const useStyles: (props?: {
|
|
11
|
+
fontSize?: number | undefined;
|
|
12
|
+
headerMultiple?: number | undefined;
|
|
13
|
+
lineHeight?: number | undefined;
|
|
14
|
+
marginMultiple?: number | undefined;
|
|
15
|
+
} | undefined) => import("antd-style").ReturnStyles<{
|
|
16
|
+
root: import("antd-style").SerializedStyles;
|
|
17
|
+
variant: string;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
2
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useThemeStyles = createStyles(function (_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token;
|
|
7
|
+
return {
|
|
8
|
+
quote: 'editor_quote',
|
|
9
|
+
textBold: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-weight: bold;\n "]))),
|
|
10
|
+
textCode: 'editor_code',
|
|
11
|
+
textItalic: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-style: italic;\n "]))),
|
|
12
|
+
textStrikethrough: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n text-decoration: line-through;\n "])), token.colorTextDescription),
|
|
13
|
+
textUnderline: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n text-decoration: underline;\n "]))),
|
|
14
|
+
textUnderlineStrikethrough: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n text-decoration: underline line-through;\n "])))
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
export var useStyles = createStyles(function (_ref2, _ref3) {
|
|
18
|
+
var cx = _ref2.cx,
|
|
19
|
+
token = _ref2.token,
|
|
20
|
+
css = _ref2.css;
|
|
21
|
+
var _ref3$fontSize = _ref3.fontSize,
|
|
22
|
+
fontSize = _ref3$fontSize === void 0 ? 16 : _ref3$fontSize,
|
|
23
|
+
_ref3$headerMultiple = _ref3.headerMultiple,
|
|
24
|
+
headerMultiple = _ref3$headerMultiple === void 0 ? 1 : _ref3$headerMultiple,
|
|
25
|
+
_ref3$marginMultiple = _ref3.marginMultiple,
|
|
26
|
+
marginMultiple = _ref3$marginMultiple === void 0 ? 2 : _ref3$marginMultiple,
|
|
27
|
+
_ref3$lineHeight = _ref3.lineHeight,
|
|
28
|
+
lineHeight = _ref3$lineHeight === void 0 ? 1.8 : _ref3$lineHeight;
|
|
29
|
+
var __root = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n --lobe-markdown-font-size: ", "px;\n --lobe-markdown-header-multiple: ", ";\n --lobe-markdown-margin-multiple: ", ";\n --lobe-markdown-line-height: ", ";\n --lobe-markdown-border-radius: ", ";\n --lobe-markdown-border-color: ", ";\n\n position: relative;\n\n width: 100%;\n max-width: 100%;\n\n font-size: var(--lobe-markdown-font-size);\n line-height: var(--lobe-markdown-line-height);\n word-break: break-word;\n\n @keyframes cursor-blink {\n to {\n visibility: hidden;\n }\n }\n\n [data-lexical-cursor='true'] {\n pointer-events: none;\n position: absolute;\n display: block;\n\n &::after {\n content: '';\n\n position: absolute;\n inset-block-start: -2px;\n\n display: block;\n\n width: 20px;\n border-block-start: 1px solid ", ";\n\n animation: cursor-blink 1.1s steps(2, start) infinite;\n }\n }\n "])), fontSize, headerMultiple, marginMultiple, lineHeight, token.borderRadiusLG, token.colorFillQuaternary, token.colorText);
|
|
30
|
+
var header = css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-block: max(\n calc(var(--lobe-markdown-header-multiple) * var(--lobe-markdown-margin-multiple) * 0.4em),\n var(--lobe-markdown-font-size)\n );\n font-weight: bold;\n line-height: 1.25;\n }\n\n h1 {\n font-size: calc(\n var(--lobe-markdown-font-size) * (1 + 1.5 * var(--lobe-markdown-header-multiple))\n );\n }\n\n h2 {\n font-size: calc(\n var(--lobe-markdown-font-size) * (1 + var(--lobe-markdown-header-multiple))\n );\n }\n\n h3 {\n font-size: calc(\n var(--lobe-markdown-font-size) * (1 + 0.5 * var(--lobe-markdown-header-multiple))\n );\n }\n\n h4 {\n font-size: calc(\n var(--lobe-markdown-font-size) * (1 + 0.25 * var(--lobe-markdown-header-multiple))\n );\n }\n\n h5,\n h6 {\n font-size: calc(var(--lobe-markdown-font-size) * 1);\n }\n "])));
|
|
31
|
+
var p = css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n p {\n margin-block: 4px;\n line-height: var(--lobe-markdown-line-height);\n letter-spacing: 0.02em;\n\n &:not(:first-child) {\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n }\n\n &:not(:last-child) {\n margin-block-end: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n }\n }\n "])));
|
|
32
|
+
var blockquote = css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n .editor_quote {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n margin-inline: 0;\n padding-block: 0;\n padding-inline: 1em;\n border-inline-start: solid 4px ", ";\n\n color: ", ";\n }\n "])), token.colorBorder, token.colorTextSecondary);
|
|
33
|
+
var code = css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n .editor_code {\n display: inline;\n\n margin-inline: 0.25em;\n padding-block: 0.2em;\n padding-inline: 0.4em;\n border: 1px solid var(--lobe-markdown-border-color);\n border-radius: 0.25em;\n\n font-family: ", ";\n font-size: 0.875em;\n line-height: 1;\n word-break: break-word;\n white-space: break-spaces;\n\n background: ", ";\n }\n "])), token.fontFamilyCode, token.colorFillSecondary);
|
|
34
|
+
return {
|
|
35
|
+
root: __root,
|
|
36
|
+
variant: cx(header, p, blockquote, code)
|
|
37
|
+
};
|
|
38
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { CommonPluginOptions } from "..";
|
|
3
|
+
import type { IEditor } from "../../../types";
|
|
4
|
+
export interface ReactEditorContentProps {
|
|
5
|
+
content: any;
|
|
6
|
+
placeholder?: ReactNode;
|
|
7
|
+
type: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ReactPlainTextProps {
|
|
10
|
+
children: ReactElement<ReactEditorContentProps>;
|
|
11
|
+
className?: string;
|
|
12
|
+
onChange?: (editor: IEditor) => void;
|
|
13
|
+
style?: CSSProperties;
|
|
14
|
+
theme?: CommonPluginOptions['theme'] & {
|
|
15
|
+
fontSize?: number;
|
|
16
|
+
headerMultiple?: number;
|
|
17
|
+
lineHeight?: number;
|
|
18
|
+
marginMultiple?: number;
|
|
19
|
+
};
|
|
20
|
+
variant?: 'default' | 'chat';
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ElementNode } from 'lexical';
|
|
2
|
+
import { ElementTransformer } from "../../markdown/service/shortcut";
|
|
3
|
+
export declare const createBlockNode: (createNode: (match: Array<string>, parentNode: ElementNode) => ElementNode) => ElementTransformer['replace'];
|
|
4
|
+
/**
|
|
5
|
+
* Returns the root's text content.
|
|
6
|
+
* @returns The root's text content.
|
|
7
|
+
*/
|
|
8
|
+
export declare function $rootTextContent(): string;
|
|
9
|
+
/**
|
|
10
|
+
* Determines if the root has any text content and can trim any whitespace if it does.
|
|
11
|
+
* @param isEditorComposing - Is the editor in composition mode due to an active Input Method Editor?
|
|
12
|
+
* @param trim - Should the root text have its whitespaced trimmed? Defaults to true.
|
|
13
|
+
* @returns true if text content is empty, false if there is text or isEditorComposing is true.
|
|
14
|
+
*/
|
|
15
|
+
export declare function $isRootTextContentEmpty(isEditorComposing: boolean, trim?: boolean): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Determines if the input should show the placeholder. If anything is in
|
|
18
|
+
* in the root the placeholder should not be shown.
|
|
19
|
+
* @param isComposing - Is the editor in composition mode due to an active Input Method Editor?
|
|
20
|
+
* @returns true if the input should show the placeholder, false otherwise.
|
|
21
|
+
*/
|
|
22
|
+
export declare function $canShowPlaceholder(isComposing: boolean): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Returns a function that executes {@link $canShowPlaceholder}
|
|
25
|
+
* @param isEditorComposing - Is the editor in composition mode due to an active Input Method Editor?
|
|
26
|
+
* @returns A function that executes $canShowPlaceholder with arguments.
|
|
27
|
+
*/
|
|
28
|
+
export declare function $canShowPlaceholderCurry(isEditorComposing: boolean): () => boolean;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
import { $getRoot, $isDecoratorNode, $isElementNode, $isParagraphNode, $isTextNode } from 'lexical';
|
|
8
|
+
export var createBlockNode = function createBlockNode(createNode) {
|
|
9
|
+
return function (parentNode, children, match, isImport) {
|
|
10
|
+
var node = createNode(match, parentNode);
|
|
11
|
+
node.append.apply(node, _toConsumableArray(children));
|
|
12
|
+
parentNode.replace(node);
|
|
13
|
+
if (!isImport) {
|
|
14
|
+
node.select(0, 0);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns the root's text content.
|
|
21
|
+
* @returns The root's text content.
|
|
22
|
+
*/
|
|
23
|
+
export function $rootTextContent() {
|
|
24
|
+
var root = $getRoot();
|
|
25
|
+
return root.getTextContent();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Determines if the root has any text content and can trim any whitespace if it does.
|
|
30
|
+
* @param isEditorComposing - Is the editor in composition mode due to an active Input Method Editor?
|
|
31
|
+
* @param trim - Should the root text have its whitespaced trimmed? Defaults to true.
|
|
32
|
+
* @returns true if text content is empty, false if there is text or isEditorComposing is true.
|
|
33
|
+
*/
|
|
34
|
+
export function $isRootTextContentEmpty(isEditorComposing) {
|
|
35
|
+
var trim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
36
|
+
if (isEditorComposing) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
var text = $rootTextContent();
|
|
40
|
+
if (trim) {
|
|
41
|
+
text = text.trim();
|
|
42
|
+
}
|
|
43
|
+
return text === '';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Determines if the input should show the placeholder. If anything is in
|
|
48
|
+
* in the root the placeholder should not be shown.
|
|
49
|
+
* @param isComposing - Is the editor in composition mode due to an active Input Method Editor?
|
|
50
|
+
* @returns true if the input should show the placeholder, false otherwise.
|
|
51
|
+
*/
|
|
52
|
+
export function $canShowPlaceholder(isComposing) {
|
|
53
|
+
if (!$isRootTextContentEmpty(isComposing, false)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
var root = $getRoot();
|
|
57
|
+
var children = root.getChildren();
|
|
58
|
+
var childrenLength = children.length;
|
|
59
|
+
if (childrenLength > 1) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
for (var i = 0; i < childrenLength; i++) {
|
|
63
|
+
var topBlock = children[i];
|
|
64
|
+
if ($isDecoratorNode(topBlock)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if ($isElementNode(topBlock)) {
|
|
68
|
+
if (!$isParagraphNode(topBlock)) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (topBlock.__indent !== 0) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
var topBlockChildren = topBlock.getChildren();
|
|
75
|
+
var topBlockChildrenLength = topBlockChildren.length;
|
|
76
|
+
for (var s = 0; s < topBlockChildrenLength; s++) {
|
|
77
|
+
var child = topBlockChildren[i];
|
|
78
|
+
if (!$isTextNode(child)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Returns a function that executes {@link $canShowPlaceholder}
|
|
89
|
+
* @param isEditorComposing - Is the editor in composition mode due to an active Input Method Editor?
|
|
90
|
+
* @returns A function that executes $canShowPlaceholder with arguments.
|
|
91
|
+
*/
|
|
92
|
+
export function $canShowPlaceholderCurry(isEditorComposing) {
|
|
93
|
+
return function () {
|
|
94
|
+
return $canShowPlaceholder(isEditorComposing);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LexicalEditor } from 'lexical';
|
|
2
|
+
export declare const INSERT_FILE_COMMAND: import("lexical").LexicalCommand<{
|
|
3
|
+
file: File;
|
|
4
|
+
}>;
|
|
5
|
+
export declare function registerFileCommand(editor: LexicalEditor, handleUpload: (file: File) => Promise<{
|
|
6
|
+
url: string;
|
|
7
|
+
}>): () => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { $wrapNodeInElement } from '@lexical/utils';
|
|
2
|
+
import { $createParagraphNode, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_HIGH, createCommand } from 'lexical';
|
|
3
|
+
import { $createFileNode } from "../node/FileNode";
|
|
4
|
+
export var INSERT_FILE_COMMAND = createCommand('INSERT_FILE_COMMAND');
|
|
5
|
+
export function registerFileCommand(editor, handleUpload) {
|
|
6
|
+
return editor.registerCommand(INSERT_FILE_COMMAND, function (payload) {
|
|
7
|
+
var file = payload.file;
|
|
8
|
+
editor.update(function () {
|
|
9
|
+
var fileNode = $createFileNode(file.name);
|
|
10
|
+
$insertNodes([fileNode]); // Insert a zero-width space to ensure the image is not the last child
|
|
11
|
+
if ($isRootOrShadowRoot(fileNode.getParentOrThrow())) {
|
|
12
|
+
$wrapNodeInElement(fileNode, $createParagraphNode).selectEnd();
|
|
13
|
+
}
|
|
14
|
+
handleUpload(file).then(function (url) {
|
|
15
|
+
editor.update(function () {
|
|
16
|
+
fileNode.setUploaded(url.url);
|
|
17
|
+
});
|
|
18
|
+
}).catch(function (error) {
|
|
19
|
+
console.error('File upload failed:', error);
|
|
20
|
+
editor.update(function () {
|
|
21
|
+
fileNode.setError('File upload failed : ' + error.message);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
return false;
|
|
26
|
+
}, COMMAND_PRIORITY_HIGH // Priority
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DOMConversionMap, DOMExportOutput, DecoratorNode, EditorConfig, LexicalEditor, LexicalNode, LexicalUpdateJSON, SerializedLexicalNode, Spread } from 'lexical';
|
|
2
|
+
export type SerializedFileNode = Spread<{
|
|
3
|
+
fileUrl?: string;
|
|
4
|
+
message?: string;
|
|
5
|
+
name: string;
|
|
6
|
+
size?: number;
|
|
7
|
+
status?: 'pending' | 'uploaded' | 'error';
|
|
8
|
+
}, SerializedLexicalNode>;
|
|
9
|
+
export declare class FileNode extends DecoratorNode<any> {
|
|
10
|
+
static getType(): string;
|
|
11
|
+
static clone(node: FileNode): FileNode;
|
|
12
|
+
static importJSON(serializedNode: SerializedFileNode): FileNode;
|
|
13
|
+
static importDOM(): DOMConversionMap | null;
|
|
14
|
+
__name: string;
|
|
15
|
+
__fileUrl: string | undefined;
|
|
16
|
+
__size: number | undefined;
|
|
17
|
+
__status: 'pending' | 'uploaded' | 'error';
|
|
18
|
+
__message?: string;
|
|
19
|
+
get name(): string;
|
|
20
|
+
get fileUrl(): string | undefined;
|
|
21
|
+
get size(): number | undefined;
|
|
22
|
+
get status(): 'pending' | 'uploaded' | 'error';
|
|
23
|
+
get message(): string | undefined;
|
|
24
|
+
constructor(name: string, fileUrl?: string, size?: number, status?: 'pending' | 'uploaded' | 'error', message?: string, key?: string);
|
|
25
|
+
setUploaded(url: string): void;
|
|
26
|
+
setError(message: string): void;
|
|
27
|
+
exportDOM(): DOMExportOutput;
|
|
28
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
29
|
+
exportJSON(): SerializedFileNode;
|
|
30
|
+
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedFileNode>): this;
|
|
31
|
+
getTextContent(): string;
|
|
32
|
+
updateDOM(): boolean;
|
|
33
|
+
decorate(editor: LexicalEditor): any;
|
|
34
|
+
}
|
|
35
|
+
export declare function $createFileNode(name?: string, fileUrl?: string, size?: number, status?: 'pending' | 'uploaded' | 'error', message?: string): FileNode;
|
|
36
|
+
export declare function $isFileNode(node: LexicalNode): node is FileNode;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
8
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
9
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
11
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
13
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
14
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
15
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
18
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
20
|
+
import { addClassNamesToElement } from '@lexical/utils';
|
|
21
|
+
import { $applyNodeReplacement, DecoratorNode } from 'lexical';
|
|
22
|
+
import { getKernelFromEditor } from "../../../editor-kernel/utils";
|
|
23
|
+
export var FileNode = /*#__PURE__*/function (_DecoratorNode) {
|
|
24
|
+
_inherits(FileNode, _DecoratorNode);
|
|
25
|
+
var _super = _createSuper(FileNode);
|
|
26
|
+
function FileNode(name, fileUrl, size, status, message, key) {
|
|
27
|
+
var _this;
|
|
28
|
+
_classCallCheck(this, FileNode);
|
|
29
|
+
_this = _super.call(this, key);
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "__name", void 0);
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "__fileUrl", void 0);
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "__size", void 0);
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "__status", void 0);
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "__message", void 0);
|
|
35
|
+
_this.__name = name;
|
|
36
|
+
_this.__fileUrl = fileUrl;
|
|
37
|
+
_this.__size = size;
|
|
38
|
+
_this.__status = status || 'pending';
|
|
39
|
+
_this.__message = message;
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
_createClass(FileNode, [{
|
|
43
|
+
key: "name",
|
|
44
|
+
get: function get() {
|
|
45
|
+
return this.__name;
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
key: "fileUrl",
|
|
49
|
+
get: function get() {
|
|
50
|
+
return this.__fileUrl;
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "size",
|
|
54
|
+
get: function get() {
|
|
55
|
+
return this.__size;
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "status",
|
|
59
|
+
get: function get() {
|
|
60
|
+
return this.__status;
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
key: "message",
|
|
64
|
+
get: function get() {
|
|
65
|
+
return this.__message;
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "setUploaded",
|
|
69
|
+
value: function setUploaded(url) {
|
|
70
|
+
var writable = this.getWritable();
|
|
71
|
+
writable.__fileUrl = url;
|
|
72
|
+
writable.__status = 'uploaded';
|
|
73
|
+
writable.__message = undefined; // Clear any previous error message
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "setError",
|
|
77
|
+
value: function setError(message) {
|
|
78
|
+
var writable = this.getWritable();
|
|
79
|
+
writable.__status = 'error';
|
|
80
|
+
writable.__message = message;
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "exportDOM",
|
|
84
|
+
value: function exportDOM() {
|
|
85
|
+
return {
|
|
86
|
+
element: document.createElement('span')
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "createDOM",
|
|
91
|
+
value: function createDOM(config) {
|
|
92
|
+
var element = document.createElement('span');
|
|
93
|
+
addClassNamesToElement(element, config.theme.file);
|
|
94
|
+
return element;
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "exportJSON",
|
|
98
|
+
value: function exportJSON() {
|
|
99
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(FileNode.prototype), "exportJSON", this).call(this)), {}, {
|
|
100
|
+
fileUrl: this.fileUrl,
|
|
101
|
+
message: this.message,
|
|
102
|
+
name: this.name,
|
|
103
|
+
size: this.size,
|
|
104
|
+
status: this.status
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
key: "updateFromJSON",
|
|
109
|
+
value: function updateFromJSON(serializedNode) {
|
|
110
|
+
var node = _get(_getPrototypeOf(FileNode.prototype), "updateFromJSON", this).call(this, serializedNode);
|
|
111
|
+
return node;
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "getTextContent",
|
|
115
|
+
value: function getTextContent() {
|
|
116
|
+
return '\n';
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
key: "updateDOM",
|
|
120
|
+
value: function updateDOM() {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "decorate",
|
|
125
|
+
value: function decorate(editor) {
|
|
126
|
+
var _getKernelFromEditor, _getKernelFromEditor$;
|
|
127
|
+
return ((_getKernelFromEditor = getKernelFromEditor(editor)) === null || _getKernelFromEditor === void 0 || (_getKernelFromEditor$ = _getKernelFromEditor.getDecorator('file')) === null || _getKernelFromEditor$ === void 0 ? void 0 : _getKernelFromEditor$(this, editor)) || null;
|
|
128
|
+
}
|
|
129
|
+
}], [{
|
|
130
|
+
key: "getType",
|
|
131
|
+
value: function getType() {
|
|
132
|
+
return 'file';
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "clone",
|
|
136
|
+
value: function clone(node) {
|
|
137
|
+
return new FileNode(node.__name, node.__fileUrl, node.__size, node.__status, node.__message, node.__key);
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "importJSON",
|
|
141
|
+
value: function importJSON(serializedNode) {
|
|
142
|
+
return new FileNode(serializedNode.name, serializedNode.fileUrl, serializedNode.size, serializedNode.status, serializedNode.message);
|
|
143
|
+
}
|
|
144
|
+
}, {
|
|
145
|
+
key: "importDOM",
|
|
146
|
+
value: function importDOM() {
|
|
147
|
+
return {
|
|
148
|
+
span: function span(node) {
|
|
149
|
+
if (node.classList.contains('file')) {
|
|
150
|
+
return {
|
|
151
|
+
conversion: $convertFileElement,
|
|
152
|
+
priority: 0
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}]);
|
|
160
|
+
return FileNode;
|
|
161
|
+
}(DecoratorNode);
|
|
162
|
+
export function $createFileNode() {
|
|
163
|
+
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'unknown';
|
|
164
|
+
var fileUrl = arguments.length > 1 ? arguments[1] : undefined;
|
|
165
|
+
var size = arguments.length > 2 ? arguments[2] : undefined;
|
|
166
|
+
var status = arguments.length > 3 ? arguments[3] : undefined;
|
|
167
|
+
var message = arguments.length > 4 ? arguments[4] : undefined;
|
|
168
|
+
return $applyNodeReplacement(new FileNode(name, fileUrl, size, status, message));
|
|
169
|
+
}
|
|
170
|
+
function $convertFileElement() {
|
|
171
|
+
return {
|
|
172
|
+
node: $createFileNode()
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export function $isFileNode(node) {
|
|
176
|
+
return node.getType() === FileNode.getType();
|
|
177
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LexicalEditor } from 'lexical';
|
|
2
|
+
import { IEditorPluginConstructor } from "../../../types";
|
|
3
|
+
import { FileNode } from '../node/FileNode';
|
|
4
|
+
export interface FilePluginOptions {
|
|
5
|
+
decorator: (node: FileNode, editor: LexicalEditor) => any;
|
|
6
|
+
handleUpload: (file: File) => Promise<{
|
|
7
|
+
url: string;
|
|
8
|
+
}>;
|
|
9
|
+
markdownWriter?: (file: FileNode) => string;
|
|
10
|
+
theme?: {
|
|
11
|
+
file?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const FilePlugin: IEditorPluginConstructor<FilePluginOptions>;
|