@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,481 @@
|
|
|
1
|
+
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; } } }; }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
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."); }
|
|
4
|
+
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); }
|
|
5
|
+
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; }
|
|
6
|
+
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; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
import { $computeTableMapSkipCellCheck, $deleteTableColumnAtSelection, $deleteTableRowAtSelection, $getTableCellNodeFromLexicalNode, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $insertTableColumnAtSelection, $insertTableRowAtSelection, $isTableCellNode, $isTableSelection, $mergeCells, $unmergeCell, TableCellHeaderStates, TableCellNode, getTableElement, getTableObserverFromTableElement } from '@lexical/table';
|
|
16
|
+
import { mergeRegister } from '@lexical/utils';
|
|
17
|
+
import { ActionIcon, Dropdown } from '@lobehub/ui';
|
|
18
|
+
import { $getSelection, $isRangeSelection, $setSelection, COMMAND_PRIORITY_CRITICAL, SELECTION_CHANGE_COMMAND, getDOMSelection } from 'lexical';
|
|
19
|
+
import { ChevronDown, Grid2X2XIcon, PanelBottomCloseIcon, PanelLeftCloseIcon, PanelRightCloseIcon, PanelTopCloseIcon, TableColumnsSplitIcon, TableRowsSplitIcon } from 'lucide-react';
|
|
20
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
21
|
+
import { createPortal } from 'react-dom';
|
|
22
|
+
import { useTranslation } from "../../../../editor-kernel/react/useTranslation";
|
|
23
|
+
import { useStyles } from "./style";
|
|
24
|
+
import { $canUnmerge, $selectLastDescendant, computeSelectionCount, currentCellBackgroundColor } from "./utils";
|
|
25
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
+
var TableActionMenu = /*#__PURE__*/memo(function (_ref) {
|
|
27
|
+
var editor = _ref.editor,
|
|
28
|
+
_tableCellNode = _ref.tableCellNode,
|
|
29
|
+
cellMerge = _ref.cellMerge,
|
|
30
|
+
children = _ref.children;
|
|
31
|
+
var _useState = useState(_tableCellNode),
|
|
32
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
33
|
+
tableCellNode = _useState2[0],
|
|
34
|
+
updateTableCellNode = _useState2[1];
|
|
35
|
+
var _useState3 = useState({
|
|
36
|
+
columns: 1,
|
|
37
|
+
rows: 1
|
|
38
|
+
}),
|
|
39
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
|
+
selectionCounts = _useState4[0],
|
|
41
|
+
updateSelectionCounts = _useState4[1];
|
|
42
|
+
var _useState5 = useState(false),
|
|
43
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
44
|
+
canMergeCells = _useState6[0],
|
|
45
|
+
setCanMergeCells = _useState6[1];
|
|
46
|
+
var _useState7 = useState(false),
|
|
47
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
48
|
+
canUnmergeCell = _useState8[0],
|
|
49
|
+
setCanUnmergeCell = _useState8[1];
|
|
50
|
+
var _useState9 = useState(function () {
|
|
51
|
+
return currentCellBackgroundColor(editor) || '';
|
|
52
|
+
}),
|
|
53
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
54
|
+
setBackgroundColor = _useState10[1];
|
|
55
|
+
var t = useTranslation();
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
return editor.registerMutationListener(TableCellNode, function (nodeMutations) {
|
|
58
|
+
var nodeUpdated = nodeMutations.get(tableCellNode.getKey()) === 'updated';
|
|
59
|
+
if (nodeUpdated) {
|
|
60
|
+
editor.getEditorState().read(function () {
|
|
61
|
+
updateTableCellNode(tableCellNode.getLatest());
|
|
62
|
+
});
|
|
63
|
+
setBackgroundColor(currentCellBackgroundColor(editor) || '');
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
skipInitialization: true
|
|
67
|
+
});
|
|
68
|
+
}, [editor, tableCellNode]);
|
|
69
|
+
useEffect(function () {
|
|
70
|
+
editor.getEditorState().read(function () {
|
|
71
|
+
var selection = $getSelection();
|
|
72
|
+
// Merge cells
|
|
73
|
+
if ($isTableSelection(selection)) {
|
|
74
|
+
var currentSelectionCounts = computeSelectionCount(selection);
|
|
75
|
+
updateSelectionCounts(computeSelectionCount(selection));
|
|
76
|
+
setCanMergeCells(currentSelectionCounts.columns > 1 || currentSelectionCounts.rows > 1);
|
|
77
|
+
}
|
|
78
|
+
// Unmerge cell
|
|
79
|
+
setCanUnmergeCell($canUnmerge());
|
|
80
|
+
});
|
|
81
|
+
}, [editor]);
|
|
82
|
+
var clearTableSelection = useCallback(function () {
|
|
83
|
+
editor.update(function () {
|
|
84
|
+
if (tableCellNode.isAttached()) {
|
|
85
|
+
var tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
86
|
+
var tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()));
|
|
87
|
+
if (tableElement === null) {
|
|
88
|
+
throw new Error('TableActionMenu: Expected to find tableElement in DOM');
|
|
89
|
+
}
|
|
90
|
+
var tableObserver = getTableObserverFromTableElement(tableElement);
|
|
91
|
+
if (tableObserver !== null) {
|
|
92
|
+
tableObserver.$clearHighlight();
|
|
93
|
+
}
|
|
94
|
+
tableNode.markDirty();
|
|
95
|
+
updateTableCellNode(tableCellNode.getLatest());
|
|
96
|
+
}
|
|
97
|
+
$setSelection(null);
|
|
98
|
+
});
|
|
99
|
+
}, [editor, tableCellNode]);
|
|
100
|
+
var mergeTableCellsAtSelection = function mergeTableCellsAtSelection() {
|
|
101
|
+
editor.update(function () {
|
|
102
|
+
var selection = $getSelection();
|
|
103
|
+
if (!$isTableSelection(selection)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
var nodes = selection.getNodes();
|
|
107
|
+
var tableCells = nodes.filter($isTableCellNode);
|
|
108
|
+
var targetCell = $mergeCells(tableCells);
|
|
109
|
+
if (targetCell) {
|
|
110
|
+
$selectLastDescendant(targetCell);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
var unmergeTableCellsAtSelection = function unmergeTableCellsAtSelection() {
|
|
115
|
+
editor.update(function () {
|
|
116
|
+
$unmergeCell();
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
var insertTableRowAtSelection = useCallback(function (shouldInsertAfter) {
|
|
120
|
+
editor.update(function () {
|
|
121
|
+
for (var i = 0; i < selectionCounts.rows; i++) {
|
|
122
|
+
$insertTableRowAtSelection(shouldInsertAfter);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}, [editor, selectionCounts.rows]);
|
|
126
|
+
var insertTableColumnAtSelection = useCallback(function (shouldInsertAfter) {
|
|
127
|
+
editor.update(function () {
|
|
128
|
+
for (var i = 0; i < selectionCounts.columns; i++) {
|
|
129
|
+
$insertTableColumnAtSelection(shouldInsertAfter);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}, [editor, selectionCounts.columns]);
|
|
133
|
+
var deleteTableRowAtSelection = useCallback(function () {
|
|
134
|
+
editor.update(function () {
|
|
135
|
+
$deleteTableRowAtSelection();
|
|
136
|
+
});
|
|
137
|
+
}, [editor]);
|
|
138
|
+
var deleteTableAtSelection = useCallback(function () {
|
|
139
|
+
editor.update(function () {
|
|
140
|
+
var tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
141
|
+
tableNode.remove();
|
|
142
|
+
clearTableSelection();
|
|
143
|
+
});
|
|
144
|
+
}, [editor, tableCellNode, clearTableSelection]);
|
|
145
|
+
var deleteTableColumnAtSelection = useCallback(function () {
|
|
146
|
+
editor.update(function () {
|
|
147
|
+
$deleteTableColumnAtSelection();
|
|
148
|
+
});
|
|
149
|
+
}, [editor]);
|
|
150
|
+
var toggleTableRowIsHeader = useCallback(function () {
|
|
151
|
+
editor.update(function () {
|
|
152
|
+
var tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
153
|
+
var tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode);
|
|
154
|
+
var _$computeTableMapSkip = $computeTableMapSkipCellCheck(tableNode, null, null),
|
|
155
|
+
_$computeTableMapSkip2 = _slicedToArray(_$computeTableMapSkip, 1),
|
|
156
|
+
gridMap = _$computeTableMapSkip2[0];
|
|
157
|
+
var rowCells = new Set();
|
|
158
|
+
var newStyle = tableCellNode.getHeaderStyles() ^ TableCellHeaderStates.ROW;
|
|
159
|
+
for (var col = 0; col < gridMap[tableRowIndex].length; col++) {
|
|
160
|
+
var mapCell = gridMap[tableRowIndex][col];
|
|
161
|
+
if (!(mapCell !== null && mapCell !== void 0 && mapCell.cell)) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (!rowCells.has(mapCell.cell)) {
|
|
165
|
+
rowCells.add(mapCell.cell);
|
|
166
|
+
mapCell.cell.setHeaderStyles(newStyle, TableCellHeaderStates.ROW);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
clearTableSelection();
|
|
170
|
+
});
|
|
171
|
+
}, [editor, tableCellNode, clearTableSelection]);
|
|
172
|
+
var toggleTableColumnIsHeader = useCallback(function () {
|
|
173
|
+
editor.update(function () {
|
|
174
|
+
var tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
175
|
+
var tableColumnIndex = $getTableColumnIndexFromTableCellNode(tableCellNode);
|
|
176
|
+
var _$computeTableMapSkip3 = $computeTableMapSkipCellCheck(tableNode, null, null),
|
|
177
|
+
_$computeTableMapSkip4 = _slicedToArray(_$computeTableMapSkip3, 1),
|
|
178
|
+
gridMap = _$computeTableMapSkip4[0];
|
|
179
|
+
var columnCells = new Set();
|
|
180
|
+
var newStyle = tableCellNode.getHeaderStyles() ^ TableCellHeaderStates.COLUMN;
|
|
181
|
+
var _iterator = _createForOfIteratorHelper(gridMap),
|
|
182
|
+
_step;
|
|
183
|
+
try {
|
|
184
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
185
|
+
var element = _step.value;
|
|
186
|
+
var mapCell = element[tableColumnIndex];
|
|
187
|
+
if (!(mapCell !== null && mapCell !== void 0 && mapCell.cell)) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (!columnCells.has(mapCell.cell)) {
|
|
191
|
+
columnCells.add(mapCell.cell);
|
|
192
|
+
mapCell.cell.setHeaderStyles(newStyle, TableCellHeaderStates.COLUMN);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
} catch (err) {
|
|
196
|
+
_iterator.e(err);
|
|
197
|
+
} finally {
|
|
198
|
+
_iterator.f();
|
|
199
|
+
}
|
|
200
|
+
clearTableSelection();
|
|
201
|
+
});
|
|
202
|
+
}, [editor, tableCellNode, clearTableSelection]);
|
|
203
|
+
|
|
204
|
+
// Create menu items array with useMemo for performance
|
|
205
|
+
var menuItems = useMemo(function () {
|
|
206
|
+
return [
|
|
207
|
+
// // Merge/Unmerge cells (conditional)
|
|
208
|
+
// ...(cellMerge && canMergeCells
|
|
209
|
+
// ? [
|
|
210
|
+
// {
|
|
211
|
+
// key: 'table-merge-cells',
|
|
212
|
+
// label: 'Merge cells',
|
|
213
|
+
// onClick: () => mergeTableCellsAtSelection(),
|
|
214
|
+
// },
|
|
215
|
+
// ]
|
|
216
|
+
// : []),
|
|
217
|
+
// ...(cellMerge && canUnmergeCell
|
|
218
|
+
// ? [
|
|
219
|
+
// {
|
|
220
|
+
// key: 'table-unmerge-cells',
|
|
221
|
+
// label: 'Unmerge cells',
|
|
222
|
+
// onClick: () => unmergeTableCellsAtSelection(),
|
|
223
|
+
// },
|
|
224
|
+
// ]
|
|
225
|
+
// : []),
|
|
226
|
+
// // Divider after merge operations (if any merge operations exist)
|
|
227
|
+
// ...(cellMerge && (canMergeCells || canUnmergeCell) ? [{ type: 'divider' as const }] : []),
|
|
228
|
+
//
|
|
229
|
+
// // Row operations
|
|
230
|
+
{
|
|
231
|
+
icon: PanelTopCloseIcon,
|
|
232
|
+
key: 'table-insert-row-above',
|
|
233
|
+
label: t("table.insertRowAbove", {
|
|
234
|
+
count: selectionCounts.rows
|
|
235
|
+
}),
|
|
236
|
+
onClick: function onClick() {
|
|
237
|
+
return insertTableRowAtSelection(false);
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
240
|
+
icon: PanelBottomCloseIcon,
|
|
241
|
+
key: 'table-insert-row-below',
|
|
242
|
+
label: t("table.insertRowBelow", {
|
|
243
|
+
count: selectionCounts.rows
|
|
244
|
+
}),
|
|
245
|
+
onClick: function onClick() {
|
|
246
|
+
return insertTableRowAtSelection(true);
|
|
247
|
+
}
|
|
248
|
+
}, {
|
|
249
|
+
type: 'divider'
|
|
250
|
+
},
|
|
251
|
+
// Column operations
|
|
252
|
+
{
|
|
253
|
+
icon: PanelLeftCloseIcon,
|
|
254
|
+
key: 'table-insert-column-before',
|
|
255
|
+
// label: `Insert ${selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`} left`,
|
|
256
|
+
label: t("table.insertColumnLeft", {
|
|
257
|
+
count: selectionCounts.columns
|
|
258
|
+
}),
|
|
259
|
+
onClick: function onClick() {
|
|
260
|
+
return insertTableColumnAtSelection(false);
|
|
261
|
+
}
|
|
262
|
+
}, {
|
|
263
|
+
icon: PanelRightCloseIcon,
|
|
264
|
+
key: 'table-insert-column-after',
|
|
265
|
+
// label: `Insert ${selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`} right`,
|
|
266
|
+
label: t("table.insertColumnRight", {
|
|
267
|
+
count: selectionCounts.columns
|
|
268
|
+
}),
|
|
269
|
+
onClick: function onClick() {
|
|
270
|
+
return insertTableColumnAtSelection(true);
|
|
271
|
+
}
|
|
272
|
+
}, {
|
|
273
|
+
type: 'divider'
|
|
274
|
+
},
|
|
275
|
+
// Delete operations
|
|
276
|
+
{
|
|
277
|
+
icon: TableColumnsSplitIcon,
|
|
278
|
+
key: 'table-delete-columns',
|
|
279
|
+
// label: 'Delete column',
|
|
280
|
+
label: t("table.deleteColumn"),
|
|
281
|
+
onClick: function onClick() {
|
|
282
|
+
return deleteTableColumnAtSelection();
|
|
283
|
+
}
|
|
284
|
+
}, {
|
|
285
|
+
icon: TableRowsSplitIcon,
|
|
286
|
+
key: 'table-delete-rows',
|
|
287
|
+
// label: 'Delete row',
|
|
288
|
+
label: t("table.deleteRow"),
|
|
289
|
+
onClick: function onClick() {
|
|
290
|
+
return deleteTableRowAtSelection();
|
|
291
|
+
}
|
|
292
|
+
}, {
|
|
293
|
+
type: 'divider'
|
|
294
|
+
}, {
|
|
295
|
+
icon: Grid2X2XIcon,
|
|
296
|
+
key: 'table-delete',
|
|
297
|
+
// label: 'Delete table',
|
|
298
|
+
label: t("table.delete"),
|
|
299
|
+
onClick: function onClick() {
|
|
300
|
+
return deleteTableAtSelection();
|
|
301
|
+
}
|
|
302
|
+
}];
|
|
303
|
+
}, [cellMerge, canMergeCells, canUnmergeCell, selectionCounts.rows, selectionCounts.columns, tableCellNode.__headerState, mergeTableCellsAtSelection, unmergeTableCellsAtSelection, insertTableRowAtSelection, insertTableColumnAtSelection, deleteTableColumnAtSelection, deleteTableRowAtSelection, deleteTableAtSelection, toggleTableRowIsHeader, toggleTableColumnIsHeader]);
|
|
304
|
+
return /*#__PURE__*/_jsx(Dropdown, {
|
|
305
|
+
menu: {
|
|
306
|
+
items: menuItems
|
|
307
|
+
},
|
|
308
|
+
children: children
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
function TableCellActionMenuContainer(_ref2) {
|
|
312
|
+
var anchorElem = _ref2.anchorElem,
|
|
313
|
+
cellMerge = _ref2.cellMerge,
|
|
314
|
+
editor = _ref2.editor;
|
|
315
|
+
var menuButtonRef = useRef(null);
|
|
316
|
+
var _useState11 = useState(null),
|
|
317
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
318
|
+
tableCellNode = _useState12[0],
|
|
319
|
+
setTableMenuCellNode = _useState12[1];
|
|
320
|
+
|
|
321
|
+
// const [colorPickerModal, showColorPickerModal] = useModal();
|
|
322
|
+
|
|
323
|
+
var checkTableCellOverflow = useCallback(function (tableCellParentNodeDOM) {
|
|
324
|
+
var scrollableContainer = tableCellParentNodeDOM.closest('.PlaygroundEditorTheme__tableScrollableWrapper');
|
|
325
|
+
if (scrollableContainer) {
|
|
326
|
+
var containerRect = scrollableContainer.getBoundingClientRect();
|
|
327
|
+
var cellRect = tableCellParentNodeDOM.getBoundingClientRect();
|
|
328
|
+
|
|
329
|
+
// Calculate where the action button would be positioned (5px from right edge of cell)
|
|
330
|
+
// Also account for the button width and table cell padding (8px)
|
|
331
|
+
var actionButtonRight = cellRect.right - 5;
|
|
332
|
+
var actionButtonLeft = actionButtonRight - 28; // 20px width + 8px padding
|
|
333
|
+
|
|
334
|
+
// Only hide if the action button would overflow the container
|
|
335
|
+
if (actionButtonRight > containerRect.right || actionButtonLeft < containerRect.left) {
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return false;
|
|
340
|
+
}, []);
|
|
341
|
+
var $moveMenu = useCallback(function () {
|
|
342
|
+
var menu = menuButtonRef.current;
|
|
343
|
+
var selection = $getSelection();
|
|
344
|
+
var nativeSelection = getDOMSelection(editor._window);
|
|
345
|
+
var activeElement = typeof document !== 'undefined' ? document.activeElement : null;
|
|
346
|
+
function disable() {
|
|
347
|
+
if (menu) {
|
|
348
|
+
menu.classList.remove('table-cell-action-button-container--active');
|
|
349
|
+
menu.classList.add('table-cell-action-button-container--inactive');
|
|
350
|
+
}
|
|
351
|
+
setTableMenuCellNode(null);
|
|
352
|
+
}
|
|
353
|
+
if (!selection || !menu) {
|
|
354
|
+
return disable();
|
|
355
|
+
}
|
|
356
|
+
var rootElement = editor.getRootElement();
|
|
357
|
+
var tableObserver = null;
|
|
358
|
+
var tableCellParentNodeDOM = null;
|
|
359
|
+
if ($isRangeSelection(selection) && rootElement !== null && nativeSelection !== null && rootElement.contains(nativeSelection.anchorNode)) {
|
|
360
|
+
var tableCellNodeFromSelection = $getTableCellNodeFromLexicalNode(selection.anchor.getNode());
|
|
361
|
+
if (!tableCellNodeFromSelection) {
|
|
362
|
+
return disable();
|
|
363
|
+
}
|
|
364
|
+
tableCellParentNodeDOM = editor.getElementByKey(tableCellNodeFromSelection.getKey());
|
|
365
|
+
if (!tableCellParentNodeDOM || !tableCellNodeFromSelection.isAttached()) {
|
|
366
|
+
return disable();
|
|
367
|
+
}
|
|
368
|
+
if (checkTableCellOverflow(tableCellParentNodeDOM)) {
|
|
369
|
+
return disable();
|
|
370
|
+
}
|
|
371
|
+
var tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNodeFromSelection);
|
|
372
|
+
var tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()));
|
|
373
|
+
if (tableElement === null) {
|
|
374
|
+
throw new Error('TableActionMenu: Expected to find tableElement in DOM');
|
|
375
|
+
}
|
|
376
|
+
tableObserver = getTableObserverFromTableElement(tableElement);
|
|
377
|
+
setTableMenuCellNode(tableCellNodeFromSelection);
|
|
378
|
+
} else if ($isTableSelection(selection)) {
|
|
379
|
+
var anchorNode = $getTableCellNodeFromLexicalNode(selection.anchor.getNode());
|
|
380
|
+
if (!$isTableCellNode(anchorNode)) {
|
|
381
|
+
throw new Error('TableSelection anchorNode must be a TableCellNode');
|
|
382
|
+
}
|
|
383
|
+
var _tableNode = $getTableNodeFromLexicalNodeOrThrow(anchorNode);
|
|
384
|
+
var _tableElement = getTableElement(_tableNode, editor.getElementByKey(_tableNode.getKey()));
|
|
385
|
+
if (_tableElement === null) {
|
|
386
|
+
throw new Error('TableActionMenu: Expected to find tableElement in DOM');
|
|
387
|
+
}
|
|
388
|
+
tableObserver = getTableObserverFromTableElement(_tableElement);
|
|
389
|
+
tableCellParentNodeDOM = editor.getElementByKey(anchorNode.getKey());
|
|
390
|
+
if (tableCellParentNodeDOM === null) {
|
|
391
|
+
return disable();
|
|
392
|
+
}
|
|
393
|
+
if (checkTableCellOverflow(tableCellParentNodeDOM)) {
|
|
394
|
+
return disable();
|
|
395
|
+
}
|
|
396
|
+
} else if (!activeElement) {
|
|
397
|
+
return disable();
|
|
398
|
+
}
|
|
399
|
+
if (tableObserver === null || tableCellParentNodeDOM === null) {
|
|
400
|
+
return disable();
|
|
401
|
+
}
|
|
402
|
+
var enabled = !tableObserver || !tableObserver.isSelecting;
|
|
403
|
+
menu.classList.toggle('table-cell-action-button-container--active', enabled);
|
|
404
|
+
menu.classList.toggle('table-cell-action-button-container--inactive', !enabled);
|
|
405
|
+
if (enabled) {
|
|
406
|
+
var tableCellRect = tableCellParentNodeDOM.getBoundingClientRect();
|
|
407
|
+
var anchorRect = anchorElem.getBoundingClientRect();
|
|
408
|
+
var top = tableCellRect.top - anchorRect.top;
|
|
409
|
+
var left = tableCellRect.right - anchorRect.left;
|
|
410
|
+
menu.style.transform = "translate(".concat(left, "px, ").concat(top, "px)");
|
|
411
|
+
}
|
|
412
|
+
}, [editor, anchorElem, checkTableCellOverflow]);
|
|
413
|
+
useEffect(function () {
|
|
414
|
+
// We call the $moveMenu callback every time the selection changes,
|
|
415
|
+
// once up front, and once after each pointerUp
|
|
416
|
+
var timeoutId = undefined;
|
|
417
|
+
var callback = function callback() {
|
|
418
|
+
timeoutId = undefined;
|
|
419
|
+
editor.getEditorState().read($moveMenu);
|
|
420
|
+
};
|
|
421
|
+
var delayedCallback = function delayedCallback() {
|
|
422
|
+
if (timeoutId === undefined) {
|
|
423
|
+
timeoutId = setTimeout(callback, 0);
|
|
424
|
+
}
|
|
425
|
+
return false;
|
|
426
|
+
};
|
|
427
|
+
return mergeRegister(editor.registerUpdateListener(delayedCallback), editor.registerCommand(SELECTION_CHANGE_COMMAND, delayedCallback, COMMAND_PRIORITY_CRITICAL), editor.registerRootListener(function (rootElement, prevRootElement) {
|
|
428
|
+
if (prevRootElement) {
|
|
429
|
+
prevRootElement.removeEventListener('pointerup', delayedCallback);
|
|
430
|
+
}
|
|
431
|
+
if (rootElement) {
|
|
432
|
+
rootElement.addEventListener('pointerup', delayedCallback);
|
|
433
|
+
delayedCallback();
|
|
434
|
+
}
|
|
435
|
+
}), function () {
|
|
436
|
+
return clearTimeout(timeoutId);
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
var prevTableCellDOM = useRef(tableCellNode);
|
|
440
|
+
useEffect(function () {
|
|
441
|
+
prevTableCellDOM.current = tableCellNode;
|
|
442
|
+
}, [prevTableCellDOM, tableCellNode]);
|
|
443
|
+
var _useStyles = useStyles(),
|
|
444
|
+
styles = _useStyles.styles;
|
|
445
|
+
return /*#__PURE__*/_jsx("div", {
|
|
446
|
+
className: styles,
|
|
447
|
+
ref: menuButtonRef,
|
|
448
|
+
children: tableCellNode && /*#__PURE__*/_jsx(TableActionMenu, {
|
|
449
|
+
cellMerge: cellMerge,
|
|
450
|
+
editor: editor,
|
|
451
|
+
tableCellNode: tableCellNode,
|
|
452
|
+
children: /*#__PURE__*/_jsx(ActionIcon, {
|
|
453
|
+
glass: true,
|
|
454
|
+
icon: ChevronDown,
|
|
455
|
+
size: 'small',
|
|
456
|
+
style: {
|
|
457
|
+
position: 'absolute',
|
|
458
|
+
right: 4,
|
|
459
|
+
top: 4
|
|
460
|
+
},
|
|
461
|
+
variant: 'filled'
|
|
462
|
+
})
|
|
463
|
+
})
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
export default /*#__PURE__*/memo(function (_ref3) {
|
|
467
|
+
var anchorElem = _ref3.anchorElem,
|
|
468
|
+
_ref3$cellMerge = _ref3.cellMerge,
|
|
469
|
+
cellMerge = _ref3$cellMerge === void 0 ? false : _ref3$cellMerge,
|
|
470
|
+
editor = _ref3.editor;
|
|
471
|
+
// Don't render portal on server side
|
|
472
|
+
if (typeof document === 'undefined') {
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
var targetElement = anchorElem || document.body;
|
|
476
|
+
return /*#__PURE__*/createPortal( /*#__PURE__*/_jsx(TableCellActionMenuContainer, {
|
|
477
|
+
anchorElem: targetElement,
|
|
478
|
+
cellMerge: cellMerge,
|
|
479
|
+
editor: editor
|
|
480
|
+
}), targetElement);
|
|
481
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<import("antd-style").SerializedStyles>;
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n will-change: transform;\n\n position: absolute;\n z-index: 3;\n inset-block-start: 0;\n inset-inline-start: 0;\n "])));
|
|
7
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TableSelection } from '@lexical/table';
|
|
2
|
+
import { type ElementNode, type LexicalEditor } from 'lexical';
|
|
3
|
+
export declare function computeSelectionCount(selection: TableSelection): {
|
|
4
|
+
columns: number;
|
|
5
|
+
rows: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function $canUnmerge(): boolean;
|
|
8
|
+
export declare function $selectLastDescendant(node: ElementNode): void;
|
|
9
|
+
export declare function currentCellBackgroundColor(editor: LexicalEditor): null | string;
|
|
@@ -0,0 +1,49 @@
|
|
|
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 _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { $getNodeTriplet, $isTableCellNode, $isTableSelection } from '@lexical/table';
|
|
8
|
+
import { $getSelection, $isElementNode, $isRangeSelection, $isTextNode } from 'lexical';
|
|
9
|
+
export function computeSelectionCount(selection) {
|
|
10
|
+
var selectionShape = selection.getShape();
|
|
11
|
+
return {
|
|
12
|
+
columns: selectionShape.toX - selectionShape.fromX + 1,
|
|
13
|
+
rows: selectionShape.toY - selectionShape.fromY + 1
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function $canUnmerge() {
|
|
17
|
+
var selection = $getSelection();
|
|
18
|
+
if ($isRangeSelection(selection) && !selection.isCollapsed() || $isTableSelection(selection) && !selection.anchor.is(selection.focus) || !$isRangeSelection(selection) && !$isTableSelection(selection)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
var _$getNodeTriplet = $getNodeTriplet(selection.anchor),
|
|
22
|
+
_$getNodeTriplet2 = _slicedToArray(_$getNodeTriplet, 1),
|
|
23
|
+
cell = _$getNodeTriplet2[0];
|
|
24
|
+
return cell.__colSpan > 1 || cell.__rowSpan > 1;
|
|
25
|
+
}
|
|
26
|
+
export function $selectLastDescendant(node) {
|
|
27
|
+
var lastDescendant = node.getLastDescendant();
|
|
28
|
+
if ($isTextNode(lastDescendant)) {
|
|
29
|
+
lastDescendant.select();
|
|
30
|
+
} else if ($isElementNode(lastDescendant)) {
|
|
31
|
+
lastDescendant.selectEnd();
|
|
32
|
+
} else if (lastDescendant !== null) {
|
|
33
|
+
lastDescendant.selectNext();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function currentCellBackgroundColor(editor) {
|
|
37
|
+
return editor.getEditorState().read(function () {
|
|
38
|
+
var selection = $getSelection();
|
|
39
|
+
if ($isRangeSelection(selection) || $isTableSelection(selection)) {
|
|
40
|
+
var _$getNodeTriplet3 = $getNodeTriplet(selection.anchor),
|
|
41
|
+
_$getNodeTriplet4 = _slicedToArray(_$getNodeTriplet3, 1),
|
|
42
|
+
cell = _$getNodeTriplet4[0];
|
|
43
|
+
if ($isTableCellNode(cell)) {
|
|
44
|
+
return cell.getBackgroundColor();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LexicalEditor } from 'lexical';
|
|
3
|
+
declare const _default: import("react").MemoExoticComponent<({ anchorElem, editor }: {
|
|
4
|
+
anchorElem?: HTMLElement | undefined;
|
|
5
|
+
editor: LexicalEditor;
|
|
6
|
+
}) => import("react").ReactPortal | null>;
|
|
7
|
+
export default _default;
|