@payloadcms/richtext-lexical 3.0.0-canary.a5aaf21 → 3.0.0-canary.a7293f6
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/index.js +1 -1
- package/dist/cell/index.js.map +1 -1
- package/dist/exports/client/Field-ETCEVZLL.js +2 -0
- package/dist/exports/client/Field-ETCEVZLL.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-FTWR5YDX.js +2 -0
- package/dist/exports/client/RelationshipComponent-FTWR5YDX.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-PY6JO5OH.js → chunk-32KXGBIQ.js} +2 -2
- package/dist/exports/client/{chunk-PY6JO5OH.js.map → chunk-32KXGBIQ.js.map} +2 -2
- package/dist/exports/client/chunk-6LZZDOEO.js +2 -0
- package/dist/exports/client/chunk-6LZZDOEO.js.map +7 -0
- package/dist/exports/client/{chunk-TXEIKM77.js → chunk-GD6LBQBJ.js} +2 -2
- package/dist/exports/client/chunk-GD6LBQBJ.js.map +7 -0
- package/dist/exports/client/{chunk-GK7ZKYHL.js → chunk-IIWHHN4J.js} +2 -2
- package/dist/exports/client/chunk-IIWHHN4J.js.map +7 -0
- package/dist/exports/client/{chunk-GTKNWSQW.js → chunk-QZNJUROL.js} +2 -2
- package/dist/exports/client/{chunk-GTKNWSQW.js.map → chunk-QZNJUROL.js.map} +2 -2
- package/dist/exports/client/chunk-WAMTSCVM.js +2 -0
- package/dist/exports/client/{chunk-F5DIILW3.js.map → chunk-WAMTSCVM.js.map} +2 -2
- package/dist/exports/client/{chunk-PECDZEZY.js → chunk-XCEM47RI.js} +2 -2
- package/dist/exports/client/{chunk-PECDZEZY.js.map → chunk-XCEM47RI.js.map} +2 -2
- package/dist/exports/client/component-6PBZ2U3Z.js +2 -0
- package/dist/exports/client/component-6PBZ2U3Z.js.map +7 -0
- package/dist/exports/client/component-6Y2K2RNP.js +2 -0
- package/dist/exports/client/component-6Y2K2RNP.js.map +7 -0
- package/dist/exports/client/component-ANB7VZLA.js +2 -0
- package/dist/exports/client/component-ANB7VZLA.js.map +7 -0
- package/dist/exports/client/componentInline-NUDJIIQ4.js +2 -0
- package/dist/exports/client/componentInline-NUDJIIQ4.js.map +7 -0
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +7 -7
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blockquote/markdownTransformer.js.map +1 -1
- package/dist/features/blockquote/server/index.d.ts +1 -1
- package/dist/features/blockquote/server/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +5 -4
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +3 -3
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +14 -11
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +21 -11
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +2 -2
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/plugin/index.d.ts +2 -2
- package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/index.js +4 -4
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js +4 -2
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +10 -4
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +2 -2
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/server/validate.js.map +1 -1
- package/dist/features/converters/html/converter/index.js +2 -2
- package/dist/features/converters/html/converter/index.js.map +1 -1
- package/dist/features/converters/html/field/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +29 -43
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +39 -39
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +19 -18
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/experimental_table/server/index.js +2 -2
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/horizontalRule/client/component/index.d.ts +1 -1
- package/dist/features/horizontalRule/client/component/index.d.ts.map +1 -1
- package/dist/features/horizontalRule/client/component/index.js +12 -9
- package/dist/features/horizontalRule/client/component/index.js.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +2 -2
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/features/indent/client/index.d.ts.map +1 -1
- package/dist/features/indent/client/index.js +2 -1
- package/dist/features/indent/client/index.js.map +1 -1
- package/dist/features/link/client/index.js +1 -1
- package/dist/features/link/client/index.js.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.d.ts +1 -1
- package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +3 -7
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/nodes/AutoLinkNode.js +2 -2
- package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
- package/dist/features/link/nodes/LinkNode.js +11 -7
- package/dist/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/features/link/nodes/types.d.ts +3 -3
- package/dist/features/link/nodes/types.d.ts.map +1 -1
- package/dist/features/link/nodes/types.js.map +1 -1
- package/dist/features/link/server/baseFields.d.ts +1 -1
- package/dist/features/link/server/baseFields.d.ts.map +1 -1
- package/dist/features/link/server/baseFields.js +3 -1
- package/dist/features/link/server/baseFields.js.map +1 -1
- package/dist/features/link/server/index.d.ts.map +1 -1
- package/dist/features/link/server/index.js +2 -2
- package/dist/features/link/server/index.js.map +1 -1
- package/dist/features/link/server/transformExtraFields.d.ts +1 -1
- package/dist/features/link/server/transformExtraFields.d.ts.map +1 -1
- package/dist/features/link/server/transformExtraFields.js.map +1 -1
- package/dist/features/link/server/validate.js.map +1 -1
- package/dist/features/lists/shared/markdown.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/converter/index.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/converter/index.js +1 -0
- package/dist/features/migrations/lexicalPluginToLexical/converter/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/blockquote/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/heading/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/listItem/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/orderedList/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/unknown/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/unorderedList/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/index.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/index.js +1 -0
- package/dist/features/migrations/slateToLexical/converter/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/paragraph/server/index.d.ts +1 -1
- package/dist/features/paragraph/server/index.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +18 -13
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/drawer/index.js +3 -3
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +1 -1
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +1 -1
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +40 -41
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +33 -34
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +4 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts +3 -4
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +82 -64
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/toolbars/types.d.ts +21 -11
- package/dist/features/toolbars/types.d.ts.map +1 -1
- package/dist/features/toolbars/types.js.map +1 -1
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +11 -8
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/drawer/index.d.ts.map +1 -1
- package/dist/features/upload/client/drawer/index.js +2 -0
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js +1 -1
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/feature.server.js +3 -4
- package/dist/features/upload/server/feature.server.js.map +1 -1
- package/dist/features/upload/server/validate.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +11 -11
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.js +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -63
- package/dist/index.js.map +1 -1
- package/dist/lexical/EditorPlugin.d.ts.map +1 -1
- package/dist/lexical/EditorPlugin.js +2 -1
- package/dist/lexical/EditorPlugin.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +5 -5
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.d.ts +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +8 -7
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.js +2 -2
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/server/loader.js.map +1 -1
- package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/server/sanitize.js +11 -11
- package/dist/lexical/config/server/sanitize.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +2 -2
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +9 -6
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +5 -5
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.js +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +9 -4
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.js +3 -4
- package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.js.map +1 -1
- package/dist/lexical/theme/EditorTheme.d.ts.map +1 -1
- package/dist/lexical/theme/EditorTheme.js +1 -0
- package/dist/lexical/theme/EditorTheme.js.map +1 -1
- package/dist/lexical/utils/rect.d.ts +4 -4
- package/dist/lexical/utils/setFloatingElemPosition.d.ts +1 -1
- package/dist/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
- package/dist/lexical/utils/setFloatingElemPosition.js.map +1 -1
- package/dist/populateGraphQL/populate.js +1 -1
- package/dist/populateGraphQL/populate.js.map +1 -1
- package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts +1 -1
- package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts.map +1 -1
- package/dist/populateGraphQL/populateLexicalPopulationPromises.js +5 -4
- package/dist/populateGraphQL/populateLexicalPopulationPromises.js.map +1 -1
- package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/generateComponentMap.d.ts.map +1 -1
- package/dist/utilities/generateComponentMap.js +1 -0
- package/dist/utilities/generateComponentMap.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts.map +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/dist/validate/validateNodes.d.ts.map +1 -1
- package/dist/validate/validateNodes.js +2 -2
- package/dist/validate/validateNodes.js.map +1 -1
- package/package.json +30 -30
- package/dist/exports/client/Field-EL5TNVZW.js +0 -2
- package/dist/exports/client/Field-EL5TNVZW.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-Z5SZ5FFT.js +0 -2
- package/dist/exports/client/RelationshipComponent-Z5SZ5FFT.js.map +0 -7
- package/dist/exports/client/chunk-F5DIILW3.js +0 -2
- package/dist/exports/client/chunk-GK7ZKYHL.js.map +0 -7
- package/dist/exports/client/chunk-TXEIKM77.js.map +0 -7
- package/dist/exports/client/component-ATPITPNI.js +0 -2
- package/dist/exports/client/component-ATPITPNI.js.map +0 -7
- package/dist/exports/client/component-GAX6BHKZ.js +0 -2
- package/dist/exports/client/component-GAX6BHKZ.js.map +0 -7
- package/dist/exports/client/component-M3ZCPXEG.js +0 -2
- package/dist/exports/client/component-M3ZCPXEG.js.map +0 -7
- package/dist/exports/client/componentInline-HAGGWKA7.js +0 -2
- package/dist/exports/client/componentInline-HAGGWKA7.js.map +0 -7
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
5
5
|
import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
6
|
-
import { $computeTableMapSkipCellCheck, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $isTableCellNode, $isTableRowNode, getDOMCellFromTarget } from '@lexical/table';
|
|
6
|
+
import { $computeTableMapSkipCellCheck, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $isTableCellNode, $isTableRowNode, getDOMCellFromTarget, TableNode } from '@lexical/table';
|
|
7
7
|
import { calculateZoomLevel } from '@lexical/utils';
|
|
8
8
|
import { $getNearestNodeFromDOMNode } from 'lexical';
|
|
9
9
|
import * as React from 'react';
|
|
@@ -11,7 +11,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
11
11
|
import { createPortal } from 'react-dom';
|
|
12
12
|
import { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js';
|
|
13
13
|
const MIN_ROW_HEIGHT = 33;
|
|
14
|
-
const MIN_COLUMN_WIDTH =
|
|
14
|
+
const MIN_COLUMN_WIDTH = 92;
|
|
15
15
|
function TableCellResizer({
|
|
16
16
|
editor
|
|
17
17
|
}) {
|
|
@@ -34,6 +34,17 @@ function TableCellResizer({
|
|
|
34
34
|
const isMouseDownOnEvent = event => {
|
|
35
35
|
return (event.buttons & 1) === 1;
|
|
36
36
|
};
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
return editor.registerNodeTransform(TableNode, tableNode => {
|
|
39
|
+
if (tableNode.getColWidths()) {
|
|
40
|
+
return tableNode;
|
|
41
|
+
}
|
|
42
|
+
const numColumns = tableNode.getColumnCount();
|
|
43
|
+
const columnWidth = MIN_COLUMN_WIDTH;
|
|
44
|
+
tableNode.setColWidths(Array(numColumns).fill(columnWidth));
|
|
45
|
+
return tableNode;
|
|
46
|
+
});
|
|
47
|
+
}, [editor]);
|
|
37
48
|
useEffect(() => {
|
|
38
49
|
const onMouseMove = event_0 => {
|
|
39
50
|
setTimeout(() => {
|
|
@@ -58,8 +69,8 @@ function TableCellResizer({
|
|
|
58
69
|
if (!tableCellNode) {
|
|
59
70
|
throw new Error('TableCellResizer: Table cell node not found.');
|
|
60
71
|
}
|
|
61
|
-
const
|
|
62
|
-
const tableElement = editor.getElementByKey(
|
|
72
|
+
const tableNode_0 = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
73
|
+
const tableElement = editor.getElementByKey(tableNode_0.getKey());
|
|
63
74
|
if (!tableElement) {
|
|
64
75
|
throw new Error('TableCellResizer: Table element not found.');
|
|
65
76
|
}
|
|
@@ -84,12 +95,12 @@ function TableCellResizer({
|
|
|
84
95
|
}, 0);
|
|
85
96
|
};
|
|
86
97
|
const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {
|
|
87
|
-
rootElement?.addEventListener('mousemove', onMouseMove);
|
|
88
|
-
rootElement?.addEventListener('mousedown', onMouseDown);
|
|
89
|
-
rootElement?.addEventListener('mouseup', onMouseUp);
|
|
90
98
|
prevRootElement?.removeEventListener('mousemove', onMouseMove);
|
|
91
99
|
prevRootElement?.removeEventListener('mousedown', onMouseDown);
|
|
92
100
|
prevRootElement?.removeEventListener('mouseup', onMouseUp);
|
|
101
|
+
rootElement?.addEventListener('mousemove', onMouseMove);
|
|
102
|
+
rootElement?.addEventListener('mousedown', onMouseDown);
|
|
103
|
+
rootElement?.addEventListener('mouseup', onMouseUp);
|
|
93
104
|
});
|
|
94
105
|
return () => {
|
|
95
106
|
removeRootListener();
|
|
@@ -110,9 +121,9 @@ function TableCellResizer({
|
|
|
110
121
|
if (!$isTableCellNode(tableCellNode_0)) {
|
|
111
122
|
throw new Error('TableCellResizer: Table cell node not found.');
|
|
112
123
|
}
|
|
113
|
-
const
|
|
114
|
-
const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode_0);
|
|
115
|
-
const tableRows =
|
|
124
|
+
const tableNode_1 = $getTableNodeFromLexicalNodeOrThrow(tableCellNode_0);
|
|
125
|
+
const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode_0) + tableCellNode_0.getRowSpan() - 1;
|
|
126
|
+
const tableRows = tableNode_1.getChildren();
|
|
116
127
|
if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
|
|
117
128
|
throw new Error('Expected table cell to be inside of table row.');
|
|
118
129
|
}
|
|
@@ -131,21 +142,9 @@ function TableCellResizer({
|
|
|
131
142
|
tag: 'skip-scroll-into-view'
|
|
132
143
|
});
|
|
133
144
|
}, [activeCell, editor]);
|
|
134
|
-
const
|
|
135
|
-
const width = cell_1.getWidth();
|
|
136
|
-
if (width !== undefined) {
|
|
137
|
-
return width;
|
|
138
|
-
}
|
|
145
|
+
const getCellNodeHeight = (cell_1, activeEditor) => {
|
|
139
146
|
const domCellNode = activeEditor.getElementByKey(cell_1.getKey());
|
|
140
|
-
|
|
141
|
-
return undefined;
|
|
142
|
-
}
|
|
143
|
-
const computedStyle = getComputedStyle(domCellNode);
|
|
144
|
-
return domCellNode.clientWidth - parseFloat(computedStyle.paddingLeft) - parseFloat(computedStyle.paddingRight);
|
|
145
|
-
};
|
|
146
|
-
const getCellNodeHeight = (cell_2, activeEditor_0) => {
|
|
147
|
-
const domCellNode_0 = activeEditor_0.getElementByKey(cell_2.getKey());
|
|
148
|
-
return domCellNode_0?.clientHeight;
|
|
147
|
+
return domCellNode?.clientHeight;
|
|
149
148
|
};
|
|
150
149
|
const getCellColumnIndex = (tableCellNode_1, tableMap) => {
|
|
151
150
|
for (let row = 0; row < tableMap.length; row++) {
|
|
@@ -165,23 +164,24 @@ function TableCellResizer({
|
|
|
165
164
|
if (!$isTableCellNode(tableCellNode_2)) {
|
|
166
165
|
throw new Error('TableCellResizer: Table cell node not found.');
|
|
167
166
|
}
|
|
168
|
-
const
|
|
169
|
-
const [tableMap_0] = $computeTableMapSkipCellCheck(
|
|
167
|
+
const tableNode_2 = $getTableNodeFromLexicalNodeOrThrow(tableCellNode_2);
|
|
168
|
+
const [tableMap_0] = $computeTableMapSkipCellCheck(tableNode_2, null, null);
|
|
170
169
|
const columnIndex = getCellColumnIndex(tableCellNode_2, tableMap_0);
|
|
171
170
|
if (columnIndex === undefined) {
|
|
172
171
|
throw new Error('TableCellResizer: Table column not found.');
|
|
173
172
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const newWidth = Math.max(width_0 + widthChange, MIN_COLUMN_WIDTH);
|
|
182
|
-
cell_3.cell.setWidth(newWidth);
|
|
183
|
-
}
|
|
173
|
+
const colWidths = tableNode_2.getColWidths();
|
|
174
|
+
if (!colWidths) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const width = colWidths[columnIndex];
|
|
178
|
+
if (width === undefined) {
|
|
179
|
+
return;
|
|
184
180
|
}
|
|
181
|
+
const newColWidths = [...colWidths];
|
|
182
|
+
const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);
|
|
183
|
+
newColWidths[columnIndex] = newWidth;
|
|
184
|
+
tableNode_2.setColWidths(newColWidths);
|
|
185
185
|
}, {
|
|
186
186
|
tag: 'skip-scroll-into-view'
|
|
187
187
|
});
|
|
@@ -235,7 +235,7 @@ function TableCellResizer({
|
|
|
235
235
|
height: height_0,
|
|
236
236
|
left,
|
|
237
237
|
top,
|
|
238
|
-
width:
|
|
238
|
+
width: width_0
|
|
239
239
|
} = activeCell.elem.getBoundingClientRect();
|
|
240
240
|
const zoom_0 = calculateZoomLevel(activeCell.elem);
|
|
241
241
|
const zoneWidth = 10 // Pixel width of the zone where you can drag the edge
|
|
@@ -247,13 +247,13 @@ function TableCellResizer({
|
|
|
247
247
|
height: `${zoneWidth}px`,
|
|
248
248
|
left: `${window.pageXOffset + left}px`,
|
|
249
249
|
top: `${window.pageYOffset + top + height_0 - zoneWidth / 2}px`,
|
|
250
|
-
width: `${
|
|
250
|
+
width: `${width_0}px`
|
|
251
251
|
},
|
|
252
252
|
right: {
|
|
253
253
|
backgroundColor: 'none',
|
|
254
254
|
cursor: 'col-resize',
|
|
255
255
|
height: `${height_0}px`,
|
|
256
|
-
left: `${window.pageXOffset + left +
|
|
256
|
+
left: `${window.pageXOffset + left + width_0 - zoneWidth / 2}px`,
|
|
257
257
|
top: `${window.pageYOffset + top}px`,
|
|
258
258
|
width: `${zoneWidth}px`
|
|
259
259
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$isTableCellNode","$isTableRowNode","getDOMCellFromTarget","calculateZoomLevel","$getNearestNodeFromDOMNode","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","useEditorConfigContext","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","TableCellResizer","editor","targetRef","resizerRef","tableRectRef","editorConfig","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","current","isMouseDownOnEvent","event","buttons","onMouseMove","setTimeout","target","x","clientX","y","clientY","contains","cell","update","tableCellNode","elem","Error","tableNode","tableElement","getElementByKey","getKey","getBoundingClientRect","onMouseDown","onMouseUp","removeRootListener","registerRootListener","rootElement","prevRootElement","addEventListener","removeEventListener","isHeightChanging","direction","updateRowHeight","heightChange","tableRowIndex","tableRows","getChildren","length","tableRow","height","getHeight","undefined","rowCells","Math","min","map","getCellNodeHeight","Infinity","newHeight","max","setHeight","tag","getCellNodeWidth","activeEditor","width","getWidth","domCellNode","computedStyle","getComputedStyle","clientWidth","parseFloat","paddingLeft","paddingRight","clientHeight","getCellColumnIndex","tableMap","row","column","updateColumnWidth","widthChange","columnIndex","startRow","newWidth","setWidth","mouseUpHandler","handler","preventDefault","stopPropagation","zoom","document","toggleResize","getResizers","left","top","zoneWidth","styles","bottom","backgroundColor","cursor","window","pageXOffset","pageYOffset","right","tableRect","resizerStyles","_jsx","ref","_jsxs","Fragment","className","lexical","theme","tableCellResizer","style","TableCellResizerPlugin","isEditable","body"],"sources":["../../../../../../src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableCellNode, TableDOMCell, TableMapType, TableMapValueType } from '@lexical/table'\nimport type { LexicalEditor } 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} from '@lexical/table'\nimport { calculateZoomLevel } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode } 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 { 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 = 50\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 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 onMouseMove = (event: MouseEvent) => {\n setTimeout(() => {\n const target = event.target\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 as Node)) {\n return\n }\n\n if (targetRef.current !== target) {\n targetRef.current = target as HTMLElement\n const cell = getDOMCellFromTarget(target as HTMLElement)\n\n if (cell && activeCell !== cell) {\n editor.update(() => {\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 = editor.getElementByKey(tableNode.getKey())\n\n if (!tableElement) {\n throw new Error('TableCellResizer: Table element not found.')\n }\n\n targetRef.current = target as HTMLElement\n tableRectRef.current = tableElement.getBoundingClientRect()\n updateActiveCell(cell)\n })\n } else if (cell == null) {\n resetState()\n }\n }\n }, 0)\n }\n\n const onMouseDown = (event: MouseEvent) => {\n setTimeout(() => {\n updateIsMouseDown(true)\n }, 0)\n }\n\n const onMouseUp = (event: MouseEvent) => {\n setTimeout(() => {\n updateIsMouseDown(false)\n }, 0)\n }\n\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\n rootElement?.addEventListener('mousemove', onMouseMove)\n rootElement?.addEventListener('mousedown', onMouseDown)\n rootElement?.addEventListener('mouseup', onMouseUp)\n\n prevRootElement?.removeEventListener('mousemove', onMouseMove)\n prevRootElement?.removeEventListener('mousedown', onMouseDown)\n prevRootElement?.removeEventListener('mouseup', onMouseUp)\n })\n\n return () => {\n removeRootListener()\n }\n }, [activeCell, draggingDirection, editor, 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 tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode)\n\n const tableRows = tableNode.getChildren()\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' },\n )\n },\n [activeCell, editor],\n )\n\n const getCellNodeWidth = (\n cell: TableCellNode,\n activeEditor: LexicalEditor,\n ): number | undefined => {\n const width = cell.getWidth()\n if (width !== undefined) {\n return width\n }\n\n const domCellNode = activeEditor.getElementByKey(cell.getKey())\n if (domCellNode == null) {\n return undefined\n }\n const computedStyle = getComputedStyle(domCellNode)\n return (\n domCellNode.clientWidth -\n parseFloat(computedStyle.paddingLeft) -\n parseFloat(computedStyle.paddingRight)\n )\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 for (let row = 0; row < tableMap.length; row++) {\n for (let column = 0; column < tableMap[row].length; column++) {\n if (tableMap[row][column].cell === tableCellNode) {\n return column\n }\n }\n }\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 for (let row = 0; row < tableMap.length; row++) {\n const cell: TableMapValueType = tableMap[row][columnIndex]\n if (\n cell.startRow === row &&\n (columnIndex === tableMap[row].length - 1 ||\n tableMap[row][columnIndex].cell !== tableMap[row][columnIndex + 1].cell)\n ) {\n const width = getCellNodeWidth(cell.cell, editor)\n if (width === undefined) {\n continue\n }\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH)\n cell.cell.setWidth(newWidth)\n }\n }\n },\n { tag: 'skip-scroll-into-view' },\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 getResizers = useCallback(() => {\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.pageXOffset + left}px`,\n top: `${window.pageYOffset + 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.pageXOffset + left + width - zoneWidth / 2}px`,\n top: `${window.pageYOffset + 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.pageXOffset + tableRect.left}px`\n styles[draggingDirection].top = `${window.pageYOffset + mouseCurrentPos.y / zoom}px`\n styles[draggingDirection].height = '3px'\n styles[draggingDirection].width = `${tableRect.width}px`\n } else {\n styles[draggingDirection].top = `${window.pageYOffset + tableRect.top}px`\n styles[draggingDirection].left = `${window.pageXOffset + 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 return styles\n }\n\n return {\n bottom: null,\n left: null,\n right: null,\n top: null,\n }\n }, [activeCell, draggingDirection, mouseCurrentPos])\n\n const resizerStyles = getResizers()\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"],"mappings":"AAAA;;;AAMA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SACEC,6BAA6B,EAC7BC,mCAAmC,EACnCC,kCAAkC,EAClCC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,QACf;AACP,SAASC,kBAAkB,QAAQ;AACnC,SAASC,0BAA0B,QAAQ;AAC3C,YAAYC,KAAA,MAAW;AACvB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAClE,SAASC,YAAY,QAAQ;AAI7B,SAASC,sBAAsB,QAAQ;AASvC,MAAMC,cAAA,GAAiB;AACvB,MAAMC,gBAAA,GAAmB;AAEzB,SAASC,iBAAiB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BN,eAAA,CAAgB;EAEnD,MAAMuG,aAAA,GAAgBb,WAAA;EAEtB,oBACEc,IAAA,CAAC;IAAIC,GAAA,EAAK7G,UAAA;cACPM,UAAA,IAAc,QAAQ,CAACE,WAAA,iBACtBsG,KAAA,CAAC3H,KAAA,CAAM4H,QAAQ;8BACbH,IAAA,CAAC;QACCI,SAAA,EAAW,GAAG9G,YAAA,CAAaA,YAAY,CAAC+G,OAAO,CAACC,KAAK,CAACC,gBAAgB,uBAAuB;QAC7FhF,WAAA,EAAa0D,YAAA,CAAa;QAC1BuB,KAAA,EAAOT,aAAA,CAAcF,KAAK,IAAInD;uBAEhCsD,IAAA,CAAC;QACCI,SAAA,EAAW,GAAG9G,YAAA,CAAaA,YAAY,CAAC+G,OAAO,CAACC,KAAK,CAACC,gBAAgB,uBAAuB;QAC7FhF,WAAA,EAAa0D,YAAA,CAAa;QAC1BuB,KAAA,EAAOT,aAAA,CAAcR,MAAM,IAAI7C;;;;AAM3C;AAEA,OAAO,MAAM+D,sBAAA,GAA0CA,CAAA;EACrD,MAAM,CAACvH,MAAA,CAAO,GAAGrB,yBAAA;EACjB,MAAM6I,UAAA,GAAa5I,kBAAA;EAEnB,OAAOY,OAAA,CACL,MAAOgI,UAAA,gBAAa7H,YAAA,eAAamH,IAAA,CAAC/G,gBAAA;IAAiBC,MAAA,EAAQA;MAAY8F,QAAA,CAAS2B,IAAI,IAAI,MACxF,CAACzH,MAAA,EAAQwH,UAAA,CAAW;AAExB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$isTableCellNode","$isTableRowNode","getDOMCellFromTarget","TableNode","calculateZoomLevel","$getNearestNodeFromDOMNode","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","useEditorConfigContext","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","TableCellResizer","editor","targetRef","resizerRef","tableRectRef","editorConfig","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","current","isMouseDownOnEvent","event","buttons","registerNodeTransform","tableNode","getColWidths","numColumns","getColumnCount","columnWidth","setColWidths","Array","fill","onMouseMove","setTimeout","target","x","clientX","y","clientY","contains","cell","update","tableCellNode","elem","Error","tableElement","getElementByKey","getKey","getBoundingClientRect","onMouseDown","onMouseUp","removeRootListener","registerRootListener","rootElement","prevRootElement","removeEventListener","addEventListener","isHeightChanging","direction","updateRowHeight","heightChange","tableRowIndex","getRowSpan","tableRows","getChildren","length","tableRow","height","getHeight","undefined","rowCells","Math","min","map","getCellNodeHeight","Infinity","newHeight","max","setHeight","tag","activeEditor","domCellNode","clientHeight","getCellColumnIndex","tableMap","row","column","updateColumnWidth","widthChange","columnIndex","colWidths","width","newColWidths","newWidth","mouseUpHandler","handler","preventDefault","stopPropagation","zoom","document","toggleResize","getResizers","left","top","zoneWidth","styles","bottom","backgroundColor","cursor","window","pageXOffset","pageYOffset","right","tableRect","resizerStyles","_jsx","ref","_jsxs","Fragment","className","lexical","theme","tableCellResizer","style","TableCellResizerPlugin","isEditable","body"],"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 } 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 TableNode,\n} from '@lexical/table'\nimport { calculateZoomLevel } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode } 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 { 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 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 return 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 }, [editor])\n\n useEffect(() => {\n const onMouseMove = (event: MouseEvent) => {\n setTimeout(() => {\n const target = event.target\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 as Node)) {\n return\n }\n\n if (targetRef.current !== target) {\n targetRef.current = target as HTMLElement\n const cell = getDOMCellFromTarget(target as HTMLElement)\n\n if (cell && activeCell !== cell) {\n editor.update(() => {\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 = editor.getElementByKey(tableNode.getKey())\n\n if (!tableElement) {\n throw new Error('TableCellResizer: Table element not found.')\n }\n\n targetRef.current = target as HTMLElement\n tableRectRef.current = tableElement.getBoundingClientRect()\n updateActiveCell(cell)\n })\n } else if (cell == null) {\n resetState()\n }\n }\n }, 0)\n }\n\n const onMouseDown = (event: MouseEvent) => {\n setTimeout(() => {\n updateIsMouseDown(true)\n }, 0)\n }\n\n const onMouseUp = (event: MouseEvent) => {\n setTimeout(() => {\n updateIsMouseDown(false)\n }, 0)\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, 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 tableRowIndex =\n $getTableRowIndexFromTableCellNode(tableCellNode) + tableCellNode.getRowSpan() - 1\n\n const tableRows = tableNode.getChildren()\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' },\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 for (let row = 0; row < tableMap.length; row++) {\n for (let column = 0; column < tableMap[row].length; column++) {\n if (tableMap[row][column].cell === tableCellNode) {\n return column\n }\n }\n }\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' },\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 getResizers = useCallback(() => {\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.pageXOffset + left}px`,\n top: `${window.pageYOffset + 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.pageXOffset + left + width - zoneWidth / 2}px`,\n top: `${window.pageYOffset + 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.pageXOffset + tableRect.left}px`\n styles[draggingDirection].top = `${window.pageYOffset + mouseCurrentPos.y / zoom}px`\n styles[draggingDirection].height = '3px'\n styles[draggingDirection].width = `${tableRect.width}px`\n } else {\n styles[draggingDirection].top = `${window.pageYOffset + tableRect.top}px`\n styles[draggingDirection].left = `${window.pageXOffset + 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 return styles\n }\n\n return {\n bottom: null,\n left: null,\n right: null,\n top: null,\n }\n }, [activeCell, draggingDirection, mouseCurrentPos])\n\n const resizerStyles = getResizers()\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"],"mappings":"AAAA;;;AAMA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SACEC,6BAA6B,EAC7BC,mCAAmC,EACnCC,kCAAkC,EAClCC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,EACpBC,SAAS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CAAC;IAAIC,GAAA,EAAK9G,UAAA;cACPM,UAAA,IAAc,QAAQ,CAACE,WAAA,iBACtBuG,KAAA,CAAC5H,KAAA,CAAM6H,QAAQ;8BACbH,IAAA,CAAC;QACCI,SAAA,EAAW,GAAG/G,YAAA,CAAaA,YAAY,CAACgH,OAAO,CAACC,KAAK,CAACC,gBAAgB,uBAAuB;QAC7FzE,WAAA,EAAamD,YAAA,CAAa;QAC1BuB,KAAA,EAAOT,aAAA,CAAcF,KAAK,IAAI3C;uBAEhC8C,IAAA,CAAC;QACCI,SAAA,EAAW,GAAG/G,YAAA,CAAaA,YAAY,CAACgH,OAAO,CAACC,KAAK,CAACC,gBAAgB,uBAAuB;QAC7FzE,WAAA,EAAamD,YAAA,CAAa;QAC1BuB,KAAA,EAAOT,aAAA,CAAcR,MAAM,IAAIrC;;;;AAM3C;AAEA,OAAO,MAAMuD,sBAAA,GAA0CA,CAAA;EACrD,MAAM,CAACxH,MAAA,CAAO,GAAGtB,yBAAA;EACjB,MAAM+I,UAAA,GAAa9I,kBAAA;EAEnB,OAAOa,OAAA,CACL,MAAOiI,UAAA,gBAAa9H,YAAA,eAAaoH,IAAA,CAAChH,gBAAA;IAAiBC,MAAA,EAAQA;MAAY+F,QAAA,CAAS2B,IAAI,IAAI,MACxF,CAAC1H,MAAA,EAAQyH,UAAA,CAAW;AAExB","ignoreList":[]}
|
|
@@ -42,7 +42,7 @@ export function TableContext({
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
export const TablePlugin = () => {
|
|
45
|
-
const $ = _c(
|
|
45
|
+
const $ = _c(19);
|
|
46
46
|
const [editor] = useLexicalComposerContext();
|
|
47
47
|
const cellContext = useContext(CellContext);
|
|
48
48
|
const {
|
|
@@ -96,18 +96,19 @@ export const TablePlugin = () => {
|
|
|
96
96
|
t2 = $[6];
|
|
97
97
|
}
|
|
98
98
|
let t3;
|
|
99
|
-
if ($[7] !== cellContext || $[8] !==
|
|
100
|
-
t3 = [cellContext, editor, toggleModal];
|
|
99
|
+
if ($[7] !== cellContext || $[8] !== drawerSlug || $[9] !== editor || $[10] !== toggleModal) {
|
|
100
|
+
t3 = [cellContext, drawerSlug, editor, toggleModal];
|
|
101
101
|
$[7] = cellContext;
|
|
102
|
-
$[8] =
|
|
103
|
-
$[9] =
|
|
104
|
-
$[10] =
|
|
102
|
+
$[8] = drawerSlug;
|
|
103
|
+
$[9] = editor;
|
|
104
|
+
$[10] = toggleModal;
|
|
105
|
+
$[11] = t3;
|
|
105
106
|
} else {
|
|
106
|
-
t3 = $[
|
|
107
|
+
t3 = $[11];
|
|
107
108
|
}
|
|
108
109
|
useEffect(t2, t3);
|
|
109
110
|
let t4;
|
|
110
|
-
if ($[
|
|
111
|
+
if ($[12] !== closeModal || $[13] !== drawerSlug || $[14] !== editor) {
|
|
111
112
|
t4 = (_fields, data) => {
|
|
112
113
|
closeModal(drawerSlug);
|
|
113
114
|
if (!data.columns || !data.rows) {
|
|
@@ -118,15 +119,15 @@ export const TablePlugin = () => {
|
|
|
118
119
|
rows: String(data.rows)
|
|
119
120
|
});
|
|
120
121
|
};
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
122
|
+
$[12] = closeModal;
|
|
123
|
+
$[13] = drawerSlug;
|
|
124
|
+
$[14] = editor;
|
|
125
|
+
$[15] = t4;
|
|
125
126
|
} else {
|
|
126
|
-
t4 = $[
|
|
127
|
+
t4 = $[15];
|
|
127
128
|
}
|
|
128
129
|
let t5;
|
|
129
|
-
if ($[
|
|
130
|
+
if ($[16] !== drawerSlug || $[17] !== t4) {
|
|
130
131
|
t5 = _jsxs(React.Fragment, {
|
|
131
132
|
children: [_jsx(FieldsDrawer, {
|
|
132
133
|
drawerSlug,
|
|
@@ -139,11 +140,11 @@ export const TablePlugin = () => {
|
|
|
139
140
|
hasCellMerge: true
|
|
140
141
|
})]
|
|
141
142
|
});
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
144
|
-
$[
|
|
143
|
+
$[16] = drawerSlug;
|
|
144
|
+
$[17] = t4;
|
|
145
|
+
$[18] = t5;
|
|
145
146
|
} else {
|
|
146
|
-
t5 = $[
|
|
147
|
+
t5 = $[18];
|
|
147
148
|
}
|
|
148
149
|
return t5;
|
|
149
150
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","TablePlugin","LexicalReactTablePlugin","INSERT_TABLE_COMMAND","TableNode","mergeRegister","formatDrawerSlug","useEditDepth","useModal","$getSelection","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","createContext","useContext","useEffect","useMemo","useState","React","useEditorConfigContext","FieldsDrawer","OPEN_TABLE_DRAWER_COMMAND","CellContext","cellEditorConfig","cellEditorPlugins","set","TableContext","children","contextValue","setContextValue","_jsx","Provider","value","$","editor","cellContext","closeModal","toggleModal","editDepth","uuid","t0","t1","slug","depth","drawerSlug","t2","hasNodes","Error","registerCommand","rangeSelection","getEditorState","read","selection","t3","t4","_fields","data","columns","rows","dispatchCommand","String","t5","_jsxs","Fragment","drawerTitle","featureKey","handleDrawerSubmit","schemaPathSuffix","hasCellBackgroundColor","hasCellMerge"],"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, TableNode } from '@lexical/table'\nimport { mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth, useModal } from '@payloadcms/ui'\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical'\nimport { createContext, useContext, 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 './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.Provider\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.Provider>\n )\n}\n\nexport const TablePlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const cellContext = useContext(CellContext)\n const { closeModal, toggleModal } = useModal()\n const editDepth = useEditDepth()\n const { uuid } = useEditorConfigContext()\n\n const drawerSlug = formatDrawerSlug({\n slug: 'lexical-table-create-' + uuid,\n depth: editDepth,\n })\n\n useEffect(() => {\n if (!editor.hasNodes([TableNode])) {\n throw new Error('TablePlugin: TableNode is not registered on editor')\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 toggleModal(drawerSlug)\n }\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [cellContext, editor, toggleModal])\n\n return (\n <React.Fragment>\n <FieldsDrawer\n drawerSlug={drawerSlug}\n drawerTitle=\"Create Table\"\n featureKey=\"experimental_table\"\n handleDrawerSubmit={(_fields, data) => {\n closeModal(drawerSlug)\n\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 schemaPathSuffix=\"fields\"\n />\n <LexicalReactTablePlugin hasCellBackgroundColor={false} hasCellMerge />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAYA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,WAAA,IAAeC,uBAAuB,QAAQ;AACvD,SAASC,oBAAoB,EAAEC,SAAS,QAAQ;AAChD,SAASC,aAAa,QAAQ;AAC9B,SAASC,gBAAgB,EAAEC,YAAY,EAAEC,QAAQ,QAAQ;AACzD,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,uBAAuB,EAAEC,aAAa,QAAQ;AACzF,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACxE,YAAYC,KAAA,MAAW;AAIvB,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAoB7B,OAAO,MAAMC,yBAAA,GAAgDT,aAAA,CAC3D;AAGF,OAAO,MAAMU,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GAAAR,CAAA;EAAA;EAHA,MAAAW,UAAA,GAAmBH,EAGnB;EAAA,IAAAI,EAAA;EAAA,IAAAZ,CAAA,QAAAC,MAAA,IAAAD,CAAA,QAAAI,WAAA,IAAAJ,CAAA,QAAAW,UAAA;IAEUC,EAAA,GAAAA,CAAA;MAAA,KACHX,MAAA,CAAAY,QAAA,EAAA1C,SAAA,CAA2B;QAAA,UAAA2C,KAAA,CACd;MAAA;MAAA,OAGX1C,aAAA,CACL6B,MAAA,CAAAc,eAAA,CAAA3B,yBAAA;QAGI,IAAA4B,cAAA;QAAAA,cAAA;QAEAf,MAAA,CAAAgB,cAAA,CAAqB,EAAAC,IAAA;UACnB,MAAAC,SAAA,GAAkB3C,aAAA;UAAA,IACdC,iBAAA,CAAkB0C,SAAA;YACpBH,cAAA,CAAAA,CAAA,CAAiBG,SAAA;UAAjB;QAAA,CAEJ;QAAA,IAEIH,cAAA;UACFZ,WAAA,CAAYO,UAAA;QAAA;QAAA;MAAA,GAAAjC,uBAIhB;IAAA;IAGNsB,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAI,WAAA;IAAAJ,CAAA,MAAAW,UAAA;IAAAX,CAAA,MAAAY,EAAA;EAAA;IAAAA,EAAA,GAAAZ,CAAA;EAAA;EAAA,IAAAoB,EAAA;EAAA,IAAApB,CAAA,QAAAE,WAAA,IAAAF,CAAA,QAAAC,MAAA,IAAAD,CAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","TablePlugin","LexicalReactTablePlugin","INSERT_TABLE_COMMAND","TableNode","mergeRegister","formatDrawerSlug","useEditDepth","useModal","$getSelection","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","createContext","useContext","useEffect","useMemo","useState","React","useEditorConfigContext","FieldsDrawer","OPEN_TABLE_DRAWER_COMMAND","CellContext","cellEditorConfig","cellEditorPlugins","set","TableContext","children","contextValue","setContextValue","_jsx","Provider","value","$","editor","cellContext","closeModal","toggleModal","editDepth","uuid","t0","t1","slug","depth","drawerSlug","t2","hasNodes","Error","registerCommand","rangeSelection","getEditorState","read","selection","t3","t4","_fields","data","columns","rows","dispatchCommand","String","t5","_jsxs","Fragment","drawerTitle","featureKey","handleDrawerSubmit","schemaPathSuffix","hasCellBackgroundColor","hasCellMerge"],"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, TableNode } from '@lexical/table'\nimport { mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth, useModal } from '@payloadcms/ui'\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical'\nimport { createContext, useContext, 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 './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.Provider\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.Provider>\n )\n}\n\nexport const TablePlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const cellContext = useContext(CellContext)\n const { closeModal, toggleModal } = useModal()\n const editDepth = useEditDepth()\n const { uuid } = useEditorConfigContext()\n\n const drawerSlug = formatDrawerSlug({\n slug: 'lexical-table-create-' + uuid,\n depth: editDepth,\n })\n\n useEffect(() => {\n if (!editor.hasNodes([TableNode])) {\n throw new Error('TablePlugin: TableNode is not registered on editor')\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 toggleModal(drawerSlug)\n }\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [cellContext, drawerSlug, editor, toggleModal])\n\n return (\n <React.Fragment>\n <FieldsDrawer\n drawerSlug={drawerSlug}\n drawerTitle=\"Create Table\"\n featureKey=\"experimental_table\"\n handleDrawerSubmit={(_fields, data) => {\n closeModal(drawerSlug)\n\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 schemaPathSuffix=\"fields\"\n />\n <LexicalReactTablePlugin hasCellBackgroundColor={false} hasCellMerge />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAYA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,WAAA,IAAeC,uBAAuB,QAAQ;AACvD,SAASC,oBAAoB,EAAEC,SAAS,QAAQ;AAChD,SAASC,aAAa,QAAQ;AAC9B,SAASC,gBAAgB,EAAEC,YAAY,EAAEC,QAAQ,QAAQ;AACzD,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,uBAAuB,EAAEC,aAAa,QAAQ;AACzF,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACxE,YAAYC,KAAA,MAAW;AAIvB,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAoB7B,OAAO,MAAMC,yBAAA,GAAgDT,aAAA,CAC3D;AAGF,OAAO,MAAMU,WAAA,gBAAcT,aAAA,CAAgC;EACzDU,gBAAA,EAAkB;EAClBC,iBAAA,EAAmB;EACnBC,GAAA,EAAKA,CAAA;IACH;EAAA;AAEJ;AAEA,OAAO,SAASC,aAAa;EAAEC;AAAQ,CAA6B;EAClE,MAAM,CAACC,YAAA,EAAcC,eAAA,CAAgB,GAAGZ,QAAA,CAGrC;IACDM,gBAAA,EAAkB;IAClBC,iBAAA,EAAmB;EACrB;EACA,oBACEM,IAAA,CAACR,WAAA,CAAYS,QAAQ;IACnBC,KAAA,EAAOhB,OAAA,CACL,OAAO;MACLO,gBAAA,EAAkBK,YAAA,CAAaL,gBAAgB;MAC/CC,iBAAA,EAAmBI,YAAA,CAAaJ,iBAAiB;MACjDC,GAAA,EAAKA,CAACF,gBAAA,EAAkBC,iBAAA;QACtBK,eAAA,CAAgB;UAAEN,gBAAA;UAAkBC;QAAkB;MACxD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A,IAAA4B,EAAA;EAAA,IAAA5B,CAAA,SAAAW,UAAA,IAAAX,CAAA,SAAAqB,EAAA;IAhBJO,EAAA,GAAAC,KAAA,CAAA5C,KAAA,CAAA6C,QAAA;MAAApC,QAAA,GACEG,IAAA,CAAAV,YAAA;QAAAwB,UAAA;QAAAoB,WAAA,EAEc;QAAAC,UAAA,EACD;QAAAC,kBAAA,EACSZ,EAWpB;QAAAa,gBAAA,EACiB;MAAA,C,GAEnBrC,IAAA,CAAA5B,uBAAA;QAAAkE,sBAAA;QAAAC,YAAA;MAAA,C;;;;;;;;SAnBFR,E;CAsBJ","ignoreList":[]}
|
|
@@ -100,8 +100,8 @@ export const EXPERIMENTAL_TableFeature = createServerFeature({
|
|
|
100
100
|
const tagName = node.headerState > 0 ? 'th' : 'td';
|
|
101
101
|
const headerStateClass = `lexical-table-cell-header-${node.headerState}`;
|
|
102
102
|
const backgroundColor = node.backgroundColor ? `background-color: ${node.backgroundColor};` : '';
|
|
103
|
-
const colSpan = node.colSpan > 1 ? `colspan="${node.colSpan}"` : '';
|
|
104
|
-
const rowSpan = node.rowSpan > 1 ? `rowspan="${node.rowSpan}"` : '';
|
|
103
|
+
const colSpan = node.colSpan && node.colSpan > 1 ? `colspan="${node.colSpan}"` : '';
|
|
104
|
+
const rowSpan = node.rowSpan && node.rowSpan > 1 ? `rowspan="${node.rowSpan}"` : '';
|
|
105
105
|
return `<${tagName} class="lexical-table-cell ${headerStateClass}" style="border: 1px solid #ccc; padding: 8px; ${backgroundColor}" ${colSpan} ${rowSpan}>${childrenText}</${tagName}>`;
|
|
106
106
|
},
|
|
107
107
|
nodeTypes: [TableCellNode.getType()]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["TableCellNode","TableNode","TableRowNode","sanitizeFields","createServerFeature","convertLexicalNodesToHTML","createNode","fields","name","type","defaultValue","required","EXPERIMENTAL_TableFeature","feature","config","isRoot","parentIsLocalized","validRelationships","collections","map","c","slug","sanitizedFields","requireFieldLevelRichTextEditor","ClientFeature","generateSchemaMap","schemaMap","Map","set","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","nodeTypes","getType","tagName","headerState","headerStateClass","backgroundColor","colSpan","rowSpan","key"],"sources":["../../../../src/features/experimental_table/server/index.ts"],"sourcesContent":["import type {\n SerializedTableCellNode as _SerializedTableCellNode,\n SerializedTableNode as _SerializedTableNode,\n SerializedTableRowNode as _SerializedTableRowNode,\n} from '@lexical/table'\nimport type { Spread } from 'lexical'\nimport type { Config, Field } from 'payload'\n\nimport { TableCellNode, TableNode, TableRowNode } from '@lexical/table'\nimport { sanitizeFields } from 'payload'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../../converters/html/converter/index.js'\nimport { createNode } from '../../typeUtilities.js'\n\nconst fields: Field[] = [\n {\n name: 'rows',\n type: 'number',\n defaultValue: 5,\n required: true,\n },\n {\n name: 'columns',\n type: 'number',\n defaultValue: 5,\n required: true,\n },\n]\n\nexport type SerializedTableCellNode = Spread<\n {\n type: 'tablecell'\n },\n _SerializedTableCellNode\n>\n\nexport type SerializedTableNode = Spread<\n {\n type: 'table'\n },\n _SerializedTableNode\n>\n\nexport type SerializedTableRowNode = Spread<\n {\n type: 'tablerow'\n },\n _SerializedTableRowNode\n>\nexport const EXPERIMENTAL_TableFeature = createServerFeature({\n feature: async ({ config, isRoot, parentIsLocalized }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n const sanitizedFields = await sanitizeFields({\n config: config as unknown as Config,\n fields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#TableFeatureClient',\n generateSchemaMap: () => {\n const schemaMap = new Map<string, Field[]>()\n\n schemaMap.set('fields', sanitizedFields)\n\n return schemaMap\n },\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n return `<table class=\"lexical-table\" style=\"border-collapse: collapse;\">${childrenText}</table>`\n },\n nodeTypes: [TableNode.getType()],\n },\n },\n node: TableNode,\n }),\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n\n const tagName = node.headerState > 0 ? 'th' : 'td'\n const headerStateClass = `lexical-table-cell-header-${node.headerState}`\n const backgroundColor = node.backgroundColor\n ? `background-color: ${node.backgroundColor};`\n : ''\n const colSpan = node.colSpan > 1 ? `colspan=\"${node.colSpan}\"` : ''\n const rowSpan = node.rowSpan > 1 ? `rowspan=\"${node.rowSpan}\"` : ''\n\n return `<${tagName} class=\"lexical-table-cell ${headerStateClass}\" style=\"border: 1px solid #ccc; padding: 8px; ${backgroundColor}\" ${colSpan} ${rowSpan}>${childrenText}</${tagName}>`\n },\n nodeTypes: [TableCellNode.getType()],\n },\n },\n node: TableCellNode,\n }),\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n return `<tr class=\"lexical-table-row\">${childrenText}</tr>`\n },\n nodeTypes: [TableRowNode.getType()],\n },\n },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CAA0B;gBACnDyB,UAAA;gBACAG,YAAA;gBACAC,KAAA;gBACAC,KAAA;gBACAO,YAAA,EAAcN,IAAA,CAAKO,QAAQ;gBAC3BN,cAAA;gBACAC,MAAA,EAAQ;kBACN,GAAGF,IAAI;kBACPE;gBACF;gBACAC,GAAA;gBACAC;cACF;cACA,OAAO,mEAAmEC,YAAA,UAAsB;YAClG;YACAG,SAAA,EAAW,CAAC3C,SAAA,CAAU4C,OAAO;UAC/B;QACF;QACAT,IAAA,EAAMnC;MACR,IACAK,UAAA,CAAW;QACTwB,UAAA,EAAY;UACVC,IAAA,EAAM;YACJC,SAAA,EAAW,MAAAA,CAAO;cAChBF,UAAU;cACVG,YAAY;cACZC,KAAK;cACLC,KAAK;cACLC,IAAI;cACJC,cAAc;cACdC,MAAM;cACNC,GAAG;cACHC;YAAgB,CACjB;cACC,MAAMC,YAAA,GAAe,MAAMpC,yBAAA,CAA0B;gBACnDyB,UAAA;gBACAG,YAAA;gBACAC,KAAA;gBACAC,KAAA;gBACAO,YAAA,EAAcN,IAAA,CAAKO,QAAQ;gBAC3BN,cAAA;gBACAC,MAAA,EAAQ;kBACN,GAAGF,IAAI;kBACPE;gBACF;gBACAC,GAAA;gBACAC;cACF;cAEA,MAAMM,OAAA,GAAUV,IAAA,CAAKW,WAAW,GAAG,IAAI,OAAO;cAC9C,MAAMC,gBAAA,GAAmB,6BAA6BZ,IAAA,CAAKW,WAAW,EAAE;cACxE,MAAME,eAAA,GAAkBb,IAAA,CAAKa,eAAe,GACxC,qBAAqBb,IAAA,CAAKa,eAAe,GAAG,GAC5C;cACJ,MAAMC,OAAA,GAAUd,IAAA,CAAKc,OAAO,GAAG,IAAI,YAAYd,IAAA,CAAKc,OAAO,GAAG,GAAG;
|
|
1
|
+
{"version":3,"file":"index.js","names":["TableCellNode","TableNode","TableRowNode","sanitizeFields","createServerFeature","convertLexicalNodesToHTML","createNode","fields","name","type","defaultValue","required","EXPERIMENTAL_TableFeature","feature","config","isRoot","parentIsLocalized","validRelationships","collections","map","c","slug","sanitizedFields","requireFieldLevelRichTextEditor","ClientFeature","generateSchemaMap","schemaMap","Map","set","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","nodeTypes","getType","tagName","headerState","headerStateClass","backgroundColor","colSpan","rowSpan","key"],"sources":["../../../../src/features/experimental_table/server/index.ts"],"sourcesContent":["import type {\n SerializedTableCellNode as _SerializedTableCellNode,\n SerializedTableNode as _SerializedTableNode,\n SerializedTableRowNode as _SerializedTableRowNode,\n} from '@lexical/table'\nimport type { Spread } from 'lexical'\nimport type { Config, Field } from 'payload'\n\nimport { TableCellNode, TableNode, TableRowNode } from '@lexical/table'\nimport { sanitizeFields } from 'payload'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../../converters/html/converter/index.js'\nimport { createNode } from '../../typeUtilities.js'\n\nconst fields: Field[] = [\n {\n name: 'rows',\n type: 'number',\n defaultValue: 5,\n required: true,\n },\n {\n name: 'columns',\n type: 'number',\n defaultValue: 5,\n required: true,\n },\n]\n\nexport type SerializedTableCellNode = Spread<\n {\n type: 'tablecell'\n },\n _SerializedTableCellNode\n>\n\nexport type SerializedTableNode = Spread<\n {\n type: 'table'\n },\n _SerializedTableNode\n>\n\nexport type SerializedTableRowNode = Spread<\n {\n type: 'tablerow'\n },\n _SerializedTableRowNode\n>\nexport const EXPERIMENTAL_TableFeature = createServerFeature({\n feature: async ({ config, isRoot, parentIsLocalized }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n const sanitizedFields = await sanitizeFields({\n config: config as unknown as Config,\n fields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#TableFeatureClient',\n generateSchemaMap: () => {\n const schemaMap = new Map<string, Field[]>()\n\n schemaMap.set('fields', sanitizedFields)\n\n return schemaMap\n },\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n return `<table class=\"lexical-table\" style=\"border-collapse: collapse;\">${childrenText}</table>`\n },\n nodeTypes: [TableNode.getType()],\n },\n },\n node: TableNode,\n }),\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n\n const tagName = node.headerState > 0 ? 'th' : 'td'\n const headerStateClass = `lexical-table-cell-header-${node.headerState}`\n const backgroundColor = node.backgroundColor\n ? `background-color: ${node.backgroundColor};`\n : ''\n const colSpan = node.colSpan && node.colSpan > 1 ? `colspan=\"${node.colSpan}\"` : ''\n const rowSpan = node.rowSpan && node.rowSpan > 1 ? `rowspan=\"${node.rowSpan}\"` : ''\n\n return `<${tagName} class=\"lexical-table-cell ${headerStateClass}\" style=\"border: 1px solid #ccc; padding: 8px; ${backgroundColor}\" ${colSpan} ${rowSpan}>${childrenText}</${tagName}>`\n },\n nodeTypes: [TableCellNode.getType()],\n },\n },\n node: TableCellNode,\n }),\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n return `<tr class=\"lexical-table-row\">${childrenText}</tr>`\n },\n nodeTypes: [TableRowNode.getType()],\n },\n },\n node: TableRowNode,\n }),\n ],\n }\n },\n key: 'experimental_table',\n})\n"],"mappings":"AAQA,SAASA,aAAa,EAAEC,SAAS,EAAEC,YAAY,QAAQ;AACvD,SAASC,cAAc,QAAQ;AAE/B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAE3B,MAAMC,MAAA,GAAkB,CACtB;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,YAAA,EAAc;EACdC,QAAA,EAAU;AACZ,GACA;EACEH,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,YAAA,EAAc;EACdC,QAAA,EAAU;AACZ,EACD;AAsBD,OAAO,MAAMC,yBAAA,GAA4BR,mBAAA,CAAoB;EAC3DS,OAAA,EAAS,MAAAA,CAAO;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAiB,CAAE;IACnD,MAAMC,kBAAA,GAAqBH,MAAA,CAAOI,WAAW,CAACC,GAAG,CAAEC,CAAA,IAAMA,CAAA,CAAEC,IAAI,KAAK,EAAE;IAEtE,MAAMC,eAAA,GAAkB,MAAMnB,cAAA,CAAe;MAC3CW,MAAA,EAAQA,MAAA;MACRP,MAAA;MACAS,iBAAA;MACAO,+BAAA,EAAiCR,MAAA;MACjCE;IACF;IACA,OAAO;MACLO,aAAA,EAAe;MACfC,iBAAA,EAAmBA,CAAA;QACjB,MAAMC,SAAA,GAAY,IAAIC,GAAA;QAEtBD,SAAA,CAAUE,GAAG,CAAC,UAAUN,eAAA;QAExB,OAAOI,SAAA;MACT;MACAG,KAAA,EAAO,CACLvB,UAAA,CAAW;QACTwB,UAAA,EAAY;UACVC,IAAA,EAAM;YACJC,SAAA,EAAW,MAAAA,CAAO;cAChBF,UAAU;cACVG,YAAY;cACZC,KAAK;cACLC,KAAK;cACLC,IAAI;cACJC,cAAc;cACdC,MAAM;cACNC,GAAG;cACHC;YA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G,IAAI,YAAYf,IAAA,CAAKe,OAAO,GAAG,GAAG;cAEjF,OAAO,IAAIL,OAAA,8BAAqCE,gBAAA,kDAAkEC,eAAA,KAAoBC,OAAA,IAAWC,OAAA,IAAWV,YAAA,KAAiBK,OAAA,GAAU;YACzL;YACAF,SAAA,EAAW,CAAC5C,aAAA,CAAc6C,OAAO;UACnC;QACF;QACAT,IAAA,EAAMpC;MACR,IACAM,UAAA,CAAW;QACTwB,UAAA,EAAY;UACVC,IAAA,EAAM;YACJC,SAAA,EAAW,MAAAA,CAAO;cAChBF,UAAU;cACVG,YAAY;cACZC,KAAK;cACLC,KAAK;cACLC,IAAI;cACJC,cAAc;cACdC,MAAM;cACNC,GAAG;cACHC;YAAgB,CACjB;cACC,MAAMC,YAAA,GAAe,MAAMpC,yBAAA,CAA0B;gBACnDyB,UAAA;gBACAG,YAAA;gBACAC,KAAA;gBACAC,KAAA;gBACAO,YAAA,EAAcN,IAAA,CAAKO,QAAQ;gBAC3BN,cAAA;gBACAC,MAAA,EAAQ;kBACN,GAAGF,IAAI;kBACPE;gBACF;gBACAC,GAAA;gBACAC;cACF;cACA,OAAO,iCAAiCC,YAAA,OAAmB;YAC7D;YACAG,SAAA,EAAW,CAAC1C,YAAA,CAAa2C,OAAO;UAClC;QACF;QACAT,IAAA,EAAMlC;MACR;IAEJ;EACF;EACAkD,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/horizontalRule/client/component/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/horizontalRule/client/component/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAmBtC;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,QA0DxE"}
|
|
@@ -4,7 +4,7 @@ import { c as _c } from "react/compiler-runtime";
|
|
|
4
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
5
5
|
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js';
|
|
6
6
|
import { addClassNamesToElement, mergeRegister, removeClassNamesFromElement } from '@lexical/utils';
|
|
7
|
-
import { $
|
|
7
|
+
import { $getSelection, $isNodeSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND } from 'lexical';
|
|
8
8
|
import { useCallback, useEffect } from 'react';
|
|
9
9
|
import { $isHorizontalRuleNode } from '../nodes/HorizontalRuleNode.js';
|
|
10
10
|
const isSelectedClassName = 'selected';
|
|
@@ -21,20 +21,23 @@ export function HorizontalRuleComponent(t0) {
|
|
|
21
21
|
const [editor] = useLexicalComposerContext();
|
|
22
22
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
23
23
|
let t1;
|
|
24
|
-
if ($[0] !== isSelected || $[1] !==
|
|
24
|
+
if ($[0] !== isSelected || $[1] !== editor) {
|
|
25
25
|
t1 = event => {
|
|
26
|
-
|
|
26
|
+
const deleteSelection = $getSelection();
|
|
27
|
+
if (isSelected && $isNodeSelection(deleteSelection)) {
|
|
27
28
|
event.preventDefault();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
editor.update(() => {
|
|
30
|
+
deleteSelection.getNodes().forEach(node => {
|
|
31
|
+
if ($isHorizontalRuleNode(node)) {
|
|
32
|
+
node.remove();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
33
36
|
}
|
|
34
37
|
return false;
|
|
35
38
|
};
|
|
36
39
|
$[0] = isSelected;
|
|
37
|
-
$[1] =
|
|
40
|
+
$[1] = editor;
|
|
38
41
|
$[2] = t1;
|
|
39
42
|
} else {
|
|
40
43
|
t1 = $[2];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalNodeSelection","addClassNamesToElement","mergeRegister","removeClassNamesFromElement","$
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalNodeSelection","addClassNamesToElement","mergeRegister","removeClassNamesFromElement","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","useCallback","useEffect","$isHorizontalRuleNode","isSelectedClassName","HorizontalRuleComponent","t0","$","nodeKey","editor","isSelected","setSelected","clearSelection","t1","event","deleteSelection","preventDefault","update","getNodes","forEach","node","remove","$onDelete","t2","t3","registerCommand","event_0","hrElem","getElementByKey","target","shiftKey","t4","t5","hrElem_0"],"sources":["../../../../../src/features/horizontalRule/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport type { NodeKey } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { addClassNamesToElement, mergeRegister, removeClassNamesFromElement } from '@lexical/utils'\nimport {\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect } from 'react'\n\nimport { $isHorizontalRuleNode } from '../nodes/HorizontalRuleNode.js'\n\nconst isSelectedClassName = 'selected'\n\n/**\n * React component rendered in the lexical editor, WITHIN the hr element created by createDOM of the HorizontalRuleNode.\n *\n * @param nodeKey every node has a unique key (this key is not saved to the database and thus may differ between sessions). It's useful for working with the CURRENT lexical editor state\n */\nexport function HorizontalRuleComponent({ nodeKey }: { nodeKey: NodeKey }) {\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isHorizontalRuleNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n CLICK_COMMAND,\n (event: MouseEvent) => {\n const hrElem = editor.getElementByKey(nodeKey)\n\n if (event.target === hrElem) {\n if (!event.shiftKey) {\n clearSelection()\n }\n setSelected(!isSelected)\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected])\n\n useEffect(() => {\n const hrElem = editor.getElementByKey(nodeKey)\n if (hrElem !== null) {\n if (isSelected) {\n addClassNamesToElement(hrElem, isSelectedClassName)\n } else {\n removeClassNamesFromElement(hrElem, isSelectedClassName)\n }\n }\n }, [editor, isSelected, nodeKey])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,uBAAuB,QAAQ;AACxC,SAASC,sBAAsB,EAAEC,aAAa,EAAEC,2BAA2B,QAAQ;AACnF,SACEC,aAAa,EACbC,gBAAgB,EAChBC,aAAa,EACbC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,QACb;AACP,SAASC,WAAW,EAAEC,SAAS,QAAQ;AAEvC,SAASC,qBAAqB,QAAQ;AAEtC,MAAMC,mBAAA,GAAsB;AAE5B;;;;;AAKA,OAAO,SAAAC,wBAA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EAAA,GAAAxB,CAAA;IAAAyB,EAAA,GAAAzB,CAAA;EAAA;EAThCL,SAAA,CAAU6B,EASV,EAAGC,EAA6B;EAAA;AAAA","ignoreList":[]}
|
|
@@ -16,7 +16,7 @@ export declare const INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
|
|
|
16
16
|
*
|
|
17
17
|
* If we used DecoratorBlockNode instead, we would only need a decorate method
|
|
18
18
|
*/
|
|
19
|
-
export declare class HorizontalRuleServerNode extends DecoratorNode<React.ReactElement> {
|
|
19
|
+
export declare class HorizontalRuleServerNode extends DecoratorNode<null | React.ReactElement> {
|
|
20
20
|
static clone(node: HorizontalRuleServerNode): HorizontalRuleServerNode;
|
|
21
21
|
static getType(): string;
|
|
22
22
|
/**
|
|
@@ -33,7 +33,7 @@ export declare class HorizontalRuleServerNode extends DecoratorNode<React.ReactE
|
|
|
33
33
|
* Determines how the hr element is rendered in the lexical editor. This is only the "initial" / "outer" HTML element.
|
|
34
34
|
*/
|
|
35
35
|
createDOM(config: EditorConfig): HTMLElement;
|
|
36
|
-
decorate():
|
|
36
|
+
decorate(): null | React.ReactElement;
|
|
37
37
|
/**
|
|
38
38
|
* Opposite of importDOM, this function defines what happens when you copy an hr element from the lexical editor and paste it into another page.
|
|
39
39
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HorizontalRuleNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/horizontalRule/server/nodes/HorizontalRuleNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AAGnC,OAAO,EAAwC,aAAa,EAAE,MAAM,SAAS,CAAA;AAE7E;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAC/C;IACE,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,IAAI,EAAE,gBAAgB,CAAA;CACvB,EACD,qBAAqB,CACtB,CAAA;AAED,eAAO,MAAM,8BAA8B,EAAE,cAAc,CAAC,IAAI,CAE/D,CAAA;AAED;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"HorizontalRuleNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/horizontalRule/server/nodes/HorizontalRuleNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AAGnC,OAAO,EAAwC,aAAa,EAAE,MAAM,SAAS,CAAA;AAE7E;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAC/C;IACE,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,IAAI,EAAE,gBAAgB,CAAA;CACvB,EACD,qBAAqB,CACtB,CAAA;AAED,eAAO,MAAM,8BAA8B,EAAE,cAAc,CAAC,IAAI,CAE/D,CAAA;AAED;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,aAAa,CAAC,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC;IACpF,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,wBAAwB,GAAG,wBAAwB;IAItE,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB;;;;OAIG;IACH,MAAM,CAAC,SAAS,IAAI,gBAAgB,GAAG,IAAI;IAS3C;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,4BAA4B,GAAG,wBAAwB;IAIzF;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IAM5C,QAAQ,IAAI,IAAI,GAAG,KAAK,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