@payloadcms/richtext-lexical 3.68.0-internal-debug.185cc5f → 3.68.0-internal-debug.591ab42
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/dist/cell/rscEntry.js +13 -5
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +29 -9
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +7 -3
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockEditButton.js +6 -2
- package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js +6 -2
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/component/index.js +123 -43
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/component/index.scss +188 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +7 -3
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +6 -2
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +6 -2
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +6 -2
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +117 -37
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.scss +90 -0
- package/dist/features/blocks/client/getBlockImageComponent.js +7 -3
- package/dist/features/blocks/client/getBlockImageComponent.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +7 -3
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +7 -3
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +87 -27
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js +7 -3
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +12 -4
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.scss +6 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +18 -6
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.scss +29 -0
- package/dist/features/blocks/premade/CodeBlock/Component/index.scss +97 -0
- package/dist/features/converters/lexicalToJSX/Component/index.js +9 -5
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js +7 -3
- package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +7 -3
- package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js +6 -2
- package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js +6 -2
- package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js +13 -5
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/list.js +38 -14
- package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js +18 -6
- package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/table.js +31 -11
- package/dist/features/converters/lexicalToJSX/converter/converters/table.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/text.js +43 -15
- package/dist/features/converters/lexicalToJSX/converter/converters/text.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +31 -11
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +8 -4
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +13 -5
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/style.scss +12 -0
- package/dist/features/debug/testRecorder/client/plugin/index.js +61 -21
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.scss +53 -0
- package/dist/features/debug/treeView/client/plugin/index.js +7 -3
- package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
- package/dist/features/debug/treeView/client/plugin/index.scss +80 -0
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +224 -72
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.scss +87 -0
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +31 -11
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.scss +11 -0
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +21 -9
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +25 -9
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.scss +233 -0
- package/dist/features/horizontalRule/client/plugin/index.scss +23 -0
- package/dist/features/indent/client/IndentPlugin.js +6 -2
- package/dist/features/indent/client/IndentPlugin.js.map +1 -1
- package/dist/features/link/client/plugins/clickableLink/index.js +6 -2
- package/dist/features/link/client/plugins/clickableLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +76 -24
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js +7 -3
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.scss +92 -0
- package/dist/features/lists/checklist/client/plugin/index.js +6 -2
- package/dist/features/lists/checklist/client/plugin/index.js.map +1 -1
- package/dist/features/lists/plugin/index.js +6 -2
- package/dist/features/lists/plugin/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +13 -5
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +7 -3
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.scss +16 -0
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +13 -5
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +7 -3
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.scss +16 -0
- package/dist/features/relationship/client/components/RelationshipComponent.js +55 -19
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/components/index.scss +95 -0
- package/dist/features/relationship/client/drawer/index.js +18 -6
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.js +7 -3
- package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +7 -3
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/textState/feature.client.js +18 -6
- package/dist/features/textState/feature.client.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +71 -23
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.scss +113 -0
- package/dist/features/toolbars/inline/client/Toolbar/index.js +71 -23
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.scss +58 -0
- package/dist/features/toolbars/shared/ToolbarButton/index.js +7 -3
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.scss +46 -0
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +60 -20
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +36 -12
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.scss +129 -0
- package/dist/features/upload/client/component/index.js +91 -31
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/component/index.scss +191 -0
- package/dist/features/upload/client/component/pending/index.js +13 -5
- package/dist/features/upload/client/component/pending/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.js +18 -6
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +12 -4
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js +7 -3
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/field/Diff/converters/listitem/index.js +36 -12
- package/dist/field/Diff/converters/listitem/index.js.map +1 -1
- package/dist/field/Diff/converters/listitem/index.scss +47 -0
- package/dist/field/Diff/converters/relationship/index.js +36 -12
- package/dist/field/Diff/converters/relationship/index.js.map +1 -1
- package/dist/field/Diff/converters/relationship/index.scss +73 -0
- package/dist/field/Diff/converters/unknown/index.js +30 -10
- package/dist/field/Diff/converters/unknown/index.js.map +1 -1
- package/dist/field/Diff/converters/unknown/index.scss +40 -0
- package/dist/field/Diff/converters/upload/index.js +59 -19
- package/dist/field/Diff/converters/upload/index.js.map +1 -1
- package/dist/field/Diff/converters/upload/index.scss +115 -0
- package/dist/field/Diff/index.js +7 -3
- package/dist/field/Diff/index.js.map +1 -1
- package/dist/field/Diff/index.scss +102 -0
- package/dist/field/Field.js +79 -27
- package/dist/field/Field.js.map +1 -1
- package/dist/field/RenderLexical/index.js +36 -12
- package/dist/field/RenderLexical/index.js.map +1 -1
- package/dist/field/index.js +19 -7
- package/dist/field/index.js.map +1 -1
- package/dist/field/index.scss +41 -0
- package/dist/field/rscEntry.js +7 -3
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/lexical/EditorPlugin.js +13 -5
- package/dist/lexical/EditorPlugin.js.map +1 -1
- package/dist/lexical/LexicalEditor.js +162 -50
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalEditor.scss +54 -0
- package/dist/lexical/LexicalProvider.js +49 -17
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +7 -3
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.scss +13 -0
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +19 -7
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.scss +54 -0
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +7 -3
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +48 -16
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.scss +68 -0
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +19 -7
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.scss +35 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +31 -11
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.scss +80 -0
- package/dist/lexical/theme/EditorTheme.scss +357 -0
- package/dist/lexical/ui/ContentEditable.js +13 -5
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.scss +105 -0
- package/dist/lexical/ui/icons/AI/index.js +37 -13
- package/dist/lexical/ui/icons/AI/index.js.map +1 -1
- package/dist/lexical/ui/icons/Add/index.js +19 -7
- package/dist/lexical/ui/icons/Add/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignCenter/index.js +25 -9
- package/dist/lexical/ui/icons/AlignCenter/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignJustify/index.js +25 -9
- package/dist/lexical/ui/icons/AlignJustify/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignLeft/index.js +25 -9
- package/dist/lexical/ui/icons/AlignLeft/index.js.map +1 -1
- package/dist/lexical/ui/icons/AlignRight/index.js +25 -9
- package/dist/lexical/ui/icons/AlignRight/index.js.map +1 -1
- package/dist/lexical/ui/icons/Block/index.js +25 -9
- package/dist/lexical/ui/icons/Block/index.js.map +1 -1
- package/dist/lexical/ui/icons/Blockquote/index.js +13 -5
- package/dist/lexical/ui/icons/Blockquote/index.js.map +1 -1
- package/dist/lexical/ui/icons/Bold/index.js +13 -5
- package/dist/lexical/ui/icons/Bold/index.js.map +1 -1
- package/dist/lexical/ui/icons/Checklist/index.js +19 -7
- package/dist/lexical/ui/icons/Checklist/index.js.map +1 -1
- package/dist/lexical/ui/icons/Code/index.js +19 -7
- package/dist/lexical/ui/icons/Code/index.js.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.js +13 -5
- package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
- package/dist/lexical/ui/icons/Collapse/index.js +13 -5
- package/dist/lexical/ui/icons/Collapse/index.js.map +1 -1
- package/dist/lexical/ui/icons/H1/index.js +13 -5
- package/dist/lexical/ui/icons/H1/index.js.map +1 -1
- package/dist/lexical/ui/icons/H2/index.js +13 -5
- package/dist/lexical/ui/icons/H2/index.js.map +1 -1
- package/dist/lexical/ui/icons/H3/index.js +13 -5
- package/dist/lexical/ui/icons/H3/index.js.map +1 -1
- package/dist/lexical/ui/icons/H4/index.js +13 -5
- package/dist/lexical/ui/icons/H4/index.js.map +1 -1
- package/dist/lexical/ui/icons/H5/index.js +13 -5
- package/dist/lexical/ui/icons/H5/index.js.map +1 -1
- package/dist/lexical/ui/icons/H6/index.js +13 -5
- package/dist/lexical/ui/icons/H6/index.js.map +1 -1
- package/dist/lexical/ui/icons/HorizontalRule/index.js +13 -5
- package/dist/lexical/ui/icons/HorizontalRule/index.js.map +1 -1
- package/dist/lexical/ui/icons/IndentDecrease/index.js +31 -11
- package/dist/lexical/ui/icons/IndentDecrease/index.js.map +1 -1
- package/dist/lexical/ui/icons/IndentIncrease/index.js +31 -11
- package/dist/lexical/ui/icons/IndentIncrease/index.js.map +1 -1
- package/dist/lexical/ui/icons/InlineBlocks/index.js +13 -5
- package/dist/lexical/ui/icons/InlineBlocks/index.js.map +1 -1
- package/dist/lexical/ui/icons/Italic/index.js +13 -5
- package/dist/lexical/ui/icons/Italic/index.js.map +1 -1
- package/dist/lexical/ui/icons/Link/index.js +13 -5
- package/dist/lexical/ui/icons/Link/index.js.map +1 -1
- package/dist/lexical/ui/icons/Meatballs/index.js +25 -9
- package/dist/lexical/ui/icons/Meatballs/index.js.map +1 -1
- package/dist/lexical/ui/icons/OrderedList/index.js +37 -13
- package/dist/lexical/ui/icons/OrderedList/index.js.map +1 -1
- package/dist/lexical/ui/icons/Relationship/index.js +37 -13
- package/dist/lexical/ui/icons/Relationship/index.js.map +1 -1
- package/dist/lexical/ui/icons/Strikethrough/index.js +19 -7
- package/dist/lexical/ui/icons/Strikethrough/index.js.map +1 -1
- package/dist/lexical/ui/icons/Subscript/index.js +13 -5
- package/dist/lexical/ui/icons/Subscript/index.js.map +1 -1
- package/dist/lexical/ui/icons/Superscript/index.js +13 -5
- package/dist/lexical/ui/icons/Superscript/index.js.map +1 -1
- package/dist/lexical/ui/icons/Table/index.js +13 -5
- package/dist/lexical/ui/icons/Table/index.js.map +1 -1
- package/dist/lexical/ui/icons/Text/index.js +13 -5
- package/dist/lexical/ui/icons/Text/index.js.map +1 -1
- package/dist/lexical/ui/icons/TextState/index.js +7 -3
- package/dist/lexical/ui/icons/TextState/index.js.map +1 -1
- package/dist/lexical/ui/icons/Underline/index.js +19 -7
- package/dist/lexical/ui/icons/Underline/index.js.map +1 -1
- package/dist/lexical/ui/icons/UnorderedList/index.js +43 -15
- package/dist/lexical/ui/icons/UnorderedList/index.js.map +1 -1
- package/dist/lexical/ui/icons/Upload/index.js +25 -9
- package/dist/lexical/ui/icons/Upload/index.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js +19 -7
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +19 -7
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js +7 -3
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js +7 -3
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
- package/package.json +9 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TableActionMenuPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableObserver, TableSelection } from '@lexical/table'\nimport type { ElementNode } from 'lexical'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $computeTableMapSkipCellCheck,\n $deleteTableColumnAtSelection,\n $deleteTableRowAtSelection,\n $getNodeTriplet,\n $getTableCellNodeFromLexicalNode,\n $getTableColumnIndexFromTableCellNode,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $insertTableColumnAtSelection,\n $insertTableRowAtSelection,\n $isTableCellNode,\n $isTableSelection,\n $mergeCells,\n $unmergeCell,\n getTableElement,\n getTableObserverFromTableElement,\n TableCellHeaderStates,\n TableCellNode,\n} from '@lexical/table'\nimport { mergeRegister } from '@lexical/utils'\nimport { useScrollInfo } from '@payloadcms/ui'\nimport {\n $getSelection,\n $isElementNode,\n $isRangeSelection,\n $isTextNode,\n $setSelection,\n COMMAND_PRIORITY_CRITICAL,\n getDOMSelection,\n isDOMNode,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponentWithAnchor } from '../../../../typesClient.js'\n\nimport './index.scss'\nimport { MeatballsIcon } from '../../../../../lexical/ui/icons/Meatballs/index.js'\n\nfunction computeSelectionCount(selection: TableSelection): {\n columns: number\n rows: number\n} {\n const selectionShape = selection.getShape()\n return {\n columns: selectionShape.toX - selectionShape.fromX + 1,\n rows: selectionShape.toY - selectionShape.fromY + 1,\n }\n}\n\nfunction $canUnmerge(): boolean {\n const selection = $getSelection()\n if (\n ($isRangeSelection(selection) && !selection.isCollapsed()) ||\n ($isTableSelection(selection) && !selection.anchor.is(selection.focus)) ||\n (!$isRangeSelection(selection) && !$isTableSelection(selection))\n ) {\n return false\n }\n const [cell] = $getNodeTriplet(selection.anchor)\n return cell.__colSpan > 1 || cell.__rowSpan > 1\n}\n\nfunction $selectLastDescendant(node: ElementNode): void {\n const lastDescendant = node.getLastDescendant()\n if ($isTextNode(lastDescendant)) {\n lastDescendant.select()\n } else if ($isElementNode(lastDescendant)) {\n lastDescendant.selectEnd()\n } else if (lastDescendant !== null) {\n lastDescendant.selectNext()\n }\n}\n\ntype TableCellActionMenuProps = Readonly<{\n cellMerge: boolean\n contextRef: { current: HTMLElement | null }\n onClose: () => void\n setIsMenuOpen: (isOpen: boolean) => void\n tableCellNode: TableCellNode\n}>\n\nfunction TableActionMenu({\n cellMerge,\n contextRef,\n onClose,\n setIsMenuOpen,\n tableCellNode: _tableCellNode,\n}: TableCellActionMenuProps) {\n const [editor] = useLexicalComposerContext()\n const dropDownRef = useRef<HTMLDivElement | null>(null)\n const [tableCellNode, updateTableCellNode] = useState(_tableCellNode)\n const [selectionCounts, updateSelectionCounts] = useState({\n columns: 1,\n rows: 1,\n })\n const [canMergeCells, setCanMergeCells] = useState(false)\n const [canUnmergeCell, setCanUnmergeCell] = useState(false)\n const { y } = useScrollInfo()\n\n useEffect(() => {\n return editor.registerMutationListener(\n TableCellNode,\n (nodeMutations) => {\n const nodeUpdated = nodeMutations.get(tableCellNode.getKey()) === 'updated'\n\n if (nodeUpdated) {\n editor.getEditorState().read(() => {\n updateTableCellNode(tableCellNode.getLatest())\n })\n }\n },\n { skipInitialization: true },\n )\n }, [editor, tableCellNode])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n // Merge cells\n if ($isTableSelection(selection)) {\n const currentSelectionCounts = computeSelectionCount(selection)\n updateSelectionCounts(computeSelectionCount(selection))\n\n setCanMergeCells(currentSelectionCounts.columns > 1 || currentSelectionCounts.rows > 1)\n }\n // Unmerge cell\n setCanUnmergeCell($canUnmerge())\n })\n }, [editor])\n\n useEffect(() => {\n const menuButtonElement = contextRef.current\n const dropDownElement = dropDownRef.current\n const rootElement = editor.getRootElement()\n\n if (menuButtonElement != null && dropDownElement != null && rootElement != null) {\n const rootEleRect = rootElement.getBoundingClientRect()\n const menuButtonRect = menuButtonElement.getBoundingClientRect()\n dropDownElement.style.opacity = '1'\n const dropDownElementRect = dropDownElement.getBoundingClientRect()\n const margin = 5\n let leftPosition = menuButtonRect.right + margin\n if (\n leftPosition + dropDownElementRect.width > window.innerWidth ||\n leftPosition + dropDownElementRect.width > rootEleRect.right\n ) {\n const position = menuButtonRect.left - dropDownElementRect.width - margin\n leftPosition = (position < 0 ? margin : position) + window.pageXOffset\n }\n dropDownElement.style.left = `${leftPosition + window.pageXOffset}px`\n\n let topPosition = menuButtonRect.top\n if (topPosition + dropDownElementRect.height > window.innerHeight) {\n const position = menuButtonRect.bottom - dropDownElementRect.height\n topPosition = position < 0 ? margin : position\n }\n dropDownElement.style.top = `${topPosition}px`\n }\n }, [contextRef, dropDownRef, editor, y])\n\n useEffect(() => {\n function handleClickOutside(event: MouseEvent) {\n if (\n dropDownRef.current != null &&\n contextRef.current != null &&\n isDOMNode(event.target) &&\n !dropDownRef.current.contains(event.target) &&\n !contextRef.current.contains(event.target)\n ) {\n setIsMenuOpen(false)\n }\n }\n\n window.addEventListener('click', handleClickOutside)\n\n return () => window.removeEventListener('click', handleClickOutside)\n }, [setIsMenuOpen, contextRef])\n\n const clearTableSelection = useCallback(() => {\n editor.update(() => {\n if (tableCellNode.isAttached()) {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()))\n\n if (tableElement === null) {\n throw new Error('Expected to find tableElement in DOM')\n }\n\n const tableObserver = getTableObserverFromTableElement(tableElement)\n if (tableObserver !== null) {\n tableObserver.$clearHighlight()\n }\n\n tableNode.markDirty()\n updateTableCellNode(tableCellNode.getLatest())\n }\n\n $setSelection(null)\n })\n }, [editor, tableCellNode])\n\n const mergeTableCellsAtSelection = () => {\n editor.update(() => {\n const selection = $getSelection()\n if (!$isTableSelection(selection)) {\n return\n }\n const nodes = selection.getNodes()\n const tableCells = nodes.filter($isTableCellNode)\n const targetCell = $mergeCells(tableCells)\n\n if (targetCell) {\n $selectLastDescendant(targetCell)\n onClose()\n }\n })\n }\n\n const unmergeTableCellsAtSelection = () => {\n editor.update(() => {\n $unmergeCell()\n })\n }\n\n const insertTableRowAtSelection = useCallback(\n (shouldInsertAfter: boolean) => {\n editor.update(() => {\n for (let i = 0; i < selectionCounts.rows; i++) {\n $insertTableRowAtSelection(shouldInsertAfter)\n }\n onClose()\n })\n },\n [editor, onClose, selectionCounts.rows],\n )\n\n const insertTableColumnAtSelection = useCallback(\n (shouldInsertAfter: boolean) => {\n editor.update(() => {\n for (let i = 0; i < selectionCounts.columns; i++) {\n $insertTableColumnAtSelection(shouldInsertAfter)\n }\n onClose()\n })\n },\n [editor, onClose, selectionCounts.columns],\n )\n\n const deleteTableRowAtSelection = useCallback(() => {\n editor.update(() => {\n $deleteTableRowAtSelection()\n onClose()\n })\n }, [editor, onClose])\n\n const deleteTableAtSelection = useCallback(() => {\n editor.update(() => {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n tableNode.remove()\n\n clearTableSelection()\n onClose()\n })\n }, [editor, tableCellNode, clearTableSelection, onClose])\n\n const deleteTableColumnAtSelection = useCallback(() => {\n editor.update(() => {\n $deleteTableColumnAtSelection()\n onClose()\n })\n }, [editor, onClose])\n\n const toggleTableRowIsHeader = useCallback(() => {\n editor.update(() => {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode)\n\n const [gridMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n\n const rowCells = new Set<TableCellNode>()\n\n const newStyle = tableCellNode.getHeaderStyles() ^ TableCellHeaderStates.ROW\n if (gridMap[tableRowIndex]) {\n for (let col = 0; col < gridMap[tableRowIndex].length; col++) {\n const mapCell = gridMap[tableRowIndex][col]\n\n if (!mapCell?.cell) {\n continue\n }\n\n if (!rowCells.has(mapCell.cell)) {\n rowCells.add(mapCell.cell)\n mapCell.cell.setHeaderStyles(newStyle, TableCellHeaderStates.ROW)\n }\n }\n }\n\n clearTableSelection()\n onClose()\n })\n }, [editor, tableCellNode, clearTableSelection, onClose])\n\n const toggleTableColumnIsHeader = useCallback(() => {\n editor.update(() => {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const tableColumnIndex = $getTableColumnIndexFromTableCellNode(tableCellNode)\n\n const [gridMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n\n const columnCells = new Set<TableCellNode>()\n\n const newStyle = tableCellNode.getHeaderStyles() ^ TableCellHeaderStates.COLUMN\n if (gridMap) {\n for (let row = 0; row < gridMap.length; row++) {\n const mapCell = gridMap?.[row]?.[tableColumnIndex]\n\n if (!mapCell?.cell) {\n continue\n }\n\n if (!columnCells.has(mapCell.cell)) {\n columnCells.add(mapCell.cell)\n mapCell.cell.setHeaderStyles(newStyle, TableCellHeaderStates.COLUMN)\n }\n }\n }\n\n clearTableSelection()\n onClose()\n })\n }, [editor, tableCellNode, clearTableSelection, onClose])\n\n const toggleRowStriping = useCallback(() => {\n editor.update(() => {\n if (tableCellNode.isAttached()) {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n if (tableNode) {\n tableNode.setRowStriping(!tableNode.getRowStriping())\n }\n }\n\n clearTableSelection()\n onClose()\n })\n }, [editor, tableCellNode, clearTableSelection, onClose])\n\n const toggleFirstColumnFreeze = useCallback(() => {\n editor.update(() => {\n if (tableCellNode.isAttached()) {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n if (tableNode) {\n tableNode.setFrozenColumns(tableNode.getFrozenColumns() === 0 ? 1 : 0)\n }\n }\n clearTableSelection()\n onClose()\n })\n }, [editor, tableCellNode, clearTableSelection, onClose])\n\n let mergeCellButton: JSX.Element | null = null\n if (cellMerge) {\n if (canMergeCells) {\n mergeCellButton = (\n <button\n className=\"item\"\n data-test-id=\"table-merge-cells\"\n onClick={() => mergeTableCellsAtSelection()}\n type=\"button\"\n >\n <span className=\"text\">Merge cells</span>\n </button>\n )\n } else if (canUnmergeCell) {\n mergeCellButton = (\n <button\n className=\"item\"\n data-test-id=\"table-unmerge-cells\"\n onClick={() => unmergeTableCellsAtSelection()}\n type=\"button\"\n >\n <span className=\"text\">Unmerge cells</span>\n </button>\n )\n }\n }\n\n return createPortal(\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions,jsx-a11y/click-events-have-key-events\n <div\n className=\"table-action-menu-dropdown\"\n onClick={(e) => {\n e.stopPropagation()\n }}\n ref={dropDownRef}\n >\n {mergeCellButton ? (\n <React.Fragment>\n {mergeCellButton}\n <hr />\n </React.Fragment>\n ) : null}\n\n <button\n className=\"item\"\n data-test-id=\"table-row-striping\"\n onClick={() => toggleRowStriping()}\n type=\"button\"\n >\n <span className=\"text\">Toggle Row Striping</span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-freeze-first-column\"\n onClick={() => toggleFirstColumnFreeze()}\n type=\"button\"\n >\n <span className=\"text\">Toggle First Column Freeze</span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-insert-row-above\"\n onClick={() => insertTableRowAtSelection(false)}\n type=\"button\"\n >\n <span className=\"text\">\n Insert {selectionCounts.rows === 1 ? 'row' : `${selectionCounts.rows} rows`} above\n </span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-insert-row-below\"\n onClick={() => insertTableRowAtSelection(true)}\n type=\"button\"\n >\n <span className=\"text\">\n Insert {selectionCounts.rows === 1 ? 'row' : `${selectionCounts.rows} rows`} below\n </span>\n </button>\n <hr />\n <button\n className=\"item\"\n data-test-id=\"table-insert-column-before\"\n onClick={() => insertTableColumnAtSelection(false)}\n type=\"button\"\n >\n <span className=\"text\">\n Insert {selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`}{' '}\n left\n </span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-insert-column-after\"\n onClick={() => insertTableColumnAtSelection(true)}\n type=\"button\"\n >\n <span className=\"text\">\n Insert {selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`}{' '}\n right\n </span>\n </button>\n <hr />\n <button\n className=\"item\"\n data-test-id=\"table-delete-columns\"\n onClick={() => deleteTableColumnAtSelection()}\n type=\"button\"\n >\n <span className=\"text\">Delete column</span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-delete-rows\"\n onClick={() => deleteTableRowAtSelection()}\n type=\"button\"\n >\n <span className=\"text\">Delete row</span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-delete\"\n onClick={() => deleteTableAtSelection()}\n type=\"button\"\n >\n <span className=\"text\">Delete table</span>\n </button>\n <hr />\n <button\n className=\"item\"\n data-test-id=\"table-row-header\"\n onClick={() => toggleTableRowIsHeader()}\n type=\"button\"\n >\n <span className=\"text\">\n {(tableCellNode.__headerState & TableCellHeaderStates.ROW) === TableCellHeaderStates.ROW\n ? 'Remove'\n : 'Add'}{' '}\n row header\n </span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-column-header\"\n onClick={() => toggleTableColumnIsHeader()}\n type=\"button\"\n >\n <span className=\"text\">\n {(tableCellNode.__headerState & TableCellHeaderStates.COLUMN) ===\n TableCellHeaderStates.COLUMN\n ? 'Remove'\n : 'Add'}{' '}\n column header\n </span>\n </button>\n </div>,\n document.body,\n )\n}\n\nfunction TableCellActionMenuContainer({\n anchorElem,\n cellMerge,\n}: {\n anchorElem: HTMLElement\n cellMerge: boolean\n}): JSX.Element {\n const [editor] = useLexicalComposerContext()\n\n const menuButtonRef = useRef<HTMLDivElement | null>(null)\n const menuRootRef = useRef<HTMLButtonElement | null>(null)\n const [isMenuOpen, setIsMenuOpen] = useState(false)\n\n const [tableCellNode, setTableMenuCellNode] = useState<null | TableCellNode>(null)\n\n const $moveMenu = useCallback(() => {\n const menu = menuButtonRef.current\n const selection = $getSelection()\n const nativeSelection = getDOMSelection(editor._window)\n const activeElement = document.activeElement\n function disable() {\n if (menu) {\n menu.classList.remove('table-cell-action-button-container--active')\n menu.classList.add('table-cell-action-button-container--inactive')\n }\n setTableMenuCellNode(null)\n }\n\n if (selection == null || menu == null) {\n return disable()\n }\n\n const rootElement = editor.getRootElement()\n let tableObserver: null | TableObserver = null\n let tableCellParentNodeDOM: HTMLElement | null = null\n\n if (\n $isRangeSelection(selection) &&\n rootElement !== null &&\n nativeSelection !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n const tableCellNodeFromSelection = $getTableCellNodeFromLexicalNode(\n selection.anchor.getNode(),\n )\n\n if (tableCellNodeFromSelection == null) {\n return disable()\n }\n\n tableCellParentNodeDOM = editor.getElementByKey(tableCellNodeFromSelection.getKey())\n\n if (tableCellParentNodeDOM == null || !tableCellNodeFromSelection.isAttached()) {\n return disable()\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNodeFromSelection)\n const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()))\n\n if (tableElement === null) {\n throw new Error('TableActionMenu: Expected to find tableElement in DOM')\n }\n\n tableObserver = getTableObserverFromTableElement(tableElement)\n setTableMenuCellNode(tableCellNodeFromSelection)\n } else if ($isTableSelection(selection)) {\n const anchorNode = $getTableCellNodeFromLexicalNode(selection.anchor.getNode())\n if (!$isTableCellNode(anchorNode)) {\n throw new Error('TableSelection anchorNode must be a TableCellNode')\n }\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(anchorNode)\n const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()))\n\n if (tableElement === null) {\n throw new Error('TableActionMenu: Expected to find tableElement in DOM')\n }\n\n tableObserver = getTableObserverFromTableElement(tableElement)\n tableCellParentNodeDOM = editor.getElementByKey(anchorNode.getKey())\n } else if (!activeElement) {\n return disable()\n }\n if (tableObserver === null || tableCellParentNodeDOM === null) {\n return disable()\n }\n const enabled = !tableObserver || !tableObserver.isSelecting\n menu.classList.toggle('table-cell-action-button-container--active', enabled)\n menu.classList.toggle('table-cell-action-button-container--inactive', !enabled)\n if (enabled) {\n const tableCellRect = tableCellParentNodeDOM.getBoundingClientRect()\n const anchorRect = anchorElem.getBoundingClientRect()\n const top = tableCellRect.top - anchorRect.top\n const left = tableCellRect.right - anchorRect.left\n menu.style.transform = `translate(${left}px, ${top}px)`\n }\n }, [editor, anchorElem])\n\n useEffect(() => {\n // We call the $moveMenu callback every time the selection changes,\n // once up front, and once after each pointerup\n let timeoutId: ReturnType<typeof setTimeout> | undefined = undefined\n const callback = () => {\n timeoutId = undefined\n editor.getEditorState().read($moveMenu)\n }\n const delayedCallback = () => {\n if (timeoutId === undefined) {\n timeoutId = setTimeout(callback, 0)\n }\n return false\n }\n return mergeRegister(\n editor.registerUpdateListener(delayedCallback),\n editor.registerCommand(SELECTION_CHANGE_COMMAND, delayedCallback, COMMAND_PRIORITY_CRITICAL),\n editor.registerRootListener((rootElement, prevRootElement) => {\n if (prevRootElement) {\n prevRootElement.removeEventListener('pointerup', delayedCallback)\n }\n if (rootElement) {\n rootElement.addEventListener('pointerup', delayedCallback)\n delayedCallback()\n }\n }),\n () => clearTimeout(timeoutId),\n )\n })\n\n const prevTableCellDOM = useRef(tableCellNode)\n\n useEffect(() => {\n if (prevTableCellDOM.current !== tableCellNode) {\n setIsMenuOpen(false)\n }\n\n prevTableCellDOM.current = tableCellNode\n }, [prevTableCellDOM, tableCellNode])\n\n return (\n <div className=\"table-cell-action-button-container\" ref={menuButtonRef}>\n {tableCellNode != null && (\n <React.Fragment>\n <button\n className=\"table-cell-action-button\"\n onClick={(e) => {\n e.stopPropagation()\n setIsMenuOpen(!isMenuOpen)\n }}\n ref={menuRootRef}\n type=\"button\"\n >\n <MeatballsIcon />\n </button>\n {isMenuOpen && (\n <TableActionMenu\n cellMerge={cellMerge}\n contextRef={menuRootRef}\n onClose={() => setIsMenuOpen(false)}\n setIsMenuOpen={setIsMenuOpen}\n tableCellNode={tableCellNode}\n />\n )}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nexport const TableActionMenuPlugin: PluginComponentWithAnchor = ({ anchorElem }) => {\n const isEditable = useLexicalEditable()\n return createPortal(\n isEditable ? (\n <TableCellActionMenuContainer anchorElem={anchorElem ?? document.body} cellMerge />\n ) : null,\n anchorElem ?? document.body,\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$deleteTableColumnAtSelection","$deleteTableRowAtSelection","$getNodeTriplet","$getTableCellNodeFromLexicalNode","$getTableColumnIndexFromTableCellNode","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$insertTableColumnAtSelection","$insertTableRowAtSelection","$isTableCellNode","$isTableSelection","$mergeCells","$unmergeCell","getTableElement","getTableObserverFromTableElement","TableCellHeaderStates","TableCellNode","mergeRegister","useScrollInfo","$getSelection","$isElementNode","$isRangeSelection","$isTextNode","$setSelection","COMMAND_PRIORITY_CRITICAL","getDOMSelection","isDOMNode","SELECTION_CHANGE_COMMAND","React","useCallback","useEffect","useRef","useState","createPortal","MeatballsIcon","computeSelectionCount","selection","selectionShape","getShape","columns","toX","fromX","rows","toY","fromY","$canUnmerge","isCollapsed","anchor","is","focus","cell","__colSpan","__rowSpan","$selectLastDescendant","node","lastDescendant","getLastDescendant","select","selectEnd","selectNext","TableActionMenu","cellMerge","contextRef","onClose","setIsMenuOpen","tableCellNode","_tableCellNode","editor","dropDownRef","updateTableCellNode","selectionCounts","updateSelectionCounts","canMergeCells","setCanMergeCells","canUnmergeCell","setCanUnmergeCell","y","registerMutationListener","nodeMutations","nodeUpdated","get","getKey","getEditorState","read","getLatest","skipInitialization","currentSelectionCounts","menuButtonElement","current","dropDownElement","rootElement","getRootElement","rootEleRect","getBoundingClientRect","menuButtonRect","style","opacity","dropDownElementRect","margin","leftPosition","right","width","window","innerWidth","position","left","pageXOffset","topPosition","top","height","innerHeight","bottom","handleClickOutside","event","target","contains","addEventListener","removeEventListener","clearTableSelection","update","isAttached","tableNode","tableElement","getElementByKey","Error","tableObserver","$clearHighlight","markDirty","mergeTableCellsAtSelection","nodes","getNodes","tableCells","filter","targetCell","unmergeTableCellsAtSelection","insertTableRowAtSelection","shouldInsertAfter","i","insertTableColumnAtSelection","deleteTableRowAtSelection","deleteTableAtSelection","remove","deleteTableColumnAtSelection","toggleTableRowIsHeader","tableRowIndex","gridMap","rowCells","Set","newStyle","getHeaderStyles","ROW","col","length","mapCell","has","add","setHeaderStyles","toggleTableColumnIsHeader","tableColumnIndex","columnCells","COLUMN","row","toggleRowStriping","setRowStriping","getRowStriping","toggleFirstColumnFreeze","setFrozenColumns","getFrozenColumns","mergeCellButton","button","className","data-test-id","onClick","type","span","div","e","stopPropagation","ref","Fragment","hr","__headerState","document","body","TableCellActionMenuContainer","anchorElem","menuButtonRef","menuRootRef","isMenuOpen","setTableMenuCellNode","$moveMenu","menu","nativeSelection","_window","activeElement","disable","classList","tableCellParentNodeDOM","anchorNode","tableCellNodeFromSelection","getNode","enabled","isSelecting","toggle","tableCellRect","anchorRect","transform","timeoutId","undefined","callback","delayedCallback","setTimeout","registerUpdateListener","registerCommand","registerRootListener","prevRootElement","clearTimeout","prevTableCellDOM","TableActionMenuPlugin","isEditable"],"mappings":"AAAA;;AAMA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SACEC,6BAA6B,EAC7BC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,eAAe,EACfC,gCAAgC,EAChCC,qCAAqC,EACrCC,mCAAmC,EACnCC,kCAAkC,EAClCC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,gBA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A,EAAEC,eAAe;wBACjBjH,cAAc,CAAC4H;oBACjB;oBACAV,KAAKS;oBACLd,MAAK;8BAEL,cAAA,KAAC3I;;gBAEF0J,4BACC,KAAChI;oBACCC,WAAWA;oBACXC,YAAY6H;oBACZ5H,SAAS,IAAMC,cAAc;oBAC7BA,eAAeA;oBACfC,eAAeA;;;;;AAO7B;AAEA,OAAO,MAAMyJ,wBAAmD,CAAC,EAAEjC,UAAU,EAAE;IAC7E,MAAMkC,aAAa7N;IACnB,qBAAOmC,aACL0L,2BACE,KAACnC;QAA6BC,YAAYA,cAAcH,SAASC,IAAI;QAAE1H,SAAS;SAC9E,MACJ4H,cAAcH,SAASC,IAAI;AAE/B,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TableActionMenuPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableObserver, TableSelection } from '@lexical/table'\nimport type { ElementNode } from 'lexical'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $computeTableMapSkipCellCheck,\n $deleteTableColumnAtSelection,\n $deleteTableRowAtSelection,\n $getNodeTriplet,\n $getTableCellNodeFromLexicalNode,\n $getTableColumnIndexFromTableCellNode,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $insertTableColumnAtSelection,\n $insertTableRowAtSelection,\n $isTableCellNode,\n $isTableSelection,\n $mergeCells,\n $unmergeCell,\n getTableElement,\n getTableObserverFromTableElement,\n TableCellHeaderStates,\n TableCellNode,\n} from '@lexical/table'\nimport { mergeRegister } from '@lexical/utils'\nimport { useScrollInfo } from '@payloadcms/ui'\nimport {\n $getSelection,\n $isElementNode,\n $isRangeSelection,\n $isTextNode,\n $setSelection,\n COMMAND_PRIORITY_CRITICAL,\n getDOMSelection,\n isDOMNode,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponentWithAnchor } from '../../../../typesClient.js'\n\nimport './index.scss'\nimport { MeatballsIcon } from '../../../../../lexical/ui/icons/Meatballs/index.js'\n\nfunction computeSelectionCount(selection: TableSelection): {\n columns: number\n rows: number\n} {\n const selectionShape = selection.getShape()\n return {\n columns: selectionShape.toX - selectionShape.fromX + 1,\n rows: selectionShape.toY - selectionShape.fromY + 1,\n }\n}\n\nfunction $canUnmerge(): boolean {\n const selection = $getSelection()\n if (\n ($isRangeSelection(selection) && !selection.isCollapsed()) ||\n ($isTableSelection(selection) && !selection.anchor.is(selection.focus)) ||\n (!$isRangeSelection(selection) && !$isTableSelection(selection))\n ) {\n return false\n }\n const [cell] = $getNodeTriplet(selection.anchor)\n return cell.__colSpan > 1 || cell.__rowSpan > 1\n}\n\nfunction $selectLastDescendant(node: ElementNode): void {\n const lastDescendant = node.getLastDescendant()\n if ($isTextNode(lastDescendant)) {\n lastDescendant.select()\n } else if ($isElementNode(lastDescendant)) {\n lastDescendant.selectEnd()\n } else if (lastDescendant !== null) {\n lastDescendant.selectNext()\n }\n}\n\ntype TableCellActionMenuProps = Readonly<{\n cellMerge: boolean\n contextRef: { current: HTMLElement | null }\n onClose: () => void\n setIsMenuOpen: (isOpen: boolean) => void\n tableCellNode: TableCellNode\n}>\n\nfunction TableActionMenu({\n cellMerge,\n contextRef,\n onClose,\n setIsMenuOpen,\n tableCellNode: _tableCellNode,\n}: TableCellActionMenuProps) {\n const [editor] = useLexicalComposerContext()\n const dropDownRef = useRef<HTMLDivElement | null>(null)\n const [tableCellNode, updateTableCellNode] = useState(_tableCellNode)\n const [selectionCounts, updateSelectionCounts] = useState({\n columns: 1,\n rows: 1,\n })\n const [canMergeCells, setCanMergeCells] = useState(false)\n const [canUnmergeCell, setCanUnmergeCell] = useState(false)\n const { y } = useScrollInfo()\n\n useEffect(() => {\n return editor.registerMutationListener(\n TableCellNode,\n (nodeMutations) => {\n const nodeUpdated = nodeMutations.get(tableCellNode.getKey()) === 'updated'\n\n if (nodeUpdated) {\n editor.getEditorState().read(() => {\n updateTableCellNode(tableCellNode.getLatest())\n })\n }\n },\n { skipInitialization: true },\n )\n }, [editor, tableCellNode])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n // Merge cells\n if ($isTableSelection(selection)) {\n const currentSelectionCounts = computeSelectionCount(selection)\n updateSelectionCounts(computeSelectionCount(selection))\n\n setCanMergeCells(currentSelectionCounts.columns > 1 || currentSelectionCounts.rows > 1)\n }\n // Unmerge cell\n setCanUnmergeCell($canUnmerge())\n })\n }, [editor])\n\n useEffect(() => {\n const menuButtonElement = contextRef.current\n const dropDownElement = dropDownRef.current\n const rootElement = editor.getRootElement()\n\n if (menuButtonElement != null && dropDownElement != null && rootElement != null) {\n const rootEleRect = rootElement.getBoundingClientRect()\n const menuButtonRect = menuButtonElement.getBoundingClientRect()\n dropDownElement.style.opacity = '1'\n const dropDownElementRect = dropDownElement.getBoundingClientRect()\n const margin = 5\n let leftPosition = menuButtonRect.right + margin\n if (\n leftPosition + dropDownElementRect.width > window.innerWidth ||\n leftPosition + dropDownElementRect.width > rootEleRect.right\n ) {\n const position = menuButtonRect.left - dropDownElementRect.width - margin\n leftPosition = (position < 0 ? margin : position) + window.pageXOffset\n }\n dropDownElement.style.left = `${leftPosition + window.pageXOffset}px`\n\n let topPosition = menuButtonRect.top\n if (topPosition + dropDownElementRect.height > window.innerHeight) {\n const position = menuButtonRect.bottom - dropDownElementRect.height\n topPosition = position < 0 ? margin : position\n }\n dropDownElement.style.top = `${topPosition}px`\n }\n }, [contextRef, dropDownRef, editor, y])\n\n useEffect(() => {\n function handleClickOutside(event: MouseEvent) {\n if (\n dropDownRef.current != null &&\n contextRef.current != null &&\n isDOMNode(event.target) &&\n !dropDownRef.current.contains(event.target) &&\n !contextRef.current.contains(event.target)\n ) {\n setIsMenuOpen(false)\n }\n }\n\n window.addEventListener('click', handleClickOutside)\n\n return () => window.removeEventListener('click', handleClickOutside)\n }, [setIsMenuOpen, contextRef])\n\n const clearTableSelection = useCallback(() => {\n editor.update(() => {\n if (tableCellNode.isAttached()) {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()))\n\n if (tableElement === null) {\n throw new Error('Expected to find tableElement in DOM')\n }\n\n const tableObserver = getTableObserverFromTableElement(tableElement)\n if (tableObserver !== null) {\n tableObserver.$clearHighlight()\n }\n\n tableNode.markDirty()\n updateTableCellNode(tableCellNode.getLatest())\n }\n\n $setSelection(null)\n })\n }, [editor, tableCellNode])\n\n const mergeTableCellsAtSelection = () => {\n editor.update(() => {\n const selection = $getSelection()\n if (!$isTableSelection(selection)) {\n return\n }\n const nodes = selection.getNodes()\n const tableCells = nodes.filter($isTableCellNode)\n const targetCell = $mergeCells(tableCells)\n\n if (targetCell) {\n $selectLastDescendant(targetCell)\n onClose()\n }\n })\n }\n\n const unmergeTableCellsAtSelection = () => {\n editor.update(() => {\n $unmergeCell()\n })\n }\n\n const insertTableRowAtSelection = useCallback(\n (shouldInsertAfter: boolean) => {\n editor.update(() => {\n for (let i = 0; i < selectionCounts.rows; i++) {\n $insertTableRowAtSelection(shouldInsertAfter)\n }\n onClose()\n })\n },\n [editor, onClose, selectionCounts.rows],\n )\n\n const insertTableColumnAtSelection = useCallback(\n (shouldInsertAfter: boolean) => {\n editor.update(() => {\n for (let i = 0; i < selectionCounts.columns; i++) {\n $insertTableColumnAtSelection(shouldInsertAfter)\n }\n onClose()\n })\n },\n [editor, onClose, selectionCounts.columns],\n )\n\n const deleteTableRowAtSelection = useCallback(() => {\n editor.update(() => {\n $deleteTableRowAtSelection()\n onClose()\n })\n }, [editor, onClose])\n\n const deleteTableAtSelection = useCallback(() => {\n editor.update(() => {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n tableNode.remove()\n\n clearTableSelection()\n onClose()\n })\n }, [editor, tableCellNode, clearTableSelection, onClose])\n\n const deleteTableColumnAtSelection = useCallback(() => {\n editor.update(() => {\n $deleteTableColumnAtSelection()\n onClose()\n })\n }, [editor, onClose])\n\n const toggleTableRowIsHeader = useCallback(() => {\n editor.update(() => {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode)\n\n const [gridMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n\n const rowCells = new Set<TableCellNode>()\n\n const newStyle = tableCellNode.getHeaderStyles() ^ TableCellHeaderStates.ROW\n if (gridMap[tableRowIndex]) {\n for (let col = 0; col < gridMap[tableRowIndex].length; col++) {\n const mapCell = gridMap[tableRowIndex][col]\n\n if (!mapCell?.cell) {\n continue\n }\n\n if (!rowCells.has(mapCell.cell)) {\n rowCells.add(mapCell.cell)\n mapCell.cell.setHeaderStyles(newStyle, TableCellHeaderStates.ROW)\n }\n }\n }\n\n clearTableSelection()\n onClose()\n })\n }, [editor, tableCellNode, clearTableSelection, onClose])\n\n const toggleTableColumnIsHeader = useCallback(() => {\n editor.update(() => {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const tableColumnIndex = $getTableColumnIndexFromTableCellNode(tableCellNode)\n\n const [gridMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n\n const columnCells = new Set<TableCellNode>()\n\n const newStyle = tableCellNode.getHeaderStyles() ^ TableCellHeaderStates.COLUMN\n if (gridMap) {\n for (let row = 0; row < gridMap.length; row++) {\n const mapCell = gridMap?.[row]?.[tableColumnIndex]\n\n if (!mapCell?.cell) {\n continue\n }\n\n if (!columnCells.has(mapCell.cell)) {\n columnCells.add(mapCell.cell)\n mapCell.cell.setHeaderStyles(newStyle, TableCellHeaderStates.COLUMN)\n }\n }\n }\n\n clearTableSelection()\n onClose()\n })\n }, [editor, tableCellNode, clearTableSelection, onClose])\n\n const toggleRowStriping = useCallback(() => {\n editor.update(() => {\n if (tableCellNode.isAttached()) {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n if (tableNode) {\n tableNode.setRowStriping(!tableNode.getRowStriping())\n }\n }\n\n clearTableSelection()\n onClose()\n })\n }, [editor, tableCellNode, clearTableSelection, onClose])\n\n const toggleFirstColumnFreeze = useCallback(() => {\n editor.update(() => {\n if (tableCellNode.isAttached()) {\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n if (tableNode) {\n tableNode.setFrozenColumns(tableNode.getFrozenColumns() === 0 ? 1 : 0)\n }\n }\n clearTableSelection()\n onClose()\n })\n }, [editor, tableCellNode, clearTableSelection, onClose])\n\n let mergeCellButton: JSX.Element | null = null\n if (cellMerge) {\n if (canMergeCells) {\n mergeCellButton = (\n <button\n className=\"item\"\n data-test-id=\"table-merge-cells\"\n onClick={() => mergeTableCellsAtSelection()}\n type=\"button\"\n >\n <span className=\"text\">Merge cells</span>\n </button>\n )\n } else if (canUnmergeCell) {\n mergeCellButton = (\n <button\n className=\"item\"\n data-test-id=\"table-unmerge-cells\"\n onClick={() => unmergeTableCellsAtSelection()}\n type=\"button\"\n >\n <span className=\"text\">Unmerge cells</span>\n </button>\n )\n }\n }\n\n return createPortal(\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions,jsx-a11y/click-events-have-key-events\n <div\n className=\"table-action-menu-dropdown\"\n onClick={(e) => {\n e.stopPropagation()\n }}\n ref={dropDownRef}\n >\n {mergeCellButton ? (\n <React.Fragment>\n {mergeCellButton}\n <hr />\n </React.Fragment>\n ) : null}\n\n <button\n className=\"item\"\n data-test-id=\"table-row-striping\"\n onClick={() => toggleRowStriping()}\n type=\"button\"\n >\n <span className=\"text\">Toggle Row Striping</span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-freeze-first-column\"\n onClick={() => toggleFirstColumnFreeze()}\n type=\"button\"\n >\n <span className=\"text\">Toggle First Column Freeze</span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-insert-row-above\"\n onClick={() => insertTableRowAtSelection(false)}\n type=\"button\"\n >\n <span className=\"text\">\n Insert {selectionCounts.rows === 1 ? 'row' : `${selectionCounts.rows} rows`} above\n </span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-insert-row-below\"\n onClick={() => insertTableRowAtSelection(true)}\n type=\"button\"\n >\n <span className=\"text\">\n Insert {selectionCounts.rows === 1 ? 'row' : `${selectionCounts.rows} rows`} below\n </span>\n </button>\n <hr />\n <button\n className=\"item\"\n data-test-id=\"table-insert-column-before\"\n onClick={() => insertTableColumnAtSelection(false)}\n type=\"button\"\n >\n <span className=\"text\">\n Insert {selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`}{' '}\n left\n </span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-insert-column-after\"\n onClick={() => insertTableColumnAtSelection(true)}\n type=\"button\"\n >\n <span className=\"text\">\n Insert {selectionCounts.columns === 1 ? 'column' : `${selectionCounts.columns} columns`}{' '}\n right\n </span>\n </button>\n <hr />\n <button\n className=\"item\"\n data-test-id=\"table-delete-columns\"\n onClick={() => deleteTableColumnAtSelection()}\n type=\"button\"\n >\n <span className=\"text\">Delete column</span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-delete-rows\"\n onClick={() => deleteTableRowAtSelection()}\n type=\"button\"\n >\n <span className=\"text\">Delete row</span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-delete\"\n onClick={() => deleteTableAtSelection()}\n type=\"button\"\n >\n <span className=\"text\">Delete table</span>\n </button>\n <hr />\n <button\n className=\"item\"\n data-test-id=\"table-row-header\"\n onClick={() => toggleTableRowIsHeader()}\n type=\"button\"\n >\n <span className=\"text\">\n {(tableCellNode.__headerState & TableCellHeaderStates.ROW) === TableCellHeaderStates.ROW\n ? 'Remove'\n : 'Add'}{' '}\n row header\n </span>\n </button>\n <button\n className=\"item\"\n data-test-id=\"table-column-header\"\n onClick={() => toggleTableColumnIsHeader()}\n type=\"button\"\n >\n <span className=\"text\">\n {(tableCellNode.__headerState & TableCellHeaderStates.COLUMN) ===\n TableCellHeaderStates.COLUMN\n ? 'Remove'\n : 'Add'}{' '}\n column header\n </span>\n </button>\n </div>,\n document.body,\n )\n}\n\nfunction TableCellActionMenuContainer({\n anchorElem,\n cellMerge,\n}: {\n anchorElem: HTMLElement\n cellMerge: boolean\n}): JSX.Element {\n const [editor] = useLexicalComposerContext()\n\n const menuButtonRef = useRef<HTMLDivElement | null>(null)\n const menuRootRef = useRef<HTMLButtonElement | null>(null)\n const [isMenuOpen, setIsMenuOpen] = useState(false)\n\n const [tableCellNode, setTableMenuCellNode] = useState<null | TableCellNode>(null)\n\n const $moveMenu = useCallback(() => {\n const menu = menuButtonRef.current\n const selection = $getSelection()\n const nativeSelection = getDOMSelection(editor._window)\n const activeElement = document.activeElement\n function disable() {\n if (menu) {\n menu.classList.remove('table-cell-action-button-container--active')\n menu.classList.add('table-cell-action-button-container--inactive')\n }\n setTableMenuCellNode(null)\n }\n\n if (selection == null || menu == null) {\n return disable()\n }\n\n const rootElement = editor.getRootElement()\n let tableObserver: null | TableObserver = null\n let tableCellParentNodeDOM: HTMLElement | null = null\n\n if (\n $isRangeSelection(selection) &&\n rootElement !== null &&\n nativeSelection !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n const tableCellNodeFromSelection = $getTableCellNodeFromLexicalNode(\n selection.anchor.getNode(),\n )\n\n if (tableCellNodeFromSelection == null) {\n return disable()\n }\n\n tableCellParentNodeDOM = editor.getElementByKey(tableCellNodeFromSelection.getKey())\n\n if (tableCellParentNodeDOM == null || !tableCellNodeFromSelection.isAttached()) {\n return disable()\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNodeFromSelection)\n const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()))\n\n if (tableElement === null) {\n throw new Error('TableActionMenu: Expected to find tableElement in DOM')\n }\n\n tableObserver = getTableObserverFromTableElement(tableElement)\n setTableMenuCellNode(tableCellNodeFromSelection)\n } else if ($isTableSelection(selection)) {\n const anchorNode = $getTableCellNodeFromLexicalNode(selection.anchor.getNode())\n if (!$isTableCellNode(anchorNode)) {\n throw new Error('TableSelection anchorNode must be a TableCellNode')\n }\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(anchorNode)\n const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()))\n\n if (tableElement === null) {\n throw new Error('TableActionMenu: Expected to find tableElement in DOM')\n }\n\n tableObserver = getTableObserverFromTableElement(tableElement)\n tableCellParentNodeDOM = editor.getElementByKey(anchorNode.getKey())\n } else if (!activeElement) {\n return disable()\n }\n if (tableObserver === null || tableCellParentNodeDOM === null) {\n return disable()\n }\n const enabled = !tableObserver || !tableObserver.isSelecting\n menu.classList.toggle('table-cell-action-button-container--active', enabled)\n menu.classList.toggle('table-cell-action-button-container--inactive', !enabled)\n if (enabled) {\n const tableCellRect = tableCellParentNodeDOM.getBoundingClientRect()\n const anchorRect = anchorElem.getBoundingClientRect()\n const top = tableCellRect.top - anchorRect.top\n const left = tableCellRect.right - anchorRect.left\n menu.style.transform = `translate(${left}px, ${top}px)`\n }\n }, [editor, anchorElem])\n\n useEffect(() => {\n // We call the $moveMenu callback every time the selection changes,\n // once up front, and once after each pointerup\n let timeoutId: ReturnType<typeof setTimeout> | undefined = undefined\n const callback = () => {\n timeoutId = undefined\n editor.getEditorState().read($moveMenu)\n }\n const delayedCallback = () => {\n if (timeoutId === undefined) {\n timeoutId = setTimeout(callback, 0)\n }\n return false\n }\n return mergeRegister(\n editor.registerUpdateListener(delayedCallback),\n editor.registerCommand(SELECTION_CHANGE_COMMAND, delayedCallback, COMMAND_PRIORITY_CRITICAL),\n editor.registerRootListener((rootElement, prevRootElement) => {\n if (prevRootElement) {\n prevRootElement.removeEventListener('pointerup', delayedCallback)\n }\n if (rootElement) {\n rootElement.addEventListener('pointerup', delayedCallback)\n delayedCallback()\n }\n }),\n () => clearTimeout(timeoutId),\n )\n })\n\n const prevTableCellDOM = useRef(tableCellNode)\n\n useEffect(() => {\n if (prevTableCellDOM.current !== tableCellNode) {\n setIsMenuOpen(false)\n }\n\n prevTableCellDOM.current = tableCellNode\n }, [prevTableCellDOM, tableCellNode])\n\n return (\n <div className=\"table-cell-action-button-container\" ref={menuButtonRef}>\n {tableCellNode != null && (\n <React.Fragment>\n <button\n className=\"table-cell-action-button\"\n onClick={(e) => {\n e.stopPropagation()\n setIsMenuOpen(!isMenuOpen)\n }}\n ref={menuRootRef}\n type=\"button\"\n >\n <MeatballsIcon />\n </button>\n {isMenuOpen && (\n <TableActionMenu\n cellMerge={cellMerge}\n contextRef={menuRootRef}\n onClose={() => setIsMenuOpen(false)}\n setIsMenuOpen={setIsMenuOpen}\n tableCellNode={tableCellNode}\n />\n )}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nexport const TableActionMenuPlugin: PluginComponentWithAnchor = ({ anchorElem }) => {\n const isEditable = useLexicalEditable()\n return createPortal(\n isEditable ? (\n <TableCellActionMenuContainer anchorElem={anchorElem ?? document.body} cellMerge />\n ) : null,\n anchorElem ?? document.body,\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$deleteTableColumnAtSelection","$deleteTableRowAtSelection","$getNodeTriplet","$getTableCellNodeFromLexicalNode","$getTableColumnIndexFromTableCellNode","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$insertTableColumnAtSelection","$insertTableRowAtSelection","$isTableCellNode","$isTableSelection","$mergeCells","$unmergeCell","getTableElement","getTableObserverFromTableElement","TableCellHeaderStates","TableCellNode","mergeRegister","useScrollInfo","$getSelection","$isElementNode","$isRangeSelection","$isTextNode","$setSelection","COMMAND_PRIORITY_CRITICAL","getDOMSelection","isDOMNode","SELECTION_CHANGE_COMMAND","React","useCallback","useEffect","useRef","useState","createPortal","MeatballsIcon","computeSelectionCount","selection","selectionShape","getShape","columns","toX","fromX","rows","toY","fromY","$canUnmerge","isCollapsed","anchor","is","focus","cell","__colSpan","__rowSpan","$selectLastDescendant","node","lastDescendant","getLastDescendant","select","selectEnd","selectNext","TableActionMenu","cellMerge","contextRef","onClose","setIsMenuOpen","tableCellNode","_tableCellNode","editor","dropDownRef","updateTableCellNode","selectionCounts","updateSelectionCounts","canMergeCells","setCanMergeCells","canUnmergeCell","setCanUnmergeCell","y","registerMutationListener","nodeMutations","nodeUpdated","get","getKey","getEditorState","read","getLatest","skipInitialization","currentSelectionCounts","menuButtonElement","current","dropDownElement","rootElement","getRootElement","rootEleRect","getBoundingClientRect","menuButtonRect","style","opacity","dropDownElementRect","margin","leftPosition","right","width","window","innerWidth","position","left","pageXOffset","topPosition","top","height","innerHeight","bottom","handleClickOutside","event","target","contains","addEventListener","removeEventListener","clearTableSelection","update","isAttached","tableNode","tableElement","getElementByKey","Error","tableObserver","$clearHighlight","markDirty","mergeTableCellsAtSelection","nodes","getNodes","tableCells","filter","targetCell","unmergeTableCellsAtSelection","insertTableRowAtSelection","shouldInsertAfter","i","insertTableColumnAtSelection","deleteTableRowAtSelection","deleteTableAtSelection","remove","deleteTableColumnAtSelection","toggleTableRowIsHeader","tableRowIndex","gridMap","rowCells","Set","newStyle","getHeaderStyles","ROW","col","length","mapCell","has","add","setHeaderStyles","toggleTableColumnIsHeader","tableColumnIndex","columnCells","COLUMN","row","toggleRowStriping","setRowStriping","getRowStriping","toggleFirstColumnFreeze","setFrozenColumns","getFrozenColumns","mergeCellButton","button","className","data-test-id","onClick","type","span","div","e","stopPropagation","ref","Fragment","hr","__headerState","document","body","TableCellActionMenuContainer","anchorElem","menuButtonRef","menuRootRef","isMenuOpen","setTableMenuCellNode","$moveMenu","menu","nativeSelection","_window","activeElement","disable","classList","tableCellParentNodeDOM","anchorNode","tableCellNodeFromSelection","getNode","enabled","isSelecting","toggle","tableCellRect","anchorRect","transform","timeoutId","undefined","callback","delayedCallback","setTimeout","registerUpdateListener","registerCommand","registerRootListener","prevRootElement","clearTimeout","prevTableCellDOM","TableAct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xH,aAAa;gBACfA,YAAY0B,gBAAgB,CAAC,aAAa8F;gBAC1CA;YACF;QACF,IACA,IAAMM,aAAaT;IAEvB;IAEA,MAAMU,mBAAmB1L,OAAOkC;IAEhCnC,UAAU;QACR,IAAI2L,iBAAiBjI,OAAO,KAAKvB,eAAe;YAC9CD,cAAc;QAChB;QAEAyJ,iBAAiBjI,OAAO,GAAGvB;IAC7B,GAAG;QAACwJ;QAAkBxJ;KAAc;IAEpC,qBACE,QAAC8G;QAAIL,WAAU;QAAqCQ,KAAKQ;kBACtDzH,iBAAiB,sBAChB,QAACrC,MAAMuJ,QAAQ;;8BACb,QAACV;oBACCC,WAAU;oBACVE,SAAS,CAACI;wBACRA,EAAEC,eAAe;wBACjBjH,cAAc,CAAC4H;oBACjB;oBACAV,KAAKS;oBACLd,MAAK;8BAEL,cAAA,QAAC3I;;;;;;;;;;gBAEF0J,4BACC,QAAChI;oBACCC,WAAWA;oBACXC,YAAY6H;oBACZ5H,SAAS,IAAMC,cAAc;oBAC7BA,eAAeA;oBACfC,eAAeA;;;;;;;;;;;;;;;;;AAO7B;AAEA,OAAO,MAAMyJ,wBAAmD,CAAC,EAAEjC,UAAU,EAAE;IAC7E,MAAMkC,aAAa7N;IACnB,qBAAOmC,aACL0L,2BACE,QAACnC;QAA6BC,YAAYA,cAAcH,SAASC,IAAI;QAAE1H,SAAS;;;;;eAC9E,MACJ4H,cAAcH,SAASC,IAAI;AAE/B,EAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.table-cell-action-button-container {
|
|
5
|
+
position: absolute;
|
|
6
|
+
z-index: 3;
|
|
7
|
+
top: 0;
|
|
8
|
+
left: 0;
|
|
9
|
+
will-change: transform;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.table-cell-action-button-container.table-cell-action-button-container--active {
|
|
13
|
+
pointer-events: auto;
|
|
14
|
+
opacity: 1;
|
|
15
|
+
}
|
|
16
|
+
.table-cell-action-button-container.table-cell-action-button-container--inactive {
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
opacity: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.table-cell-action-button {
|
|
22
|
+
//background-color: var(--theme-elevation-200);
|
|
23
|
+
border: 0;
|
|
24
|
+
padding: 2px;
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: 10px;
|
|
27
|
+
right: 10px;
|
|
28
|
+
border-radius: $style-radius-m;
|
|
29
|
+
color: var(--theme-elevation-800);
|
|
30
|
+
display: inline-block;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
|
|
33
|
+
&:hover {
|
|
34
|
+
background-color: var(--theme-elevation-300);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
html[data-theme='light'] {
|
|
39
|
+
.table-action-menu-dropdown {
|
|
40
|
+
box-shadow:
|
|
41
|
+
0px 1px 2px 1px rgba(0, 0, 0, 0.05),
|
|
42
|
+
0px 4px 8px 0px rgba(0, 0, 0, 0.1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.table-action-menu-dropdown {
|
|
47
|
+
z-index: 100;
|
|
48
|
+
display: block;
|
|
49
|
+
position: fixed;
|
|
50
|
+
background: var(--theme-input-bg);
|
|
51
|
+
min-width: 160px;
|
|
52
|
+
border-radius: $style-radius-m;
|
|
53
|
+
min-height: 40px;
|
|
54
|
+
overflow-y: auto;
|
|
55
|
+
box-shadow:
|
|
56
|
+
0px 1px 2px 1px rgba(0, 0, 0, 0.1),
|
|
57
|
+
0px 4px 16px 0px rgba(0, 0, 0, 0.2),
|
|
58
|
+
0px -4px 8px 0px rgba(0, 0, 0, 0.1);
|
|
59
|
+
|
|
60
|
+
hr {
|
|
61
|
+
border: none;
|
|
62
|
+
height: 1px;
|
|
63
|
+
background-color: var(--theme-elevation-200);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.item {
|
|
67
|
+
padding: 8px;
|
|
68
|
+
color: var(--theme-elevation-900);
|
|
69
|
+
background: var(--theme-input-bg);
|
|
70
|
+
cursor: pointer;
|
|
71
|
+
font-size: 13px;
|
|
72
|
+
font-family: var(--font-body);
|
|
73
|
+
display: flex;
|
|
74
|
+
align-content: center;
|
|
75
|
+
flex-direction: row;
|
|
76
|
+
flex-shrink: 0;
|
|
77
|
+
justify-content: space-between;
|
|
78
|
+
border: 0;
|
|
79
|
+
height: 30px;
|
|
80
|
+
width: 100%;
|
|
81
|
+
|
|
82
|
+
&:hover {
|
|
83
|
+
background: var(--theme-elevation-100);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
4
|
import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
5
5
|
import { $computeTableMapSkipCellCheck, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $isTableCellNode, $isTableRowNode, getDOMCellFromTarget, getTableElement, TableNode } from '@lexical/table';
|
|
@@ -326,30 +326,50 @@ function TableCellResizer({ editor }) {
|
|
|
326
326
|
draggingDirection,
|
|
327
327
|
mouseCurrentPos
|
|
328
328
|
]);
|
|
329
|
-
return /*#__PURE__*/
|
|
329
|
+
return /*#__PURE__*/ _jsxDEV("div", {
|
|
330
330
|
ref: resizerRef,
|
|
331
|
-
children: activeCell != null && !isMouseDown && /*#__PURE__*/
|
|
331
|
+
children: activeCell != null && !isMouseDown && /*#__PURE__*/ _jsxDEV(React.Fragment, {
|
|
332
332
|
children: [
|
|
333
|
-
/*#__PURE__*/
|
|
333
|
+
/*#__PURE__*/ _jsxDEV("div", {
|
|
334
334
|
className: `${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,
|
|
335
335
|
onMouseDown: toggleResize('right'),
|
|
336
336
|
style: resizerStyles.right || undefined
|
|
337
|
-
}
|
|
338
|
-
|
|
337
|
+
}, void 0, false, {
|
|
338
|
+
fileName: "src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx",
|
|
339
|
+
lineNumber: 416,
|
|
340
|
+
columnNumber: 11
|
|
341
|
+
}, this),
|
|
342
|
+
/*#__PURE__*/ _jsxDEV("div", {
|
|
339
343
|
className: `${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,
|
|
340
344
|
onMouseDown: toggleResize('bottom'),
|
|
341
345
|
style: resizerStyles.bottom || undefined
|
|
342
|
-
}
|
|
346
|
+
}, void 0, false, {
|
|
347
|
+
fileName: "src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx",
|
|
348
|
+
lineNumber: 421,
|
|
349
|
+
columnNumber: 11
|
|
350
|
+
}, this)
|
|
343
351
|
]
|
|
344
|
-
}
|
|
345
|
-
|
|
352
|
+
}, void 0, true, {
|
|
353
|
+
fileName: "src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx",
|
|
354
|
+
lineNumber: 415,
|
|
355
|
+
columnNumber: 9
|
|
356
|
+
}, this)
|
|
357
|
+
}, void 0, false, {
|
|
358
|
+
fileName: "src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx",
|
|
359
|
+
lineNumber: 413,
|
|
360
|
+
columnNumber: 5
|
|
361
|
+
}, this);
|
|
346
362
|
}
|
|
347
363
|
export const TableCellResizerPlugin = ()=>{
|
|
348
364
|
const [editor] = useLexicalComposerContext();
|
|
349
365
|
const isEditable = useLexicalEditable();
|
|
350
|
-
return useMemo(()=>isEditable ? /*#__PURE__*/ createPortal(/*#__PURE__*/
|
|
366
|
+
return useMemo(()=>isEditable ? /*#__PURE__*/ createPortal(/*#__PURE__*/ _jsxDEV(TableCellResizer, {
|
|
351
367
|
editor: editor
|
|
352
|
-
}
|
|
368
|
+
}, void 0, false, {
|
|
369
|
+
fileName: "src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx",
|
|
370
|
+
lineNumber: 437,
|
|
371
|
+
columnNumber: 38
|
|
372
|
+
}, this), document.body) : null, [
|
|
353
373
|
editor,
|
|
354
374
|
isEditable
|
|
355
375
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableCellNode, TableDOMCell, TableMapType } from '@lexical/table'\nimport type { LexicalEditor, NodeKey } from 'lexical'\nimport type { JSX, MouseEventHandler } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $computeTableMapSkipCellCheck,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $isTableCellNode,\n $isTableRowNode,\n getDOMCellFromTarget,\n getTableElement,\n TableNode,\n} from '@lexical/table'\nimport { calculateZoomLevel, mergeRegister } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode, isHTMLElement, SKIP_SCROLL_INTO_VIEW_TAG } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport './index.scss'\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\n\ntype MousePosition = {\n x: number\n y: number\n}\n\ntype MouseDraggingDirection = 'bottom' | 'right'\n\nconst MIN_ROW_HEIGHT = 33\nconst MIN_COLUMN_WIDTH = 92\n\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\n const targetRef = useRef<HTMLElement | null>(null)\n const resizerRef = useRef<HTMLDivElement | null>(null)\n const tableRectRef = useRef<ClientRect | null>(null)\n const [hasTable, setHasTable] = useState(false)\n const editorConfig = useEditorConfigContext()\n\n const mouseStartPosRef = useRef<MousePosition | null>(null)\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null)\n\n const [activeCell, updateActiveCell] = useState<null | TableDOMCell>(null)\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false)\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null)\n\n const resetState = useCallback(() => {\n updateActiveCell(null)\n targetRef.current = null\n updateDraggingDirection(null)\n mouseStartPosRef.current = null\n tableRectRef.current = null\n }, [])\n\n const isMouseDownOnEvent = (event: MouseEvent) => {\n return (event.buttons & 1) === 1\n }\n\n useEffect(() => {\n const tableKeys = new Set<NodeKey>()\n return mergeRegister(\n editor.registerMutationListener(TableNode, (nodeMutations) => {\n for (const [nodeKey, mutation] of nodeMutations) {\n if (mutation === 'destroyed') {\n tableKeys.delete(nodeKey)\n } else {\n tableKeys.add(nodeKey)\n }\n }\n setHasTable(tableKeys.size > 0)\n }),\n editor.registerNodeTransform(TableNode, (tableNode) => {\n if (tableNode.getColWidths()) {\n return tableNode\n }\n\n const numColumns = tableNode.getColumnCount()\n const columnWidth = MIN_COLUMN_WIDTH\n\n tableNode.setColWidths(Array(numColumns).fill(columnWidth))\n return tableNode\n }),\n )\n }, [editor])\n\n useEffect(() => {\n if (!hasTable) {\n return\n }\n\n const onMouseMove = (event: MouseEvent) => {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n if (draggingDirection) {\n updateMouseCurrentPos({\n x: event.clientX,\n y: event.clientY,\n })\n return\n }\n updateIsMouseDown(isMouseDownOnEvent(event))\n if (resizerRef.current && resizerRef.current.contains(target)) {\n return\n }\n\n if (targetRef.current !== target) {\n targetRef.current = target\n const cell = getDOMCellFromTarget(target)\n\n if (cell && activeCell !== cell) {\n editor.getEditorState().read(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem)\n\n if (!tableCellNode) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const tableElement = getTableElement(\n tableNode,\n editor.getElementByKey(tableNode.getKey()),\n )\n if (!tableElement) {\n throw new Error('TableCellResizer: Table element not found.')\n }\n\n targetRef.current = target\n tableRectRef.current = tableElement.getBoundingClientRect()\n updateActiveCell(cell)\n },\n { editor },\n )\n } else if (cell == null) {\n resetState()\n }\n }\n }\n\n const onMouseDown = (event: MouseEvent) => {\n updateIsMouseDown(true)\n }\n\n const onMouseUp = (event: MouseEvent) => {\n updateIsMouseDown(false)\n }\n\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\n prevRootElement?.removeEventListener('mousemove', onMouseMove)\n prevRootElement?.removeEventListener('mousedown', onMouseDown)\n prevRootElement?.removeEventListener('mouseup', onMouseUp)\n rootElement?.addEventListener('mousemove', onMouseMove)\n rootElement?.addEventListener('mousedown', onMouseDown)\n rootElement?.addEventListener('mouseup', onMouseUp)\n })\n\n return () => {\n removeRootListener()\n }\n }, [activeCell, draggingDirection, editor, hasTable, resetState])\n\n const isHeightChanging = (direction: MouseDraggingDirection) => {\n if (direction === 'bottom') {\n return true\n }\n return false\n }\n\n const updateRowHeight = useCallback(\n (heightChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const baseRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode)\n const tableRows = tableNode.getChildren()\n\n // Determine if this is a full row merge by checking colspan\n const isFullRowMerge = tableCellNode.getColSpan() === tableNode.getColumnCount()\n\n // For full row merges, apply to first row. For partial merges, apply to last row\n const tableRowIndex = isFullRowMerge\n ? baseRowIndex\n : baseRowIndex + tableCellNode.getRowSpan() - 1\n\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\n throw new Error('Expected table cell to be inside of table row.')\n }\n\n const tableRow = tableRows[tableRowIndex]\n\n if (!$isTableRowNode(tableRow)) {\n throw new Error('Expected table row')\n }\n\n let height = tableRow.getHeight()\n if (height === undefined) {\n const rowCells = tableRow.getChildren<TableCellNode>()\n height = Math.min(\n ...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity),\n )\n }\n\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT)\n tableRow.setHeight(newHeight)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const getCellNodeHeight = (\n cell: TableCellNode,\n activeEditor: LexicalEditor,\n ): number | undefined => {\n const domCellNode = activeEditor.getElementByKey(cell.getKey())\n return domCellNode?.clientHeight\n }\n\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\n let columnIndex: number | undefined\n tableMap.forEach((row) => {\n row.forEach((cell, columnIndexInner) => {\n if (cell.cell === tableCellNode) {\n columnIndex = columnIndexInner\n }\n })\n })\n return columnIndex\n }\n\n const updateColumnWidth = useCallback(\n (widthChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap)\n if (columnIndex === undefined) {\n throw new Error('TableCellResizer: Table column not found.')\n }\n\n const colWidths = tableNode.getColWidths()\n if (!colWidths) {\n return\n }\n const width = colWidths[columnIndex]\n if (width === undefined) {\n return\n }\n const newColWidths = [...colWidths]\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH)\n newColWidths[columnIndex] = newWidth\n tableNode.setColWidths(newColWidths)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const mouseUpHandler = useCallback(\n (direction: MouseDraggingDirection) => {\n const handler = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n if (mouseStartPosRef.current) {\n const { x, y } = mouseStartPosRef.current\n\n if (activeCell === null) {\n return\n }\n const zoom = calculateZoomLevel(event.target as Element)\n\n if (isHeightChanging(direction)) {\n const heightChange = (event.clientY - y) / zoom\n updateRowHeight(heightChange)\n } else {\n const widthChange = (event.clientX - x) / zoom\n updateColumnWidth(widthChange)\n }\n\n resetState()\n document.removeEventListener('mouseup', handler)\n }\n }\n return handler\n },\n [activeCell, resetState, updateColumnWidth, updateRowHeight],\n )\n\n const toggleResize = useCallback(\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\n (event) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n mouseStartPosRef.current = {\n x: event.clientX,\n y: event.clientY,\n }\n updateMouseCurrentPos(mouseStartPosRef.current)\n updateDraggingDirection(direction)\n\n document.addEventListener('mouseup', mouseUpHandler(direction))\n },\n [activeCell, mouseUpHandler],\n )\n\n const [resizerStyles, setResizerStyles] = useState<{\n bottom?: null | React.CSSProperties\n left?: null | React.CSSProperties\n right?: null | React.CSSProperties\n top?: null | React.CSSProperties\n }>({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n\n useEffect(() => {\n if (activeCell) {\n const { height, left, top, width } = activeCell.elem.getBoundingClientRect()\n const zoom = calculateZoomLevel(activeCell.elem)\n const zoneWidth = 10 // Pixel width of the zone where you can drag the edge\n const styles = {\n bottom: {\n backgroundColor: 'none',\n cursor: 'row-resize',\n height: `${zoneWidth}px`,\n left: `${window.scrollX + left}px`,\n top: `${window.scrollY + top + height - zoneWidth / 2}px`,\n width: `${width}px`,\n },\n right: {\n backgroundColor: 'none',\n cursor: 'col-resize',\n height: `${height}px`,\n left: `${window.scrollX + left + width - zoneWidth / 2}px`,\n top: `${window.scrollY + top}px`,\n width: `${zoneWidth}px`,\n },\n }\n\n const tableRect = tableRectRef.current\n\n if (draggingDirection && mouseCurrentPos && tableRect) {\n if (isHeightChanging(draggingDirection)) {\n styles[draggingDirection].left = `${window.scrollX + tableRect.left}px`\n styles[draggingDirection].top = `${window.scrollY + mouseCurrentPos.y / zoom}px`\n styles[draggingDirection].height = '3px'\n styles[draggingDirection].width = `${tableRect.width}px`\n } else {\n styles[draggingDirection].top = `${window.scrollY + tableRect.top}px`\n styles[draggingDirection].left = `${window.scrollX + mouseCurrentPos.x / zoom}px`\n styles[draggingDirection].width = '3px'\n styles[draggingDirection].height = `${tableRect.height}px`\n }\n\n styles[draggingDirection].backgroundColor = '#adf'\n }\n\n setResizerStyles(styles)\n } else {\n setResizerStyles({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n }\n }, [activeCell, draggingDirection, mouseCurrentPos])\n\n return (\n <div ref={resizerRef}>\n {activeCell != null && !isMouseDown && (\n <React.Fragment>\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('right')}\n style={resizerStyles.right || undefined}\n />\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('bottom')}\n style={resizerStyles.bottom || undefined}\n />\n </React.Fragment>\n )}\n </div>\n )\n}\n\nexport const TableCellResizerPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n return useMemo(\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\n [editor, isEditable],\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$isTableCellNode","$isTableRowNode","getDOMCellFromTarget","getTableElement","TableNode","calculateZoomLevel","mergeRegister","$getNearestNodeFromDOMNode","isHTMLElement","SKIP_SCROLL_INTO_VIEW_TAG","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","useEditorConfigContext","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","TableCellResizer","editor","targetRef","resizerRef","tableRectRef","hasTable","setHasTable","editorConfig","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","current","isMouseDownOnEvent","event","buttons","tableKeys","Set","registerMutationListener","nodeMutations","nodeKey","mutation","delete","add","size","registerNodeTransform","tableNode","getColWidths","numColumns","getColumnCount","columnWidth","setColWidths","Array","fill","onMouseMove","target","x","clientX","y","clientY","contains","cell","getEditorState","read","tableCellNode","elem","Error","tableElement","getElementByKey","getKey","getBoundingClientRect","onMouseDown","onMouseUp","removeRootListener","registerRootListener","rootElement","prevRootElement","removeEventListener","addEventListener","isHeightChanging","direction","updateRowHeight","heightChange","update","baseRowIndex","tableRows","getChildren","isFullRowMerge","getColSpan","tableRowIndex","getRowSpan","length","tableRow","height","getHeight","undefined","rowCells","Math","min","map","getCellNodeHeight","Infinity","newHeight","max","setHeight","tag","activeEditor","domCellNode","clientHeight","getCellColumnIndex","tableMap","columnIndex","forEach","row","columnIndexInner","updateColumnWidth","widthChange","colWidths","width","newColWidths","newWidth","mouseUpHandler","handler","preventDefault","stopPropagation","zoom","document","toggleResize","resizerStyles","setResizerStyles","bottom","left","right","top","zoneWidth","styles","backgroundColor","cursor","window","scrollX","scrollY","tableRect","div","ref","Fragment","className","lexical","theme","tableCellResizer","style","TableCellResizerPlugin","isEditable","body"],"mappings":"AAAA;;AAMA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SACEC,6BAA6B,EA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ACuH;QAAIC,KAAK9H;kBACPQ,cAAc,QAAQ,CAACE,6BACtB,MAACvB,MAAM4I,QAAQ;;8BACb,KAACF;oBACCG,WAAW,GAAG5H,aAAaA,YAAY,CAAC6H,OAAO,CAACC,KAAK,CAACC,gBAAgB,CAAC,qBAAqB,CAAC;oBAC7F7E,aAAawD,aAAa;oBAC1BsB,OAAOrB,cAAcI,KAAK,IAAIrC;;8BAEhC,KAAC+C;oBACCG,WAAW,GAAG5H,aAAaA,YAAY,CAAC6H,OAAO,CAACC,KAAK,CAACC,gBAAgB,CAAC,qBAAqB,CAAC;oBAC7F7E,aAAawD,aAAa;oBAC1BsB,OAAOrB,cAAcE,MAAM,IAAInC;;;;;AAM3C;AAEA,OAAO,MAAMuD,yBAA0C;IACrD,MAAM,CAACvI,OAAO,GAAG1B;IACjB,MAAMkK,aAAajK;IAEnB,OAAOiB,QACL,IAAOgJ,2BAAa7I,2BAAa,KAACI;YAAiBC,QAAQA;YAAY+G,SAAS0B,IAAI,IAAI,MACxF;QAACzI;QAAQwI;KAAW;AAExB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableCellNode, TableDOMCell, TableMapType } from '@lexical/table'\nimport type { LexicalEditor, NodeKey } from 'lexical'\nimport type { JSX, MouseEventHandler } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $computeTableMapSkipCellCheck,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $isTableCellNode,\n $isTableRowNode,\n getDOMCellFromTarget,\n getTableElement,\n TableNode,\n} from '@lexical/table'\nimport { calculateZoomLevel, mergeRegister } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode, isHTMLElement, SKIP_SCROLL_INTO_VIEW_TAG } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport './index.scss'\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\n\ntype MousePosition = {\n x: number\n y: number\n}\n\ntype MouseDraggingDirection = 'bottom' | 'right'\n\nconst MIN_ROW_HEIGHT = 33\nconst MIN_COLUMN_WIDTH = 92\n\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\n const targetRef = useRef<HTMLElement | null>(null)\n const resizerRef = useRef<HTMLDivElement | null>(null)\n const tableRectRef = useRef<ClientRect | null>(null)\n const [hasTable, setHasTable] = useState(false)\n const editorConfig = useEditorConfigContext()\n\n const mouseStartPosRef = useRef<MousePosition | null>(null)\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null)\n\n const [activeCell, updateActiveCell] = useState<null | TableDOMCell>(null)\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false)\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null)\n\n const resetState = useCallback(() => {\n updateActiveCell(null)\n targetRef.current = null\n updateDraggingDirection(null)\n mouseStartPosRef.current = null\n tableRectRef.current = null\n }, [])\n\n const isMouseDownOnEvent = (event: MouseEvent) => {\n return (event.buttons & 1) === 1\n }\n\n useEffect(() => {\n const tableKeys = new Set<NodeKey>()\n return mergeRegister(\n editor.registerMutationListener(TableNode, (nodeMutations) => {\n for (const [nodeKey, mutation] of nodeMutations) {\n if (mutation === 'destroyed') {\n tableKeys.delete(nodeKey)\n } else {\n tableKeys.add(nodeKey)\n }\n }\n setHasTable(tableKeys.size > 0)\n }),\n editor.registerNodeTransform(TableNode, (tableNode) => {\n if (tableNode.getColWidths()) {\n return tableNode\n }\n\n const numColumns = tableNode.getColumnCount()\n const columnWidth = MIN_COLUMN_WIDTH\n\n tableNode.setColWidths(Array(numColumns).fill(columnWidth))\n return tableNode\n }),\n )\n }, [editor])\n\n useEffect(() => {\n if (!hasTable) {\n return\n }\n\n const onMouseMove = (event: MouseEvent) => {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n if (draggingDirection) {\n updateMouseCurrentPos({\n x: event.clientX,\n y: event.clientY,\n })\n return\n }\n updateIsMouseDown(isMouseDownOnEvent(event))\n if (resizerRef.current && resizerRef.current.contains(target)) {\n return\n }\n\n if (targetRef.current !== target) {\n targetRef.current = target\n const cell = getDOMCellFromTarget(target)\n\n if (cell && activeCell !== cell) {\n editor.getEditorState().read(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem)\n\n if (!tableCellNode) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const tableElement = getTableElement(\n tableNode,\n editor.getElementByKey(tableNode.getKey()),\n )\n if (!tableElement) {\n throw new Error('TableCellResizer: Table element not found.')\n }\n\n targetRef.current = target\n tableRectRef.current = tableElement.getBoundingClientRect()\n updateActiveCell(cell)\n },\n { editor },\n )\n } else if (cell == null) {\n resetState()\n }\n }\n }\n\n const onMouseDown = (event: MouseEvent) => {\n updateIsMouseDown(true)\n }\n\n const onMouseUp = (event: MouseEvent) => {\n updateIsMouseDown(false)\n }\n\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\n prevRootElement?.removeEventListener('mousemove', onMouseMove)\n prevRootElement?.removeEventListener('mousedown', onMouseDown)\n prevRootElement?.removeEventListener('mouseup', onMouseUp)\n rootElement?.addEventListener('mousemove', onMouseMove)\n rootElement?.addEventListener('mousedown', onMouseDown)\n rootElement?.addEventListener('mouseup', onMouseUp)\n })\n\n return () => {\n removeRootListener()\n }\n }, [activeCell, draggingDirection, editor, hasTable, resetState])\n\n const isHeightChanging = (direction: MouseDraggingDirection) => {\n if (direction === 'bottom') {\n return true\n }\n return false\n }\n\n const updateRowHeight = useCallback(\n (heightChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const baseRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode)\n const tableRows = tableNode.getChildren()\n\n // Determine if this is a full row merge by checking colspan\n const isFullRowMerge = tableCellNode.getColSpan() === tableNode.getColumnCount()\n\n // For full row merges, apply to first row. For partial merges, apply to last row\n const tableRowIndex = isFullRowMerge\n ? baseRowIndex\n : baseRowIndex + tableCellNode.getRowSpan() - 1\n\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\n throw new Error('Expected table cell to be inside of table row.')\n }\n\n const tableRow = tableRows[tableRowIndex]\n\n if (!$isTableRowNode(tableRow)) {\n throw new Error('Expected table row')\n }\n\n let height = tableRow.getHeight()\n if (height === undefined) {\n const rowCells = tableRow.getChildren<TableCellNode>()\n height = Math.min(\n ...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity),\n )\n }\n\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT)\n tableRow.setHeight(newHeight)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const getCellNodeHeight = (\n cell: TableCellNode,\n activeEditor: LexicalEditor,\n ): number | undefined => {\n const domCellNode = activeEditor.getElementByKey(cell.getKey())\n return domCellNode?.clientHeight\n }\n\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\n let columnIndex: number | undefined\n tableMap.forEach((row) => {\n row.forEach((cell, columnIndexInner) => {\n if (cell.cell === tableCellNode) {\n columnIndex = columnIndexInner\n }\n })\n })\n return columnIndex\n }\n\n const updateColumnWidth = useCallback(\n (widthChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap)\n if (columnIndex === undefined) {\n throw new Error('TableCellResizer: Table column not found.')\n }\n\n const colWidths = tableNode.getColWidths()\n if (!colWidths) {\n return\n }\n const width = colWidths[columnIndex]\n if (width === undefined) {\n return\n }\n const newColWidths = [...colWidths]\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH)\n newColWidths[columnIndex] = newWidth\n tableNode.setColWidths(newColWidths)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const mouseUpHandler = useCallback(\n (direction: MouseDraggingDirection) => {\n const handler = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n if (mouseStartPosRef.current) {\n const { x, y } = mouseStartPosRef.current\n\n if (activeCell === null) {\n return\n }\n const zoom = calculateZoomLevel(event.target as Element)\n\n if (isHeightChanging(direction)) {\n const heightChange = (event.clientY - y) / zoom\n updateRowHeight(heightChange)\n } else {\n const widthChange = (event.clientX - x) / zoom\n updateColumnWidth(widthChange)\n }\n\n resetState()\n document.removeEventListener('mouseup', handler)\n }\n }\n return handler\n },\n [activeCell, resetState, updateColumnWidth, updateRowHeight],\n )\n\n const toggleResize = useCallback(\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\n (event) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n mouseStartPosRef.current = {\n x: event.clientX,\n y: event.clientY,\n }\n updateMouseCurrentPos(mouseStartPosRef.current)\n updateDraggingDirection(direction)\n\n document.addEventListener('mouseup', mouseUpHandler(direction))\n },\n [activeCell, mouseUpHandler],\n )\n\n const [resizerStyles, setResizerStyles] = useState<{\n bottom?: null | React.CSSProperties\n left?: null | React.CSSProperties\n right?: null | React.CSSProperties\n top?: null | React.CSSProperties\n }>({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n\n useEffect(() => {\n if (activeCell) {\n const { height, left, top, width } = activeCell.elem.getBoundingClientRect()\n const zoom = calculateZoomLevel(activeCell.elem)\n const zoneWidth = 10 // Pixel width of the zone where you can drag the edge\n const styles = {\n bottom: {\n backgroundColor: 'none',\n cursor: 'row-resize',\n height: `${zoneWidth}px`,\n left: `${window.scrollX + left}px`,\n top: `${window.scrollY + top + height - zoneWidth / 2}px`,\n width: `${width}px`,\n },\n right: {\n backgroundColor: 'none',\n cursor: 'col-resize',\n height: `${height}px`,\n left: `${window.scrollX + left + width - zoneWidth / 2}px`,\n top: `${window.scrollY + top}px`,\n width: `${zoneWidth}px`,\n },\n }\n\n const tableRect = tableRectRef.current\n\n if (draggingDirection && mouseCurrentPos && tableRect) {\n if (isHeightChanging(draggingDirection)) {\n styles[draggingDirection].left = `${window.scrollX + tableRect.left}px`\n styles[draggingDirection].top = `${window.scrollY + mouseCurrentPos.y / zoom}px`\n styles[draggingDirection].height = '3px'\n styles[draggingDirection].width = `${tableRect.width}px`\n } else {\n styles[draggingDirection].top = `${window.scrollY + tableRect.top}px`\n styles[draggingDirection].left = `${window.scrollX + mouseCurrentPos.x / zoom}px`\n styles[draggingDirection].width = '3px'\n styles[draggingDirection].height = `${tableRect.height}px`\n }\n\n styles[draggingDirection].backgroundColor = '#adf'\n }\n\n setResizerStyles(styles)\n } else {\n setResizerStyles({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n }\n }, [activeCell, draggingDirection, mouseCurrentPos])\n\n return (\n <div ref={resizerRef}>\n {activeCell != null && !isMouseDown && (\n <React.Fragment>\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('right')}\n style={resizerStyles.right || undefined}\n />\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('bottom')}\n style={resizerStyles.bottom || undefined}\n />\n </React.Fragment>\n )}\n </div>\n )\n}\n\nexport const TableCellResizerPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n return useMemo(\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\n [editor, isEditable],\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$isTableCellNode","$isTableRowNode","getDOMCellFromTarget","getTableElement","TableNode","calculateZoomLevel","mergeRegister","$getNearestNodeFromDOMNode","isHTMLElement","SKIP_SCROLL_INTO_VIEW_TAG","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","useEditorConfigContext","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","TableCellResizer","editor","targetRef","resizerRef","tableRectRef","hasTable","setHasTable","editorConfig","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","current","isMouseDownOnEvent","event","buttons","tableKeys","Set","registerMutationListener","nodeMutations","nodeKey","mutation","delete","add","size","registerNodeTransform","tableNode","getColWidths","numColumns","getColumnCount","columnWidth","setColWidths","Array","fill","onMouseMove","target","x","clientX","y","clientY","contains","cell","getEditorState","read","tableCellNode","elem","Error","tableElement","getElementByKey","getKey","getBoundingClientRect","onMouseDown","onMouseUp","removeRootListener","registerRootListener","rootElement","prevRootElement","removeEventListener","addEventListener","isHeightChanging","direction","updateRowHeight","heightChange","update","baseRowIndex","tableRows","getChildren","isFullRowMerge","getColSpan","tableRowIndex","getRowSpan","length","tableRow","height","getHeight","undefined","rowCells","Math","min","map","getCellNodeHeight","Infinity","newHeight","max","setHeight","tag","activeEditor","domCellNode","clientHeight","getCellColumnIndex","tableMap","columnIndex","forEach","row","columnIndexInner","updateColumnWidth","widthChange","colWidths","width","newColWidths","newWidth","mouseUpHandler","handler","preventDefault","stopPropagation","zoom","document","toggleResize","resizerStyles","setResizerStyles","bottom","left","right","top","zoneWidth","styles","backgroundColor","cursor","window","scrollX","scrollY","tableRect","div","ref","Fragment","className","lexical","theme","tableCellResizer","style","TableCellResizerPlugin","isEditable","body"],"mappings":"AAAA;;AAMA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SACEC,6BAA6B,EAC7BC,mCAAmC,EACnCC,kCAAkC,EAClCC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,EACpBC,eAAe,EACfC,SAAS,QACJ,iBAAgB;AACvB,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,iBAAgB;AAClE,SAASC,0BAA0B,EAAEC,aAAa,EAAEC,yBAAyB,QAAQ,UAAS;AAC9F,YAAYC,WAAW,QAAO;AAC9B,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACzE,SAASC,YAAY,QAAQ,YAAW;AAIxC,OAAO,eAAc;AACrB,SAASC,sBAAsB,QAAQ,+DAA8D;AASrG,MAAMC,iBAAiB;AACvB,MAAMC,mBAAmB;AAEzB,SAASC,iBAAiB,EAAEC,MAAM,EAA6B;IAC7D,MAAMC,YAAYR,OAA2B;IAC7C,MAAMS,aAAaT,OAA8B;IACjD,MAAMU,eAAeV,OAA0B;IAC/C,MAAM,CAACW,UAAUC,YAAY,GAAGX,SAAS;IACzC,MAAMY,eAAeV;IAErB,MAAMW,mBAAmBd,OAA6B;IACtD,MAAM,CAACe,iBAAiBC,sBAAsB,GAAGf,SAA+B;IAEhF,MAAM,CAACgB,YAAYC,iBAAiB,GAAGjB,SAA8B;IACrE,MAAM,C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dev-runtime";
|
|
3
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
4
|
import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
5
5
|
import { $getTableAndElementByKey, $getTableColumnIndexFromTableCellNode, $getTableRowIndexFromTableCellNode, $insertTableColumnAtSelection, $insertTableRowAtSelection, $isTableCellNode, $isTableNode, getTableElement, TableNode } from '@lexical/table';
|
|
@@ -173,9 +173,9 @@ function TableHoverActionsContainer({ anchorElem }) {
|
|
|
173
173
|
if (!isEditable) {
|
|
174
174
|
return null;
|
|
175
175
|
}
|
|
176
|
-
return /*#__PURE__*/
|
|
176
|
+
return /*#__PURE__*/ _jsxDEV(_Fragment, {
|
|
177
177
|
children: [
|
|
178
|
-
isShownRow && /*#__PURE__*/
|
|
178
|
+
isShownRow && /*#__PURE__*/ _jsxDEV("button", {
|
|
179
179
|
"aria-label": "Add Row",
|
|
180
180
|
className: editorConfig.editorConfig.lexical.theme.tableAddRows,
|
|
181
181
|
onClick: ()=>insertAction(true),
|
|
@@ -183,8 +183,12 @@ function TableHoverActionsContainer({ anchorElem }) {
|
|
|
183
183
|
...position
|
|
184
184
|
},
|
|
185
185
|
type: "button"
|
|
186
|
-
}
|
|
187
|
-
|
|
186
|
+
}, void 0, false, {
|
|
187
|
+
fileName: "src/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.tsx",
|
|
188
|
+
lineNumber: 246,
|
|
189
|
+
columnNumber: 9
|
|
190
|
+
}, this),
|
|
191
|
+
isShownColumn && /*#__PURE__*/ _jsxDEV("button", {
|
|
188
192
|
"aria-label": "Add Column",
|
|
189
193
|
className: editorConfig.editorConfig.lexical.theme.tableAddColumns,
|
|
190
194
|
onClick: ()=>insertAction(false),
|
|
@@ -192,9 +196,13 @@ function TableHoverActionsContainer({ anchorElem }) {
|
|
|
192
196
|
...position
|
|
193
197
|
},
|
|
194
198
|
type: "button"
|
|
195
|
-
}
|
|
199
|
+
}, void 0, false, {
|
|
200
|
+
fileName: "src/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.tsx",
|
|
201
|
+
lineNumber: 255,
|
|
202
|
+
columnNumber: 9
|
|
203
|
+
}, this)
|
|
196
204
|
]
|
|
197
|
-
});
|
|
205
|
+
}, void 0, true);
|
|
198
206
|
}
|
|
199
207
|
function getMouseInfo(event, editorConfig) {
|
|
200
208
|
const target = event.target;
|
|
@@ -217,9 +225,13 @@ export function TableHoverActionsPlugin({ anchorElem = document.body }) {
|
|
|
217
225
|
if (!isEditable) {
|
|
218
226
|
return null;
|
|
219
227
|
}
|
|
220
|
-
return /*#__PURE__*/ createPortal(/*#__PURE__*/
|
|
228
|
+
return /*#__PURE__*/ createPortal(/*#__PURE__*/ _jsxDEV(TableHoverActionsContainer, {
|
|
221
229
|
anchorElem: anchorElem
|
|
222
|
-
}
|
|
230
|
+
}, void 0, false, {
|
|
231
|
+
fileName: "src/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.tsx",
|
|
232
|
+
lineNumber: 305,
|
|
233
|
+
columnNumber: 23
|
|
234
|
+
}, this), anchorElem);
|
|
223
235
|
}
|
|
224
236
|
|
|
225
237
|
//# sourceMappingURL=index.js.map
|