@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/es/common/sys.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IS_APPLE } from '@lexical/utils';
|
|
2
|
+
export var nodeDetect = function nodeDetect() {
|
|
3
|
+
return typeof process !== 'undefined' && process.versions && !!process.versions.node;
|
|
4
|
+
};
|
|
5
|
+
export var browserDetect = function browserDetect() {
|
|
6
|
+
return typeof window !== 'undefined' && window.document !== undefined;
|
|
7
|
+
};
|
|
8
|
+
export var isNode = nodeDetect();
|
|
9
|
+
export var isBrowser = browserDetect();
|
|
10
|
+
export var macOSDetect = function macOSDetect() {
|
|
11
|
+
if (isNode) {
|
|
12
|
+
return process.platform === 'darwin';
|
|
13
|
+
}
|
|
14
|
+
if (isBrowser) {
|
|
15
|
+
return window.navigator.platform.includes('Mac');
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
export var isMac = macOSDetect();
|
|
20
|
+
export var CONTROL_OR_META = {
|
|
21
|
+
ctrlKey: !IS_APPLE,
|
|
22
|
+
metaKey: IS_APPLE
|
|
23
|
+
};
|
|
24
|
+
export var CONTROL_OR_META_AND_SHIFT = {
|
|
25
|
+
ctrlKey: !IS_APPLE,
|
|
26
|
+
metaKey: IS_APPLE,
|
|
27
|
+
shiftKey: true
|
|
28
|
+
};
|
|
29
|
+
export { IS_FIREFOX, IS_APPLE as isApple } from '@lexical/utils';
|
|
30
|
+
export var isOnServerSide = typeof window === 'undefined';
|
|
@@ -0,0 +1,30 @@
|
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
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); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
8
|
+
/* eslint-disable unused-imports/no-unused-vars */
|
|
9
|
+
var DataSource = /*#__PURE__*/function () {
|
|
10
|
+
function DataSource(dataType) {
|
|
11
|
+
_classCallCheck(this, DataSource);
|
|
12
|
+
this.dataType = dataType;
|
|
13
|
+
}
|
|
14
|
+
_createClass(DataSource, [{
|
|
15
|
+
key: "type",
|
|
16
|
+
get: function get() {
|
|
17
|
+
return this.dataType;
|
|
18
|
+
}
|
|
19
|
+
}, {
|
|
20
|
+
key: "read",
|
|
21
|
+
value: function read(editor, data) {}
|
|
22
|
+
}, {
|
|
23
|
+
key: "write",
|
|
24
|
+
value: function write(editor) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}]);
|
|
28
|
+
return DataSource;
|
|
29
|
+
}();
|
|
30
|
+
export { DataSource as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createCommand } from 'lexical';
|
|
2
|
+
export var HOVER_COMMAND = createCommand();
|
|
3
|
+
export function registerEvent(editor, dom) {
|
|
4
|
+
var hoverHandler = function hoverHandler(event) {
|
|
5
|
+
editor.dispatchCommand(HOVER_COMMAND, event);
|
|
6
|
+
};
|
|
7
|
+
dom.addEventListener('mouseenter', hoverHandler);
|
|
8
|
+
return function () {
|
|
9
|
+
dom.removeEventListener('mouseenter', hoverHandler);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IEditor } from "../types";
|
|
2
|
+
export { default as DataSource } from './data-source';
|
|
3
|
+
export * from './utils';
|
|
4
|
+
/**
|
|
5
|
+
* Editor object to create an instance of the editor
|
|
6
|
+
*/
|
|
7
|
+
declare const Editor: {
|
|
8
|
+
createEditor(): IEditor;
|
|
9
|
+
};
|
|
10
|
+
export default Editor;
|
|
11
|
+
export { HOVER_COMMAND } from './event';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Kernel } from "./kernel";
|
|
2
|
+
export { default as DataSource } from "./data-source";
|
|
3
|
+
export * from "./utils";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Editor object to create an instance of the editor
|
|
7
|
+
*/
|
|
8
|
+
var Editor = {
|
|
9
|
+
createEditor: function createEditor() {
|
|
10
|
+
return new Kernel();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default Editor;
|
|
14
|
+
export { HOVER_COMMAND } from "./event";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IElementNode } from './i-element-node';
|
|
2
|
+
import { INode } from './i-node';
|
|
3
|
+
import { IParagraphNode } from './paragraph-node';
|
|
4
|
+
import { IRootNode } from './root-node';
|
|
5
|
+
import { ITextNode } from './text-node';
|
|
6
|
+
export declare const INodeHelper: {
|
|
7
|
+
appendChild(parent: IElementNode, child: INode): void;
|
|
8
|
+
createParagraph(attrs?: Record<string, unknown>): IParagraphNode;
|
|
9
|
+
createRootNode(attrs?: Record<string, unknown>): IRootNode;
|
|
10
|
+
createTextNode(text: string, attrs?: Record<string, unknown>): ITextNode;
|
|
11
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
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 _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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
var BaseContent = {
|
|
8
|
+
direction: 'ltr',
|
|
9
|
+
format: '',
|
|
10
|
+
indent: 0,
|
|
11
|
+
version: 1
|
|
12
|
+
};
|
|
13
|
+
export var INodeHelper = {
|
|
14
|
+
appendChild: function appendChild(parent, child) {
|
|
15
|
+
if (!parent.children) {
|
|
16
|
+
parent.children = [];
|
|
17
|
+
}
|
|
18
|
+
parent.children.push(child);
|
|
19
|
+
},
|
|
20
|
+
createParagraph: function createParagraph() {
|
|
21
|
+
var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
22
|
+
return _objectSpread(_objectSpread(_objectSpread({}, BaseContent), {}, {
|
|
23
|
+
children: [],
|
|
24
|
+
textFormat: 0,
|
|
25
|
+
textStyle: ''
|
|
26
|
+
}, attrs), {}, {
|
|
27
|
+
type: 'paragraph'
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
createRootNode: function createRootNode() {
|
|
31
|
+
var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
32
|
+
return _objectSpread(_objectSpread(_objectSpread({}, BaseContent), attrs), {}, {
|
|
33
|
+
children: [],
|
|
34
|
+
type: 'root'
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
createTextNode: function createTextNode(text) {
|
|
38
|
+
var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
39
|
+
return _objectSpread(_objectSpread(_objectSpread({}, BaseContent), {}, {
|
|
40
|
+
detail: 0,
|
|
41
|
+
mode: 'normal',
|
|
42
|
+
style: ''
|
|
43
|
+
}, attrs), {}, {
|
|
44
|
+
text: text,
|
|
45
|
+
type: 'text'
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
import { CommandPayloadType, DecoratorNode, LexicalCommand, LexicalEditor, LexicalNodeConfig } from 'lexical';
|
|
3
|
+
import DataSource from './data-source';
|
|
4
|
+
import { IEditor, IEditorKernel, IEditorPluginConstructor, ILocaleKeys, IPlugin, IServiceID } from './types';
|
|
5
|
+
export declare class Kernel extends EventEmitter implements IEditorKernel {
|
|
6
|
+
private dataTypeMap;
|
|
7
|
+
private plugins;
|
|
8
|
+
private pluginsInstances;
|
|
9
|
+
private nodes;
|
|
10
|
+
private themes;
|
|
11
|
+
private decorators;
|
|
12
|
+
private serviceMap;
|
|
13
|
+
private localeMap;
|
|
14
|
+
private editor?;
|
|
15
|
+
constructor();
|
|
16
|
+
getLexicalEditor(): LexicalEditor | null;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
getRootElement(): HTMLElement | null;
|
|
19
|
+
setRootElement(dom: HTMLElement): LexicalEditor;
|
|
20
|
+
setDocument(type: string, content: any): void;
|
|
21
|
+
focus(): void;
|
|
22
|
+
blur(): void;
|
|
23
|
+
getDocument(type: string): DataSource | undefined;
|
|
24
|
+
registerDecorator(name: string, decorator: (_node: DecoratorNode<any>, _editor: LexicalEditor) => any): this;
|
|
25
|
+
getDecorator(name: string): ((_node: DecoratorNode<any>, _editor: LexicalEditor) => any) | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Support registering target data source
|
|
28
|
+
* @param dataSource Data source
|
|
29
|
+
*/
|
|
30
|
+
registerDataSource(dataSource: DataSource): void;
|
|
31
|
+
registerThemes(themes: Record<string, any>): void;
|
|
32
|
+
registerPlugin<T>(plugin: IEditorPluginConstructor<T>, config?: T): IEditor;
|
|
33
|
+
registerPlugins(plugins: Array<IPlugin>): IEditor;
|
|
34
|
+
registerNodes(nodes: Array<LexicalNodeConfig>): void;
|
|
35
|
+
registerService<T>(serviceId: IServiceID<T>, service: T): void;
|
|
36
|
+
/**
|
|
37
|
+
* Get service
|
|
38
|
+
* @param serviceId Service ID
|
|
39
|
+
*/
|
|
40
|
+
requireService<T>(serviceId: IServiceID<T>): T | null;
|
|
41
|
+
dispatchCommand<TCommand extends LexicalCommand<unknown>>(type: TCommand, payload: CommandPayloadType<TCommand>): boolean;
|
|
42
|
+
getTheme(): Record<string, any>;
|
|
43
|
+
updateTheme(key: string, value: string | Record<string, string>): void;
|
|
44
|
+
registerLocale(locale: Partial<Record<keyof ILocaleKeys, string>>): void;
|
|
45
|
+
t<K extends keyof ILocaleKeys>(key: K, params?: Record<string, any>): string;
|
|
46
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
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."); }
|
|
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
|
+
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); } }
|
|
11
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
12
|
+
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); }
|
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
|
+
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); }; }
|
|
15
|
+
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); }
|
|
16
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
17
|
+
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; } }
|
|
18
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
21
|
+
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); }
|
|
22
|
+
import EventEmitter from 'eventemitter3';
|
|
23
|
+
import { createEditor } from 'lexical';
|
|
24
|
+
import { get, merge, template, templateSettings } from 'lodash-es';
|
|
25
|
+
import defaultLocale from "../locale";
|
|
26
|
+
import { registerEvent } from "./event";
|
|
27
|
+
import { createEmptyEditorState } from "./utils";
|
|
28
|
+
templateSettings.interpolate = /{{([\S\s]+?)}}/g;
|
|
29
|
+
export var Kernel = /*#__PURE__*/function (_EventEmitter) {
|
|
30
|
+
_inherits(Kernel, _EventEmitter);
|
|
31
|
+
var _super = _createSuper(Kernel);
|
|
32
|
+
function Kernel() {
|
|
33
|
+
var _this;
|
|
34
|
+
_classCallCheck(this, Kernel);
|
|
35
|
+
_this = _super.call(this);
|
|
36
|
+
_defineProperty(_assertThisInitialized(_this), "dataTypeMap", void 0);
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "plugins", []);
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "pluginsInstances", []);
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "nodes", []);
|
|
40
|
+
_defineProperty(_assertThisInitialized(_this), "themes", {});
|
|
41
|
+
// Used to store theme configuration
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "decorators", {});
|
|
43
|
+
_defineProperty(_assertThisInitialized(_this), "serviceMap", new Map());
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "localeMap", defaultLocale);
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "editor", void 0);
|
|
46
|
+
_this.dataTypeMap = new Map();
|
|
47
|
+
return _this;
|
|
48
|
+
}
|
|
49
|
+
_createClass(Kernel, [{
|
|
50
|
+
key: "getLexicalEditor",
|
|
51
|
+
value: function getLexicalEditor() {
|
|
52
|
+
return this.editor || null;
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "destroy",
|
|
56
|
+
value: function destroy() {
|
|
57
|
+
var _this$editor;
|
|
58
|
+
(_this$editor = this.editor) === null || _this$editor === void 0 || _this$editor.setEditorState(createEmptyEditorState());
|
|
59
|
+
this.dataTypeMap.clear();
|
|
60
|
+
this.pluginsInstances.forEach(function (plugin) {
|
|
61
|
+
if (plugin.destroy) {
|
|
62
|
+
plugin.destroy();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
this.pluginsInstances = [];
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "getRootElement",
|
|
69
|
+
value: function getRootElement() {
|
|
70
|
+
var _this$editor2;
|
|
71
|
+
return ((_this$editor2 = this.editor) === null || _this$editor2 === void 0 ? void 0 : _this$editor2.getRootElement()) || null;
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "setRootElement",
|
|
75
|
+
value: function setRootElement(dom) {
|
|
76
|
+
var _this2 = this;
|
|
77
|
+
var _iterator = _createForOfIteratorHelper(this.plugins),
|
|
78
|
+
_step;
|
|
79
|
+
try {
|
|
80
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
81
|
+
var plugin = _step.value;
|
|
82
|
+
var instance = new plugin(this, plugin.__config);
|
|
83
|
+
this.pluginsInstances.push(instance);
|
|
84
|
+
}
|
|
85
|
+
} catch (err) {
|
|
86
|
+
_iterator.e(err);
|
|
87
|
+
} finally {
|
|
88
|
+
_iterator.f();
|
|
89
|
+
}
|
|
90
|
+
var editor = this.editor = createEditor({
|
|
91
|
+
// @ts-expect-error Inject into lexical editor instance
|
|
92
|
+
__kernel: this,
|
|
93
|
+
nodes: this.nodes,
|
|
94
|
+
onError: function onError(error) {
|
|
95
|
+
_this2.emit('error', error);
|
|
96
|
+
},
|
|
97
|
+
theme: this.themes
|
|
98
|
+
});
|
|
99
|
+
this.editor.setRootElement(dom);
|
|
100
|
+
registerEvent(editor, dom);
|
|
101
|
+
this.pluginsInstances.forEach(function (plugin) {
|
|
102
|
+
var _plugin$onInit;
|
|
103
|
+
(_plugin$onInit = plugin.onInit) === null || _plugin$onInit === void 0 || _plugin$onInit.call(plugin, editor);
|
|
104
|
+
});
|
|
105
|
+
this.emit('initialized', editor);
|
|
106
|
+
return this.editor;
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "setDocument",
|
|
110
|
+
value: function setDocument(type, content) {
|
|
111
|
+
var datasource = this.dataTypeMap.get(type);
|
|
112
|
+
if (!datasource) {
|
|
113
|
+
throw new Error("DataSource for type \"".concat(type, "\" is not registered."));
|
|
114
|
+
}
|
|
115
|
+
if (!this.editor) {
|
|
116
|
+
throw new Error("Editor is not initialized.");
|
|
117
|
+
}
|
|
118
|
+
datasource.read(this.editor, content);
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "focus",
|
|
122
|
+
value: function focus() {
|
|
123
|
+
var _this$editor3;
|
|
124
|
+
(_this$editor3 = this.editor) === null || _this$editor3 === void 0 || _this$editor3.focus();
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "blur",
|
|
128
|
+
value: function blur() {
|
|
129
|
+
var _this$editor4;
|
|
130
|
+
(_this$editor4 = this.editor) === null || _this$editor4 === void 0 || _this$editor4.blur();
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "getDocument",
|
|
134
|
+
value: function getDocument(type) {
|
|
135
|
+
var datasource = this.dataTypeMap.get(type);
|
|
136
|
+
if (!datasource) {
|
|
137
|
+
throw new Error("DataSource for type \"".concat(type, "\" is not registered."));
|
|
138
|
+
}
|
|
139
|
+
if (!this.editor) {
|
|
140
|
+
throw new Error("Editor is not initialized.");
|
|
141
|
+
}
|
|
142
|
+
return datasource.write(this.editor);
|
|
143
|
+
}
|
|
144
|
+
}, {
|
|
145
|
+
key: "registerDecorator",
|
|
146
|
+
value: function registerDecorator(name, decorator) {
|
|
147
|
+
this.decorators[name] = decorator;
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "getDecorator",
|
|
152
|
+
value: function getDecorator(name) {
|
|
153
|
+
return this.decorators[name];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Support registering target data source
|
|
158
|
+
* @param dataSource Data source
|
|
159
|
+
*/
|
|
160
|
+
}, {
|
|
161
|
+
key: "registerDataSource",
|
|
162
|
+
value: function registerDataSource(dataSource) {
|
|
163
|
+
this.dataTypeMap.set(dataSource.type, dataSource);
|
|
164
|
+
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "registerThemes",
|
|
167
|
+
value: function registerThemes(themes) {
|
|
168
|
+
this.themes = merge(this.themes, themes);
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
key: "registerPlugin",
|
|
172
|
+
value: function registerPlugin(plugin, config) {
|
|
173
|
+
var findPlugin = this.plugins.find(function (p) {
|
|
174
|
+
return p.pluginName === plugin.pluginName;
|
|
175
|
+
});
|
|
176
|
+
if (findPlugin) {
|
|
177
|
+
// Error if same name but different plugin
|
|
178
|
+
if (findPlugin !== plugin) {
|
|
179
|
+
throw new Error("Plugin with name \"".concat(plugin.pluginName, "\" is already registered with a different implementation."));
|
|
180
|
+
}
|
|
181
|
+
return this; // If plugin already exists, don't register again
|
|
182
|
+
}
|
|
183
|
+
// @ts-expect-error not error
|
|
184
|
+
plugin.__config = config || {};
|
|
185
|
+
// @ts-expect-error not error
|
|
186
|
+
this.plugins.push(plugin);
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
}, {
|
|
190
|
+
key: "registerPlugins",
|
|
191
|
+
value: function registerPlugins(plugins) {
|
|
192
|
+
var _iterator2 = _createForOfIteratorHelper(plugins),
|
|
193
|
+
_step2;
|
|
194
|
+
try {
|
|
195
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
196
|
+
var plugin = _step2.value;
|
|
197
|
+
if (Array.isArray(plugin)) {
|
|
198
|
+
this.registerPlugin(plugin[0], plugin[1]);
|
|
199
|
+
} else {
|
|
200
|
+
this.registerPlugin(plugin);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
} catch (err) {
|
|
204
|
+
_iterator2.e(err);
|
|
205
|
+
} finally {
|
|
206
|
+
_iterator2.f();
|
|
207
|
+
}
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
key: "registerNodes",
|
|
212
|
+
value: function registerNodes(nodes) {
|
|
213
|
+
var _this$nodes;
|
|
214
|
+
(_this$nodes = this.nodes).push.apply(_this$nodes, _toConsumableArray(nodes));
|
|
215
|
+
}
|
|
216
|
+
}, {
|
|
217
|
+
key: "registerService",
|
|
218
|
+
value: function registerService(serviceId, service) {
|
|
219
|
+
if (this.serviceMap.has(serviceId.__serviceId)) {
|
|
220
|
+
throw new Error("Service with ID \"".concat(serviceId.__serviceId, "\" is already registered."));
|
|
221
|
+
}
|
|
222
|
+
this.serviceMap.set(serviceId.__serviceId, service);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Get service
|
|
227
|
+
* @param serviceId Service ID
|
|
228
|
+
*/
|
|
229
|
+
}, {
|
|
230
|
+
key: "requireService",
|
|
231
|
+
value: function requireService(serviceId) {
|
|
232
|
+
var service = this.serviceMap.get(serviceId.__serviceId);
|
|
233
|
+
if (!service) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
return service;
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
key: "dispatchCommand",
|
|
240
|
+
value: function dispatchCommand(type, payload) {
|
|
241
|
+
if (!this.editor) {
|
|
242
|
+
throw new Error('Editor is not initialized.');
|
|
243
|
+
}
|
|
244
|
+
return this.editor.dispatchCommand(type, payload);
|
|
245
|
+
}
|
|
246
|
+
}, {
|
|
247
|
+
key: "getTheme",
|
|
248
|
+
value: function getTheme() {
|
|
249
|
+
return this.themes;
|
|
250
|
+
}
|
|
251
|
+
}, {
|
|
252
|
+
key: "updateTheme",
|
|
253
|
+
value: function updateTheme(key, value) {
|
|
254
|
+
this.themes[key] = value;
|
|
255
|
+
}
|
|
256
|
+
}, {
|
|
257
|
+
key: "registerLocale",
|
|
258
|
+
value: function registerLocale(locale) {
|
|
259
|
+
this.localeMap = merge(this.localeMap, locale);
|
|
260
|
+
}
|
|
261
|
+
}, {
|
|
262
|
+
key: "t",
|
|
263
|
+
value: function t(key, params) {
|
|
264
|
+
var translation = get(this.localeMap, key) || key;
|
|
265
|
+
if (params) {
|
|
266
|
+
var compiled = template(translation);
|
|
267
|
+
translation = compiled(params);
|
|
268
|
+
}
|
|
269
|
+
return translation;
|
|
270
|
+
}
|
|
271
|
+
}]);
|
|
272
|
+
return Kernel;
|
|
273
|
+
}(EventEmitter);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
export declare abstract class KernelPlugin extends EventEmitter {
|
|
3
|
+
protected clears: Array<() => void>;
|
|
4
|
+
protected register(clear: () => void): void;
|
|
5
|
+
protected registerClears(...clears: Array<() => void>): void;
|
|
6
|
+
destroy(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
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); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
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); }
|
|
6
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
7
|
+
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); }; }
|
|
8
|
+
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); }
|
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10
|
+
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; } }
|
|
11
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
12
|
+
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; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
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); }
|
|
15
|
+
import EventEmitter from 'eventemitter3';
|
|
16
|
+
export var KernelPlugin = /*#__PURE__*/function (_EventEmitter) {
|
|
17
|
+
_inherits(KernelPlugin, _EventEmitter);
|
|
18
|
+
var _super = _createSuper(KernelPlugin);
|
|
19
|
+
function KernelPlugin() {
|
|
20
|
+
var _this;
|
|
21
|
+
_classCallCheck(this, KernelPlugin);
|
|
22
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
23
|
+
args[_key] = arguments[_key];
|
|
24
|
+
}
|
|
25
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
26
|
+
_defineProperty(_assertThisInitialized(_this), "clears", []);
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
_createClass(KernelPlugin, [{
|
|
30
|
+
key: "register",
|
|
31
|
+
value: function register(clear) {
|
|
32
|
+
this.clears.push(clear);
|
|
33
|
+
}
|
|
34
|
+
}, {
|
|
35
|
+
key: "registerClears",
|
|
36
|
+
value: function registerClears() {
|
|
37
|
+
var _this2 = this;
|
|
38
|
+
for (var _len2 = arguments.length, clears = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
39
|
+
clears[_key2] = arguments[_key2];
|
|
40
|
+
}
|
|
41
|
+
clears.forEach(function (clear) {
|
|
42
|
+
return _this2.register(clear);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "destroy",
|
|
47
|
+
value: function destroy() {
|
|
48
|
+
this.clears.forEach(function (clear) {
|
|
49
|
+
return clear();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}]);
|
|
53
|
+
return KernelPlugin;
|
|
54
|
+
}(EventEmitter);
|