@lobehub/editor 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +635 -0
- package/es/common/canUseDOM.d.ts +8 -0
- package/es/common/canUseDOM.js +9 -0
- package/es/common/sys.d.ts +17 -0
- package/es/common/sys.js +30 -0
- package/es/editor-kernel/data-source.d.ts +8 -0
- package/es/editor-kernel/data-source.js +30 -0
- package/es/editor-kernel/event.d.ts +3 -0
- package/es/editor-kernel/event.js +11 -0
- package/es/editor-kernel/index.d.ts +11 -0
- package/es/editor-kernel/index.js +14 -0
- package/es/editor-kernel/inode/helper.d.ts +11 -0
- package/es/editor-kernel/inode/helper.js +48 -0
- package/es/editor-kernel/inode/i-element-node.d.ts +5 -0
- package/es/editor-kernel/inode/i-element-node.js +1 -0
- package/es/editor-kernel/inode/i-node.d.ts +6 -0
- package/es/editor-kernel/inode/i-node.js +1 -0
- package/es/editor-kernel/inode/index.d.ts +5 -0
- package/es/editor-kernel/inode/index.js +5 -0
- package/es/editor-kernel/inode/paragraph-node.d.ts +6 -0
- package/es/editor-kernel/inode/paragraph-node.js +1 -0
- package/es/editor-kernel/inode/root-node.d.ts +7 -0
- package/es/editor-kernel/inode/root-node.js +1 -0
- package/es/editor-kernel/inode/text-node.d.ts +12 -0
- package/es/editor-kernel/inode/text-node.js +1 -0
- package/es/editor-kernel/kernel.d.ts +46 -0
- package/es/editor-kernel/kernel.js +273 -0
- package/es/editor-kernel/plugin.d.ts +7 -0
- package/es/editor-kernel/plugin.js +54 -0
- package/es/editor-kernel/react/LexicalErrorBoundary.d.ts +13 -0
- package/es/editor-kernel/react/LexicalErrorBoundary.js +26 -0
- package/es/editor-kernel/react/index.d.ts +5 -0
- package/es/editor-kernel/react/index.js +5 -0
- package/es/editor-kernel/react/react-context.d.ts +10 -0
- package/es/editor-kernel/react/react-context.js +25 -0
- package/es/editor-kernel/react/react-editor.d.ts +12 -0
- package/es/editor-kernel/react/react-editor.js +57 -0
- package/es/editor-kernel/react/useDecorators.d.ts +9 -0
- package/es/editor-kernel/react/useDecorators.js +69 -0
- package/es/editor-kernel/react/useLexicalEditor.d.ts +2 -0
- package/es/editor-kernel/react/useLexicalEditor.js +31 -0
- package/es/editor-kernel/react/useLexicalNodeSelection.d.ts +17 -0
- package/es/editor-kernel/react/useLexicalNodeSelection.js +99 -0
- package/es/editor-kernel/react/useToolbarState.d.ts +31 -0
- package/es/editor-kernel/react/useToolbarState.js +302 -0
- package/es/editor-kernel/react/useTranslation.d.ts +3 -0
- package/es/editor-kernel/react/useTranslation.js +19 -0
- package/es/editor-kernel/types.d.ts +189 -0
- package/es/editor-kernel/types.js +1 -0
- package/es/editor-kernel/utils.d.ts +25 -0
- package/es/editor-kernel/utils.js +69 -0
- package/es/index.d.ts +14 -0
- package/es/index.js +14 -0
- package/es/locale/index.d.ts +25 -0
- package/es/locale/index.js +24 -0
- package/es/plugins/codeblock/command/index.d.ts +20 -0
- package/es/plugins/codeblock/command/index.js +84 -0
- package/es/plugins/codeblock/index.d.ts +4 -0
- package/es/plugins/codeblock/index.js +4 -0
- package/es/plugins/codeblock/plugin/CodeHighlighterShiki.d.ts +24 -0
- package/es/plugins/codeblock/plugin/CodeHighlighterShiki.js +680 -0
- package/es/plugins/codeblock/plugin/FacadeShiki.d.ts +51 -0
- package/es/plugins/codeblock/plugin/FacadeShiki.js +348 -0
- package/es/plugins/codeblock/plugin/index.d.ts +18 -0
- package/es/plugins/codeblock/plugin/index.js +90 -0
- package/es/plugins/codeblock/plugin/invariant.d.ts +8 -0
- package/es/plugins/codeblock/plugin/invariant.js +17 -0
- package/es/plugins/codeblock/react/ReactCodeblockPlugin.d.ts +4 -0
- package/es/plugins/codeblock/react/ReactCodeblockPlugin.js +51 -0
- package/es/plugins/codeblock/react/index.d.ts +2 -0
- package/es/plugins/codeblock/react/index.js +1 -0
- package/es/plugins/codeblock/react/style.d.ts +6 -0
- package/es/plugins/codeblock/react/style.js +38 -0
- package/es/plugins/codeblock/react/type.d.ts +5 -0
- package/es/plugins/codeblock/react/type.js +1 -0
- package/es/plugins/codeblock/utils/language.d.ts +1 -0
- package/es/plugins/codeblock/utils/language.js +12 -0
- package/es/plugins/common/command/index.d.ts +7 -0
- package/es/plugins/common/command/index.js +31 -0
- package/es/plugins/common/data-source/json-data-source.d.ts +7 -0
- package/es/plugins/common/data-source/json-data-source.js +39 -0
- package/es/plugins/common/data-source/text-data-source.d.ts +6 -0
- package/es/plugins/common/data-source/text-data-source.js +54 -0
- package/es/plugins/common/index.d.ts +3 -0
- package/es/plugins/common/index.js +3 -0
- package/es/plugins/common/node/ElementDOMSlot.d.ts +5 -0
- package/es/plugins/common/node/ElementDOMSlot.js +59 -0
- package/es/plugins/common/node/LexicalLineBreakNode.d.ts +31 -0
- package/es/plugins/common/node/LexicalLineBreakNode.js +140 -0
- package/es/plugins/common/node/ParagraphNode.d.ts +7 -0
- package/es/plugins/common/node/ParagraphNode.js +47 -0
- package/es/plugins/common/plugin/index.d.ts +16 -0
- package/es/plugins/common/plugin/index.js +245 -0
- package/es/plugins/common/plugin/register.d.ts +4 -0
- package/es/plugins/common/plugin/register.js +230 -0
- package/es/plugins/common/react/Placeholder/index.d.ts +7 -0
- package/es/plugins/common/react/Placeholder/index.js +53 -0
- package/es/plugins/common/react/Placeholder/style.d.ts +4 -0
- package/es/plugins/common/react/Placeholder/style.js +12 -0
- package/es/plugins/common/react/ReactEditorContent.d.ts +4 -0
- package/es/plugins/common/react/ReactEditorContent.js +7 -0
- package/es/plugins/common/react/ReactPlainText.d.ts +4 -0
- package/es/plugins/common/react/ReactPlainText.js +100 -0
- package/es/plugins/common/react/index.d.ts +3 -0
- package/es/plugins/common/react/index.js +3 -0
- package/es/plugins/common/react/style.d.ts +18 -0
- package/es/plugins/common/react/style.js +38 -0
- package/es/plugins/common/react/type.d.ts +21 -0
- package/es/plugins/common/react/type.js +1 -0
- package/es/plugins/common/utils/index.d.ts +28 -0
- package/es/plugins/common/utils/index.js +96 -0
- package/es/plugins/file/command/index.d.ts +7 -0
- package/es/plugins/file/command/index.js +28 -0
- package/es/plugins/file/index.d.ts +3 -0
- package/es/plugins/file/index.js +3 -0
- package/es/plugins/file/node/FileNode.d.ts +36 -0
- package/es/plugins/file/node/FileNode.js +177 -0
- package/es/plugins/file/plugin/index.d.ts +14 -0
- package/es/plugins/file/plugin/index.js +116 -0
- package/es/plugins/file/react/ReactFilePlugin.d.ts +4 -0
- package/es/plugins/file/react/ReactFilePlugin.js +74 -0
- package/es/plugins/file/react/components/ReactFile.d.ts +10 -0
- package/es/plugins/file/react/components/ReactFile.js +65 -0
- package/es/plugins/file/react/index.d.ts +2 -0
- package/es/plugins/file/react/index.js +1 -0
- package/es/plugins/file/react/style.d.ts +3 -0
- package/es/plugins/file/react/style.js +11 -0
- package/es/plugins/file/react/type.d.ts +13 -0
- package/es/plugins/file/react/type.js +1 -0
- package/es/plugins/file/utils/index.d.ts +2 -0
- package/es/plugins/file/utils/index.js +45 -0
- package/es/plugins/hr/command/index.d.ts +3 -0
- package/es/plugins/hr/command/index.js +13 -0
- package/es/plugins/hr/index.d.ts +3 -0
- package/es/plugins/hr/index.js +3 -0
- package/es/plugins/hr/node/HorizontalRuleNode.d.ts +16 -0
- package/es/plugins/hr/node/HorizontalRuleNode.js +100 -0
- package/es/plugins/hr/plugin/index.d.ts +8 -0
- package/es/plugins/hr/plugin/index.js +70 -0
- package/es/plugins/hr/react/ReactHRPlugin.d.ts +4 -0
- package/es/plugins/hr/react/ReactHRPlugin.js +36 -0
- package/es/plugins/hr/react/components/HRNode.d.ts +10 -0
- package/es/plugins/hr/react/components/HRNode.js +45 -0
- package/es/plugins/hr/react/index.d.ts +2 -0
- package/es/plugins/hr/react/index.js +1 -0
- package/es/plugins/hr/react/style.d.ts +1 -0
- package/es/plugins/hr/react/style.js +8 -0
- package/es/plugins/hr/react/type.d.ts +3 -0
- package/es/plugins/hr/react/type.js +1 -0
- package/es/plugins/image/command/index.d.ts +8 -0
- package/es/plugins/image/command/index.js +46 -0
- package/es/plugins/image/index.d.ts +3 -0
- package/es/plugins/image/index.js +3 -0
- package/es/plugins/image/node/basie-image-node.d.ts +44 -0
- package/es/plugins/image/node/basie-image-node.js +151 -0
- package/es/plugins/image/node/image-node.d.ts +26 -0
- package/es/plugins/image/node/image-node.js +176 -0
- package/es/plugins/image/plugin/index.d.ts +13 -0
- package/es/plugins/image/plugin/index.js +74 -0
- package/es/plugins/image/react/ReactImagePlugin.d.ts +4 -0
- package/es/plugins/image/react/ReactImagePlugin.js +48 -0
- package/es/plugins/image/react/components/BrokenImage.d.ts +3 -0
- package/es/plugins/image/react/components/BrokenImage.js +18 -0
- package/es/plugins/image/react/components/Image.d.ts +7 -0
- package/es/plugins/image/react/components/Image.js +71 -0
- package/es/plugins/image/react/components/LazyImage.d.ts +8 -0
- package/es/plugins/image/react/components/LazyImage.js +99 -0
- package/es/plugins/image/react/components/useSupenseImage.d.ts +2 -0
- package/es/plugins/image/react/components/useSupenseImage.js +24 -0
- package/es/plugins/image/react/index.d.ts +2 -0
- package/es/plugins/image/react/index.js +1 -0
- package/es/plugins/image/react/style.d.ts +12 -0
- package/es/plugins/image/react/style.js +17 -0
- package/es/plugins/image/react/type.d.ts +6 -0
- package/es/plugins/image/react/type.js +1 -0
- package/es/plugins/link/command/index.d.ts +6 -0
- package/es/plugins/link/command/index.js +20 -0
- package/es/plugins/link/index.d.ts +3 -0
- package/es/plugins/link/index.js +3 -0
- package/es/plugins/link/node/LinkNode.d.ts +126 -0
- package/es/plugins/link/node/LinkNode.js +721 -0
- package/es/plugins/link/plugin/index.d.ts +8 -0
- package/es/plugins/link/plugin/index.js +94 -0
- package/es/plugins/link/react/ReactLinkPlugin.d.ts +4 -0
- package/es/plugins/link/react/ReactLinkPlugin.js +168 -0
- package/es/plugins/link/react/components/LinkEdit.d.ts +7 -0
- package/es/plugins/link/react/components/LinkEdit.js +138 -0
- package/es/plugins/link/react/components/Toolbar.d.ts +7 -0
- package/es/plugins/link/react/components/Toolbar.js +63 -0
- package/es/plugins/link/react/index.d.ts +2 -0
- package/es/plugins/link/react/index.js +1 -0
- package/es/plugins/link/react/style.d.ts +5 -0
- package/es/plugins/link/react/style.js +12 -0
- package/es/plugins/link/react/type.d.ts +9 -0
- package/es/plugins/link/react/type.js +1 -0
- package/es/plugins/link/utils/index.d.ts +4 -0
- package/es/plugins/link/utils/index.js +37 -0
- package/es/plugins/list/command/index.d.ts +1 -0
- package/es/plugins/list/command/index.js +1 -0
- package/es/plugins/list/index.d.ts +3 -0
- package/es/plugins/list/index.js +3 -0
- package/es/plugins/list/plugin/index.d.ts +5 -0
- package/es/plugins/list/plugin/index.js +193 -0
- package/es/plugins/list/react/ReactListPlugin.d.ts +4 -0
- package/es/plugins/list/react/ReactListPlugin.js +29 -0
- package/es/plugins/list/react/index.d.ts +2 -0
- package/es/plugins/list/react/index.js +1 -0
- package/es/plugins/list/react/style.d.ts +1 -0
- package/es/plugins/list/react/style.js +7 -0
- package/es/plugins/list/react/type.d.ts +3 -0
- package/es/plugins/list/react/type.js +1 -0
- package/es/plugins/list/utils/index.d.ts +5 -0
- package/es/plugins/list/utils/index.js +88 -0
- package/es/plugins/markdown/data-source/markdown-data-source.d.ts +10 -0
- package/es/plugins/markdown/data-source/markdown-data-source.js +64 -0
- package/es/plugins/markdown/data-source/markdown-writer-context.d.ts +12 -0
- package/es/plugins/markdown/data-source/markdown-writer-context.js +51 -0
- package/es/plugins/markdown/index.d.ts +2 -0
- package/es/plugins/markdown/index.js +2 -0
- package/es/plugins/markdown/plugin/index.d.ts +4 -0
- package/es/plugins/markdown/plugin/index.js +122 -0
- package/es/plugins/markdown/service/shortcut.d.ts +139 -0
- package/es/plugins/markdown/service/shortcut.js +401 -0
- package/es/plugins/markdown/utils/index.d.ts +12 -0
- package/es/plugins/markdown/utils/index.js +61 -0
- package/es/plugins/mention/command/index.d.ts +6 -0
- package/es/plugins/mention/command/index.js +19 -0
- package/es/plugins/mention/index.d.ts +3 -0
- package/es/plugins/mention/index.js +3 -0
- package/es/plugins/mention/node/MentionNode.d.ts +26 -0
- package/es/plugins/mention/node/MentionNode.js +143 -0
- package/es/plugins/mention/plugin/index.d.ts +11 -0
- package/es/plugins/mention/plugin/index.js +61 -0
- package/es/plugins/mention/plugin/register.d.ts +2 -0
- package/es/plugins/mention/plugin/register.js +46 -0
- package/es/plugins/mention/react/ReactMentionPlugin.d.ts +4 -0
- package/es/plugins/mention/react/ReactMentionPlugin.js +42 -0
- package/es/plugins/mention/react/components/Mention.d.ts +9 -0
- package/es/plugins/mention/react/components/Mention.js +39 -0
- package/es/plugins/mention/react/index.d.ts +2 -0
- package/es/plugins/mention/react/index.js +1 -0
- package/es/plugins/mention/react/style.d.ts +3 -0
- package/es/plugins/mention/react/style.js +11 -0
- package/es/plugins/mention/react/type.d.ts +8 -0
- package/es/plugins/mention/react/type.js +1 -0
- package/es/plugins/slash/index.d.ts +3 -0
- package/es/plugins/slash/index.js +3 -0
- package/es/plugins/slash/plugin/index.d.ts +23 -0
- package/es/plugins/slash/plugin/index.js +132 -0
- package/es/plugins/slash/react/ReactSlashOption.d.ts +4 -0
- package/es/plugins/slash/react/ReactSlashOption.js +7 -0
- package/es/plugins/slash/react/ReactSlashPlugin.d.ts +4 -0
- package/es/plugins/slash/react/ReactSlashPlugin.js +228 -0
- package/es/plugins/slash/react/components/SlashMenu.d.ts +8 -0
- package/es/plugins/slash/react/components/SlashMenu.js +72 -0
- package/es/plugins/slash/react/index.d.ts +4 -0
- package/es/plugins/slash/react/index.js +3 -0
- package/es/plugins/slash/react/style.d.ts +1 -0
- package/es/plugins/slash/react/style.js +9 -0
- package/es/plugins/slash/react/type.d.ts +82 -0
- package/es/plugins/slash/react/type.js +1 -0
- package/es/plugins/slash/react/utils.d.ts +5 -0
- package/es/plugins/slash/react/utils.js +20 -0
- package/es/plugins/slash/service/i-slash-service.d.ts +38 -0
- package/es/plugins/slash/service/i-slash-service.js +64 -0
- package/es/plugins/slash/utils/utils.d.ts +38 -0
- package/es/plugins/slash/utils/utils.js +192 -0
- package/es/plugins/table/command/index.d.ts +13 -0
- package/es/plugins/table/command/index.js +73 -0
- package/es/plugins/table/index.d.ts +3 -0
- package/es/plugins/table/index.js +3 -0
- package/es/plugins/table/node/index.d.ts +2 -0
- package/es/plugins/table/node/index.js +16 -0
- package/es/plugins/table/plugin/index.d.ts +5 -0
- package/es/plugins/table/plugin/index.js +85 -0
- package/es/plugins/table/react/TableActionMenu/index.d.ts +8 -0
- package/es/plugins/table/react/TableActionMenu/index.js +481 -0
- package/es/plugins/table/react/TableActionMenu/style.d.ts +1 -0
- package/es/plugins/table/react/TableActionMenu/style.js +7 -0
- package/es/plugins/table/react/TableActionMenu/utils.d.ts +9 -0
- package/es/plugins/table/react/TableActionMenu/utils.js +49 -0
- package/es/plugins/table/react/TableHoverActions/index.d.ts +7 -0
- package/es/plugins/table/react/TableHoverActions/index.js +268 -0
- package/es/plugins/table/react/TableHoverActions/style.d.ts +5 -0
- package/es/plugins/table/react/TableHoverActions/style.js +11 -0
- package/es/plugins/table/react/TableHoverActions/utils.d.ts +8 -0
- package/es/plugins/table/react/TableHoverActions/utils.js +43 -0
- package/es/plugins/table/react/TableResize/index.d.ts +10 -0
- package/es/plugins/table/react/TableResize/index.js +378 -0
- package/es/plugins/table/react/TableResize/style.d.ts +3 -0
- package/es/plugins/table/react/TableResize/style.js +10 -0
- package/es/plugins/table/react/TableResize/utils.d.ts +4 -0
- package/es/plugins/table/react/TableResize/utils.js +40 -0
- package/es/plugins/table/react/hooks.d.ts +1 -0
- package/es/plugins/table/react/hooks.js +22 -0
- package/es/plugins/table/react/index.d.ts +3 -0
- package/es/plugins/table/react/index.js +77 -0
- package/es/plugins/table/react/style.d.ts +1 -0
- package/es/plugins/table/react/style.js +8 -0
- package/es/plugins/table/react/type.d.ts +5 -0
- package/es/plugins/table/react/type.js +1 -0
- package/es/plugins/table/utils/index.d.ts +8 -0
- package/es/plugins/table/utils/index.js +83 -0
- package/es/plugins/upload/index.d.ts +3 -0
- package/es/plugins/upload/index.js +3 -0
- package/es/plugins/upload/plugin/index.d.ts +4 -0
- package/es/plugins/upload/plugin/index.js +82 -0
- package/es/plugins/upload/service/i-upload-service.d.ts +15 -0
- package/es/plugins/upload/service/i-upload-service.js +115 -0
- package/es/plugins/upload/utils/index.d.ts +1 -0
- package/es/plugins/upload/utils/index.js +20 -0
- package/es/react/ChatInput/ChatInput.d.ts +4 -0
- package/es/react/ChatInput/ChatInput.js +41 -0
- package/es/react/ChatInput/index.d.ts +2 -0
- package/es/react/ChatInput/index.js +2 -0
- package/es/react/ChatInput/style.d.ts +4 -0
- package/es/react/ChatInput/style.js +11 -0
- package/es/react/ChatInput/type.d.ts +10 -0
- package/es/react/ChatInput/type.js +1 -0
- package/es/react/ChatInputActionBar/ChatInputActionBar.d.ts +4 -0
- package/es/react/ChatInputActionBar/ChatInputActionBar.js +27 -0
- package/es/react/ChatInputActionBar/index.d.ts +2 -0
- package/es/react/ChatInputActionBar/index.js +2 -0
- package/es/react/ChatInputActionBar/style.d.ts +3 -0
- package/es/react/ChatInputActionBar/style.js +9 -0
- package/es/react/ChatInputActionBar/type.d.ts +7 -0
- package/es/react/ChatInputActionBar/type.js +1 -0
- package/es/react/ChatInputActions/ChatInputActions.d.ts +4 -0
- package/es/react/ChatInputActions/ChatInputActions.js +187 -0
- package/es/react/ChatInputActions/components/ChatInputActionsCollapse.d.ts +4 -0
- package/es/react/ChatInputActions/components/ChatInputActionsCollapse.js +97 -0
- package/es/react/ChatInputActions/index.d.ts +2 -0
- package/es/react/ChatInputActions/index.js +1 -0
- package/es/react/ChatInputActions/style.d.ts +4 -0
- package/es/react/ChatInputActions/style.js +10 -0
- package/es/react/ChatInputActions/type.d.ts +38 -0
- package/es/react/ChatInputActions/type.js +1 -0
- package/es/react/CodeLanguageSelect/CodeLanguageSelect.d.ts +4 -0
- package/es/react/CodeLanguageSelect/CodeLanguageSelect.js +96 -0
- package/es/react/CodeLanguageSelect/index.d.ts +2 -0
- package/es/react/CodeLanguageSelect/index.js +2 -0
- package/es/react/CodeLanguageSelect/style.d.ts +3 -0
- package/es/react/CodeLanguageSelect/style.js +9 -0
- package/es/react/CodeLanguageSelect/type.d.ts +2 -0
- package/es/react/CodeLanguageSelect/type.js +1 -0
- package/es/react/Editor/Editor.d.ts +4 -0
- package/es/react/Editor/Editor.js +78 -0
- package/es/react/Editor/index.d.ts +14 -0
- package/es/react/Editor/index.js +10 -0
- package/es/react/Editor/type.d.ts +24 -0
- package/es/react/Editor/type.js +1 -0
- package/es/react/Editor/useEditor.d.ts +3 -0
- package/es/react/Editor/useEditor.js +4 -0
- package/es/react/Editor/utils.d.ts +2 -0
- package/es/react/Editor/utils.js +3 -0
- package/es/react/EditorProvider/index.d.ts +20 -0
- package/es/react/EditorProvider/index.js +25 -0
- package/es/react/SendButton/SendButton.d.ts +4 -0
- package/es/react/SendButton/SendButton.js +77 -0
- package/es/react/SendButton/components/SendIcon.d.ts +6 -0
- package/es/react/SendButton/components/SendIcon.js +32 -0
- package/es/react/SendButton/components/StopIcon.d.ts +6 -0
- package/es/react/SendButton/components/StopIcon.js +61 -0
- package/es/react/SendButton/index.d.ts +2 -0
- package/es/react/SendButton/index.js +2 -0
- package/es/react/SendButton/style.d.ts +6 -0
- package/es/react/SendButton/style.js +15 -0
- package/es/react/SendButton/type.d.ts +6 -0
- package/es/react/SendButton/type.js +1 -0
- package/es/react/SlashMenu/SlashMenu.d.ts +4 -0
- package/es/react/SlashMenu/SlashMenu.js +68 -0
- package/es/react/SlashMenu/index.d.ts +2 -0
- package/es/react/SlashMenu/index.js +2 -0
- package/es/react/SlashMenu/style.d.ts +4 -0
- package/es/react/SlashMenu/style.js +11 -0
- package/es/react/SlashMenu/type.d.ts +8 -0
- package/es/react/SlashMenu/type.js +1 -0
- package/es/react/index.d.ts +8 -0
- package/es/react/index.js +8 -0
- package/es/types/global.d.ts +20 -0
- package/es/types/index.d.ts +2 -0
- package/es/types/index.js +2 -0
- package/es/types/kernel.d.ts +180 -0
- package/es/types/kernel.js +1 -0
- package/es/types/locale.d.ts +10 -0
- package/es/types/locale.js +1 -0
- package/package.json +66 -0
- package/patches/lexical+0.33.1.patch +88 -0
- package/react.d.ts +1 -0
- package/react.js +1 -0
- package/scripts/patch-lexical-package-json.js +20 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var _class;
|
|
2
|
+
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); }
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
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); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
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); }
|
|
7
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
8
|
+
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); }; }
|
|
9
|
+
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); }
|
|
10
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
13
|
+
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; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
|
+
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); }
|
|
16
|
+
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
17
|
+
import { IMarkdownShortCutService } from "../../markdown";
|
|
18
|
+
import { registerHorizontalRuleCommand } from "../command";
|
|
19
|
+
import { $createHorizontalRuleNode, $isHorizontalRuleNode, HorizontalRuleNode } from "../node/HorizontalRuleNode";
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
22
|
+
|
|
23
|
+
export var HRPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
24
|
+
_inherits(HRPlugin, _KernelPlugin);
|
|
25
|
+
var _super = _createSuper(HRPlugin);
|
|
26
|
+
function HRPlugin(kernel, config) {
|
|
27
|
+
var _kernel$requireServic, _kernel$requireServic2;
|
|
28
|
+
var _this;
|
|
29
|
+
_classCallCheck(this, HRPlugin);
|
|
30
|
+
_this = _super.call(this);
|
|
31
|
+
// Register the horizontal rule node
|
|
32
|
+
_this.kernel = kernel;
|
|
33
|
+
kernel.registerNodes([HorizontalRuleNode]);
|
|
34
|
+
kernel.registerThemes({
|
|
35
|
+
hr: (config === null || config === void 0 ? void 0 : config.theme) || ''
|
|
36
|
+
});
|
|
37
|
+
kernel.registerDecorator('horizontalrule', function (node, editor) {
|
|
38
|
+
return config !== null && config !== void 0 && config.decorator ? config.decorator(node, editor) : null;
|
|
39
|
+
});
|
|
40
|
+
(_kernel$requireServic = kernel.requireService(IMarkdownShortCutService)) === null || _kernel$requireServic === void 0 || _kernel$requireServic.registerMarkdownShortCut({
|
|
41
|
+
regExp: /^(---|\*\*\*|___)$/,
|
|
42
|
+
replace: function replace(parentNode, _1, _2, isImport) {
|
|
43
|
+
var line = $createHorizontalRuleNode();
|
|
44
|
+
|
|
45
|
+
// TODO: Get rid of isImport flag
|
|
46
|
+
if (isImport || parentNode.getNextSibling()) {
|
|
47
|
+
parentNode.replace(line);
|
|
48
|
+
} else {
|
|
49
|
+
parentNode.insertBefore(line);
|
|
50
|
+
}
|
|
51
|
+
line.selectNext();
|
|
52
|
+
},
|
|
53
|
+
trigger: 'enter',
|
|
54
|
+
type: 'element'
|
|
55
|
+
});
|
|
56
|
+
(_kernel$requireServic2 = kernel.requireService(IMarkdownShortCutService)) === null || _kernel$requireServic2 === void 0 || _kernel$requireServic2.registerMarkdownWriter(HorizontalRuleNode.getType(), function (ctx, node) {
|
|
57
|
+
if ($isHorizontalRuleNode(node)) {
|
|
58
|
+
ctx.appendLine('---\n\n');
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return _this;
|
|
62
|
+
}
|
|
63
|
+
_createClass(HRPlugin, [{
|
|
64
|
+
key: "onInit",
|
|
65
|
+
value: function onInit(editor) {
|
|
66
|
+
this.register(registerHorizontalRuleCommand(editor));
|
|
67
|
+
}
|
|
68
|
+
}]);
|
|
69
|
+
return HRPlugin;
|
|
70
|
+
}(KernelPlugin), _defineProperty(_class, "pluginName", 'HRPlugin'), _class);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
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); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
8
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
|
+
import { useLayoutEffect } from 'react';
|
|
10
|
+
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
11
|
+
import { MarkdownPlugin } from "../../markdown";
|
|
12
|
+
import { HRPlugin } from "../plugin";
|
|
13
|
+
import HRNode from "./components/HRNode";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
var ReactHRPlugin = function ReactHRPlugin(_ref) {
|
|
16
|
+
var className = _ref.className;
|
|
17
|
+
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
18
|
+
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
19
|
+
editor = _useLexicalComposerCo2[0];
|
|
20
|
+
useLayoutEffect(function () {
|
|
21
|
+
editor.registerPlugin(MarkdownPlugin);
|
|
22
|
+
editor.registerPlugin(HRPlugin, {
|
|
23
|
+
decorator: function decorator(node, editor) {
|
|
24
|
+
return /*#__PURE__*/_jsx(HRNode, {
|
|
25
|
+
className: className,
|
|
26
|
+
editor: editor,
|
|
27
|
+
node: node
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
theme: className
|
|
31
|
+
});
|
|
32
|
+
}, []);
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
ReactHRPlugin.displayName = 'ReactHRPlugin';
|
|
36
|
+
export default ReactHRPlugin;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LexicalEditor } from 'lexical';
|
|
3
|
+
import { HorizontalRuleNode } from '../../node/HorizontalRuleNode';
|
|
4
|
+
interface HRNodeProps {
|
|
5
|
+
className?: string;
|
|
6
|
+
editor: LexicalEditor;
|
|
7
|
+
node: HorizontalRuleNode;
|
|
8
|
+
}
|
|
9
|
+
declare const HRNode: import("react").NamedExoticComponent<HRNodeProps>;
|
|
10
|
+
export default HRNode;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
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); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
8
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
|
+
import { mergeRegister } from '@lexical/utils';
|
|
10
|
+
import { CLICK_COMMAND, COMMAND_PRIORITY_LOW } from 'lexical';
|
|
11
|
+
import { memo, useEffect } from 'react';
|
|
12
|
+
import { useLexicalNodeSelection } from "../../../../editor-kernel/react/useLexicalNodeSelection";
|
|
13
|
+
import { useStyles } from "../style";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
var HRNode = /*#__PURE__*/memo(function (_ref) {
|
|
16
|
+
var node = _ref.node,
|
|
17
|
+
className = _ref.className,
|
|
18
|
+
editor = _ref.editor;
|
|
19
|
+
var _useLexicalNodeSelect = useLexicalNodeSelection(node.getKey()),
|
|
20
|
+
_useLexicalNodeSelect2 = _slicedToArray(_useLexicalNodeSelect, 3),
|
|
21
|
+
isSelected = _useLexicalNodeSelect2[0],
|
|
22
|
+
setSelected = _useLexicalNodeSelect2[1],
|
|
23
|
+
clearSelection = _useLexicalNodeSelect2[2];
|
|
24
|
+
var _useStyles = useStyles(),
|
|
25
|
+
cx = _useStyles.cx,
|
|
26
|
+
styles = _useStyles.styles;
|
|
27
|
+
useEffect(function () {
|
|
28
|
+
return mergeRegister(editor.registerCommand(CLICK_COMMAND, function (event) {
|
|
29
|
+
var hrElem = editor.getElementByKey(node.getKey());
|
|
30
|
+
if (hrElem !== null && hrElem !== void 0 && hrElem.contains(event.target) || event.target === hrElem) {
|
|
31
|
+
if (!event.shiftKey) {
|
|
32
|
+
clearSelection();
|
|
33
|
+
}
|
|
34
|
+
setSelected(!isSelected);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}, COMMAND_PRIORITY_LOW));
|
|
39
|
+
}, [clearSelection, editor, isSelected, node, setSelected]);
|
|
40
|
+
return /*#__PURE__*/_jsx("hr", {
|
|
41
|
+
className: cx(styles, isSelected && 'selected', className)
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
HRNode.displayName = 'HRNode';
|
|
45
|
+
export default HRNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ReactHRPlugin } from "./ReactHRPlugin";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<import("antd-style").SerializedStyles>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token;
|
|
7
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n\n width: 100%;\n height: 4px;\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 1.5em);\n border-color: ", ";\n border-style: dashed;\n border-width: 1px;\n border-block-start: none;\n border-inline-start: none;\n border-inline-end: none;\n\n &.selected {\n border-color: ", ";\n }\n "])), token.colorBorder, token.yellow);
|
|
8
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LexicalEditor } from 'lexical';
|
|
2
|
+
export declare const INSERT_IMAGE_COMMAND: import("lexical").LexicalCommand<{
|
|
3
|
+
file: File;
|
|
4
|
+
range?: Range | null | undefined;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function registerImageCommand(editor: LexicalEditor, handleUpload: (file: File) => Promise<{
|
|
7
|
+
url: string;
|
|
8
|
+
}>): () => void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { $wrapNodeInElement } from '@lexical/utils';
|
|
2
|
+
import { $createParagraphNode, $createRangeSelection, $insertNodes, $isRootOrShadowRoot, $setSelection, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
3
|
+
import { $createImageNode } from "../node/image-node";
|
|
4
|
+
export var INSERT_IMAGE_COMMAND = createCommand('INSERT_IMAGE_COMMAND');
|
|
5
|
+
function isImageFile(file) {
|
|
6
|
+
return file.type.startsWith('image/');
|
|
7
|
+
}
|
|
8
|
+
export function registerImageCommand(editor, handleUpload) {
|
|
9
|
+
return editor.registerCommand(INSERT_IMAGE_COMMAND, function (payload) {
|
|
10
|
+
var file = payload.file,
|
|
11
|
+
range = payload.range;
|
|
12
|
+
if (!isImageFile(file)) {
|
|
13
|
+
return false; // Not an image file
|
|
14
|
+
}
|
|
15
|
+
var placeholderURL = URL.createObjectURL(file); // Create a local URL for the image
|
|
16
|
+
editor.update(function () {
|
|
17
|
+
if (range) {
|
|
18
|
+
var rangeSelection = $createRangeSelection();
|
|
19
|
+
if (range !== null && range !== undefined) {
|
|
20
|
+
rangeSelection.applyDOMRange(range);
|
|
21
|
+
}
|
|
22
|
+
$setSelection(rangeSelection);
|
|
23
|
+
}
|
|
24
|
+
var imageNode = $createImageNode({
|
|
25
|
+
altText: file.name,
|
|
26
|
+
src: placeholderURL
|
|
27
|
+
});
|
|
28
|
+
$insertNodes([imageNode]); // Insert a zero-width space to ensure the image is not the last child
|
|
29
|
+
if ($isRootOrShadowRoot(imageNode.getParentOrThrow())) {
|
|
30
|
+
$wrapNodeInElement(imageNode, $createParagraphNode).selectEnd();
|
|
31
|
+
}
|
|
32
|
+
handleUpload(file).then(function (res) {
|
|
33
|
+
editor.update(function () {
|
|
34
|
+
imageNode.setUploaded(res.url);
|
|
35
|
+
});
|
|
36
|
+
}).catch(function (error) {
|
|
37
|
+
console.error('Image upload failed:', error);
|
|
38
|
+
editor.update(function () {
|
|
39
|
+
imageNode.setError('Image upload failed : ' + error.message);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
return true;
|
|
44
|
+
}, COMMAND_PRIORITY_EDITOR // Priority
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DOMExportOutput, DecoratorNode, EditorConfig, LexicalEditor, LexicalUpdateJSON, NodeKey, SerializedEditor, SerializedLexicalNode, Spread } from 'lexical';
|
|
2
|
+
export interface ImagePayload {
|
|
3
|
+
altText: string;
|
|
4
|
+
caption?: LexicalEditor;
|
|
5
|
+
captionsEnabled?: boolean;
|
|
6
|
+
height?: number;
|
|
7
|
+
key?: NodeKey;
|
|
8
|
+
maxWidth?: number;
|
|
9
|
+
showCaption?: boolean;
|
|
10
|
+
src: string;
|
|
11
|
+
width?: number;
|
|
12
|
+
}
|
|
13
|
+
export type SerializedImageNode = Spread<{
|
|
14
|
+
altText: string;
|
|
15
|
+
caption: SerializedEditor;
|
|
16
|
+
height?: number;
|
|
17
|
+
maxWidth: number;
|
|
18
|
+
showCaption: boolean;
|
|
19
|
+
src: string;
|
|
20
|
+
width?: number;
|
|
21
|
+
}, SerializedLexicalNode>;
|
|
22
|
+
export declare class BaseImageNode extends DecoratorNode<any> {
|
|
23
|
+
__src: string;
|
|
24
|
+
__altText: string;
|
|
25
|
+
__width: 'inherit' | number;
|
|
26
|
+
__height: 'inherit' | number;
|
|
27
|
+
__maxWidth: number;
|
|
28
|
+
__showCaption: boolean;
|
|
29
|
+
__caption: LexicalEditor;
|
|
30
|
+
__captionsEnabled: boolean;
|
|
31
|
+
static clone(node: BaseImageNode): BaseImageNode;
|
|
32
|
+
static importJSON(serializedNode: SerializedImageNode): BaseImageNode;
|
|
33
|
+
static getType(): string;
|
|
34
|
+
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedImageNode>): this;
|
|
35
|
+
exportDOM(): DOMExportOutput;
|
|
36
|
+
constructor(src: string, altText: string, maxWidth: number, width?: 'inherit' | number, height?: 'inherit' | number, showCaption?: boolean, caption?: LexicalEditor, captionsEnabled?: boolean, key?: NodeKey);
|
|
37
|
+
exportJSON(): SerializedImageNode;
|
|
38
|
+
setWidthAndHeight(width: 'inherit' | number, height: 'inherit' | number): void;
|
|
39
|
+
setShowCaption(showCaption: boolean): void;
|
|
40
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
41
|
+
updateDOM(): false;
|
|
42
|
+
getSrc(): string;
|
|
43
|
+
getAltText(): string;
|
|
44
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _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); }
|
|
8
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
9
|
+
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); }; }
|
|
10
|
+
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); }
|
|
11
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
12
|
+
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; } }
|
|
13
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
14
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
15
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
18
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
+
import { DecoratorNode, ParagraphNode, RootNode, TextNode, createEditor } from 'lexical';
|
|
20
|
+
export var BaseImageNode = /*#__PURE__*/function (_DecoratorNode) {
|
|
21
|
+
_inherits(BaseImageNode, _DecoratorNode);
|
|
22
|
+
var _super = _createSuper(BaseImageNode);
|
|
23
|
+
function BaseImageNode(src, altText, maxWidth, width, height, showCaption, caption, captionsEnabled, key) {
|
|
24
|
+
var _this;
|
|
25
|
+
_classCallCheck(this, BaseImageNode);
|
|
26
|
+
_this = _super.call(this, key);
|
|
27
|
+
_defineProperty(_assertThisInitialized(_this), "__src", void 0);
|
|
28
|
+
_defineProperty(_assertThisInitialized(_this), "__altText", void 0);
|
|
29
|
+
_defineProperty(_assertThisInitialized(_this), "__width", void 0);
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "__height", void 0);
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "__maxWidth", void 0);
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "__showCaption", void 0);
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "__caption", void 0);
|
|
34
|
+
// Captions cannot yet be used within editor cells
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "__captionsEnabled", void 0);
|
|
36
|
+
_this.__src = src;
|
|
37
|
+
_this.__altText = altText;
|
|
38
|
+
_this.__maxWidth = maxWidth;
|
|
39
|
+
_this.__width = width || 'inherit';
|
|
40
|
+
_this.__height = height || 'inherit';
|
|
41
|
+
_this.__showCaption = showCaption || false;
|
|
42
|
+
_this.__caption = caption || createEditor({
|
|
43
|
+
namespace: 'Playground/ImageNodeCaption',
|
|
44
|
+
nodes: [RootNode, TextNode, ParagraphNode]
|
|
45
|
+
});
|
|
46
|
+
_this.__captionsEnabled = captionsEnabled || captionsEnabled === undefined;
|
|
47
|
+
return _this;
|
|
48
|
+
}
|
|
49
|
+
_createClass(BaseImageNode, [{
|
|
50
|
+
key: "updateFromJSON",
|
|
51
|
+
value: function updateFromJSON(serializedNode) {
|
|
52
|
+
var node = _get(_getPrototypeOf(BaseImageNode.prototype), "updateFromJSON", this).call(this, serializedNode);
|
|
53
|
+
var caption = serializedNode.caption;
|
|
54
|
+
var nestedEditor = node.__caption;
|
|
55
|
+
var editorState = nestedEditor.parseEditorState(caption.editorState);
|
|
56
|
+
if (!editorState.isEmpty()) {
|
|
57
|
+
nestedEditor.setEditorState(editorState);
|
|
58
|
+
}
|
|
59
|
+
return node;
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "exportDOM",
|
|
63
|
+
value: function exportDOM() {
|
|
64
|
+
var element = document.createElement('img');
|
|
65
|
+
element.setAttribute('src', this.__src);
|
|
66
|
+
element.setAttribute('alt', this.__altText);
|
|
67
|
+
element.setAttribute('width', this.__width.toString());
|
|
68
|
+
element.setAttribute('height', this.__height.toString());
|
|
69
|
+
return {
|
|
70
|
+
element: element
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "exportJSON",
|
|
75
|
+
value: function exportJSON() {
|
|
76
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(BaseImageNode.prototype), "exportJSON", this).call(this)), {}, {
|
|
77
|
+
altText: this.getAltText(),
|
|
78
|
+
caption: this.__caption.toJSON(),
|
|
79
|
+
height: this.__height === 'inherit' ? 0 : this.__height,
|
|
80
|
+
maxWidth: this.__maxWidth,
|
|
81
|
+
showCaption: this.__showCaption,
|
|
82
|
+
src: this.getSrc(),
|
|
83
|
+
width: this.__width === 'inherit' ? 0 : this.__width
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "setWidthAndHeight",
|
|
88
|
+
value: function setWidthAndHeight(width, height) {
|
|
89
|
+
var writable = this.getWritable();
|
|
90
|
+
writable.__width = width;
|
|
91
|
+
writable.__height = height;
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
key: "setShowCaption",
|
|
95
|
+
value: function setShowCaption(showCaption) {
|
|
96
|
+
var writable = this.getWritable();
|
|
97
|
+
writable.__showCaption = showCaption;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// View
|
|
101
|
+
}, {
|
|
102
|
+
key: "createDOM",
|
|
103
|
+
value: function createDOM(config) {
|
|
104
|
+
var span = document.createElement('span');
|
|
105
|
+
var theme = config.theme;
|
|
106
|
+
var className = theme.image;
|
|
107
|
+
if (className !== undefined) {
|
|
108
|
+
span.className = className;
|
|
109
|
+
}
|
|
110
|
+
return span;
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "updateDOM",
|
|
114
|
+
value: function updateDOM() {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "getSrc",
|
|
119
|
+
value: function getSrc() {
|
|
120
|
+
return this.__src;
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "getAltText",
|
|
124
|
+
value: function getAltText() {
|
|
125
|
+
return this.__altText;
|
|
126
|
+
}
|
|
127
|
+
}], [{
|
|
128
|
+
key: "clone",
|
|
129
|
+
value: function clone(node) {
|
|
130
|
+
return new BaseImageNode(node.__src, node.__altText, node.__maxWidth, node.__width, node.__height, node.__showCaption, node.__caption, node.__captionsEnabled, node.__key);
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "importJSON",
|
|
134
|
+
value: function importJSON(serializedNode) {
|
|
135
|
+
var altText = serializedNode.altText,
|
|
136
|
+
height = serializedNode.height,
|
|
137
|
+
width = serializedNode.width,
|
|
138
|
+
maxWidth = serializedNode.maxWidth,
|
|
139
|
+
src = serializedNode.src,
|
|
140
|
+
showCaption = serializedNode.showCaption;
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
142
|
+
return new BaseImageNode(src, altText, maxWidth, width, height, showCaption);
|
|
143
|
+
}
|
|
144
|
+
}, {
|
|
145
|
+
key: "getType",
|
|
146
|
+
value: function getType() {
|
|
147
|
+
return 'image';
|
|
148
|
+
}
|
|
149
|
+
}]);
|
|
150
|
+
return BaseImageNode;
|
|
151
|
+
}(DecoratorNode);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DOMConversionMap, LexicalNode } from 'lexical';
|
|
2
|
+
import { BaseImageNode, ImagePayload, SerializedImageNode } from './basie-image-node';
|
|
3
|
+
export declare class ImageNode extends BaseImageNode {
|
|
4
|
+
private static _decorate;
|
|
5
|
+
static setDecorate(decorate: (node: ImageNode) => any): void;
|
|
6
|
+
static getType(): string;
|
|
7
|
+
private __loading;
|
|
8
|
+
private __status;
|
|
9
|
+
private __message;
|
|
10
|
+
private __extra;
|
|
11
|
+
get isLoading(): boolean;
|
|
12
|
+
get status(): 'uploaded' | 'loading' | 'error';
|
|
13
|
+
get message(): string | null;
|
|
14
|
+
get src(): string;
|
|
15
|
+
get altText(): string;
|
|
16
|
+
get maxWidth(): number;
|
|
17
|
+
get width(): number | string;
|
|
18
|
+
setUploaded(url: string): void;
|
|
19
|
+
setError(message: string): void;
|
|
20
|
+
static clone(node: ImageNode): ImageNode;
|
|
21
|
+
static importJSON(serializedNode: SerializedImageNode): ImageNode;
|
|
22
|
+
static importDOM(): DOMConversionMap | null;
|
|
23
|
+
decorate(): any;
|
|
24
|
+
}
|
|
25
|
+
export declare function $createImageNode({ altText, height, maxWidth, captionsEnabled, src, width, showCaption, caption, key, }: ImagePayload): ImageNode;
|
|
26
|
+
export declare function $isImageNode(node: LexicalNode): node is ImageNode;
|