@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
package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableCellNode, TableRowNode } from '@lexical/table'\nimport type { EditorConfig, NodeKey } from 'lexical'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $getTableAndElementByKey,\n $getTableColumnIndexFromTableCellNode,\n $getTableRowIndexFromTableCellNode,\n $insertTableColumnAtSelection,\n $insertTableRowAtSelection,\n $isTableCellNode,\n $isTableNode,\n getTableElement,\n TableNode,\n} from '@lexical/table'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode, isHTMLElement } from 'lexical'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useDebounce } from '../../utils/useDebounce.js'\n\nconst BUTTON_WIDTH_PX = 20\n\nfunction TableHoverActionsContainer({\n anchorElem,\n}: {\n anchorElem: HTMLElement\n}): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const editorConfig = useEditorConfigContext()\n const [isShownRow, setShownRow] = useState<boolean>(false)\n const [isShownColumn, setShownColumn] = useState<boolean>(false)\n const [shouldListenMouseMove, setShouldListenMouseMove] = useState<boolean>(false)\n const [position, setPosition] = useState({})\n const tableSetRef = useRef<Set<NodeKey>>(new Set())\n const tableCellDOMNodeRef = useRef<HTMLElement | null>(null)\n\n const debouncedOnMouseMove = useDebounce(\n (event: MouseEvent) => {\n const { isOutside, tableDOMNode } = getMouseInfo(event, editorConfig.editorConfig?.lexical)\n\n if (isOutside) {\n setShownRow(false)\n setShownColumn(false)\n return\n }\n\n if (!tableDOMNode) {\n return\n }\n\n tableCellDOMNodeRef.current = tableDOMNode\n\n let hoveredRowNode: null | TableCellNode = null\n let hoveredColumnNode: null | TableCellNode = null\n let tableDOMElement: HTMLElement | null = null\n\n editor.getEditorState().read(\n () => {\n const maybeTableCell = $getNearestNodeFromDOMNode(tableDOMNode)\n\n if ($isTableCellNode(maybeTableCell)) {\n const table = $findMatchingParent(maybeTableCell, (node) => $isTableNode(node))\n if (!$isTableNode(table)) {\n return\n }\n\n tableDOMElement = getTableElement(table, editor.getElementByKey(table.getKey()))\n\n if (tableDOMElement) {\n const rowCount = table.getChildrenSize()\n const colCount = (table.getChildAtIndex(0) as TableRowNode)?.getChildrenSize()\n\n const rowIndex = $getTableRowIndexFromTableCellNode(maybeTableCell)\n const colIndex = $getTableColumnIndexFromTableCellNode(maybeTableCell)\n\n if (rowIndex === rowCount - 1) {\n hoveredRowNode = maybeTableCell\n } else if (colIndex === colCount - 1) {\n hoveredColumnNode = maybeTableCell\n }\n }\n }\n },\n { editor },\n )\n\n if (!tableDOMElement) {\n return\n }\n\n // this is the scrollable div container of the table (in case of overflow)\n const tableContainerElement = (tableDOMElement as HTMLTableElement).parentElement\n\n if (!tableContainerElement) {\n return\n }\n\n const {\n bottom: tableElemBottom,\n height: tableElemHeight,\n left: tableElemLeft,\n right: tableElemRight,\n width: tableElemWidth,\n y: tableElemY,\n } = (tableDOMElement as HTMLTableElement).getBoundingClientRect()\n\n let tableHasScroll = false\n if (\n tableContainerElement &&\n tableContainerElement.classList.contains('LexicalEditorTheme__tableScrollableWrapper')\n ) {\n tableHasScroll = tableContainerElement.scrollWidth > tableContainerElement.clientWidth\n }\n\n const { left: editorElemLeft, y: editorElemY } = anchorElem.getBoundingClientRect()\n\n if (hoveredRowNode) {\n setShownColumn(false)\n setShownRow(true)\n setPosition({\n height: BUTTON_WIDTH_PX,\n left:\n tableHasScroll && tableContainerElement\n ? tableContainerElement.offsetLeft\n : tableElemLeft - editorElemLeft,\n top: tableElemBottom - editorElemY + 5,\n width:\n tableHasScroll && tableContainerElement\n ? tableContainerElement.offsetWidth\n : tableElemWidth,\n })\n } else if (hoveredColumnNode) {\n setShownColumn(true)\n setShownRow(false)\n setPosition({\n height: tableElemHeight,\n left: tableElemRight - editorElemLeft + 5,\n top: tableElemY - editorElemY,\n width: BUTTON_WIDTH_PX,\n })\n }\n },\n 50,\n 250,\n )\n\n // Hide the buttons on any table dimensions change to prevent last row cells\n // overlap behind the 'Add Row' button when text entry changes cell height\n const tableResizeObserver = useMemo(() => {\n return new ResizeObserver(() => {\n setShownRow(false)\n setShownColumn(false)\n })\n }, [])\n\n useEffect(() => {\n if (!shouldListenMouseMove) {\n return\n }\n\n document.addEventListener('mousemove', debouncedOnMouseMove)\n\n return () => {\n setShownRow(false)\n setShownColumn(false)\n\n document.removeEventListener('mousemove', debouncedOnMouseMove)\n }\n }, [shouldListenMouseMove, debouncedOnMouseMove])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerMutationListener(\n TableNode,\n (mutations) => {\n editor.getEditorState().read(\n () => {\n let resetObserver = false\n for (const [key, type] of mutations) {\n switch (type) {\n case 'created': {\n tableSetRef.current.add(key)\n resetObserver = true\n break\n }\n case 'destroyed': {\n tableSetRef.current.delete(key)\n resetObserver = true\n break\n }\n default:\n break\n }\n }\n if (resetObserver) {\n // Reset resize observers\n tableResizeObserver.disconnect()\n for (const tableKey of tableSetRef.current) {\n const { tableElement } = $getTableAndElementByKey(tableKey)\n tableResizeObserver.observe(tableElement)\n }\n setShouldListenMouseMove(tableSetRef.current.size > 0)\n }\n },\n { editor },\n )\n },\n { skipInitialization: false },\n ),\n )\n }, [editor, tableResizeObserver])\n\n const insertAction = (insertRow: boolean) => {\n editor.update(() => {\n if (tableCellDOMNodeRef.current) {\n const maybeTableNode = $getNearestNodeFromDOMNode(tableCellDOMNodeRef.current)\n maybeTableNode?.selectEnd()\n if (insertRow) {\n $insertTableRowAtSelection()\n setShownRow(false)\n } else {\n $insertTableColumnAtSelection()\n setShownColumn(false)\n }\n }\n })\n }\n\n if (!isEditable) {\n return null\n }\n\n return (\n <>\n {isShownRow && (\n <button\n aria-label=\"Add Row\"\n className={editorConfig.editorConfig.lexical.theme.tableAddRows}\n onClick={() => insertAction(true)}\n style={{ ...position }}\n type=\"button\"\n />\n )}\n {isShownColumn && (\n <button\n aria-label=\"Add Column\"\n className={editorConfig.editorConfig.lexical.theme.tableAddColumns}\n onClick={() => insertAction(false)}\n style={{ ...position }}\n type=\"button\"\n />\n )}\n </>\n )\n}\n\nfunction getMouseInfo(\n event: MouseEvent,\n editorConfig: EditorConfig,\n): {\n isOutside: boolean\n tableDOMNode: HTMLElement | null\n} {\n const target = event.target\n\n if (isHTMLElement(target)) {\n const tableDOMNode = target.closest<HTMLElement>(\n `td.${editorConfig.theme.tableCell}, th.${editorConfig.theme.tableCell}`,\n )\n\n const isOutside = !(\n tableDOMNode ||\n target.closest<HTMLElement>(`button.${editorConfig.theme.tableAddRows}`) ||\n target.closest<HTMLElement>(`button.${editorConfig.theme.tableAddColumns}`) ||\n target.closest<HTMLElement>(`div.${editorConfig.theme.tableCellResizer}`)\n )\n\n return { isOutside, tableDOMNode }\n } else {\n return { isOutside: true, tableDOMNode: null }\n }\n}\n\nexport function TableHoverActionsPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): null | React.ReactPortal {\n const isEditable = useLexicalEditable()\n\n if (!isEditable) {\n return null\n }\n\n return createPortal(<TableHoverActionsContainer anchorElem={anchorElem} />, anchorElem)\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","$getTableAndElementByKey","$getTableColumnIndexFromTableCellNode","$getTableRowIndexFromTableCellNode","$insertTableColumnAtSelection","$insertTableRowAtSelection","$isTableCellNode","$isTableNode","getTableElement","TableNode","$findMatchingParent","mergeRegister","$getNearestNodeFromDOMNode","isHTMLElement","useEffect","useMemo","useRef","useState","React","createPortal","useEditorConfigContext","useDebounce","BUTTON_WIDTH_PX","TableHoverActionsContainer","anchorElem","editor","isEditable","editorConfig","isShownRow","setShownRow","isShownColumn","setShownColumn","shouldListenMouseMove","setShouldListenMouseMove","position","setPosition","tableSetRef","Set","tableCellDOMNodeRef","debouncedOnMouseMove","event","isOutside","tableDOMNode","getMouseInfo","lexical","current","hoveredRowNode","hoveredColumnNode","tableDOMElement","getEditorState","read","maybeTableCell","table","node","getElementByKey","getKey","rowCount","getChildrenSize","colCount","getChildAtIndex","rowIndex","colIndex","tableContainerElement","parentElement","bottom","tableElemBottom","height","tableElemHeight","left","tableElemLeft","right","tableElemRight","width","tableElemWidth","y","tableElemY","getBoundingClientRect","tableHasScroll","classList","contains","scrollWidth","clientWidth","editorElemLeft","editorElemY","offsetLeft","top","offsetWidth","tableResizeObserver","ResizeObserver","document","addEventListener","removeEventListener","registerMutationListener","mutations","resetObserver","key","type","add","delete","disconnect","tableKey","tableElement","observe","size","skipInitialization","insertAction","insertRow","update","maybeTableNode","selectEnd","button","aria-label","className","theme","tableAddRows","onClick","style","tableAddColumns","target","closest","tableCell","tableCellResizer","TableHoverActionsPlugin","body"],"mappings":"AAAA;;AAMA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SACEC,wBAAwB,EACxBC,qCAAqC,EACrCC,kCAAkC,EAClCC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,gBAAgB,EAChBC,YAAY,EACZC,eAAe,EACfC,SAAS,QACJ,iBAAgB;AACvB,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,iBAAgB;AACnE,SAASC,0BAA0B,EAAEC,aAAa,QAAQ,UAAS;AACnE,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO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AwB,EACtClG,aAAaiE,SAASkC,IAAI,EAG3B;IACC,MAAMjG,aAAa1B;IAEnB,IAAI,CAAC0B,YAAY;QACf,OAAO;IACT;IAEA,qBAAOP,2BAAa,KAACI;QAA2BC,YAAYA;QAAgBA;AAC9E"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableCellNode, TableRowNode } from '@lexical/table'\nimport type { EditorConfig, NodeKey } from 'lexical'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $getTableAndElementByKey,\n $getTableColumnIndexFromTableCellNode,\n $getTableRowIndexFromTableCellNode,\n $insertTableColumnAtSelection,\n $insertTableRowAtSelection,\n $isTableCellNode,\n $isTableNode,\n getTableElement,\n TableNode,\n} from '@lexical/table'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode, isHTMLElement } from 'lexical'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useDebounce } from '../../utils/useDebounce.js'\n\nconst BUTTON_WIDTH_PX = 20\n\nfunction TableHoverActionsContainer({\n anchorElem,\n}: {\n anchorElem: HTMLElement\n}): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const editorConfig = useEditorConfigContext()\n const [isShownRow, setShownRow] = useState<boolean>(false)\n const [isShownColumn, setShownColumn] = useState<boolean>(false)\n const [shouldListenMouseMove, setShouldListenMouseMove] = useState<boolean>(false)\n const [position, setPosition] = useState({})\n const tableSetRef = useRef<Set<NodeKey>>(new Set())\n const tableCellDOMNodeRef = useRef<HTMLElement | null>(null)\n\n const debouncedOnMouseMove = useDebounce(\n (event: MouseEvent) => {\n const { isOutside, tableDOMNode } = getMouseInfo(event, editorConfig.editorConfig?.lexical)\n\n if (isOutside) {\n setShownRow(false)\n setShownColumn(false)\n return\n }\n\n if (!tableDOMNode) {\n return\n }\n\n tableCellDOMNodeRef.current = tableDOMNode\n\n let hoveredRowNode: null | TableCellNode = null\n let hoveredColumnNode: null | TableCellNode = null\n let tableDOMElement: HTMLElement | null = null\n\n editor.getEditorState().read(\n () => {\n const maybeTableCell = $getNearestNodeFromDOMNode(tableDOMNode)\n\n if ($isTableCellNode(maybeTableCell)) {\n const table = $findMatchingParent(maybeTableCell, (node) => $isTableNode(node))\n if (!$isTableNode(table)) {\n return\n }\n\n tableDOMElement = getTableElement(table, editor.getElementByKey(table.getKey()))\n\n if (tableDOMElement) {\n const rowCount = table.getChildrenSize()\n const colCount = (table.getChildAtIndex(0) as TableRowNode)?.getChildrenSize()\n\n const rowIndex = $getTableRowIndexFromTableCellNode(maybeTableCell)\n const colIndex = $getTableColumnIndexFromTableCellNode(maybeTableCell)\n\n if (rowIndex === rowCount - 1) {\n hoveredRowNode = maybeTableCell\n } else if (colIndex === colCount - 1) {\n hoveredColumnNode = maybeTableCell\n }\n }\n }\n },\n { editor },\n )\n\n if (!tableDOMElement) {\n return\n }\n\n // this is the scrollable div container of the table (in case of overflow)\n const tableContainerElement = (tableDOMElement as HTMLTableElement).parentElement\n\n if (!tableContainerElement) {\n return\n }\n\n const {\n bottom: tableElemBottom,\n height: tableElemHeight,\n left: tableElemLeft,\n right: tableElemRight,\n width: tableElemWidth,\n y: tableElemY,\n } = (tableDOMElement as HTMLTableElement).getBoundingClientRect()\n\n let tableHasScroll = false\n if (\n tableContainerElement &&\n tableContainerElement.classList.contains('LexicalEditorTheme__tableScrollableWrapper')\n ) {\n tableHasScroll = tableContainerElement.scrollWidth > tableContainerElement.clientWidth\n }\n\n const { left: editorElemLeft, y: editorElemY } = anchorElem.getBoundingClientRect()\n\n if (hoveredRowNode) {\n setShownColumn(false)\n setShownRow(true)\n setPosition({\n height: BUTTON_WIDTH_PX,\n left:\n tableHasScroll && tableContainerElement\n ? tableContainerElement.offsetLeft\n : tableElemLeft - editorElemLeft,\n top: tableElemBottom - editorElemY + 5,\n width:\n tableHasScroll && tableContainerElement\n ? tableContainerElement.offsetWidth\n : tableElemWidth,\n })\n } else if (hoveredColumnNode) {\n setShownColumn(true)\n setShownRow(false)\n setPosition({\n height: tableElemHeight,\n left: tableElemRight - editorElemLeft + 5,\n top: tableElemY - editorElemY,\n width: BUTTON_WIDTH_PX,\n })\n }\n },\n 50,\n 250,\n )\n\n // Hide the buttons on any table dimensions change to prevent last row cells\n // overlap behind the 'Add Row' button when text entry changes cell height\n const tableResizeObserver = useMemo(() => {\n return new ResizeObserver(() => {\n setShownRow(false)\n setShownColumn(false)\n })\n }, [])\n\n useEffect(() => {\n if (!shouldListenMouseMove) {\n return\n }\n\n document.addEventListener('mousemove', debouncedOnMouseMove)\n\n return () => {\n setShownRow(false)\n setShownColumn(false)\n\n document.removeEventListener('mousemove', debouncedOnMouseMove)\n }\n }, [shouldListenMouseMove, debouncedOnMouseMove])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerMutationListener(\n TableNode,\n (mutations) => {\n editor.getEditorState().read(\n () => {\n let resetObserver = false\n for (const [key, type] of mutations) {\n switch (type) {\n case 'created': {\n tableSetRef.current.add(key)\n resetObserver = true\n break\n }\n case 'destroyed': {\n tableSetRef.current.delete(key)\n resetObserver = true\n break\n }\n default:\n break\n }\n }\n if (resetObserver) {\n // Reset resize observers\n tableResizeObserver.disconnect()\n for (const tableKey of tableSetRef.current) {\n const { tableElement } = $getTableAndElementByKey(tableKey)\n tableResizeObserver.observe(tableElement)\n }\n setShouldListenMouseMove(tableSetRef.current.size > 0)\n }\n },\n { editor },\n )\n },\n { skipInitialization: false },\n ),\n )\n }, [editor, tableResizeObserver])\n\n const insertAction = (insertRow: boolean) => {\n editor.update(() => {\n if (tableCellDOMNodeRef.current) {\n const maybeTableNode = $getNearestNodeFromDOMNode(tableCellDOMNodeRef.current)\n maybeTableNode?.selectEnd()\n if (insertRow) {\n $insertTableRowAtSelection()\n setShownRow(false)\n } else {\n $insertTableColumnAtSelection()\n setShownColumn(false)\n }\n }\n })\n }\n\n if (!isEditable) {\n return null\n }\n\n return (\n <>\n {isShownRow && (\n <button\n aria-label=\"Add Row\"\n className={editorConfig.editorConfig.lexical.theme.tableAddRows}\n onClick={() => insertAction(true)}\n style={{ ...position }}\n type=\"button\"\n />\n )}\n {isShownColumn && (\n <button\n aria-label=\"Add Column\"\n className={editorConfig.editorConfig.lexical.theme.tableAddColumns}\n onClick={() => insertAction(false)}\n style={{ ...position }}\n type=\"button\"\n />\n )}\n </>\n )\n}\n\nfunction getMouseInfo(\n event: MouseEvent,\n editorConfig: EditorConfig,\n): {\n isOutside: boolean\n tableDOMNode: HTMLElement | null\n} {\n const target = event.target\n\n if (isHTMLElement(target)) {\n const tableDOMNode = target.closest<HTMLElement>(\n `td.${editorConfig.theme.tableCell}, th.${editorConfig.theme.tableCell}`,\n )\n\n const isOutside = !(\n tableDOMNode ||\n target.closest<HTMLElement>(`button.${editorConfig.theme.tableAddRows}`) ||\n target.closest<HTMLElement>(`button.${editorConfig.theme.tableAddColumns}`) ||\n target.closest<HTMLElement>(`div.${editorConfig.theme.tableCellResizer}`)\n )\n\n return { isOutside, tableDOMNode }\n } else {\n return { isOutside: true, tableDOMNode: null }\n }\n}\n\nexport function TableHoverActionsPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): null | React.ReactPortal {\n const isEditable = useLexicalEditable()\n\n if (!isEditable) {\n return null\n }\n\n return createPortal(<TableHoverActionsContainer anchorElem={anchorElem} />, anchorElem)\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","$getTableAndElementByKey","$getTableColumnIndexFromTableCellNode","$getTableRowIndexFromTableCellNode","$insertTableColumnAtSelection","$insertTableRowAtSelection","$isTableCellNode","$isTableNode","getTableElement","TableNode","$findMatchingParent","mergeRegister","$getNearestNodeFromDOMNode","isHTMLElement","useEffect","useMemo","useRef","useState","React","createPortal","useEditorConfigContext","useDebounce","BUTTON_WIDTH_PX","TableHoverActionsContainer","anchorElem","editor","isEditable","editorConfig","isShownRow","setShownRow","isShownColumn","setShownColumn","shouldListenMouseMove","setShouldListenMouseMove","position","setPosition","tableSetRef","Set","tableCellDOMNodeRef","debouncedOnMouseMove","event","isOutside","tableDOMNode","getMouseInfo","lexical","current","hoveredRowNode","hoveredColumnNode","tableDOMElement","getEditorState","read","maybeTableCell","table","node","getElementByKey","getKey","rowCount","getChildrenSize","colCount","getChildAtIndex","rowIndex","colIndex","tableContainerElement","parentElement","bottom","tableElemBottom","height","tableElemHeight","left","tableElemLeft","right","tableElemRight","width","tableElemWidth","y","tableElemY","getBoundingClientRect","tableHasScroll","classList","contains","scrollWidth","clientWidth","editorElemLeft","editorElemY","offsetLeft","top","offsetWidth","tableResizeObserver","ResizeObserver","document","addEventListener","removeEventListener","registerMutationListener","mutations","resetObserver","key","type","add","delete","disconnect","tableKey","tableElement","observe","size","skipInitialization","insertAction","insertRow","update","maybeTableNode","selectEnd","button","aria-label","className","theme","tableAddRows","onClick","style","tableAddColumns","target","closest","tableCell","tableCellResizer","TableHoverActionsPlugin","body"],"mappings":"AAAA;;AAMA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SACEC,wBAAwB,EACxBC,qCAAqC,EACrCC,kCAAkC,EAClCC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,gBAAgB,EAChBC,YAAY,EACZC,eAAe,EACfC,SAAS,QACJ,iBAAgB;AACvB,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,iBAAgB;AACnE,SAASC,0BAA0B,EAAEC,aAAa,QAAQ,UAAS;AACnE,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAC5D,YAAYC,WAAW,QAAO;AAC9B,SAASC,YAAY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G3B;IACC,MAAMjG,aAAa1B;IAEnB,IAAI,CAAC0B,YAAY;QACf,OAAO;IACT;IAEA,qBAAOP,2BAAa,QAACI;QAA2BC,YAAYA;;;;;cAAgBA;AAC9E"}
|
|
@@ -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 { TablePlugin as LexicalReactTablePlugin } from '@lexical/react/LexicalTablePlugin';
|
|
5
5
|
import { INSERT_TABLE_COMMAND, TableCellNode, TableNode, TableRowNode } from '@lexical/table';
|
|
@@ -24,7 +24,7 @@ export function TableContext({ children }) {
|
|
|
24
24
|
cellEditorConfig: null,
|
|
25
25
|
cellEditorPlugins: null
|
|
26
26
|
});
|
|
27
|
-
return /*#__PURE__*/
|
|
27
|
+
return /*#__PURE__*/ _jsxDEV(CellContext, {
|
|
28
28
|
value: useMemo(()=>({
|
|
29
29
|
cellEditorConfig: contextValue.cellEditorConfig,
|
|
30
30
|
cellEditorPlugins: contextValue.cellEditorPlugins,
|
|
@@ -39,7 +39,11 @@ export function TableContext({ children }) {
|
|
|
39
39
|
contextValue.cellEditorPlugins
|
|
40
40
|
]),
|
|
41
41
|
children: children
|
|
42
|
-
}
|
|
42
|
+
}, void 0, false, {
|
|
43
|
+
fileName: "src/features/experimental_table/client/plugins/TablePlugin/index.tsx",
|
|
44
|
+
lineNumber: 67,
|
|
45
|
+
columnNumber: 5
|
|
46
|
+
}, this);
|
|
43
47
|
}
|
|
44
48
|
export const TablePlugin = ()=>{
|
|
45
49
|
const [editor] = useLexicalComposerContext();
|
|
@@ -77,9 +81,9 @@ export const TablePlugin = ()=>{
|
|
|
77
81
|
editor,
|
|
78
82
|
toggleDrawer
|
|
79
83
|
]);
|
|
80
|
-
return /*#__PURE__*/
|
|
84
|
+
return /*#__PURE__*/ _jsxDEV(React.Fragment, {
|
|
81
85
|
children: [
|
|
82
|
-
/*#__PURE__*/
|
|
86
|
+
/*#__PURE__*/ _jsxDEV(FieldsDrawer, {
|
|
83
87
|
drawerSlug: drawerSlug,
|
|
84
88
|
drawerTitle: "Create Table",
|
|
85
89
|
featureKey: "experimental_table",
|
|
@@ -94,14 +98,26 @@ export const TablePlugin = ()=>{
|
|
|
94
98
|
},
|
|
95
99
|
schemaPath: schemaPath,
|
|
96
100
|
schemaPathSuffix: "fields"
|
|
97
|
-
}
|
|
98
|
-
|
|
101
|
+
}, void 0, false, {
|
|
102
|
+
fileName: "src/features/experimental_table/client/plugins/TablePlugin/index.tsx",
|
|
103
|
+
lineNumber: 131,
|
|
104
|
+
columnNumber: 7
|
|
105
|
+
}, this),
|
|
106
|
+
/*#__PURE__*/ _jsxDEV(LexicalReactTablePlugin, {
|
|
99
107
|
hasCellBackgroundColor: false,
|
|
100
108
|
hasCellMerge: true,
|
|
101
109
|
hasHorizontalScroll: true
|
|
102
|
-
}
|
|
110
|
+
}, void 0, false, {
|
|
111
|
+
fileName: "src/features/experimental_table/client/plugins/TablePlugin/index.tsx",
|
|
112
|
+
lineNumber: 148,
|
|
113
|
+
columnNumber: 7
|
|
114
|
+
}, this)
|
|
103
115
|
]
|
|
104
|
-
}
|
|
116
|
+
}, void 0, true, {
|
|
117
|
+
fileName: "src/features/experimental_table/client/plugins/TablePlugin/index.tsx",
|
|
118
|
+
lineNumber: 130,
|
|
119
|
+
columnNumber: 5
|
|
120
|
+
}, this);
|
|
105
121
|
};
|
|
106
122
|
|
|
107
123
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TablePlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n EditorThemeClasses,\n Klass,\n LexicalCommand,\n LexicalEditor,\n LexicalNode,\n RangeSelection,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TablePlugin as LexicalReactTablePlugin } from '@lexical/react/LexicalTablePlugin'\nimport { INSERT_TABLE_COMMAND, TableCellNode, TableNode, TableRowNode } from '@lexical/table'\nimport { mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth } from '@payloadcms/ui'\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical'\nimport { createContext, use, useEffect, useMemo, useState } from 'react'\nimport * as React from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../../utilities/fieldsDrawer/Drawer.js'\nimport { useLexicalDrawer } from '../../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport './index.scss'\n\nexport type CellContextShape = {\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n set: (\n cellEditorConfig: CellEditorConfig | null,\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null,\n ) => void\n}\n\nexport type CellEditorConfig = Readonly<{\n namespace: string\n nodes?: ReadonlyArray<Klass<LexicalNode>>\n onError: (error: Error, editor: LexicalEditor) => void\n readOnly?: boolean\n theme?: EditorThemeClasses\n}>\n\nexport const OPEN_TABLE_DRAWER_COMMAND: LexicalCommand<{}> = createCommand(\n 'OPEN_EMBED_DRAWER_COMMAND',\n)\n\nexport const CellContext = createContext<CellContextShape>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n set: () => {\n // Empty\n },\n})\n\nexport function TableContext({ children }: { children: JSX.Element }) {\n const [contextValue, setContextValue] = useState<{\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n }>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n })\n return (\n <CellContext\n value={useMemo(\n () => ({\n cellEditorConfig: contextValue.cellEditorConfig,\n cellEditorPlugins: contextValue.cellEditorPlugins,\n set: (cellEditorConfig, cellEditorPlugins) => {\n setContextValue({ cellEditorConfig, cellEditorPlugins })\n },\n }),\n [contextValue.cellEditorConfig, contextValue.cellEditorPlugins],\n )}\n >\n {children}\n </CellContext>\n )\n}\n\nexport const TablePlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const cellContext = use(CellContext)\n const editDepth = useEditDepth()\n const {\n fieldProps: { schemaPath },\n uuid,\n } = useEditorConfigContext()\n\n const drawerSlug = formatDrawerSlug({\n slug: 'lexical-table-create-' + uuid,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n useEffect(() => {\n if (!editor.hasNodes([TableNode, TableRowNode, TableCellNode])) {\n throw new Error(\n 'TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor',\n )\n }\n\n return mergeRegister(\n editor.registerCommand(\n OPEN_TABLE_DRAWER_COMMAND,\n () => {\n let rangeSelection: null | RangeSelection = null\n\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n rangeSelection = selection\n }\n })\n\n if (rangeSelection) {\n toggleDrawer()\n }\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [cellContext, editor, toggleDrawer])\n\n return (\n <React.Fragment>\n <FieldsDrawer\n drawerSlug={drawerSlug}\n drawerTitle=\"Create Table\"\n featureKey=\"experimental_table\"\n handleDrawerSubmit={(_fields, data) => {\n if (!data.columns || !data.rows) {\n return\n }\n\n editor.dispatchCommand(INSERT_TABLE_COMMAND, {\n columns: String(data.columns),\n rows: String(data.rows),\n })\n }}\n schemaPath={schemaPath}\n schemaPathSuffix=\"fields\"\n />\n <LexicalReactTablePlugin\n hasCellBackgroundColor={false}\n hasCellMerge\n hasHorizontalScroll={true}\n />\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","TablePlugin","LexicalReactTablePlugin","INSERT_TABLE_COMMAND","TableCellNode","TableNode","TableRowNode","mergeRegister","formatDrawerSlug","useEditDepth","$getSelection","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","createContext","use","useEffect","useMemo","useState","React","useEditorConfigContext","FieldsDrawer","useLexicalDrawer","OPEN_TABLE_DRAWER_COMMAND","CellContext","cellEditorConfig","cellEditorPlugins","set","TableContext","children","contextValue","setContextValue","value","editor","cellContext","editDepth","fieldProps","schemaPath","uuid","drawerSlug","slug","depth","toggleDrawer","hasNodes","Error","registerCommand","rangeSelection","getEditorState","read","selection","Fragment","drawerTitle","featureKey","handleDrawerSubmit","_fields","data","columns","rows","dispatchCommand","String","schemaPathSuffix","hasCellBackgroundColor","hasCellMerge","hasHorizontalScroll"],"mappings":"AAAA;;AAYA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,eAAeC,uBAAuB,QAAQ,oCAAmC;AAC1F,SAASC,oBAAoB,EAAEC,aAAa,EAAEC,SAAS,EAAEC,YAAY,QAAQ,iBAAgB;AAC7F,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,iBAAgB;AAC/D,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,uBAAuB,EAAEC,aAAa,QAAQ,UAAS;AAClG,SAASC,aAAa,EAAEC,GAAG,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACxE,YAAYC,WAAW,QAAO;AAI9B,SAASC,sBAAsB,QAAQ,+DAA8D;AACrG,SAASC,YAAY,QAAQ,kDAAiD;AAC9E,SAASC,gBAAgB,QAAQ,4DAA2D;AAC5F,OAAO,eAAc;AAmBrB,OAAO,MAAMC,4BAAgDV,cAC3D,6BACD;AAED,OAAO,MAAMW,4BAAcV,cAAgC;IACzDW,kBAAkB;IAClBC,mBAAmB;IACnBC,KAAK,KAEL;AACF,GAAE;AAFE,QAAQ;AAIZ,OAAO,SAASC,aAAa,EAAEC,QAAQ,EAA6B;IAClE,MAAM,CAACC,cAAcC,gBAAgB,GAAGb,SAGrC;QACDO,kBAAkB;QAClBC,mBAAmB;IACrB;IACA,qBACE,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TablePlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n EditorThemeClasses,\n Klass,\n LexicalCommand,\n LexicalEditor,\n LexicalNode,\n RangeSelection,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TablePlugin as LexicalReactTablePlugin } from '@lexical/react/LexicalTablePlugin'\nimport { INSERT_TABLE_COMMAND, TableCellNode, TableNode, TableRowNode } from '@lexical/table'\nimport { mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth } from '@payloadcms/ui'\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical'\nimport { createContext, use, useEffect, useMemo, useState } from 'react'\nimport * as React from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../../utilities/fieldsDrawer/Drawer.js'\nimport { useLexicalDrawer } from '../../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport './index.scss'\n\nexport type CellContextShape = {\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n set: (\n cellEditorConfig: CellEditorConfig | null,\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null,\n ) => void\n}\n\nexport type CellEditorConfig = Readonly<{\n namespace: string\n nodes?: ReadonlyArray<Klass<LexicalNode>>\n onError: (error: Error, editor: LexicalEditor) => void\n readOnly?: boolean\n theme?: EditorThemeClasses\n}>\n\nexport const OPEN_TABLE_DRAWER_COMMAND: LexicalCommand<{}> = createCommand(\n 'OPEN_EMBED_DRAWER_COMMAND',\n)\n\nexport const CellContext = createContext<CellContextShape>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n set: () => {\n // Empty\n },\n})\n\nexport function TableContext({ children }: { children: JSX.Element }) {\n const [contextValue, setContextValue] = useState<{\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n }>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n })\n return (\n <CellContext\n value={useMemo(\n () => ({\n cellEditorConfig: contextValue.cellEditorConfig,\n cellEditorPlugins: contextValue.cellEditorPlugins,\n set: (cellEditorConfig, cellEditorPlugins) => {\n setContextValue({ cellEditorConfig, cellEditorPlugins })\n },\n }),\n [contextValue.cellEditorConfig, contextValue.cellEditorPlugins],\n )}\n >\n {children}\n </CellContext>\n )\n}\n\nexport const TablePlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const cellContext = use(CellContext)\n const editDepth = useEditDepth()\n const {\n fieldProps: { schemaPath },\n uuid,\n } = useEditorConfigContext()\n\n const drawerSlug = formatDrawerSlug({\n slug: 'lexical-table-create-' + uuid,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n useEffect(() => {\n if (!editor.hasNodes([TableNode, TableRowNode, TableCellNode])) {\n throw new Error(\n 'TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor',\n )\n }\n\n return mergeRegister(\n editor.registerCommand(\n OPEN_TABLE_DRAWER_COMMAND,\n () => {\n let rangeSelection: null | RangeSelection = null\n\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n rangeSelection = selection\n }\n })\n\n if (rangeSelection) {\n toggleDrawer()\n }\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [cellContext, editor, toggleDrawer])\n\n return (\n <React.Fragment>\n <FieldsDrawer\n drawerSlug={drawerSlug}\n drawerTitle=\"Create Table\"\n featureKey=\"experimental_table\"\n handleDrawerSubmit={(_fields, data) => {\n if (!data.columns || !data.rows) {\n return\n }\n\n editor.dispatchCommand(INSERT_TABLE_COMMAND, {\n columns: String(data.columns),\n rows: String(data.rows),\n })\n }}\n schemaPath={schemaPath}\n schemaPathSuffix=\"fields\"\n />\n <LexicalReactTablePlugin\n hasCellBackgroundColor={false}\n hasCellMerge\n hasHorizontalScroll={true}\n />\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","TablePlugin","LexicalReactTablePlugin","INSERT_TABLE_COMMAND","TableCellNode","TableNode","TableRowNode","mergeRegister","formatDrawerSlug","useEditDepth","$getSelection","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","createContext","use","useEffect","useMemo","useState","React","useEditorConfigContext","FieldsDrawer","useLexicalDrawer","OPEN_TABLE_DRAWER_COMMAND","CellContext","cellEditorConfig","cellEditorPlugins","set","TableContext","children","contextValue","setContextValue","value","editor","cellContext","editDepth","fieldProps","schemaPath","uuid","drawerSlug","slug","depth","toggleDrawer","hasNodes","Error","registerCommand","rangeSelection","getEditorState","read","selection","Fragment","drawerTitle","featureKey","handleDrawerSubmit","_fields","data","columns","rows","dispatchCommand","String","schemaPathSuffix","hasCellBackgroundColor","hasCellMerge","hasHorizontalScroll"],"mappings":"AAAA;;AAYA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,eAAeC,uBAAuB,QAAQ,oCAAmC;AAC1F,SAASC,oBAAoB,EAAEC,aAAa,EAAEC,SAAS,EAAEC,YAAY,QAAQ,iBAAgB;AAC7F,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,iBAAgB;AAC/D,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,uBAAuB,EAAEC,aAAa,QAAQ,UAAS;AAClG,SAASC,aAAa,EAAEC,GAAG,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACxE,YAAYC,WAAW,QAAO;AAI9B,SAASC,sBAAsB,QAAQ,+DAA8D;AACrG,SAASC,YAAY,QAAQ,kDAAiD;AAC9E,SAASC,gBAAgB,QAAQ,4DAA2D;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A,IAAIH,gBAAgB;gBAClBJ;YACF;YACA,OAAO;QACT,GACA9B;IAGN,GAAG;QAACsB;QAAaD;QAAQS;KAAa;IAEtC,qBACE,QAACvB,MAAM+B,QAAQ;;0BACb,QAAC7B;gBACCkB,YAAYA;gBACZY,aAAY;gBACZC,YAAW;gBACXC,oBAAoB,CAACC,SAASC;oBAC5B,IAAI,CAACA,KAAKC,OAAO,IAAI,CAACD,KAAKE,IAAI,EAAE;wBAC/B;oBACF;oBAEAxB,OAAOyB,eAAe,CAACvD,sBAAsB;wBAC3CqD,SAASG,OAAOJ,KAAKC,OAAO;wBAC5BC,MAAME,OAAOJ,KAAKE,IAAI;oBACxB;gBACF;gBACApB,YAAYA;gBACZuB,kBAAiB;;;;;;0BAEnB,QAAC1D;gBACC2D,wBAAwB;gBACxBC,YAAY;gBACZC,qBAAqB;;;;;;;;;;;;AAI7B,EAAC"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.LexicalEditorTheme {
|
|
5
|
+
&__tableScrollableWrapper {
|
|
6
|
+
overflow-x: auto;
|
|
7
|
+
margin: 0px 25px 30px 0px;
|
|
8
|
+
}
|
|
9
|
+
&__tableScrollableWrapper > .LexicalEditorTheme__table {
|
|
10
|
+
/* Remove the table's vertical margin and put it on the wrapper */
|
|
11
|
+
margin-top: 0;
|
|
12
|
+
margin-bottom: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&__tableAlignmentCenter {
|
|
16
|
+
margin-left: auto;
|
|
17
|
+
margin-right: auto;
|
|
18
|
+
}
|
|
19
|
+
&__tableAlignmentRight {
|
|
20
|
+
margin-left: auto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&__tableSelection *::selection {
|
|
24
|
+
background-color: transparent;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&__table {
|
|
28
|
+
border-collapse: collapse;
|
|
29
|
+
max-width: 100%;
|
|
30
|
+
border-spacing: 0;
|
|
31
|
+
overflow-y: scroll;
|
|
32
|
+
overflow-x: scroll;
|
|
33
|
+
table-layout: fixed;
|
|
34
|
+
width: fit-content;
|
|
35
|
+
margin-top: 25px;
|
|
36
|
+
margin-bottom: 30px;
|
|
37
|
+
|
|
38
|
+
::selection {
|
|
39
|
+
background: rgba(172, 206, 247);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
br::selection {
|
|
43
|
+
background: unset;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&__tableFrozenColumn tr > td:first-child {
|
|
48
|
+
background-color: var(--theme-bg);
|
|
49
|
+
position: sticky;
|
|
50
|
+
z-index: 2;
|
|
51
|
+
left: 0;
|
|
52
|
+
}
|
|
53
|
+
&__tableFrozenColumn tr > th:first-child {
|
|
54
|
+
background-color: var(--theme-elevation-50);
|
|
55
|
+
position: sticky;
|
|
56
|
+
z-index: 2;
|
|
57
|
+
left: 0;
|
|
58
|
+
}
|
|
59
|
+
&__tableFrozenColumn tr > :first-child::after {
|
|
60
|
+
content: '';
|
|
61
|
+
position: absolute;
|
|
62
|
+
left: 0;
|
|
63
|
+
top: 0;
|
|
64
|
+
right: 0;
|
|
65
|
+
height: 100%;
|
|
66
|
+
border-right: 1px solid var(--theme-elevation-400);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&__tableRowStriping tr:nth-child(even) {
|
|
70
|
+
background-color: var(--theme-elevation-100);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&__tableSelected {
|
|
74
|
+
outline: 2px solid rgb(60, 132, 244);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&__tableCell {
|
|
78
|
+
border: 1px solid var(--theme-elevation-200);
|
|
79
|
+
vertical-align: top;
|
|
80
|
+
text-align: start;
|
|
81
|
+
padding: 6px 8px;
|
|
82
|
+
position: relative;
|
|
83
|
+
cursor: default;
|
|
84
|
+
outline: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
* A firefox workaround to allow scrolling of overflowing table cell
|
|
89
|
+
* ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1904159
|
|
90
|
+
*/
|
|
91
|
+
&__tableCell > * {
|
|
92
|
+
overflow: inherit;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&__tableCellResizer {
|
|
96
|
+
position: absolute;
|
|
97
|
+
right: -4px;
|
|
98
|
+
height: 100%;
|
|
99
|
+
width: 8px;
|
|
100
|
+
cursor: ew-resize;
|
|
101
|
+
z-index: 10;
|
|
102
|
+
top: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&__tableCellHeader {
|
|
106
|
+
background-color: #f2f3f5;
|
|
107
|
+
text-align: start;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&__tableCellSelected {
|
|
111
|
+
caret-color: transparent;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&__tableCellSelected::after {
|
|
115
|
+
position: absolute;
|
|
116
|
+
left: 0;
|
|
117
|
+
right: 0;
|
|
118
|
+
bottom: 0;
|
|
119
|
+
top: 0;
|
|
120
|
+
background-color: var(--color-success-250);
|
|
121
|
+
mix-blend-mode: multiply;
|
|
122
|
+
content: '';
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&__tableAddColumns {
|
|
127
|
+
height: 100%;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&__tableAddColumns,
|
|
131
|
+
&__tableAddRows {
|
|
132
|
+
position: absolute;
|
|
133
|
+
background-color: var(--theme-elevation-100);
|
|
134
|
+
animation: table-controls 0.2s ease;
|
|
135
|
+
border: 0;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
min-width: 24px;
|
|
138
|
+
min-height: 24px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
&__tableAddColumns:after,
|
|
142
|
+
&__tableAddRows:after {
|
|
143
|
+
display: flex;
|
|
144
|
+
content: '+';
|
|
145
|
+
font-size: 1.4rem;
|
|
146
|
+
border-radius: $style-radius-s;
|
|
147
|
+
justify-content: center;
|
|
148
|
+
align-items: center;
|
|
149
|
+
position: absolute;
|
|
150
|
+
top: 0;
|
|
151
|
+
left: 0;
|
|
152
|
+
width: 100%;
|
|
153
|
+
height: 100%;
|
|
154
|
+
color: var(--theme-elevation-500);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
&__tableAddColumns:hover,
|
|
158
|
+
&__tableAddRows:hover {
|
|
159
|
+
background-color: var(--theme-elevation-150);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&__tableAddRows {
|
|
163
|
+
width: calc(100% - 25px);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@keyframes table-controls {
|
|
167
|
+
0% {
|
|
168
|
+
opacity: 0;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
100% {
|
|
172
|
+
opacity: 1;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&__tableCellResizeRuler {
|
|
177
|
+
display: block;
|
|
178
|
+
position: absolute;
|
|
179
|
+
width: 1px;
|
|
180
|
+
background-color: rgb(60, 132, 244);
|
|
181
|
+
height: 100%;
|
|
182
|
+
top: 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&__tableCellActionButtonContainer {
|
|
186
|
+
display: block;
|
|
187
|
+
right: 5px;
|
|
188
|
+
top: 6px;
|
|
189
|
+
position: absolute;
|
|
190
|
+
z-index: 4;
|
|
191
|
+
width: 20px;
|
|
192
|
+
height: 20px;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&__tableCellActionButton {
|
|
196
|
+
background-color: #eee;
|
|
197
|
+
display: block;
|
|
198
|
+
border: 0;
|
|
199
|
+
border-radius: 20px;
|
|
200
|
+
width: 20px;
|
|
201
|
+
height: 20px;
|
|
202
|
+
color: #222;
|
|
203
|
+
cursor: pointer;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&__tableCellActionButton:hover {
|
|
207
|
+
background-color: #ddd;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
html[data-theme='dark'] {
|
|
212
|
+
.LexicalEditorTheme {
|
|
213
|
+
&__tableCellHeader {
|
|
214
|
+
background-color: var(--theme-elevation-50);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
&__tableCellSelected::after {
|
|
218
|
+
background-color: var(--color-success-700);
|
|
219
|
+
mix-blend-mode: screen;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
&__tableAddColumns,
|
|
223
|
+
&__tableAddRows {
|
|
224
|
+
background-color: var(--theme-elevation-50);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
&__tableAddColumns:hover,
|
|
228
|
+
&__tableAddRows:hover {
|
|
229
|
+
background-color: var(--theme-elevation-100);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.LexicalEditorTheme__hr {
|
|
5
|
+
width: auto !important;
|
|
6
|
+
padding: 2px 2px;
|
|
7
|
+
border: none;
|
|
8
|
+
margin: 1rem 0;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.LexicalEditorTheme__hr:after {
|
|
13
|
+
content: '';
|
|
14
|
+
display: block;
|
|
15
|
+
height: 2px;
|
|
16
|
+
background-color: var(--theme-elevation-250);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.LexicalEditorTheme__hr.LexicalEditorTheme__hrSelected {
|
|
20
|
+
outline: 2px solid var(--theme-success-250);
|
|
21
|
+
user-select: none;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
3
|
import { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin';
|
|
4
4
|
import { $findMatchingParent, mergeRegister } from '@lexical/utils';
|
|
@@ -56,7 +56,11 @@ export const IndentPlugin = ({ clientProps })=>{
|
|
|
56
56
|
editor,
|
|
57
57
|
disableTabNode
|
|
58
58
|
]);
|
|
59
|
-
return /*#__PURE__*/
|
|
59
|
+
return /*#__PURE__*/ _jsxDEV(TabIndentationPlugin, {}, void 0, false, {
|
|
60
|
+
fileName: "src/features/indent/client/IndentPlugin.tsx",
|
|
61
|
+
lineNumber: 87,
|
|
62
|
+
columnNumber: 10
|
|
63
|
+
}, this);
|
|
60
64
|
};
|
|
61
65
|
function $handleIndentAndOutdent(indentOrOutdent) {
|
|
62
66
|
const selection = $getSelection();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/indent/client/IndentPlugin.tsx"],"sourcesContent":["import type { ElementNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isElementNode,\n $isRangeSelection,\n COMMAND_PRIORITY_LOW,\n INDENT_CONTENT_COMMAND,\n KEY_TAB_COMMAND,\n OUTDENT_CONTENT_COMMAND,\n TabNode,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../typesClient.js'\nimport type { IndentFeatureProps } from '../server/index.js'\n\nexport const IndentPlugin: PluginComponent<IndentFeatureProps> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n const { disabledNodes, disableTabNode } = clientProps\n\n useEffect(() => {\n if (!editor || !disabledNodes?.length) {\n return\n }\n return mergeRegister(\n editor.registerCommand(\n INDENT_CONTENT_COMMAND,\n () => {\n return $handleIndentAndOutdent((block) => {\n if (!disabledNodes.includes(block.getType())) {\n const indent = block.getIndent()\n block.setIndent(indent + 1)\n }\n })\n },\n COMMAND_PRIORITY_LOW,\n ),\n // If we disable indenting for certain nodes, we need to ensure that these are not indented,\n // if they get transformed from an indented state (e.g. an indented list node gets transformed into a\n // paragraph node for which indenting is disabled).\n editor.registerUpdateListener(({ dirtyElements, editorState }) => {\n editor.update(() => {\n for (const [nodeKey] of dirtyElements) {\n const node = editorState._nodeMap.get(nodeKey)\n if ($isElementNode(node) && disabledNodes.includes(node.getType())) {\n const currentIndent = node.getIndent()\n if (currentIndent > 0) {\n node.setIndent(0)\n }\n }\n }\n })\n }),\n )\n }, [editor, disabledNodes])\n\n useEffect(() => {\n if (!editor || !disableTabNode) {\n return\n }\n return mergeRegister(\n // This is so that when you press Tab in the middle of a paragraph,\n // it indents the paragraph, instead of inserting a TabNode.\n editor.registerCommand<KeyboardEvent>(\n KEY_TAB_COMMAND,\n (event) => {\n event.preventDefault()\n return editor.dispatchCommand(\n event.shiftKey ? OUTDENT_CONTENT_COMMAND : INDENT_CONTENT_COMMAND,\n undefined,\n )\n },\n COMMAND_PRIORITY_LOW,\n ),\n // Tab isn't the only way to insert a TabNode. We have to make sure\n // it doesn't happen, for example, when pasting from the clipboard.\n editor.registerNodeTransform(TabNode, (node) => {\n node.remove()\n }),\n )\n }, [editor, disableTabNode])\n\n return <TabIndentationPlugin />\n}\n\nfunction $handleIndentAndOutdent(indentOrOutdent: (block: ElementNode) => void): boolean {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) {\n return false\n }\n const alreadyHandled = new Set()\n const nodes = selection.getNodes()\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i]!\n const key = node.getKey()\n if (alreadyHandled.has(key)) {\n continue\n }\n const parentBlock = $findMatchingParent(\n node,\n (parentNode): parentNode is ElementNode =>\n $isElementNode(parentNode) && !parentNode.isInline(),\n )\n if (parentBlock === null) {\n continue\n }\n const parentKey = parentBlock.getKey()\n if (parentBlock.canIndent() && !alreadyHandled.has(parentKey)) {\n alreadyHandled.add(parentKey)\n indentOrOutdent(parentBlock)\n }\n }\n return alreadyHandled.size > 0\n}\n"],"names":["useLexicalComposerContext","TabIndentationPlugin","$findMatchingParent","mergeRegister","$getSelection","$isElementNode","$isRangeSelection","COMMAND_PRIORITY_LOW","INDENT_CONTENT_COMMAND","KEY_TAB_COMMAND","OUTDENT_CONTENT_COMMAND","TabNode","useEffect","IndentPlugin","clientProps","editor","disabledNodes","disableTabNode","length","registerCommand","$handleIndentAndOutdent","block","includes","getType","indent","getIndent","setIndent","registerUpdateListener","dirtyElements","editorState","update","nodeKey","node","_nodeMap","get","currentIndent","event","preventDefault","dispatchCommand","shiftKey","undefined","registerNodeTransform","remove","indentOrOutdent","selection","alreadyHandled","Set","nodes","getNodes","i","key","getKey","has","parentBlock","parentNode","isInline","parentKey","canIndent","add","size"],"mappings":";AAEA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,oBAAoB,QAAQ,6CAA4C;AACjF,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,iBAAgB;AACnE,SACEC,aAAa,EACbC,cAAc,EACdC,iBAAiB,EACjBC,oBAAoB,EACpBC,sBAAsB,EACtBC,eAAe,EACfC,uBAAuB,EACvBC,OAAO,QACF,UAAS;AAChB,SAASC,SAAS,QAAQ,QAAO;AAKjC,OAAO,MAAMC,eAAoD,CAAC,EAAEC,WAAW,EAAE;IAC/E,MAAM,CAACC,OAAO,GAAGf;IACjB,MAAM,EAAEgB,aAAa,EAAEC,cAAc,EAAE,GAAGH;IAE1CF,UAAU;QACR,IAAI,CAACG,UAAU,CAACC,eAAeE,QAAQ;YACrC;QACF;QACA,OAAOf,cACLY,OAAOI,eAAe,CACpBX,wBACA;YACE,OAAOY,wBAAwB,CAACC;gBAC9B,IAAI,CAACL,cAAcM,QAAQ,CAACD,MAAME,OAAO,KAAK;oBAC5C,MAAMC,SAASH,MAAMI,SAAS;oBAC9BJ,MAAMK,SAAS,CAACF,SAAS;gBAC3B;YACF;QACF,GACAjB,uBAEF,4FAA4F;QAC5F,qGAAqG;QACrG,mDAAmD;QACnDQ,OAAOY,sBAAsB,CAAC,CAAC,EAAEC,aAAa,EAAEC,WAAW,EAAE;YAC3Dd,OAAOe,MAAM,CAAC;gBACZ,KAAK,MAAM,CAACC,QAAQ,IAAIH,cAAe;oBACrC,MAAMI,OAAOH,YAAYI,QAAQ,CAACC,GAAG,CAACH;oBACtC,IAAI1B,eAAe2B,SAAShB,cAAcM,QAAQ,CAACU,KAAKT,OAAO,KAAK;wBAClE,MAAMY,gBAAgBH,KAAKP,SAAS;wBACpC,IAAIU,gBAAgB,GAAG;4BACrBH,KAAKN,SAAS,CAAC;wBACjB;oBACF;gBACF;YACF;QACF;IAEJ,GAAG;QAACX;QAAQC;KAAc;IAE1BJ,UAAU;QACR,IAAI,CAACG,UAAU,CAACE,gBAAgB;YAC9B;QACF;QACA,OAAOd,cACL,mEAAmE;QACnE,4DAA4D;QAC5DY,OAAOI,eAAe,CACpBV,iBACA,CAAC2B;YACCA,MAAMC,cAAc;YACpB,OAAOtB,OAAOuB,eAAe,CAC3BF,MAAMG,QAAQ,GAAG7B,0BAA0BF,wBAC3CgC;QAEJ,GACAjC,uBAEF,mEAAmE;QACnE,mEAAmE;QACnEQ,OAAO0B,qBAAqB,CAAC9B,SAAS,CAACqB;YACrCA,KAAKU,MAAM;QACb;IAEJ,GAAG;QAAC3B;QAAQE;KAAe;IAE3B,qBAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/indent/client/IndentPlugin.tsx"],"sourcesContent":["import type { ElementNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isElementNode,\n $isRangeSelection,\n COMMAND_PRIORITY_LOW,\n INDENT_CONTENT_COMMAND,\n KEY_TAB_COMMAND,\n OUTDENT_CONTENT_COMMAND,\n TabNode,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../typesClient.js'\nimport type { IndentFeatureProps } from '../server/index.js'\n\nexport const IndentPlugin: PluginComponent<IndentFeatureProps> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n const { disabledNodes, disableTabNode } = clientProps\n\n useEffect(() => {\n if (!editor || !disabledNodes?.length) {\n return\n }\n return mergeRegister(\n editor.registerCommand(\n INDENT_CONTENT_COMMAND,\n () => {\n return $handleIndentAndOutdent((block) => {\n if (!disabledNodes.includes(block.getType())) {\n const indent = block.getIndent()\n block.setIndent(indent + 1)\n }\n })\n },\n COMMAND_PRIORITY_LOW,\n ),\n // If we disable indenting for certain nodes, we need to ensure that these are not indented,\n // if they get transformed from an indented state (e.g. an indented list node gets transformed into a\n // paragraph node for which indenting is disabled).\n editor.registerUpdateListener(({ dirtyElements, editorState }) => {\n editor.update(() => {\n for (const [nodeKey] of dirtyElements) {\n const node = editorState._nodeMap.get(nodeKey)\n if ($isElementNode(node) && disabledNodes.includes(node.getType())) {\n const currentIndent = node.getIndent()\n if (currentIndent > 0) {\n node.setIndent(0)\n }\n }\n }\n })\n }),\n )\n }, [editor, disabledNodes])\n\n useEffect(() => {\n if (!editor || !disableTabNode) {\n return\n }\n return mergeRegister(\n // This is so that when you press Tab in the middle of a paragraph,\n // it indents the paragraph, instead of inserting a TabNode.\n editor.registerCommand<KeyboardEvent>(\n KEY_TAB_COMMAND,\n (event) => {\n event.preventDefault()\n return editor.dispatchCommand(\n event.shiftKey ? OUTDENT_CONTENT_COMMAND : INDENT_CONTENT_COMMAND,\n undefined,\n )\n },\n COMMAND_PRIORITY_LOW,\n ),\n // Tab isn't the only way to insert a TabNode. We have to make sure\n // it doesn't happen, for example, when pasting from the clipboard.\n editor.registerNodeTransform(TabNode, (node) => {\n node.remove()\n }),\n )\n }, [editor, disableTabNode])\n\n return <TabIndentationPlugin />\n}\n\nfunction $handleIndentAndOutdent(indentOrOutdent: (block: ElementNode) => void): boolean {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) {\n return false\n }\n const alreadyHandled = new Set()\n const nodes = selection.getNodes()\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i]!\n const key = node.getKey()\n if (alreadyHandled.has(key)) {\n continue\n }\n const parentBlock = $findMatchingParent(\n node,\n (parentNode): parentNode is ElementNode =>\n $isElementNode(parentNode) && !parentNode.isInline(),\n )\n if (parentBlock === null) {\n continue\n }\n const parentKey = parentBlock.getKey()\n if (parentBlock.canIndent() && !alreadyHandled.has(parentKey)) {\n alreadyHandled.add(parentKey)\n indentOrOutdent(parentBlock)\n }\n }\n return alreadyHandled.size > 0\n}\n"],"names":["useLexicalComposerContext","TabIndentationPlugin","$findMatchingParent","mergeRegister","$getSelection","$isElementNode","$isRangeSelection","COMMAND_PRIORITY_LOW","INDENT_CONTENT_COMMAND","KEY_TAB_COMMAND","OUTDENT_CONTENT_COMMAND","TabNode","useEffect","IndentPlugin","clientProps","editor","disabledNodes","disableTabNode","length","registerCommand","$handleIndentAndOutdent","block","includes","getType","indent","getIndent","setIndent","registerUpdateListener","dirtyElements","editorState","update","nodeKey","node","_nodeMap","get","currentIndent","event","preventDefault","dispatchCommand","shiftKey","undefined","registerNodeTransform","remove","indentOrOutdent","selection","alreadyHandled","Set","nodes","getNodes","i","key","getKey","has","parentBlock","parentNode","isInline","parentKey","canIndent","add","size"],"mappings":";AAEA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,oBAAoB,QAAQ,6CAA4C;AACjF,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,iBAAgB;AACnE,SACEC,aAAa,EACbC,cAAc,EACdC,iBAAiB,EACjBC,oBAAoB,EACpBC,sBAAsB,EACtBC,eAAe,EACfC,uBAAuB,EACvBC,OAAO,QACF,UAAS;AAChB,SAASC,SAAS,QAAQ,QAAO;AAK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AACqB;YACrCA,KAAKU,MAAM;QACb;IAEJ,GAAG;QAAC3B;QAAQE;KAAe;IAE3B,qBAAO,QAAChB;;;;;AACV,EAAC;AAED,SAASmB,wBAAwBuB,eAA6C;IAC5E,MAAMC,YAAYxC;IAClB,IAAI,CAACE,kBAAkBsC,YAAY;QACjC,OAAO;IACT;IACA,MAAMC,iBAAiB,IAAIC;IAC3B,MAAMC,QAAQH,UAAUI,QAAQ;IAChC,IAAK,IAAIC,IAAI,GAAGA,IAAIF,MAAM7B,MAAM,EAAE+B,IAAK;QACrC,MAAMjB,OAAOe,KAAK,CAACE,EAAE;QACrB,MAAMC,MAAMlB,KAAKmB,MAAM;QACvB,IAAIN,eAAeO,GAAG,CAACF,MAAM;YAC3B;QACF;QACA,MAAMG,cAAcnD,oBAClB8B,MACA,CAACsB,aACCjD,eAAeiD,eAAe,CAACA,WAAWC,QAAQ;QAEtD,IAAIF,gBAAgB,MAAM;YACxB;QACF;QACA,MAAMG,YAAYH,YAAYF,MAAM;QACpC,IAAIE,YAAYI,SAAS,MAAM,CAACZ,eAAeO,GAAG,CAACI,YAAY;YAC7DX,eAAea,GAAG,CAACF;YACnBb,gBAAgBU;QAClB;IACF;IACA,OAAOR,eAAec,IAAI,GAAG;AAC/B"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
|
|
3
3
|
import { ClickableLinkPlugin as LexicalClickableLinkPlugin } from '@lexical/react/LexicalClickableLinkPlugin.js';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
export const ClickableLinkPlugin = ()=>{
|
|
6
|
-
return /*#__PURE__*/
|
|
6
|
+
return /*#__PURE__*/ _jsxDEV(LexicalClickableLinkPlugin, {}, void 0, false, {
|
|
7
|
+
fileName: "src/features/link/client/plugins/clickableLink/index.tsx",
|
|
8
|
+
lineNumber: 9,
|
|
9
|
+
columnNumber: 10
|
|
10
|
+
}, this);
|
|
7
11
|
};
|
|
8
12
|
|
|
9
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/link/client/plugins/clickableLink/index.tsx"],"sourcesContent":["'use client'\nimport { ClickableLinkPlugin as LexicalClickableLinkPlugin } from '@lexical/react/LexicalClickableLinkPlugin.js'\nimport React from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { ClientProps } from '../../index.js'\n\nexport const ClickableLinkPlugin: PluginComponent<ClientProps> = () => {\n return <LexicalClickableLinkPlugin />\n}\n"],"names":["ClickableLinkPlugin","LexicalClickableLinkPlugin","React"],"mappings":"AAAA;;AACA,SAASA,uBAAuBC,0BAA0B,QAAQ,+CAA8C;AAChH,OAAOC,WAAW,QAAO;AAKzB,OAAO,MAAMF,sBAAoD;IAC/D,qBAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/link/client/plugins/clickableLink/index.tsx"],"sourcesContent":["'use client'\nimport { ClickableLinkPlugin as LexicalClickableLinkPlugin } from '@lexical/react/LexicalClickableLinkPlugin.js'\nimport React from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { ClientProps } from '../../index.js'\n\nexport const ClickableLinkPlugin: PluginComponent<ClientProps> = () => {\n return <LexicalClickableLinkPlugin />\n}\n"],"names":["ClickableLinkPlugin","LexicalClickableLinkPlugin","React"],"mappings":"AAAA;;AACA,SAASA,uBAAuBC,0BAA0B,QAAQ,+CAA8C;AAChH,OAAOC,WAAW,QAAO;AAKzB,OAAO,MAAMF,sBAAoD;IAC/D,qBAAO,QAACC;;;;;AACV,EAAC"}
|