@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,378 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
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; } } }; }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
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."); }
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
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; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
import { $computeTableMapSkipCellCheck, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $isTableCellNode, $isTableRowNode, TableNode, getDOMCellFromTarget, getTableElement } from '@lexical/table';
|
|
13
|
+
import { calculateZoomLevel, mergeRegister } from '@lexical/utils';
|
|
14
|
+
import { $getNearestNodeFromDOMNode, SKIP_SCROLL_INTO_VIEW_TAG, isHTMLElement } from 'lexical';
|
|
15
|
+
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
16
|
+
import { createPortal } from 'react-dom';
|
|
17
|
+
import { MIN_COLUMN_WIDTH, MIN_ROW_HEIGHT, useStyles } from "./style";
|
|
18
|
+
import { getCellColumnIndex, getCellNodeHeight } from "./utils";
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
export var TableCellResize = /*#__PURE__*/memo(function (_ref) {
|
|
23
|
+
var editor = _ref.editor,
|
|
24
|
+
eventEmitter = _ref.eventEmitter;
|
|
25
|
+
var _useStyles = useStyles(),
|
|
26
|
+
cx = _useStyles.cx,
|
|
27
|
+
styles = _useStyles.styles,
|
|
28
|
+
theme = _useStyles.theme;
|
|
29
|
+
var targetRef = useRef(null);
|
|
30
|
+
var resizerRef = useRef(null);
|
|
31
|
+
// eslint-disable-next-line no-undef
|
|
32
|
+
var tableRectRef = useRef(null);
|
|
33
|
+
var _useState = useState(false),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
hasTable = _useState2[0],
|
|
36
|
+
setHasTable = _useState2[1];
|
|
37
|
+
var pointerStartPosRef = useRef(null);
|
|
38
|
+
var _useState3 = useState(null),
|
|
39
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
|
+
pointerCurrentPos = _useState4[0],
|
|
41
|
+
updatePointerCurrentPos = _useState4[1];
|
|
42
|
+
var _useState5 = useState(null),
|
|
43
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
44
|
+
activeCell = _useState6[0],
|
|
45
|
+
updateActiveCell = _useState6[1];
|
|
46
|
+
var _useState7 = useState(null),
|
|
47
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
48
|
+
draggingDirection = _useState8[0],
|
|
49
|
+
updateDraggingDirection = _useState8[1];
|
|
50
|
+
var resetState = useCallback(function () {
|
|
51
|
+
updateActiveCell(null);
|
|
52
|
+
targetRef.current = null;
|
|
53
|
+
updateDraggingDirection(null);
|
|
54
|
+
pointerStartPosRef.current = null;
|
|
55
|
+
tableRectRef.current = null;
|
|
56
|
+
}, []);
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
var tableKeys = new Set();
|
|
59
|
+
return mergeRegister(editor.registerMutationListener(TableNode, function (nodeMutations) {
|
|
60
|
+
var _iterator = _createForOfIteratorHelper(nodeMutations),
|
|
61
|
+
_step;
|
|
62
|
+
try {
|
|
63
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
64
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
65
|
+
nodeKey = _step$value[0],
|
|
66
|
+
mutation = _step$value[1];
|
|
67
|
+
if (mutation === 'destroyed') {
|
|
68
|
+
tableKeys.delete(nodeKey);
|
|
69
|
+
} else {
|
|
70
|
+
tableKeys.add(nodeKey);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} catch (err) {
|
|
74
|
+
_iterator.e(err);
|
|
75
|
+
} finally {
|
|
76
|
+
_iterator.f();
|
|
77
|
+
}
|
|
78
|
+
setHasTable(tableKeys.size > 0);
|
|
79
|
+
}), editor.registerNodeTransform(TableNode, function (tableNode) {
|
|
80
|
+
if (tableNode.getColWidths()) {
|
|
81
|
+
return tableNode;
|
|
82
|
+
}
|
|
83
|
+
var numColumns = tableNode.getColumnCount();
|
|
84
|
+
var columnWidth = MIN_COLUMN_WIDTH;
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line unicorn/no-new-array
|
|
87
|
+
tableNode.setColWidths(new Array(numColumns).fill(columnWidth));
|
|
88
|
+
return tableNode;
|
|
89
|
+
}));
|
|
90
|
+
}, [editor]);
|
|
91
|
+
useEffect(function () {
|
|
92
|
+
if (!hasTable) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
var onPointerMove = function onPointerMove(event) {
|
|
96
|
+
var target = event.target;
|
|
97
|
+
if (!isHTMLElement(target)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (draggingDirection) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
event.stopPropagation();
|
|
103
|
+
updatePointerCurrentPos({
|
|
104
|
+
x: event.clientX,
|
|
105
|
+
y: event.clientY
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (resizerRef.current && resizerRef.current.contains(target)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (targetRef.current !== target) {
|
|
113
|
+
targetRef.current = target;
|
|
114
|
+
var cell = getDOMCellFromTarget(target);
|
|
115
|
+
if (cell && activeCell !== cell) {
|
|
116
|
+
editor.getEditorState().read(function () {
|
|
117
|
+
var tableCellNode = $getNearestNodeFromDOMNode(cell.elem);
|
|
118
|
+
if (!tableCellNode) {
|
|
119
|
+
throw new Error('TableCellResizer: Table cell node not found.');
|
|
120
|
+
}
|
|
121
|
+
var tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
122
|
+
var tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()));
|
|
123
|
+
if (!tableElement) {
|
|
124
|
+
throw new Error('TableCellResizer: Table element not found.');
|
|
125
|
+
}
|
|
126
|
+
targetRef.current = target;
|
|
127
|
+
tableRectRef.current = tableElement.getBoundingClientRect();
|
|
128
|
+
updateActiveCell(cell);
|
|
129
|
+
}, {
|
|
130
|
+
editor: editor
|
|
131
|
+
});
|
|
132
|
+
} else if (!cell) {
|
|
133
|
+
resetState();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
var onPointerDown = function onPointerDown(event) {
|
|
138
|
+
var isTouchEvent = event.pointerType === 'touch';
|
|
139
|
+
if (isTouchEvent) {
|
|
140
|
+
onPointerMove(event);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
var resizerContainer = resizerRef.current;
|
|
144
|
+
resizerContainer === null || resizerContainer === void 0 || resizerContainer.addEventListener('pointermove', onPointerMove, {
|
|
145
|
+
capture: true
|
|
146
|
+
});
|
|
147
|
+
var removeRootListener = editor.registerRootListener(function (rootElement, prevRootElement) {
|
|
148
|
+
prevRootElement === null || prevRootElement === void 0 || prevRootElement.removeEventListener('pointermove', onPointerMove);
|
|
149
|
+
prevRootElement === null || prevRootElement === void 0 || prevRootElement.removeEventListener('pointerdown', onPointerDown);
|
|
150
|
+
rootElement === null || rootElement === void 0 || rootElement.addEventListener('pointermove', onPointerMove);
|
|
151
|
+
rootElement === null || rootElement === void 0 || rootElement.addEventListener('pointerdown', onPointerDown);
|
|
152
|
+
});
|
|
153
|
+
return function () {
|
|
154
|
+
removeRootListener();
|
|
155
|
+
resizerContainer === null || resizerContainer === void 0 || resizerContainer.removeEventListener('pointermove', onPointerMove);
|
|
156
|
+
};
|
|
157
|
+
}, [activeCell, draggingDirection, editor, resetState, hasTable]);
|
|
158
|
+
var isHeightChanging = function isHeightChanging(direction) {
|
|
159
|
+
if (direction === 'bottom') {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
};
|
|
164
|
+
var updateRowHeight = useCallback(function (heightChange) {
|
|
165
|
+
if (!activeCell) {
|
|
166
|
+
throw new Error('TableCellResizer: Expected active cell.');
|
|
167
|
+
}
|
|
168
|
+
editor.update(function () {
|
|
169
|
+
var tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);
|
|
170
|
+
if (!$isTableCellNode(tableCellNode)) {
|
|
171
|
+
throw new Error('TableCellResizer: Table cell node not found.');
|
|
172
|
+
}
|
|
173
|
+
var tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
174
|
+
var baseRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode);
|
|
175
|
+
var tableRows = tableNode.getChildren();
|
|
176
|
+
|
|
177
|
+
// Determine if this is a full row merge by checking colspan
|
|
178
|
+
var isFullRowMerge = tableCellNode.getColSpan() === tableNode.getColumnCount();
|
|
179
|
+
|
|
180
|
+
// For full row merges, apply to first row. For partial merges, apply to last row
|
|
181
|
+
var tableRowIndex = isFullRowMerge ? baseRowIndex : baseRowIndex + tableCellNode.getRowSpan() - 1;
|
|
182
|
+
if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
|
|
183
|
+
throw new Error('Expected table cell to be inside of table row.');
|
|
184
|
+
}
|
|
185
|
+
var tableRow = tableRows[tableRowIndex];
|
|
186
|
+
if (!$isTableRowNode(tableRow)) {
|
|
187
|
+
throw new Error('Expected table row');
|
|
188
|
+
}
|
|
189
|
+
var height = tableRow.getHeight();
|
|
190
|
+
if (height === undefined) {
|
|
191
|
+
var rowCells = tableRow.getChildren();
|
|
192
|
+
height = Math.min.apply(Math, _toConsumableArray(rowCells.map(
|
|
193
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
194
|
+
function (cell) {
|
|
195
|
+
var _getCellNodeHeight;
|
|
196
|
+
return (_getCellNodeHeight = getCellNodeHeight(cell, editor)) !== null && _getCellNodeHeight !== void 0 ? _getCellNodeHeight : Infinity;
|
|
197
|
+
})));
|
|
198
|
+
}
|
|
199
|
+
var newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT);
|
|
200
|
+
tableRow.setHeight(newHeight);
|
|
201
|
+
eventEmitter.emit('table:resize', {
|
|
202
|
+
heightChange: heightChange,
|
|
203
|
+
newHeight: newHeight
|
|
204
|
+
});
|
|
205
|
+
}, {
|
|
206
|
+
tag: SKIP_SCROLL_INTO_VIEW_TAG
|
|
207
|
+
});
|
|
208
|
+
}, [activeCell, editor]);
|
|
209
|
+
var updateColumnWidth = useCallback(function (widthChange) {
|
|
210
|
+
if (!activeCell) {
|
|
211
|
+
throw new Error('TableCellResizer: Expected active cell.');
|
|
212
|
+
}
|
|
213
|
+
editor.update(function () {
|
|
214
|
+
var tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);
|
|
215
|
+
if (!$isTableCellNode(tableCellNode)) {
|
|
216
|
+
throw new Error('TableCellResizer: Table cell node not found.');
|
|
217
|
+
}
|
|
218
|
+
var tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
219
|
+
var _$computeTableMapSkip = $computeTableMapSkipCellCheck(tableNode, null, null),
|
|
220
|
+
_$computeTableMapSkip2 = _slicedToArray(_$computeTableMapSkip, 1),
|
|
221
|
+
tableMap = _$computeTableMapSkip2[0];
|
|
222
|
+
var columnIndex = getCellColumnIndex(tableCellNode, tableMap);
|
|
223
|
+
if (columnIndex === undefined) {
|
|
224
|
+
throw new Error('TableCellResizer: Table column not found.');
|
|
225
|
+
}
|
|
226
|
+
var colWidths = tableNode.getColWidths();
|
|
227
|
+
if (!colWidths) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
var width = colWidths[columnIndex];
|
|
231
|
+
if (width === undefined) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
var newColWidths = _toConsumableArray(colWidths);
|
|
235
|
+
var newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);
|
|
236
|
+
newColWidths[columnIndex] = newWidth;
|
|
237
|
+
tableNode.setColWidths(newColWidths);
|
|
238
|
+
requestAnimationFrame(function () {
|
|
239
|
+
eventEmitter.emit('table:resize', {
|
|
240
|
+
newColWidths: newColWidths
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
}, {
|
|
244
|
+
tag: SKIP_SCROLL_INTO_VIEW_TAG
|
|
245
|
+
});
|
|
246
|
+
}, [activeCell, editor]);
|
|
247
|
+
var pointerUpHandler = useCallback(function (direction) {
|
|
248
|
+
var handler = function handler(event) {
|
|
249
|
+
event.preventDefault();
|
|
250
|
+
event.stopPropagation();
|
|
251
|
+
if (!activeCell) {
|
|
252
|
+
throw new Error('TableCellResizer: Expected active cell.');
|
|
253
|
+
}
|
|
254
|
+
if (pointerStartPosRef.current) {
|
|
255
|
+
var _pointerStartPosRef$c = pointerStartPosRef.current,
|
|
256
|
+
x = _pointerStartPosRef$c.x,
|
|
257
|
+
y = _pointerStartPosRef$c.y;
|
|
258
|
+
if (activeCell === null) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
var zoom = calculateZoomLevel(event.target);
|
|
262
|
+
if (isHeightChanging(direction)) {
|
|
263
|
+
var heightChange = (event.clientY - y) / zoom;
|
|
264
|
+
updateRowHeight(heightChange);
|
|
265
|
+
} else {
|
|
266
|
+
var widthChange = (event.clientX - x) / zoom;
|
|
267
|
+
updateColumnWidth(widthChange);
|
|
268
|
+
}
|
|
269
|
+
resetState();
|
|
270
|
+
if (typeof document !== 'undefined') {
|
|
271
|
+
document.removeEventListener('pointerup', handler);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
return handler;
|
|
276
|
+
}, [activeCell, resetState, updateColumnWidth, updateRowHeight]);
|
|
277
|
+
var toggleResize = useCallback(function (direction) {
|
|
278
|
+
return function (event) {
|
|
279
|
+
event.preventDefault();
|
|
280
|
+
event.stopPropagation();
|
|
281
|
+
if (!activeCell) {
|
|
282
|
+
throw new Error('TableCellResizer: Expected active cell.');
|
|
283
|
+
}
|
|
284
|
+
pointerStartPosRef.current = {
|
|
285
|
+
x: event.clientX,
|
|
286
|
+
y: event.clientY
|
|
287
|
+
};
|
|
288
|
+
updatePointerCurrentPos(pointerStartPosRef.current);
|
|
289
|
+
updateDraggingDirection(direction);
|
|
290
|
+
if (typeof document !== 'undefined') {
|
|
291
|
+
document.addEventListener('pointerup', pointerUpHandler(direction));
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}, [activeCell, pointerUpHandler]);
|
|
295
|
+
var getResizers = useCallback(function () {
|
|
296
|
+
if (activeCell) {
|
|
297
|
+
var _activeCell$elem$getB = activeCell.elem.getBoundingClientRect(),
|
|
298
|
+
height = _activeCell$elem$getB.height,
|
|
299
|
+
width = _activeCell$elem$getB.width,
|
|
300
|
+
top = _activeCell$elem$getB.top,
|
|
301
|
+
left = _activeCell$elem$getB.left;
|
|
302
|
+
var zoom = calculateZoomLevel(activeCell.elem);
|
|
303
|
+
var zoneWidth = 16; // Pixel width of the zone where you can drag the edge
|
|
304
|
+
|
|
305
|
+
// Default to 0 for server side
|
|
306
|
+
var scrollX = typeof window !== 'undefined' ? window.scrollX : 0;
|
|
307
|
+
var scrollY = typeof window !== 'undefined' ? window.scrollY : 0;
|
|
308
|
+
var _styles = {
|
|
309
|
+
bottom: {
|
|
310
|
+
backgroundColor: 'none',
|
|
311
|
+
cursor: 'row-resize',
|
|
312
|
+
height: "".concat(zoneWidth, "px"),
|
|
313
|
+
left: "".concat(scrollX + left, "px"),
|
|
314
|
+
top: "".concat(scrollY + top + height - zoneWidth / 2, "px"),
|
|
315
|
+
width: "".concat(width, "px")
|
|
316
|
+
},
|
|
317
|
+
right: {
|
|
318
|
+
backgroundColor: 'none',
|
|
319
|
+
cursor: 'col-resize',
|
|
320
|
+
height: "".concat(height, "px"),
|
|
321
|
+
left: "".concat(scrollX + left + width - zoneWidth / 2, "px"),
|
|
322
|
+
top: "".concat(scrollY + top, "px"),
|
|
323
|
+
width: "".concat(zoneWidth, "px")
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
var tableRect = tableRectRef.current;
|
|
327
|
+
if (draggingDirection && pointerCurrentPos && tableRect) {
|
|
328
|
+
if (isHeightChanging(draggingDirection)) {
|
|
329
|
+
_styles[draggingDirection].left = "".concat(scrollX + tableRect.left, "px");
|
|
330
|
+
_styles[draggingDirection].top = "".concat(scrollY + pointerCurrentPos.y / zoom, "px");
|
|
331
|
+
_styles[draggingDirection].height = '3px';
|
|
332
|
+
_styles[draggingDirection].width = "".concat(tableRect.width, "px");
|
|
333
|
+
} else {
|
|
334
|
+
_styles[draggingDirection].top = "".concat(scrollY + tableRect.top, "px");
|
|
335
|
+
_styles[draggingDirection].left = "".concat(scrollX + pointerCurrentPos.x / zoom, "px");
|
|
336
|
+
_styles[draggingDirection].width = '3px';
|
|
337
|
+
_styles[draggingDirection].height = "".concat(tableRect.height, "px");
|
|
338
|
+
}
|
|
339
|
+
_styles[draggingDirection].backgroundColor = theme.colorPrimary;
|
|
340
|
+
_styles[draggingDirection].mixBlendMode = 'unset';
|
|
341
|
+
}
|
|
342
|
+
return _styles;
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
bottom: null,
|
|
346
|
+
left: null,
|
|
347
|
+
right: null,
|
|
348
|
+
top: null
|
|
349
|
+
};
|
|
350
|
+
}, [activeCell, draggingDirection, pointerCurrentPos, theme.colorPrimary]);
|
|
351
|
+
var resizerStyles = getResizers();
|
|
352
|
+
return /*#__PURE__*/_jsx("div", {
|
|
353
|
+
ref: resizerRef,
|
|
354
|
+
children: activeCell && /*#__PURE__*/_jsxs(_Fragment, {
|
|
355
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
356
|
+
className: cx(styles, 'TableCellResizer__resizer', 'TableCellResizer__ui'),
|
|
357
|
+
onPointerDown: toggleResize('right'),
|
|
358
|
+
style: resizerStyles.right || undefined
|
|
359
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
360
|
+
className: cx(styles, 'TableCellResizer__resizer', 'TableCellResizer__ui'),
|
|
361
|
+
onPointerDown: toggleResize('bottom'),
|
|
362
|
+
style: resizerStyles.bottom || undefined
|
|
363
|
+
})]
|
|
364
|
+
})
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
export default /*#__PURE__*/memo(function (_ref2) {
|
|
368
|
+
var editor = _ref2.editor,
|
|
369
|
+
eventEmitter = _ref2.eventEmitter;
|
|
370
|
+
// Don't render portal on server side
|
|
371
|
+
if (typeof document === 'undefined') {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
return /*#__PURE__*/createPortal( /*#__PURE__*/_jsx(TableCellResize, {
|
|
375
|
+
editor: editor,
|
|
376
|
+
eventEmitter: eventEmitter
|
|
377
|
+
}), document.body);
|
|
378
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
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 MIN_ROW_HEIGHT = 33;
|
|
5
|
+
export var MIN_COLUMN_WIDTH = 92;
|
|
6
|
+
export var useStyles = createStyles(function (_ref) {
|
|
7
|
+
var css = _ref.css,
|
|
8
|
+
token = _ref.token;
|
|
9
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n touch-action: none;\n position: absolute;\n z-index: 1;\n\n @media (pointer: coarse) {\n background-color: ", ";\n mix-blend-mode: color;\n }\n "])), token.colorPrimary);
|
|
10
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TableCellNode, TableMapType } from '@lexical/table';
|
|
2
|
+
import { LexicalEditor } from 'lexical';
|
|
3
|
+
export declare const getCellColumnIndex: (tableCellNode: TableCellNode, tableMap: TableMapType) => number | undefined;
|
|
4
|
+
export declare const getCellNodeHeight: (cell: TableCellNode, activeEditor: LexicalEditor) => number | undefined;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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; } }
|
|
4
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
5
|
+
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; } } }; }
|
|
6
|
+
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); }
|
|
7
|
+
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; }
|
|
8
|
+
export var getCellColumnIndex = function getCellColumnIndex(tableCellNode, tableMap) {
|
|
9
|
+
var _iterator = _createForOfIteratorHelper(tableMap),
|
|
10
|
+
_step;
|
|
11
|
+
try {
|
|
12
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
13
|
+
var element = _step.value;
|
|
14
|
+
var _iterator2 = _createForOfIteratorHelper(element.entries()),
|
|
15
|
+
_step2;
|
|
16
|
+
try {
|
|
17
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
18
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
19
|
+
column = _step2$value[0],
|
|
20
|
+
element_ = _step2$value[1];
|
|
21
|
+
if (element_.cell === tableCellNode) {
|
|
22
|
+
return column;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
} catch (err) {
|
|
26
|
+
_iterator2.e(err);
|
|
27
|
+
} finally {
|
|
28
|
+
_iterator2.f();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
_iterator.e(err);
|
|
33
|
+
} finally {
|
|
34
|
+
_iterator.f();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export var getCellNodeHeight = function getCellNodeHeight(cell, activeEditor) {
|
|
38
|
+
var domCellNode = activeEditor.getElementByKey(cell.getKey());
|
|
39
|
+
return domCellNode === null || domCellNode === void 0 ? void 0 : domCellNode.clientHeight;
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useDebounce<T extends (...args: never[]) => void>(fn: T, ms: number, maxWait?: number): import("lodash").DebouncedFunc<(...args: Parameters<T>) => void>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { debounce } from 'lodash-es';
|
|
9
|
+
import { useMemo, useRef } from 'react';
|
|
10
|
+
export function useDebounce(fn, ms, maxWait) {
|
|
11
|
+
var funcRef = useRef(null);
|
|
12
|
+
funcRef.current = fn;
|
|
13
|
+
return useMemo(function () {
|
|
14
|
+
return debounce(function () {
|
|
15
|
+
if (funcRef.current) {
|
|
16
|
+
funcRef.current.apply(funcRef, arguments);
|
|
17
|
+
}
|
|
18
|
+
}, ms, {
|
|
19
|
+
maxWait: maxWait
|
|
20
|
+
});
|
|
21
|
+
}, [ms, maxWait]);
|
|
22
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { $findTableNode, $getElementForTableNode, $isTableSelection } from '@lexical/table';
|
|
10
|
+
import EventEmitter from 'eventemitter3';
|
|
11
|
+
import { $getSelection, $isRangeSelection } from 'lexical';
|
|
12
|
+
import { useLayoutEffect, useMemo, useState } from 'react';
|
|
13
|
+
import { useLexicalEditor } from "../../../editor-kernel/react";
|
|
14
|
+
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
15
|
+
import { TablePlugin } from "../plugin";
|
|
16
|
+
import { $updateDOMForSelection } from "../utils";
|
|
17
|
+
import TableActionMenuPlugin from "./TableActionMenu";
|
|
18
|
+
import TableHoverActionsPlugin from "./TableHoverActions";
|
|
19
|
+
import TableCellResizePlugin from "./TableResize";
|
|
20
|
+
import { useStyles } from "./style";
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
export var ReactTablePlugin = function ReactTablePlugin(_ref) {
|
|
25
|
+
var className = _ref.className,
|
|
26
|
+
locale = _ref.locale;
|
|
27
|
+
var _useStyles = useStyles(),
|
|
28
|
+
cx = _useStyles.cx,
|
|
29
|
+
styles = _useStyles.styles;
|
|
30
|
+
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
31
|
+
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
32
|
+
editor = _useLexicalComposerCo2[0];
|
|
33
|
+
var _useState = useState(null),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
lexicalEditor = _useState2[0],
|
|
36
|
+
setLexicalEditor = _useState2[1];
|
|
37
|
+
var eventEmitter = useMemo(function () {
|
|
38
|
+
return new EventEmitter();
|
|
39
|
+
}, []);
|
|
40
|
+
useLayoutEffect(function () {
|
|
41
|
+
if (locale) {
|
|
42
|
+
editor.registerLocale(locale);
|
|
43
|
+
}
|
|
44
|
+
editor.registerPlugin(TablePlugin, {
|
|
45
|
+
theme: cx(styles, className)
|
|
46
|
+
});
|
|
47
|
+
}, []);
|
|
48
|
+
useLexicalEditor(function (editor) {
|
|
49
|
+
setLexicalEditor(editor);
|
|
50
|
+
editor.registerUpdateListener(function () {
|
|
51
|
+
editor.read(function () {
|
|
52
|
+
var selection = $getSelection();
|
|
53
|
+
if (!$isTableSelection(selection) && !$isRangeSelection(selection)) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
var tableNode = $findTableNode(selection.anchor.getNode());
|
|
57
|
+
if (!tableNode) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
$updateDOMForSelection(editor, $getElementForTableNode(editor, tableNode), selection);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
return function () {
|
|
64
|
+
setLexicalEditor(null);
|
|
65
|
+
};
|
|
66
|
+
}, []);
|
|
67
|
+
return lexicalEditor && /*#__PURE__*/_jsxs(_Fragment, {
|
|
68
|
+
children: [/*#__PURE__*/_jsx(TableCellResizePlugin, {
|
|
69
|
+
editor: lexicalEditor,
|
|
70
|
+
eventEmitter: eventEmitter
|
|
71
|
+
}), /*#__PURE__*/_jsx(TableActionMenuPlugin, {
|
|
72
|
+
editor: lexicalEditor
|
|
73
|
+
}), /*#__PURE__*/_jsx(TableHoverActionsPlugin, {
|
|
74
|
+
editor: lexicalEditor
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
77
|
+
};
|
|
@@ -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 overflow-x: auto;\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n\n .editor_table {\n table-layout: fixed;\n border-spacing: 0;\n border-collapse: collapse;\n\n width: fit-content;\n\n text-align: start;\n text-indent: initial;\n text-wrap: pretty;\n word-break: auto-phrase;\n overflow-wrap: break-word;\n\n background: ", ";\n\n > tr:first-of-type {\n background: ", ";\n\n .editor_table_cell_header {\n font-weight: bold;\n }\n }\n }\n\n code {\n word-break: break-word;\n }\n\n .editor_table_cell_header {\n font-weight: normal;\n }\n\n .editor_table_cell {\n position: relative;\n\n overflow: auto;\n\n width: 75px;\n padding-block: 6px;\n padding-inline: 8px;\n border: 1px solid ", ";\n\n text-align: start;\n vertical-align: top;\n\n outline: none;\n }\n\n .editor_table_cell_selected {\n color: #000;\n background-color: ", ";\n caret-color: transparent;\n }\n "])), token.colorFillQuaternary, token.colorFillQuaternary, token.colorFillSecondary, token.yellow);
|
|
8
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TableDOMCell, TableSelection } from '@lexical/table';
|
|
2
|
+
import { TableDOMTable } from '@lexical/table/LexicalTableObserver';
|
|
3
|
+
import { LexicalEditor, LexicalNode, RangeSelection } from 'lexical';
|
|
4
|
+
export declare function $forEachTableCell(grid: TableDOMTable, cb: (cell: TableDOMCell, lexicalNode: LexicalNode, cords: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}) => void): void;
|
|
8
|
+
export declare function $updateDOMForSelection(editor: LexicalEditor, table: TableDOMTable, selection: TableSelection | RangeSelection | null): void;
|