@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Alec Larson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
<div align="center"><a name="readme-top"></a>
|
|
2
|
+
|
|
3
|
+
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-logo/1.0.0/files/assets/logo-3d.webp">
|
|
4
|
+
<img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
|
|
5
|
+
<img height="120" src="https://registry.npmmirror.com/@lobehub/fluent-emoji-3d/latest/files/assets/2712-fe0f.webp">
|
|
6
|
+
|
|
7
|
+
<h1>LobeHub Editor</h1>
|
|
8
|
+
|
|
9
|
+
A modern, extensible rich text editor built on Meta's Lexical framework with dual-architecture design, featuring both a powerful kernel and React integration. Optimized for AI applications and chat interfaces.
|
|
10
|
+
|
|
11
|
+
[![][npm-release-shield]][npm-release-link]
|
|
12
|
+
[![][github-releasedate-shield]][github-releasedate-link]
|
|
13
|
+
[![][github-action-test-shield]][github-action-test-link]
|
|
14
|
+
[![][github-action-release-shield]][github-action-release-link]<br/>
|
|
15
|
+
[![][github-contributors-shield]][github-contributors-link]
|
|
16
|
+
[![][github-forks-shield]][github-forks-link]
|
|
17
|
+
[![][github-stars-shield]][github-stars-link]
|
|
18
|
+
[![][github-issues-shield]][github-issues-link]
|
|
19
|
+
[![][github-license-shield]][github-license-link]
|
|
20
|
+
|
|
21
|
+
[Changelog](./CHANGELOG.md) ยท [Report Bug][github-issues-link] ยท [Request Feature][github-issues-link]
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<details>
|
|
28
|
+
<summary><kbd>Table of contents</kbd></summary>
|
|
29
|
+
|
|
30
|
+
#### TOC
|
|
31
|
+
|
|
32
|
+
- [โจ Features](#-features)
|
|
33
|
+
- [๐ฆ Installation](#-installation)
|
|
34
|
+
- [๐ Quick Start](#-quick-start)
|
|
35
|
+
- [Basic Editor](#basic-editor)
|
|
36
|
+
- [Advanced Usage with Plugins](#advanced-usage-with-plugins)
|
|
37
|
+
- [Chat Input Component](#chat-input-component)
|
|
38
|
+
- [Editor Kernel API](#editor-kernel-api)
|
|
39
|
+
- [๐ Available Plugins](#-available-plugins)
|
|
40
|
+
- [Core Plugins](#core-plugins)
|
|
41
|
+
- [Content Plugins](#content-plugins)
|
|
42
|
+
- [Plugin Architecture](#plugin-architecture)
|
|
43
|
+
- [Plugin Features](#plugin-features)
|
|
44
|
+
- [๐ API Reference](#-api-reference)
|
|
45
|
+
- [Editor Kernel](#editor-kernel)
|
|
46
|
+
- [Plugin System](#plugin-system)
|
|
47
|
+
- [๐ ๏ธ Development](#๏ธ-development)
|
|
48
|
+
- [Setup](#setup)
|
|
49
|
+
- [Available Scripts](#available-scripts)
|
|
50
|
+
- [Project Architecture](#project-architecture)
|
|
51
|
+
- [๐ค Contributing](#-contributing)
|
|
52
|
+
- [๐ Links](#-links)
|
|
53
|
+
- [More Products](#more-products)
|
|
54
|
+
- [Design Resources](#design-resources)
|
|
55
|
+
- [Development Resources](#development-resources)
|
|
56
|
+
|
|
57
|
+
####
|
|
58
|
+
|
|
59
|
+
</details>
|
|
60
|
+
|
|
61
|
+
## โจ Features
|
|
62
|
+
|
|
63
|
+
- ๐ฏ **Dual Architecture** - Both kernel-based API and React components for maximum flexibility
|
|
64
|
+
- โ๏ธ **React-First** - Built for React 19+ with modern hooks and patterns
|
|
65
|
+
- ๐ **Rich Plugin Ecosystem** - 10+ built-in plugins for comprehensive content editing
|
|
66
|
+
- ๐ฌ **Chat Interface Ready** - Pre-built chat input components with mention support
|
|
67
|
+
- โจ๏ธ **Slash Commands** - Intuitive `/` and `@` triggered menus for quick content insertion
|
|
68
|
+
- ๐ **Multiple Export Formats** - JSON, Markdown, and plain text export capabilities
|
|
69
|
+
- ๐จ **Customizable UI** - Antd-styled components with flexible theming
|
|
70
|
+
- ๐ **File & Media Support** - Native support for images, files, tables, and more
|
|
71
|
+
- ๐ฏ **TypeScript Native** - Built with TypeScript for excellent developer experience
|
|
72
|
+
- ๐ฑ **Modern Build System** - Optimized with Vite, Dumi docs, and comprehensive testing
|
|
73
|
+
|
|
74
|
+
## ๐ฆ Installation
|
|
75
|
+
|
|
76
|
+
To install `@lobehub/editor`, run the following command:
|
|
77
|
+
|
|
78
|
+
[![][bun-shield]][bun-link]
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
$ bun add @lobehub/editor
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
$ pnpm add @lobehub/editor
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
<div align="right">
|
|
89
|
+
|
|
90
|
+
[![][back-to-top]](#readme-top)
|
|
91
|
+
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
## ๐ Quick Start
|
|
95
|
+
|
|
96
|
+
### Basic Editor
|
|
97
|
+
|
|
98
|
+
The simplest way to get started with a fully-featured editor:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import {
|
|
102
|
+
ReactCodeblockPlugin,
|
|
103
|
+
ReactImagePlugin,
|
|
104
|
+
ReactLinkPlugin,
|
|
105
|
+
ReactListPlugin,
|
|
106
|
+
} from '@lobehub/editor';
|
|
107
|
+
import { Editor } from '@lobehub/editor/react';
|
|
108
|
+
|
|
109
|
+
export default function MyEditor() {
|
|
110
|
+
const editorRef = Editor.useEditor();
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<Editor
|
|
114
|
+
placeholder="Start typing..."
|
|
115
|
+
editorRef={editorRef}
|
|
116
|
+
plugins={[ReactListPlugin, ReactLinkPlugin, ReactImagePlugin, ReactCodeblockPlugin]}
|
|
117
|
+
slashOption={{
|
|
118
|
+
items: [
|
|
119
|
+
{
|
|
120
|
+
key: 'h1',
|
|
121
|
+
label: 'Heading 1',
|
|
122
|
+
onSelect: (editor) => {
|
|
123
|
+
editor.dispatchCommand(INSERT_HEADING_COMMAND, { tag: 'h1' });
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
// More slash commands...
|
|
127
|
+
],
|
|
128
|
+
}}
|
|
129
|
+
onChange={(editor) => {
|
|
130
|
+
// Handle content changes
|
|
131
|
+
const markdown = editor.getDocument('markdown');
|
|
132
|
+
const json = editor.getDocument('json');
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Advanced Usage with Plugins
|
|
140
|
+
|
|
141
|
+
Add more functionality with built-in plugins:
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
import {
|
|
145
|
+
INSERT_FILE_COMMAND,
|
|
146
|
+
INSERT_TABLE_COMMAND,
|
|
147
|
+
ReactFilePlugin,
|
|
148
|
+
ReactHRPlugin,
|
|
149
|
+
ReactTablePlugin,
|
|
150
|
+
} from '@lobehub/editor';
|
|
151
|
+
import { Editor } from '@lobehub/editor/react';
|
|
152
|
+
|
|
153
|
+
export default function AdvancedEditor() {
|
|
154
|
+
const editorRef = Editor.useEditor();
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<Editor
|
|
158
|
+
editorRef={editorRef}
|
|
159
|
+
plugins={[
|
|
160
|
+
ReactTablePlugin,
|
|
161
|
+
ReactHRPlugin,
|
|
162
|
+
Editor.withProps(ReactFilePlugin, {
|
|
163
|
+
handleUpload: async (file) => {
|
|
164
|
+
// Handle file upload
|
|
165
|
+
return { url: await uploadFile(file) };
|
|
166
|
+
},
|
|
167
|
+
}),
|
|
168
|
+
]}
|
|
169
|
+
mentionOption={{
|
|
170
|
+
items: async (search) => [
|
|
171
|
+
{
|
|
172
|
+
key: 'user1',
|
|
173
|
+
label: 'John Doe',
|
|
174
|
+
onSelect: (editor) => {
|
|
175
|
+
editor.dispatchCommand(INSERT_MENTION_COMMAND, {
|
|
176
|
+
label: 'John Doe',
|
|
177
|
+
extra: { userId: 1 },
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
}}
|
|
183
|
+
/>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Chat Input Component
|
|
189
|
+
|
|
190
|
+
Pre-built component optimized for chat interfaces:
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
import { ChatInput } from '@lobehub/editor/react';
|
|
194
|
+
|
|
195
|
+
export default function ChatApp() {
|
|
196
|
+
return (
|
|
197
|
+
<ChatInput
|
|
198
|
+
placeholder="Type a message..."
|
|
199
|
+
onSend={(content) => {
|
|
200
|
+
// Handle message send
|
|
201
|
+
console.log('Message:', content);
|
|
202
|
+
}}
|
|
203
|
+
enabledFeatures={['mention', 'upload', 'codeblock']}
|
|
204
|
+
/>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Editor Kernel API
|
|
210
|
+
|
|
211
|
+
For advanced use cases, access the underlying kernel directly:
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
import { IEditor, createEditor } from '@lobehub/editor';
|
|
215
|
+
|
|
216
|
+
// Create editor instance
|
|
217
|
+
const editor: IEditor = createEditor();
|
|
218
|
+
|
|
219
|
+
// Register plugins
|
|
220
|
+
editor.registerPlugin(SomePlugin, { config: 'value' });
|
|
221
|
+
|
|
222
|
+
// Interact with content
|
|
223
|
+
editor.setDocument('text', 'Hello world');
|
|
224
|
+
const content = editor.getDocument('json');
|
|
225
|
+
|
|
226
|
+
// Listen to events
|
|
227
|
+
editor.on('content-changed', (newContent) => {
|
|
228
|
+
console.log('Content updated:', newContent);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// Execute commands
|
|
232
|
+
editor.dispatchCommand(INSERT_HEADING_COMMAND, { tag: 'h2' });
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
<div align="right">
|
|
236
|
+
|
|
237
|
+
[![][back-to-top]](#readme-top)
|
|
238
|
+
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
## ๐ Available Plugins
|
|
242
|
+
|
|
243
|
+
### Core Plugins
|
|
244
|
+
|
|
245
|
+
| Plugin | Description | Features |
|
|
246
|
+
| ------------------ | ----------------------------- | --------------------------------------------------------------- |
|
|
247
|
+
| **CommonPlugin** | Foundation editor components | ReactEditor, ReactEditorContent, ReactPlainText, base utilities |
|
|
248
|
+
| **MarkdownPlugin** | Markdown processing engine | Shortcuts, transformers, serialization, custom writers |
|
|
249
|
+
| **UploadPlugin** | File upload management system | Priority handlers, drag-drop, multi-source uploads |
|
|
250
|
+
|
|
251
|
+
### Content Plugins
|
|
252
|
+
|
|
253
|
+
| Plugin | Description | Features |
|
|
254
|
+
| ------------------------ | ------------------------- | --------------------------------------------------------------- |
|
|
255
|
+
| **ReactSlashPlugin** | Slash command menu system | `/` and `@` triggered menus, customizable items, async search |
|
|
256
|
+
| **ReactMentionPlugin** | User mention support | `@username` mentions, custom markdown output, async user search |
|
|
257
|
+
| **ReactImagePlugin** | Image handling | Upload, display, drag & drop, captions, resizing |
|
|
258
|
+
| **ReactCodeblockPlugin** | Code syntax highlighting | Shiki-powered, 100+ languages, custom themes, color schemes |
|
|
259
|
+
| **ReactListPlugin** | List management | Ordered/unordered lists, nested lists, keyboard shortcuts |
|
|
260
|
+
| **ReactLinkPlugin** | Link management | Auto-detection, validation, previews, custom styling |
|
|
261
|
+
| **ReactTablePlugin** | Table support | Insert tables, edit cells, add/remove rows/columns, i18n |
|
|
262
|
+
| **ReactHRPlugin** | Horizontal rules | Divider insertion, custom styling, markdown shortcuts |
|
|
263
|
+
| **ReactFilePlugin** | File attachments | File upload, status tracking, validation, drag-drop |
|
|
264
|
+
|
|
265
|
+
### Plugin Architecture
|
|
266
|
+
|
|
267
|
+
All plugins follow a **dual-architecture design**:
|
|
268
|
+
|
|
269
|
+
#### ๐ง **Kernel Layer** (Framework-agnostic)
|
|
270
|
+
|
|
271
|
+
- **Plugin Interface**: Standardized plugin system with lifecycle management
|
|
272
|
+
- **Service Container**: Centralized service registration and dependency injection
|
|
273
|
+
- **Command System**: Event-driven command pattern for editor operations
|
|
274
|
+
- **Node System**: Custom node types with serialization and transformation
|
|
275
|
+
- **Data Sources**: Content management and format conversion (JSON, Markdown, Text)
|
|
276
|
+
|
|
277
|
+
#### โ๏ธ **React Layer** (React-specific)
|
|
278
|
+
|
|
279
|
+
- **React Components**: High-level components for easy integration
|
|
280
|
+
- **Hook Integration**: Custom hooks for editor state and functionality
|
|
281
|
+
- **Event Handling**: React-friendly event system and callbacks
|
|
282
|
+
- **UI Components**: Pre-built UI elements with theming support
|
|
283
|
+
|
|
284
|
+
### Plugin Features
|
|
285
|
+
|
|
286
|
+
- โ
**Fully configurable** with TypeScript-typed options
|
|
287
|
+
- โ
**Composable** - use any combination together
|
|
288
|
+
- โ
**Extensible** - create custom plugins using the same API
|
|
289
|
+
- โ
**Event-driven** - react to user interactions and content changes
|
|
290
|
+
- โ
**Service-oriented** - modular architecture with dependency injection
|
|
291
|
+
- โ
**Internationalization** - Built-in i18n support where applicable
|
|
292
|
+
- โ
**Markdown integration** - Shortcuts, import/export, custom transformers
|
|
293
|
+
- โ
**Theme system** - Customizable styling and appearance
|
|
294
|
+
- โ
**Command pattern** - Programmatic control and automation
|
|
295
|
+
|
|
296
|
+
## ๐ API Reference
|
|
297
|
+
|
|
298
|
+
#### Utility Hooks
|
|
299
|
+
|
|
300
|
+
```tsx
|
|
301
|
+
// Get editor reference
|
|
302
|
+
const editorRef = Editor.useEditor();
|
|
303
|
+
|
|
304
|
+
// Helper for plugin configuration
|
|
305
|
+
const PluginWithConfig = Editor.withProps(ReactFilePlugin, {
|
|
306
|
+
handleUpload: async (file) => ({ url: 'uploaded-url' }),
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Editor Kernel
|
|
311
|
+
|
|
312
|
+
#### `createEditor(): IEditor`
|
|
313
|
+
|
|
314
|
+
Create a new editor kernel instance:
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
const editor = createEditor();
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
#### `IEditor` Interface
|
|
321
|
+
|
|
322
|
+
Core editor methods:
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
interface IEditor {
|
|
326
|
+
// Content management
|
|
327
|
+
setDocument(type: string, content: any): void;
|
|
328
|
+
getDocument(type: string): any;
|
|
329
|
+
|
|
330
|
+
// Plugin system
|
|
331
|
+
registerPlugin<T>(plugin: Constructor<T>, config?: T): IEditor;
|
|
332
|
+
registerPlugins(plugins: Plugin[]): IEditor;
|
|
333
|
+
|
|
334
|
+
// Commands
|
|
335
|
+
dispatchCommand<T>(command: LexicalCommand<T>, payload: T): boolean;
|
|
336
|
+
|
|
337
|
+
// Events
|
|
338
|
+
on<T>(event: string, listener: (data: T) => void): this;
|
|
339
|
+
off<T>(event: string, listener: (data: T) => void): this;
|
|
340
|
+
|
|
341
|
+
// Lifecycle
|
|
342
|
+
focus(): void;
|
|
343
|
+
blur(): void;
|
|
344
|
+
destroy(): void;
|
|
345
|
+
|
|
346
|
+
// Access
|
|
347
|
+
getLexicalEditor(): LexicalEditor | null;
|
|
348
|
+
getRootElement(): HTMLElement | null;
|
|
349
|
+
requireService<T>(serviceId: ServiceID<T>): T | null;
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Plugin System
|
|
354
|
+
|
|
355
|
+
#### Creating Custom Plugins
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
import { IEditorKernel, IEditorPlugin } from '@lobehub/editor';
|
|
359
|
+
|
|
360
|
+
class MyCustomPlugin implements IEditorPlugin {
|
|
361
|
+
constructor(private config: MyPluginConfig) {}
|
|
362
|
+
|
|
363
|
+
initialize(kernel: IEditorKernel) {
|
|
364
|
+
// Register nodes, commands, transforms, etc.
|
|
365
|
+
kernel.registerNode(MyCustomNode);
|
|
366
|
+
kernel.registerCommand(MY_COMMAND, this.handleCommand);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
destroy() {
|
|
370
|
+
// Cleanup
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
#### Available Commands
|
|
376
|
+
|
|
377
|
+
Common commands you can dispatch:
|
|
378
|
+
|
|
379
|
+
```typescript
|
|
380
|
+
// Content insertion
|
|
381
|
+
INSERT_HEADING_COMMAND; // { tag: 'h1' | 'h2' | 'h3' }
|
|
382
|
+
INSERT_LINK_COMMAND; // { url: string, text?: string }
|
|
383
|
+
INSERT_IMAGE_COMMAND; // { src: string, alt?: string }
|
|
384
|
+
INSERT_TABLE_COMMAND; // { rows: number, columns: number }
|
|
385
|
+
INSERT_MENTION_COMMAND; // { label: string, extra?: any }
|
|
386
|
+
INSERT_FILE_COMMAND; // { file: File }
|
|
387
|
+
INSERT_HORIZONTAL_RULE_COMMAND;
|
|
388
|
+
|
|
389
|
+
// Text formatting
|
|
390
|
+
FORMAT_TEXT_COMMAND; // { format: 'bold' | 'italic' | 'underline' }
|
|
391
|
+
CLEAR_FORMAT_COMMAND;
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
<div align="right">
|
|
395
|
+
|
|
396
|
+
[![][back-to-top]](#readme-top)
|
|
397
|
+
|
|
398
|
+
</div>
|
|
399
|
+
|
|
400
|
+
## ๐ ๏ธ Development
|
|
401
|
+
|
|
402
|
+
### Setup
|
|
403
|
+
|
|
404
|
+
You can use Github Codespaces for online development:
|
|
405
|
+
|
|
406
|
+
[![][github-codespace-shield]][github-codespace-link]
|
|
407
|
+
|
|
408
|
+
Or clone it for local development:
|
|
409
|
+
|
|
410
|
+
[![][bun-shield]][bun-link]
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
$ git clone https://github.com/lobehub/lobe-editor.git
|
|
414
|
+
$ cd lobe-editor
|
|
415
|
+
$ pnpm install
|
|
416
|
+
$ pnpm run dev
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
This will start the Dumi documentation server with live playground at `http://localhost:8000`.
|
|
420
|
+
|
|
421
|
+
### Available Scripts
|
|
422
|
+
|
|
423
|
+
| Script | Description |
|
|
424
|
+
| -------------------- | --------------------------------------------- |
|
|
425
|
+
| `pnpm dev` | Start Dumi development server with playground |
|
|
426
|
+
| `pnpm build` | Build library and generate type definitions |
|
|
427
|
+
| `pnpm test` | Run tests with Vitest |
|
|
428
|
+
| `pnpm test:coverage` | Run tests with coverage report |
|
|
429
|
+
| `pnpm lint` | Lint and fix code with ESLint |
|
|
430
|
+
| `pnpm type-check` | Type check with TypeScript |
|
|
431
|
+
| `pnpm ci` | Run all CI checks (lint, type-check, test) |
|
|
432
|
+
| `pnpm docs:build` | Build documentation for production |
|
|
433
|
+
| `pnpm release` | Publish new version with semantic-release |
|
|
434
|
+
|
|
435
|
+
### Project Architecture
|
|
436
|
+
|
|
437
|
+
```
|
|
438
|
+
lobe-editor/
|
|
439
|
+
โโโ src/
|
|
440
|
+
โ โโโ editor-kernel/ # ๐ง Core editor logic
|
|
441
|
+
โ โ โโโ kernel.ts # Main editor class with plugin system
|
|
442
|
+
โ โ โโโ data-source.ts # Content management (JSON/Markdown/Text)
|
|
443
|
+
โ โ โโโ service.ts # Service container and dependency injection
|
|
444
|
+
โ โ โโโ plugin/ # Plugin base classes and interfaces
|
|
445
|
+
โ โ โโโ react/ # React integration layer
|
|
446
|
+
โ โ โโโ types.ts # TypeScript interfaces
|
|
447
|
+
โ โ
|
|
448
|
+
โ โโโ plugins/ # ๐ Feature plugins
|
|
449
|
+
โ โ โโโ common/ # ๐๏ธ Foundation components
|
|
450
|
+
โ โ โ โโโ plugin/ # Base editor plugin
|
|
451
|
+
โ โ โ โโโ react/ # ReactEditor, ReactEditorContent, ReactPlainText
|
|
452
|
+
โ โ โ โโโ data-source/ # Content data sources
|
|
453
|
+
โ โ โ โโโ utils/ # Common utilities
|
|
454
|
+
โ โ โ
|
|
455
|
+
โ โ โโโ markdown/ # ๐ Markdown processing engine
|
|
456
|
+
โ โ โ โโโ plugin/ # Markdown transformation plugin
|
|
457
|
+
โ โ โ โโโ service/ # Markdown shortcut service
|
|
458
|
+
โ โ โ โโโ data-source/ # Markdown serialization
|
|
459
|
+
โ โ โ โโโ utils/ # Transformer utilities
|
|
460
|
+
โ โ โ
|
|
461
|
+
โ โ โโโ upload/ # ๐ค Upload management system
|
|
462
|
+
โ โ โ โโโ plugin/ # Upload handling plugin
|
|
463
|
+
โ โ โ โโโ service/ # Upload service with priority system
|
|
464
|
+
โ โ โ โโโ utils/ # Upload utilities
|
|
465
|
+
โ โ โ
|
|
466
|
+
โ โ โโโ slash/ # โก Slash commands (/, @)
|
|
467
|
+
โ โ โ โโโ plugin/ # Slash detection plugin
|
|
468
|
+
โ โ โ โโโ react/ # ReactSlashPlugin, ReactSlashOption
|
|
469
|
+
โ โ โ โโโ service/ # Slash service with fuzzy search
|
|
470
|
+
โ โ โ โโโ utils/ # Search and trigger utilities
|
|
471
|
+
โ โ โ
|
|
472
|
+
โ โ โโโ mention/ # ๐ค @mention system
|
|
473
|
+
โ โ โ โโโ plugin/ # Mention plugin with decorators
|
|
474
|
+
โ โ โ โโโ react/ # ReactMentionPlugin
|
|
475
|
+
โ โ โ โโโ command/ # INSERT_MENTION_COMMAND
|
|
476
|
+
โ โ โ โโโ node/ # MentionNode with serialization
|
|
477
|
+
โ โ โ
|
|
478
|
+
โ โ โโโ codeblock/ # ๐จ Syntax highlighting
|
|
479
|
+
โ โ โ โโโ plugin/ # Codeblock plugin with Shiki
|
|
480
|
+
โ โ โ โโโ react/ # ReactCodeblockPlugin
|
|
481
|
+
โ โ โ โโโ command/ # Language and color commands
|
|
482
|
+
โ โ โ โโโ utils/ # Language detection
|
|
483
|
+
โ โ โ
|
|
484
|
+
โ โ โโโ image/ # ๐ผ๏ธ Image upload & display
|
|
485
|
+
โ โ โ โโโ plugin/ # Image plugin with captions
|
|
486
|
+
โ โ โ โโโ react/ # ReactImagePlugin
|
|
487
|
+
โ โ โ โโโ command/ # INSERT_IMAGE_COMMAND
|
|
488
|
+
โ โ โ โโโ node/ # BaseImageNode, ImageNode
|
|
489
|
+
โ โ โ
|
|
490
|
+
โ โ โโโ table/ # ๐ Table support
|
|
491
|
+
โ โ โ โโโ plugin/ # Table plugin with i18n
|
|
492
|
+
โ โ โ โโโ react/ # ReactTablePlugin
|
|
493
|
+
โ โ โ โโโ command/ # Table manipulation commands
|
|
494
|
+
โ โ โ โโโ node/ # Enhanced TableNode
|
|
495
|
+
โ โ โ โโโ utils/ # Table operations
|
|
496
|
+
โ โ โ
|
|
497
|
+
โ โ โโโ file/ # ๐ File attachments
|
|
498
|
+
โ โ โ โโโ plugin/ # File plugin with status tracking
|
|
499
|
+
โ โ โ โโโ react/ # ReactFilePlugin
|
|
500
|
+
โ โ โ โโโ command/ # INSERT_FILE_COMMAND
|
|
501
|
+
โ โ โ โโโ node/ # FileNode with metadata
|
|
502
|
+
โ โ โ โโโ utils/ # File operations
|
|
503
|
+
โ โ โ
|
|
504
|
+
โ โ โโโ link/ # ๐ Link management
|
|
505
|
+
โ โ โ โโโ plugin/ # Link plugin with validation
|
|
506
|
+
โ โ โ โโโ react/ # ReactLinkPlugin
|
|
507
|
+
โ โ โ โโโ command/ # Link commands
|
|
508
|
+
โ โ โ โโโ utils/ # URL validation and detection
|
|
509
|
+
โ โ โ
|
|
510
|
+
โ โ โโโ list/ # ๐ Lists (ordered/unordered)
|
|
511
|
+
โ โ โ โโโ plugin/ # List plugin with nesting
|
|
512
|
+
โ โ โ โโโ react/ # ReactListPlugin
|
|
513
|
+
โ โ โ โโโ command/ # List manipulation commands
|
|
514
|
+
โ โ โ โโโ utils/ # List operations
|
|
515
|
+
โ โ โ
|
|
516
|
+
โ โ โโโ hr/ # โ Horizontal rules
|
|
517
|
+
โ โ โโโ plugin/ # HR plugin with styling
|
|
518
|
+
โ โ โโโ react/ # ReactHRPlugin
|
|
519
|
+
โ โ โโโ command/ # HR insertion commands
|
|
520
|
+
โ โ โโโ node/ # HorizontalRuleNode
|
|
521
|
+
โ โ
|
|
522
|
+
โ โโโ react/ # โ๏ธ High-level React components
|
|
523
|
+
โ โ โโโ Editor/ # Main Editor component with plugins
|
|
524
|
+
โ โ โโโ ChatInput/ # Chat interface component
|
|
525
|
+
โ โ โโโ ChatInputActions/ # Chat action buttons
|
|
526
|
+
โ โ โโโ ChatInputActionBar/ # Action bar layout
|
|
527
|
+
โ โ โโโ SendButton/ # Send button with states
|
|
528
|
+
โ โ โโโ CodeLanguageSelect/ # Code language selector
|
|
529
|
+
โ โ
|
|
530
|
+
โ โโโ index.ts # Public API exports
|
|
531
|
+
โ
|
|
532
|
+
โโโ docs/ # ๐ Documentation source
|
|
533
|
+
โโโ tests/ # ๐งช Test files
|
|
534
|
+
โโโ vitest.config.ts # Test configuration
|
|
535
|
+
โโโ .dumi/ # Dumi doc build cache
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
The architecture follows a **dual-layer design**:
|
|
539
|
+
|
|
540
|
+
1. **Kernel Layer** (`editor-kernel/`) - Framework-agnostic core with plugin system
|
|
541
|
+
2. **React Layer** (`react/` + `plugins/*/react/`) - React-specific implementations
|
|
542
|
+
|
|
543
|
+
Each plugin follows a consistent structure:
|
|
544
|
+
|
|
545
|
+
- **`plugin/`** - Core plugin logic and node definitions
|
|
546
|
+
- **`react/`** - React components and hooks (if applicable)
|
|
547
|
+
- **`command/`** - Editor commands and handlers
|
|
548
|
+
- **`service/`** - Services and business logic
|
|
549
|
+
- **`node/`** - Custom Lexical nodes
|
|
550
|
+
- **`utils/`** - Utility functions and helpers
|
|
551
|
+
|
|
552
|
+
This allows for maximum flexibility - you can use just the kernel for custom integrations, or the React components for rapid development.
|
|
553
|
+
|
|
554
|
+
<div align="right">
|
|
555
|
+
|
|
556
|
+
[![][back-to-top]](#readme-top)
|
|
557
|
+
|
|
558
|
+
</div>
|
|
559
|
+
|
|
560
|
+
## ๐ค Contributing
|
|
561
|
+
|
|
562
|
+
Contributions of all types are more than welcome, if you are interested in contributing code, feel free to check out our GitHub [Issues][github-issues-link] to get stuck in to show us what you're made of.
|
|
563
|
+
|
|
564
|
+
[![][pr-welcome-shield]][pr-welcome-link]
|
|
565
|
+
|
|
566
|
+
[![][github-contrib-shield]][github-contrib-link]
|
|
567
|
+
|
|
568
|
+
<div align="right">
|
|
569
|
+
|
|
570
|
+
[![][back-to-top]](#readme-top)
|
|
571
|
+
|
|
572
|
+
</div>
|
|
573
|
+
|
|
574
|
+
## ๐ Links
|
|
575
|
+
|
|
576
|
+
### More Products
|
|
577
|
+
|
|
578
|
+
- **[๐คฏ Lobe Chat](https://github.com/lobehub/lobe-chat)** - An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application.
|
|
579
|
+
- **[๐
ฐ๏ธ Lobe Theme](https://github.com/lobehub/sd-webui-lobe-theme)** - The modern theme for stable diffusion webui, exquisite interface design, highly customizable UI, and efficiency boosting features.
|
|
580
|
+
- **[๐งธ Lobe Vidol](https://github.com/lobehub/lobe-vidol)** - Experience the magic of virtual idol creation with Lobe Vidol, enjoy the elegance of our Exquisite UI Design, dance along using MMD Dance Support, and engage in Smooth Conversations.
|
|
581
|
+
|
|
582
|
+
### Design Resources
|
|
583
|
+
|
|
584
|
+
- **[๐ญ Lobe UI](https://ui.lobehub.com)** - An open-source UI component library for building AIGC web apps.
|
|
585
|
+
- **[๐ฅจ Lobe Icons](https://lobehub.com/icons)** - Popular AI / LLM Model Brand SVG Logo and Icon Collection.
|
|
586
|
+
- **[๐ Lobe Charts](https://charts.lobehub.com)** - React modern charts components built on recharts
|
|
587
|
+
|
|
588
|
+
### Development Resources
|
|
589
|
+
|
|
590
|
+
- **[๐ค Lobe TTS](https://tts.lobehub.com)** - A high-quality & reliable TTS/STT library for Server and Browser
|
|
591
|
+
- **[๐ Lobe i18n](https://github.com/lobehub/lobe-cli-toolbox/blob/master/packages/lobe-i18n)** - Automation ai tool for the i18n (internationalization) translation process.
|
|
592
|
+
|
|
593
|
+
[More Resources](https://lobehub.com/resources)
|
|
594
|
+
|
|
595
|
+
<div align="right">
|
|
596
|
+
|
|
597
|
+
[![][back-to-top]](#readme-top)
|
|
598
|
+
|
|
599
|
+
</div>
|
|
600
|
+
|
|
601
|
+
---
|
|
602
|
+
|
|
603
|
+
#### ๐ License
|
|
604
|
+
|
|
605
|
+
Copyright ยฉ 2025 [LobeHub][profile-link]. <br />
|
|
606
|
+
This project is [MIT](./LICENSE) licensed.
|
|
607
|
+
|
|
608
|
+
[back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-black?style=flat-square
|
|
609
|
+
[bun-link]: https://bun.sh
|
|
610
|
+
[bun-shield]: https://img.shields.io/badge/-speedup%20with%20bun-black?logo=bun&style=for-the-badge
|
|
611
|
+
[github-action-release-link]: https://github.com/lobehub/lobe-editor/actions/workflows/release.yml
|
|
612
|
+
[github-action-release-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-editor/release.yml?label=release&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
|
|
613
|
+
[github-action-test-link]: https://github.com/lobehub/lobe-editor/actions/workflows/test.yml
|
|
614
|
+
[github-action-test-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-editor/test.yml?label=test&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
|
|
615
|
+
[github-codespace-link]: https://codespaces.new/lobehub/lobe-editor
|
|
616
|
+
[github-codespace-shield]: https://github.com/codespaces/badge.svg
|
|
617
|
+
[github-contrib-link]: https://github.com/lobehub/lobe-editor/graphs/contributors
|
|
618
|
+
[github-contrib-shield]: https://contrib.rocks/image?repo=lobehub%2Flobe-editor
|
|
619
|
+
[github-contributors-link]: https://github.com/lobehub/lobe-editor/graphs/contributors
|
|
620
|
+
[github-contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-editor?color=c4f042&labelColor=black&style=flat-square
|
|
621
|
+
[github-forks-link]: https://github.com/lobehub/lobe-editor/network/members
|
|
622
|
+
[github-forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-editor?color=8ae8ff&labelColor=black&style=flat-square
|
|
623
|
+
[github-issues-link]: https://github.com/lobehub/lobe-editor/issues
|
|
624
|
+
[github-issues-shield]: https://img.shields.io/github/issues/lobehub/lobe-editor?color=ff80eb&labelColor=black&style=flat-square
|
|
625
|
+
[github-license-link]: https://github.com/lobehub/lobe-editor/blob/master/LICENSE
|
|
626
|
+
[github-license-shield]: https://img.shields.io/github/license/lobehub/lobe-editor?color=white&labelColor=black&style=flat-square
|
|
627
|
+
[github-releasedate-link]: https://github.com/lobehub/lobe-editor/releases
|
|
628
|
+
[github-releasedate-shield]: https://img.shields.io/github/release-date/lobehub/lobe-editor?labelColor=black&style=flat-square
|
|
629
|
+
[github-stars-link]: https://github.com/lobehub/lobe-editor/network/stargazers
|
|
630
|
+
[github-stars-shield]: https://img.shields.io/github/stars/lobehub/lobe-editor?color=ffcb47&labelColor=black&style=flat-square
|
|
631
|
+
[npm-release-link]: https://www.npmjs.com/package/@lobehub/editor
|
|
632
|
+
[npm-release-shield]: https://img.shields.io/npm/v/@lobehub/editor?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
|
633
|
+
[pr-welcome-link]: https://github.com/lobehub/lobe-editor/pulls
|
|
634
|
+
[pr-welcome-shield]: https://img.shields.io/badge/%F0%9F%A4%AF%20PR%20WELCOME-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
|
|
635
|
+
[profile-link]: https://github.com/lobehub
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export var CAN_USE_DOM = typeof window !== 'undefined' && window.document !== undefined && window.document.createElement !== undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const nodeDetect: () => boolean;
|
|
2
|
+
export declare const browserDetect: () => boolean;
|
|
3
|
+
export declare const isNode: boolean;
|
|
4
|
+
export declare const isBrowser: boolean;
|
|
5
|
+
export declare const macOSDetect: () => boolean;
|
|
6
|
+
export declare const isMac: boolean;
|
|
7
|
+
export declare const CONTROL_OR_META: {
|
|
8
|
+
ctrlKey: boolean;
|
|
9
|
+
metaKey: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const CONTROL_OR_META_AND_SHIFT: {
|
|
12
|
+
ctrlKey: boolean;
|
|
13
|
+
metaKey: boolean;
|
|
14
|
+
shiftKey: boolean;
|
|
15
|
+
};
|
|
16
|
+
export { IS_FIREFOX, IS_APPLE as isApple } from '@lexical/utils';
|
|
17
|
+
export declare const isOnServerSide: boolean;
|