@payloadcms/richtext-lexical 3.57.0-canary.0 → 3.57.0-canary.2
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/exports/client/Field-PKJPWZJL.js +2 -0
- package/dist/exports/client/{Field-SOED2PIU.js.map → Field-PKJPWZJL.js.map} +2 -2
- package/dist/exports/client/chunk-CYLMY5ZJ.js +2 -0
- package/dist/exports/client/{chunk-FSKAVN4P.js.map → chunk-CYLMY5ZJ.js.map} +2 -2
- package/dist/exports/client/chunk-YCH4JNUH.js +12 -0
- package/dist/exports/client/{chunk-KZKGNMS3.js.map → chunk-YCH4JNUH.js.map} +2 -2
- package/dist/exports/client/{component-M3U253XK.js → component-3PENNOM3.js} +2 -2
- package/dist/exports/client/index.d.ts +2 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blocks/client/component/BlockContent.js +8 -10
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +3 -5
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/heading/client/index.d.ts.map +1 -1
- package/dist/features/heading/client/index.js +60 -0
- package/dist/features/heading/client/index.js.map +1 -1
- package/dist/features/heading/server/index.d.ts.map +1 -1
- package/dist/features/heading/server/index.js +1 -0
- package/dist/features/heading/server/index.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +20 -37
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +28 -53
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +35 -37
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +20 -30
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/field/RenderLexical/index.d.ts +23 -0
- package/dist/field/RenderLexical/index.d.ts.map +1 -0
- package/dist/field/RenderLexical/index.js +130 -0
- package/dist/field/RenderLexical/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.js +22 -35
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +7 -15
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +7 -15
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +75 -141
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +2 -11
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/nodeTypes.d.ts +13 -1
- package/dist/nodeTypes.d.ts.map +1 -1
- package/dist/nodeTypes.js +4 -1
- package/dist/nodeTypes.js.map +1 -1
- package/dist/utilities/buildEditorState.d.ts +11 -0
- package/dist/utilities/buildEditorState.d.ts.map +1 -0
- package/dist/utilities/buildEditorState.js +76 -0
- package/dist/utilities/buildEditorState.js.map +1 -0
- package/package.json +10 -10
- package/dist/exports/client/Field-SOED2PIU.js +0 -2
- package/dist/exports/client/chunk-FSKAVN4P.js +0 -2
- package/dist/exports/client/chunk-KZKGNMS3.js +0 -12
- /package/dist/exports/client/{component-M3U253XK.js.map → component-3PENNOM3.js.map} +0 -0
|
@@ -29,9 +29,8 @@ export const BlockContent = props => {
|
|
|
29
29
|
const hasSubmitted = useFormSubmitted();
|
|
30
30
|
const fieldHasErrors = hasSubmitted && errorCount > 0;
|
|
31
31
|
let t0;
|
|
32
|
-
let t1;
|
|
33
32
|
if ($[0] !== Collapsible || $[1] !== errorCount || $[2] !== fieldHasErrors) {
|
|
34
|
-
|
|
33
|
+
t0 = props_0 => _jsx(Collapsible, {
|
|
35
34
|
editButton: props_0.editButton,
|
|
36
35
|
errorCount,
|
|
37
36
|
fieldHasErrors,
|
|
@@ -42,15 +41,14 @@ export const BlockContent = props => {
|
|
|
42
41
|
$[0] = Collapsible;
|
|
43
42
|
$[1] = errorCount;
|
|
44
43
|
$[2] = fieldHasErrors;
|
|
45
|
-
$[3] =
|
|
44
|
+
$[3] = t0;
|
|
46
45
|
} else {
|
|
47
|
-
|
|
46
|
+
t0 = $[3];
|
|
48
47
|
}
|
|
49
|
-
t0 = t1;
|
|
50
48
|
const CollapsibleWithErrorProps = t0;
|
|
51
|
-
let
|
|
49
|
+
let t1;
|
|
52
50
|
if ($[4] !== BlockDrawer || $[5] !== CollapsibleWithErrorProps || $[6] !== CustomBlock || $[7] !== EditButton || $[8] !== RemoveButton || $[9] !== formSchema || $[10] !== initialState || $[11] !== nodeKey) {
|
|
53
|
-
|
|
51
|
+
t1 = CustomBlock ? _jsxs(BlockComponentContext, {
|
|
54
52
|
value: {
|
|
55
53
|
BlockCollapsible: CollapsibleWithErrorProps,
|
|
56
54
|
EditButton,
|
|
@@ -77,10 +75,10 @@ export const BlockContent = props => {
|
|
|
77
75
|
$[9] = formSchema;
|
|
78
76
|
$[10] = initialState;
|
|
79
77
|
$[11] = nodeKey;
|
|
80
|
-
$[12] =
|
|
78
|
+
$[12] = t1;
|
|
81
79
|
} else {
|
|
82
|
-
|
|
80
|
+
t1 = $[12];
|
|
83
81
|
}
|
|
84
|
-
return
|
|
82
|
+
return t1;
|
|
85
83
|
};
|
|
86
84
|
//# sourceMappingURL=BlockContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockContent.js","names":["c","_c","RenderFields","useFormSubmitted","React","createContext","useMemo","BlockComponentContext","initialState","useBlockComponentContext","use","BlockContent","props","$","BlockDrawer","Collapsible","CustomBlock","EditButton","errorCount","formSchema","nodeKey","RemoveButton","hasSubmitted","fieldHasErrors","t0","
|
|
1
|
+
{"version":3,"file":"BlockContent.js","names":["c","_c","RenderFields","useFormSubmitted","React","createContext","useMemo","BlockComponentContext","initialState","useBlockComponentContext","use","BlockContent","props","$","BlockDrawer","Collapsible","CustomBlock","EditButton","errorCount","formSchema","nodeKey","RemoveButton","hasSubmitted","fieldHasErrors","t0","props_0","_jsx","editButton","Label","removeButton","children","CollapsibleWithErrorProps","t1","_jsxs","value","BlockCollapsible","fields","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions"],"sources":["../../../../../src/features/blocks/client/component/BlockContent.tsx"],"sourcesContent":["'use client'\nimport type { ClientField, FormState } from 'payload'\n\nimport { RenderFields, useFormSubmitted } from '@payloadcms/ui'\nimport React, { createContext, useMemo } from 'react'\n\ntype Props = {\n baseClass: string\n BlockDrawer: React.FC\n Collapsible: React.FC<{\n children?: React.ReactNode\n editButton?: boolean\n errorCount?: number\n fieldHasErrors?: boolean\n /**\n * Override the default label with a custom label\n */\n Label?: React.ReactNode\n removeButton?: boolean\n }>\n CustomBlock: React.ReactNode\n EditButton: React.FC\n errorCount: number\n formSchema: ClientField[]\n initialState: false | FormState | undefined\n\n nodeKey: string\n RemoveButton: React.FC\n}\n\ntype BlockComponentContextType = {\n BlockCollapsible?: React.FC<{\n children?: React.ReactNode\n editButton?: boolean\n /**\n * Override the default label with a custom label\n */\n Label?: React.ReactNode\n removeButton?: boolean\n }>\n EditButton?: React.FC\n initialState: false | FormState | undefined\n\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst BlockComponentContext = createContext<BlockComponentContextType>({\n initialState: false,\n})\n\nexport const useBlockComponentContext = () => React.use(BlockComponentContext)\n\n/**\n * The actual content of the Block. This should be INSIDE a Form component,\n * scoped to the block. All format operations in here are thus scoped to the block's form, and\n * not the whole document.\n */\nexport const BlockContent: React.FC<Props> = (props) => {\n const {\n BlockDrawer,\n Collapsible,\n CustomBlock,\n EditButton,\n errorCount,\n formSchema,\n initialState,\n nodeKey,\n RemoveButton,\n } = props\n\n const hasSubmitted = useFormSubmitted()\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const CollapsibleWithErrorProps = useMemo(\n () =>\n (props: {\n children?: React.ReactNode\n editButton?: boolean\n\n /**\n * Override the default label with a custom label\n */\n Label?: React.ReactNode\n removeButton?: boolean\n }) => (\n <Collapsible\n editButton={props.editButton}\n errorCount={errorCount}\n fieldHasErrors={fieldHasErrors}\n Label={props.Label}\n removeButton={props.removeButton}\n >\n {props.children}\n </Collapsible>\n ),\n [Collapsible, fieldHasErrors, errorCount],\n )\n\n return CustomBlock ? (\n <BlockComponentContext\n value={{\n BlockCollapsible: CollapsibleWithErrorProps,\n EditButton,\n initialState,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n <BlockDrawer />\n </BlockComponentContext>\n ) : (\n <CollapsibleWithErrorProps>\n <RenderFields\n fields={formSchema}\n forceRender={true}\n parentIndexPath=\"\"\n parentPath={''}\n parentSchemaPath=\"\"\n permissions={true}\n />\n </CollapsibleWithErrorProps>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,YAAY,EAAEC,gBAAgB,QAAQ;AAC/C,OAAOC,KAAA,IAASC,aAAa,EAAEC,OAAO,QAAQ;AA2C9C,MAAMC,qBAAA,gBAAwBF,aAAA,CAAyC;EACrEG,YAAA,EAAc;AAChB;AAEA,OAAO,MAAMC,wBAAA,GAA2BA,CAAA,KAAML,KAAA,CAAMM,GAAG,CAACH,qBAAA;AAExD;;;;;AAKA,OAAO,MAAMI,YAAA,GAAgCC,KAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EAC3C;IAAAa,WAAA;IAAAC,WAAA;IAAAC,WAAA;IAAAC,UAAA;IAAAC,UAAA;IAAAC,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ignoreList":[]}
|
|
@@ -329,18 +329,16 @@ export const TableCellResizerPlugin = () => {
|
|
|
329
329
|
const [editor] = useLexicalComposerContext();
|
|
330
330
|
const isEditable = useLexicalEditable();
|
|
331
331
|
let t0;
|
|
332
|
-
let t1;
|
|
333
332
|
if ($[0] !== editor || $[1] !== isEditable) {
|
|
334
|
-
|
|
333
|
+
t0 = isEditable ? createPortal(_jsx(TableCellResizer, {
|
|
335
334
|
editor
|
|
336
335
|
}), document.body) : null;
|
|
337
336
|
$[0] = editor;
|
|
338
337
|
$[1] = isEditable;
|
|
339
|
-
$[2] =
|
|
338
|
+
$[2] = t0;
|
|
340
339
|
} else {
|
|
341
|
-
|
|
340
|
+
t0 = $[2];
|
|
342
341
|
}
|
|
343
|
-
t0 = t1;
|
|
344
342
|
return t0;
|
|
345
343
|
};
|
|
346
344
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$isTableCellNode","$isTableRowNode","getDOMCellFromTarget","getTableElement","TableNode","calculateZoomLevel","mergeRegister","$getNearestNodeFromDOMNode","isHTMLElement","SKIP_SCROLL_INTO_VIEW_TAG","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","useEditorConfigContext","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","TableCellResizer","editor","targetRef","resizerRef","tableRectRef","hasTable","setHasTable","editorConfig","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","current","isMouseDownOnEvent","event","buttons","tableKeys","Set","registerMutationListener","nodeMutations","nodeKey","mutation","delete","add","size","registerNodeTransform","tableNode","getColWidths","numColumns","getColumnCount","columnWidth","setColWidths","Array","fill","onMouseMove","target","x","clientX","y","clientY","contains","cell","getEditorState","read","tableCellNode","elem","Error","tableElement","getElementByKey","getKey","getBoundingClientRect","onMouseDown","onMouseUp","removeRootListener","registerRootListener","rootElement","prevRootElement","removeEventListener","addEventListener","isHeightChanging","direction","updateRowHeight","heightChange","update","baseRowIndex","tableRows","getChildren","isFullRowMerge","getColSpan","tableRowIndex","getRowSpan","length","tableRow","height","getHeight","undefined","rowCells","Math","min","map","getCellNodeHeight","Infinity","newHeight","max","setHeight","tag","activeEditor","domCellNode","clientHeight","getCellColumnIndex","tableMap","columnIndex","forEach","row","columnIndexInner","updateColumnWidth","widthChange","colWidths","width","newColWidths","newWidth","mouseUpHandler","handler","preventDefault","stopPropagation","zoom","document","toggleResize","resizerStyles","setResizerStyles","bottom","left","right","top","zoneWidth","styles","backgroundColor","cursor","window","scrollX","scrollY","tableRect","_jsx","ref","_jsxs","Fragment","className","lexical","theme","tableCellResizer","style","TableCellResizerPlugin","$","isEditable","t0","t1"],"sources":["../../../../../../src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableCellNode, TableDOMCell, TableMapType } from '@lexical/table'\nimport type { LexicalEditor, NodeKey } from 'lexical'\nimport type { JSX, MouseEventHandler } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $computeTableMapSkipCellCheck,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $isTableCellNode,\n $isTableRowNode,\n getDOMCellFromTarget,\n getTableElement,\n TableNode,\n} from '@lexical/table'\nimport { calculateZoomLevel, mergeRegister } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode, isHTMLElement, SKIP_SCROLL_INTO_VIEW_TAG } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport './index.scss'\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\n\ntype MousePosition = {\n x: number\n y: number\n}\n\ntype MouseDraggingDirection = 'bottom' | 'right'\n\nconst MIN_ROW_HEIGHT = 33\nconst MIN_COLUMN_WIDTH = 92\n\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\n const targetRef = useRef<HTMLElement | null>(null)\n const resizerRef = useRef<HTMLDivElement | null>(null)\n const tableRectRef = useRef<ClientRect | null>(null)\n const [hasTable, setHasTable] = useState(false)\n const editorConfig = useEditorConfigContext()\n\n const mouseStartPosRef = useRef<MousePosition | null>(null)\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null)\n\n const [activeCell, updateActiveCell] = useState<null | TableDOMCell>(null)\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false)\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null)\n\n const resetState = useCallback(() => {\n updateActiveCell(null)\n targetRef.current = null\n updateDraggingDirection(null)\n mouseStartPosRef.current = null\n tableRectRef.current = null\n }, [])\n\n const isMouseDownOnEvent = (event: MouseEvent) => {\n return (event.buttons & 1) === 1\n }\n\n useEffect(() => {\n const tableKeys = new Set<NodeKey>()\n return mergeRegister(\n editor.registerMutationListener(TableNode, (nodeMutations) => {\n for (const [nodeKey, mutation] of nodeMutations) {\n if (mutation === 'destroyed') {\n tableKeys.delete(nodeKey)\n } else {\n tableKeys.add(nodeKey)\n }\n }\n setHasTable(tableKeys.size > 0)\n }),\n editor.registerNodeTransform(TableNode, (tableNode) => {\n if (tableNode.getColWidths()) {\n return tableNode\n }\n\n const numColumns = tableNode.getColumnCount()\n const columnWidth = MIN_COLUMN_WIDTH\n\n tableNode.setColWidths(Array(numColumns).fill(columnWidth))\n return tableNode\n }),\n )\n }, [editor])\n\n useEffect(() => {\n if (!hasTable) {\n return\n }\n\n const onMouseMove = (event: MouseEvent) => {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n if (draggingDirection) {\n updateMouseCurrentPos({\n x: event.clientX,\n y: event.clientY,\n })\n return\n }\n updateIsMouseDown(isMouseDownOnEvent(event))\n if (resizerRef.current && resizerRef.current.contains(target)) {\n return\n }\n\n if (targetRef.current !== target) {\n targetRef.current = target\n const cell = getDOMCellFromTarget(target)\n\n if (cell && activeCell !== cell) {\n editor.getEditorState().read(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem)\n\n if (!tableCellNode) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const tableElement = getTableElement(\n tableNode,\n editor.getElementByKey(tableNode.getKey()),\n )\n if (!tableElement) {\n throw new Error('TableCellResizer: Table element not found.')\n }\n\n targetRef.current = target\n tableRectRef.current = tableElement.getBoundingClientRect()\n updateActiveCell(cell)\n },\n { editor },\n )\n } else if (cell == null) {\n resetState()\n }\n }\n }\n\n const onMouseDown = (event: MouseEvent) => {\n updateIsMouseDown(true)\n }\n\n const onMouseUp = (event: MouseEvent) => {\n updateIsMouseDown(false)\n }\n\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\n prevRootElement?.removeEventListener('mousemove', onMouseMove)\n prevRootElement?.removeEventListener('mousedown', onMouseDown)\n prevRootElement?.removeEventListener('mouseup', onMouseUp)\n rootElement?.addEventListener('mousemove', onMouseMove)\n rootElement?.addEventListener('mousedown', onMouseDown)\n rootElement?.addEventListener('mouseup', onMouseUp)\n })\n\n return () => {\n removeRootListener()\n }\n }, [activeCell, draggingDirection, editor, hasTable, resetState])\n\n const isHeightChanging = (direction: MouseDraggingDirection) => {\n if (direction === 'bottom') {\n return true\n }\n return false\n }\n\n const updateRowHeight = useCallback(\n (heightChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const baseRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode)\n const tableRows = tableNode.getChildren()\n\n // Determine if this is a full row merge by checking colspan\n const isFullRowMerge = tableCellNode.getColSpan() === tableNode.getColumnCount()\n\n // For full row merges, apply to first row. For partial merges, apply to last row\n const tableRowIndex = isFullRowMerge\n ? baseRowIndex\n : baseRowIndex + tableCellNode.getRowSpan() - 1\n\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\n throw new Error('Expected table cell to be inside of table row.')\n }\n\n const tableRow = tableRows[tableRowIndex]\n\n if (!$isTableRowNode(tableRow)) {\n throw new Error('Expected table row')\n }\n\n let height = tableRow.getHeight()\n if (height === undefined) {\n const rowCells = tableRow.getChildren<TableCellNode>()\n height = Math.min(\n ...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity),\n )\n }\n\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT)\n tableRow.setHeight(newHeight)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const getCellNodeHeight = (\n cell: TableCellNode,\n activeEditor: LexicalEditor,\n ): number | undefined => {\n const domCellNode = activeEditor.getElementByKey(cell.getKey())\n return domCellNode?.clientHeight\n }\n\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\n let columnIndex: number | undefined\n tableMap.forEach((row) => {\n row.forEach((cell, columnIndexInner) => {\n if (cell.cell === tableCellNode) {\n columnIndex = columnIndexInner\n }\n })\n })\n return columnIndex\n }\n\n const updateColumnWidth = useCallback(\n (widthChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap)\n if (columnIndex === undefined) {\n throw new Error('TableCellResizer: Table column not found.')\n }\n\n const colWidths = tableNode.getColWidths()\n if (!colWidths) {\n return\n }\n const width = colWidths[columnIndex]\n if (width === undefined) {\n return\n }\n const newColWidths = [...colWidths]\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH)\n newColWidths[columnIndex] = newWidth\n tableNode.setColWidths(newColWidths)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const mouseUpHandler = useCallback(\n (direction: MouseDraggingDirection) => {\n const handler = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n if (mouseStartPosRef.current) {\n const { x, y } = mouseStartPosRef.current\n\n if (activeCell === null) {\n return\n }\n const zoom = calculateZoomLevel(event.target as Element)\n\n if (isHeightChanging(direction)) {\n const heightChange = (event.clientY - y) / zoom\n updateRowHeight(heightChange)\n } else {\n const widthChange = (event.clientX - x) / zoom\n updateColumnWidth(widthChange)\n }\n\n resetState()\n document.removeEventListener('mouseup', handler)\n }\n }\n return handler\n },\n [activeCell, resetState, updateColumnWidth, updateRowHeight],\n )\n\n const toggleResize = useCallback(\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\n (event) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n mouseStartPosRef.current = {\n x: event.clientX,\n y: event.clientY,\n }\n updateMouseCurrentPos(mouseStartPosRef.current)\n updateDraggingDirection(direction)\n\n document.addEventListener('mouseup', mouseUpHandler(direction))\n },\n [activeCell, mouseUpHandler],\n )\n\n const [resizerStyles, setResizerStyles] = useState<{\n bottom?: null | React.CSSProperties\n left?: null | React.CSSProperties\n right?: null | React.CSSProperties\n top?: null | React.CSSProperties\n }>({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n\n useEffect(() => {\n if (activeCell) {\n const { height, left, top, width } = activeCell.elem.getBoundingClientRect()\n const zoom = calculateZoomLevel(activeCell.elem)\n const zoneWidth = 10 // Pixel width of the zone where you can drag the edge\n const styles = {\n bottom: {\n backgroundColor: 'none',\n cursor: 'row-resize',\n height: `${zoneWidth}px`,\n left: `${window.scrollX + left}px`,\n top: `${window.scrollY + top + height - zoneWidth / 2}px`,\n width: `${width}px`,\n },\n right: {\n backgroundColor: 'none',\n cursor: 'col-resize',\n height: `${height}px`,\n left: `${window.scrollX + left + width - zoneWidth / 2}px`,\n top: `${window.scrollY + top}px`,\n width: `${zoneWidth}px`,\n },\n }\n\n const tableRect = tableRectRef.current\n\n if (draggingDirection && mouseCurrentPos && tableRect) {\n if (isHeightChanging(draggingDirection)) {\n styles[draggingDirection].left = `${window.scrollX + tableRect.left}px`\n styles[draggingDirection].top = `${window.scrollY + mouseCurrentPos.y / zoom}px`\n styles[draggingDirection].height = '3px'\n styles[draggingDirection].width = `${tableRect.width}px`\n } else {\n styles[draggingDirection].top = `${window.scrollY + tableRect.top}px`\n styles[draggingDirection].left = `${window.scrollX + mouseCurrentPos.x / zoom}px`\n styles[draggingDirection].width = '3px'\n styles[draggingDirection].height = `${tableRect.height}px`\n }\n\n styles[draggingDirection].backgroundColor = '#adf'\n }\n\n setResizerStyles(styles)\n } else {\n setResizerStyles({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n }\n }, [activeCell, draggingDirection, mouseCurrentPos])\n\n return (\n <div ref={resizerRef}>\n {activeCell != null && !isMouseDown && (\n <React.Fragment>\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('right')}\n style={resizerStyles.right || undefined}\n />\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('bottom')}\n style={resizerStyles.bottom || undefined}\n />\n </React.Fragment>\n )}\n </div>\n )\n}\n\nexport const TableCellResizerPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n return useMemo(\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\n [editor, isEditable],\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAMA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SACEC,6BAA6B,EAC7BC,mCAAmC,EACnCC,kCAAkC,EAClCC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,EACpBC,eAAe,EACfC,SAAS,QACJ;AACP,SAASC,kBAAkB,EAAEC,aAAa,QAAQ;AAClD,SAASC,0BAA0B,EAAEC,aAAa,EAAEC,yBAAyB,QAAQ;AACrF,YAAYC,KAAA,MAAW;AACvB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAClE,SAASC,YAAY,QAAQ;AAK7B,SAASC,sBAAsB,QAAQ;AASvC,MAAMC,cAAA,GAAiB;AACvB,MAAMC,gBAAA,GAAmB;AAEzB,SAASC,iBAAiB;EAAEC;AAAM,CAA6B;EAC7D,MAAMC,SAAA,GAAYR,MAAA,CAA2B;EAC7C,MAAMS,UAAA,GAAaT,MAAA,CAA8B;EACjD,MAAMU,YAAA,GAAeV,MAAA,CAA0B;EAC/C,MAAM,CAACW,QAAA,EAAUC,WAAA,CAAY,GAAGX,QAAA,CAAS;EACzC,MAAMY,YAAA,GAAeV,sBAAA;EAErB,MAAMW,gBAAA,GAAmBd,MAAA,CAA6B;EACtD,MAAM,CAACe,eAAA,EAAiBC,qBAAA,CAAsB,GAAGf,QAAA,CAA+B;EAEhF,MAAM,CAACgB,UAAA,EAAYC,gBAAA,CAAiB,GAAGjB,QAAA,CAA8B;EACr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;IAAIC,GAAA,EAAK9H,UAAA;cACPQ,UAAA,IAAc,QAAQ,CAACE,WAAA,iBACtBqH,KAAA,CAAC5I,KAAA,CAAM6I,QAAQ;8BACbH,IAAA,CAAC;QACCI,SAAA,EAAW,GAAG7H,YAAA,CAAaA,YAAY,CAAC8H,OAAO,CAACC,KAAK,CAACC,gBAAgB,uBAAuB;QAC7F9E,WAAA,EAAawD,YAAA,CAAa;QAC1BuB,KAAA,EAAOtB,aAAA,CAAcI,KAAK,IAAIrC;uBAEhC+C,IAAA,CAAC;QACCI,SAAA,EAAW,GAAG7H,YAAA,CAAaA,YAAY,CAAC8H,OAAO,CAACC,KAAK,CAACC,gBAAgB,uBAAuB;QAC7F9E,WAAA,EAAawD,YAAA,CAAa;QAC1BuB,KAAA,EAAOtB,aAAA,CAAcE,MAAM,IAAInC;;;;AAM3C;AAEA,OAAO,MAAMwD,sBAAA,GAA0CA,CAAA;EAAA,MAAAC,CAAA,GAAApK,EAAA;EACrD,OAAA2B,MAAA,IAAiB1B,yBAAA;EACjB,MAAAoK,UAAA,GAAmBnK,kBAAA;EAAA,IAAAoK,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAH,CAAA,QAAAzI,MAAA,IAAAyI,CAAA,QAAAC,UAAA;IAGVE,EAAA,GAAAF,UAAA,GAAa/I,YAAA,CAAaoI,IAAA,CAAAhI,gBAAA;MAAAC;IAAA,C,gBAAmD,QAAI;IAAAyI,CAAA,MAAAzI,MAAA;IAAAyI,CAAA,MAAAC,UAAA;IAAAD,CAAA,MAAAG,EAAA;EAAA;IAAAA,EAAA,GAAAH,CAAA;EAAA;EAAAE,EAAA,GAAjFC,EAAiF;EAAA,OADnFD,EAEe;AAAA,CAExB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$isTableCellNode","$isTableRowNode","getDOMCellFromTarget","getTableElement","TableNode","calculateZoomLevel","mergeRegister","$getNearestNodeFromDOMNode","isHTMLElement","SKIP_SCROLL_INTO_VIEW_TAG","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","useEditorConfigContext","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","TableCellResizer","editor","targetRef","resizerRef","tableRectRef","hasTable","setHasTable","editorConfig","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","current","isMouseDownOnEvent","event","buttons","tableKeys","Set","registerMutationListener","nodeMutations","nodeKey","mutation","delete","add","size","registerNodeTransform","tableNode","getColWidths","numColumns","getColumnCount","columnWidth","setColWidths","Array","fill","onMouseMove","target","x","clientX","y","clientY","contains","cell","getEditorState","read","tableCellNode","elem","Error","tableElement","getElementByKey","getKey","getBoundingClientRect","onMouseDown","onMouseUp","removeRootListener","registerRootListener","rootElement","prevRootElement","removeEventListener","addEventListener","isHeightChanging","direction","updateRowHeight","heightChange","update","baseRowIndex","tableRows","getChildren","isFullRowMerge","getColSpan","tableRowIndex","getRowSpan","length","tableRow","height","getHeight","undefined","rowCells","Math","min","map","getCellNodeHeight","Infinity","newHeight","max","setHeight","tag","activeEditor","domCellNode","clientHeight","getCellColumnIndex","tableMap","columnIndex","forEach","row","columnIndexInner","updateColumnWidth","widthChange","colWidths","width","newColWidths","newWidth","mouseUpHandler","handler","preventDefault","stopPropagation","zoom","document","toggleResize","resizerStyles","setResizerStyles","bottom","left","right","top","zoneWidth","styles","backgroundColor","cursor","window","scrollX","scrollY","tableRect","_jsx","ref","_jsxs","Fragment","className","lexical","theme","tableCellResizer","style","TableCellResizerPlugin","$","isEditable","t0"],"sources":["../../../../../../src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableCellNode, TableDOMCell, TableMapType } from '@lexical/table'\nimport type { LexicalEditor, NodeKey } from 'lexical'\nimport type { JSX, MouseEventHandler } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $computeTableMapSkipCellCheck,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $isTableCellNode,\n $isTableRowNode,\n getDOMCellFromTarget,\n getTableElement,\n TableNode,\n} from '@lexical/table'\nimport { calculateZoomLevel, mergeRegister } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode, isHTMLElement, SKIP_SCROLL_INTO_VIEW_TAG } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport './index.scss'\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\n\ntype MousePosition = {\n x: number\n y: number\n}\n\ntype MouseDraggingDirection = 'bottom' | 'right'\n\nconst MIN_ROW_HEIGHT = 33\nconst MIN_COLUMN_WIDTH = 92\n\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\n const targetRef = useRef<HTMLElement | null>(null)\n const resizerRef = useRef<HTMLDivElement | null>(null)\n const tableRectRef = useRef<ClientRect | null>(null)\n const [hasTable, setHasTable] = useState(false)\n const editorConfig = useEditorConfigContext()\n\n const mouseStartPosRef = useRef<MousePosition | null>(null)\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null)\n\n const [activeCell, updateActiveCell] = useState<null | TableDOMCell>(null)\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false)\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null)\n\n const resetState = useCallback(() => {\n updateActiveCell(null)\n targetRef.current = null\n updateDraggingDirection(null)\n mouseStartPosRef.current = null\n tableRectRef.current = null\n }, [])\n\n const isMouseDownOnEvent = (event: MouseEvent) => {\n return (event.buttons & 1) === 1\n }\n\n useEffect(() => {\n const tableKeys = new Set<NodeKey>()\n return mergeRegister(\n editor.registerMutationListener(TableNode, (nodeMutations) => {\n for (const [nodeKey, mutation] of nodeMutations) {\n if (mutation === 'destroyed') {\n tableKeys.delete(nodeKey)\n } else {\n tableKeys.add(nodeKey)\n }\n }\n setHasTable(tableKeys.size > 0)\n }),\n editor.registerNodeTransform(TableNode, (tableNode) => {\n if (tableNode.getColWidths()) {\n return tableNode\n }\n\n const numColumns = tableNode.getColumnCount()\n const columnWidth = MIN_COLUMN_WIDTH\n\n tableNode.setColWidths(Array(numColumns).fill(columnWidth))\n return tableNode\n }),\n )\n }, [editor])\n\n useEffect(() => {\n if (!hasTable) {\n return\n }\n\n const onMouseMove = (event: MouseEvent) => {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n if (draggingDirection) {\n updateMouseCurrentPos({\n x: event.clientX,\n y: event.clientY,\n })\n return\n }\n updateIsMouseDown(isMouseDownOnEvent(event))\n if (resizerRef.current && resizerRef.current.contains(target)) {\n return\n }\n\n if (targetRef.current !== target) {\n targetRef.current = target\n const cell = getDOMCellFromTarget(target)\n\n if (cell && activeCell !== cell) {\n editor.getEditorState().read(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem)\n\n if (!tableCellNode) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const tableElement = getTableElement(\n tableNode,\n editor.getElementByKey(tableNode.getKey()),\n )\n if (!tableElement) {\n throw new Error('TableCellResizer: Table element not found.')\n }\n\n targetRef.current = target\n tableRectRef.current = tableElement.getBoundingClientRect()\n updateActiveCell(cell)\n },\n { editor },\n )\n } else if (cell == null) {\n resetState()\n }\n }\n }\n\n const onMouseDown = (event: MouseEvent) => {\n updateIsMouseDown(true)\n }\n\n const onMouseUp = (event: MouseEvent) => {\n updateIsMouseDown(false)\n }\n\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\n prevRootElement?.removeEventListener('mousemove', onMouseMove)\n prevRootElement?.removeEventListener('mousedown', onMouseDown)\n prevRootElement?.removeEventListener('mouseup', onMouseUp)\n rootElement?.addEventListener('mousemove', onMouseMove)\n rootElement?.addEventListener('mousedown', onMouseDown)\n rootElement?.addEventListener('mouseup', onMouseUp)\n })\n\n return () => {\n removeRootListener()\n }\n }, [activeCell, draggingDirection, editor, hasTable, resetState])\n\n const isHeightChanging = (direction: MouseDraggingDirection) => {\n if (direction === 'bottom') {\n return true\n }\n return false\n }\n\n const updateRowHeight = useCallback(\n (heightChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const baseRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode)\n const tableRows = tableNode.getChildren()\n\n // Determine if this is a full row merge by checking colspan\n const isFullRowMerge = tableCellNode.getColSpan() === tableNode.getColumnCount()\n\n // For full row merges, apply to first row. For partial merges, apply to last row\n const tableRowIndex = isFullRowMerge\n ? baseRowIndex\n : baseRowIndex + tableCellNode.getRowSpan() - 1\n\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\n throw new Error('Expected table cell to be inside of table row.')\n }\n\n const tableRow = tableRows[tableRowIndex]\n\n if (!$isTableRowNode(tableRow)) {\n throw new Error('Expected table row')\n }\n\n let height = tableRow.getHeight()\n if (height === undefined) {\n const rowCells = tableRow.getChildren<TableCellNode>()\n height = Math.min(\n ...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity),\n )\n }\n\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT)\n tableRow.setHeight(newHeight)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const getCellNodeHeight = (\n cell: TableCellNode,\n activeEditor: LexicalEditor,\n ): number | undefined => {\n const domCellNode = activeEditor.getElementByKey(cell.getKey())\n return domCellNode?.clientHeight\n }\n\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\n let columnIndex: number | undefined\n tableMap.forEach((row) => {\n row.forEach((cell, columnIndexInner) => {\n if (cell.cell === tableCellNode) {\n columnIndex = columnIndexInner\n }\n })\n })\n return columnIndex\n }\n\n const updateColumnWidth = useCallback(\n (widthChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap)\n if (columnIndex === undefined) {\n throw new Error('TableCellResizer: Table column not found.')\n }\n\n const colWidths = tableNode.getColWidths()\n if (!colWidths) {\n return\n }\n const width = colWidths[columnIndex]\n if (width === undefined) {\n return\n }\n const newColWidths = [...colWidths]\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH)\n newColWidths[columnIndex] = newWidth\n tableNode.setColWidths(newColWidths)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const mouseUpHandler = useCallback(\n (direction: MouseDraggingDirection) => {\n const handler = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n if (mouseStartPosRef.current) {\n const { x, y } = mouseStartPosRef.current\n\n if (activeCell === null) {\n return\n }\n const zoom = calculateZoomLevel(event.target as Element)\n\n if (isHeightChanging(direction)) {\n const heightChange = (event.clientY - y) / zoom\n updateRowHeight(heightChange)\n } else {\n const widthChange = (event.clientX - x) / zoom\n updateColumnWidth(widthChange)\n }\n\n resetState()\n document.removeEventListener('mouseup', handler)\n }\n }\n return handler\n },\n [activeCell, resetState, updateColumnWidth, updateRowHeight],\n )\n\n const toggleResize = useCallback(\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\n (event) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n mouseStartPosRef.current = {\n x: event.clientX,\n y: event.clientY,\n }\n updateMouseCurrentPos(mouseStartPosRef.current)\n updateDraggingDirection(direction)\n\n document.addEventListener('mouseup', mouseUpHandler(direction))\n },\n [activeCell, mouseUpHandler],\n )\n\n const [resizerStyles, setResizerStyles] = useState<{\n bottom?: null | React.CSSProperties\n left?: null | React.CSSProperties\n right?: null | React.CSSProperties\n top?: null | React.CSSProperties\n }>({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n\n useEffect(() => {\n if (activeCell) {\n const { height, left, top, width } = activeCell.elem.getBoundingClientRect()\n const zoom = calculateZoomLevel(activeCell.elem)\n const zoneWidth = 10 // Pixel width of the zone where you can drag the edge\n const styles = {\n bottom: {\n backgroundColor: 'none',\n cursor: 'row-resize',\n height: `${zoneWidth}px`,\n left: `${window.scrollX + left}px`,\n top: `${window.scrollY + top + height - zoneWidth / 2}px`,\n width: `${width}px`,\n },\n right: {\n backgroundColor: 'none',\n cursor: 'col-resize',\n height: `${height}px`,\n left: `${window.scrollX + left + width - zoneWidth / 2}px`,\n top: `${window.scrollY + top}px`,\n width: `${zoneWidth}px`,\n },\n }\n\n const tableRect = tableRectRef.current\n\n if (draggingDirection && mouseCurrentPos && tableRect) {\n if (isHeightChanging(draggingDirection)) {\n styles[draggingDirection].left = `${window.scrollX + tableRect.left}px`\n styles[draggingDirection].top = `${window.scrollY + mouseCurrentPos.y / zoom}px`\n styles[draggingDirection].height = '3px'\n styles[draggingDirection].width = `${tableRect.width}px`\n } else {\n styles[draggingDirection].top = `${window.scrollY + tableRect.top}px`\n styles[draggingDirection].left = `${window.scrollX + mouseCurrentPos.x / zoom}px`\n styles[draggingDirection].width = '3px'\n styles[draggingDirection].height = `${tableRect.height}px`\n }\n\n styles[draggingDirection].backgroundColor = '#adf'\n }\n\n setResizerStyles(styles)\n } else {\n setResizerStyles({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n }\n }, [activeCell, draggingDirection, mouseCurrentPos])\n\n return (\n <div ref={resizerRef}>\n {activeCell != null && !isMouseDown && (\n <React.Fragment>\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('right')}\n style={resizerStyles.right || undefined}\n />\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('bottom')}\n style={resizerStyles.bottom || undefined}\n />\n </React.Fragment>\n )}\n </div>\n )\n}\n\nexport const TableCellResizerPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n return useMemo(\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\n [editor, isEditable],\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAMA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SACEC,6BAA6B,EAC7BC,mCAAmC,EACnCC,kCAAkC,EAClCC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,EACpBC,eAAe,EACfC,SAAS,QACJ;AACP,SAASC,kBAAkB,EAAEC,aAAa,QAAQ;AAClD,SAASC,0BAA0B,EAAEC,aAAa,EAAEC,yBAAyB,QAAQ;AACrF,YAAYC,KAAA,MAAW;AACvB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAClE,SAASC,YAAY,QAAQ;AAK7B,SAASC,sBAAsB,Q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AA,IAAAyI,CAAA,QAAAC,UAAA;IAGVC,EAAA,GAAAD,UAAA,GAAa/I,YAAA,CAAaoI,IAAA,CAAAhI,gBAAA;MAAAC;IAAA,C,gBAAmD,QAAI;IAAAyI,CAAA,MAAAzI,MAAA;IAAAyI,CAAA,MAAAC,UAAA;IAAAD,CAAA,MAAAE,EAAA;EAAA;IAAAA,EAAA,GAAAF,CAAA;EAAA;EAAA,OAAjFE,EAAiF;AAAA,CAG5F","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/heading/client/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/heading/client/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AA2B7D,eAAO,MAAM,oBAAoB,wGAmF/B,CAAA"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
5
|
import { $createHeadingNode, $isHeadingNode, HeadingNode } from '@lexical/rich-text';
|
|
4
6
|
import { $setBlocksType } from '@lexical/selection';
|
|
5
7
|
import { $getSelection, $isRangeSelection } from 'lexical';
|
|
8
|
+
import { useEffect } from 'react';
|
|
6
9
|
import { H1Icon } from '../../../lexical/ui/icons/H1/index.js';
|
|
7
10
|
import { H2Icon } from '../../../lexical/ui/icons/H2/index.js';
|
|
8
11
|
import { H3Icon } from '../../../lexical/ui/icons/H3/index.js';
|
|
@@ -73,6 +76,10 @@ export const HeadingFeatureClient = createClientFeature(({
|
|
|
73
76
|
return {
|
|
74
77
|
markdownTransformers: [MarkdownTransformer(enabledHeadingSizes)],
|
|
75
78
|
nodes: [HeadingNode],
|
|
79
|
+
plugins: [{
|
|
80
|
+
Component: HeadingPlugin,
|
|
81
|
+
position: 'normal'
|
|
82
|
+
}],
|
|
76
83
|
sanitizedClientFeatureProps: props,
|
|
77
84
|
slashMenu: {
|
|
78
85
|
groups: enabledHeadingSizes?.length ? [slashMenuBasicGroupWithItems(enabledHeadingSizes.map(headingSize => {
|
|
@@ -105,4 +112,57 @@ export const HeadingFeatureClient = createClientFeature(({
|
|
|
105
112
|
}
|
|
106
113
|
};
|
|
107
114
|
});
|
|
115
|
+
const HeadingPlugin = t0 => {
|
|
116
|
+
const $ = _c(9);
|
|
117
|
+
const {
|
|
118
|
+
clientProps
|
|
119
|
+
} = t0;
|
|
120
|
+
const {
|
|
121
|
+
enabledHeadingSizes: t1
|
|
122
|
+
} = clientProps;
|
|
123
|
+
let t2;
|
|
124
|
+
if ($[0] !== t1) {
|
|
125
|
+
t2 = t1 === undefined ? ["h1", "h2", "h3", "h4", "h5", "h6"] : t1;
|
|
126
|
+
$[0] = t1;
|
|
127
|
+
$[1] = t2;
|
|
128
|
+
} else {
|
|
129
|
+
t2 = $[1];
|
|
130
|
+
}
|
|
131
|
+
const enabledHeadingSizes = t2;
|
|
132
|
+
let t3;
|
|
133
|
+
if ($[2] !== enabledHeadingSizes) {
|
|
134
|
+
t3 = enabledHeadingSizes.at(-1);
|
|
135
|
+
$[2] = enabledHeadingSizes;
|
|
136
|
+
$[3] = t3;
|
|
137
|
+
} else {
|
|
138
|
+
t3 = $[3];
|
|
139
|
+
}
|
|
140
|
+
const lowestAllowed = t3;
|
|
141
|
+
const [editor] = useLexicalComposerContext();
|
|
142
|
+
let t4;
|
|
143
|
+
let t5;
|
|
144
|
+
if ($[4] !== editor || $[5] !== enabledHeadingSizes || $[6] !== lowestAllowed) {
|
|
145
|
+
t4 = () => {
|
|
146
|
+
if (!lowestAllowed || enabledHeadingSizes.length === 6) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
return editor.registerNodeTransform(HeadingNode, node => {
|
|
150
|
+
if (!enabledHeadingSizes.includes(node.getTag())) {
|
|
151
|
+
node.setTag(lowestAllowed);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
t5 = [editor, enabledHeadingSizes, lowestAllowed];
|
|
156
|
+
$[4] = editor;
|
|
157
|
+
$[5] = enabledHeadingSizes;
|
|
158
|
+
$[6] = lowestAllowed;
|
|
159
|
+
$[7] = t4;
|
|
160
|
+
$[8] = t5;
|
|
161
|
+
} else {
|
|
162
|
+
t4 = $[7];
|
|
163
|
+
t5 = $[8];
|
|
164
|
+
}
|
|
165
|
+
useEffect(t4, t5);
|
|
166
|
+
return null;
|
|
167
|
+
};
|
|
108
168
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["$createHeadingNode","$isHeadingNode","HeadingNode","$setBlocksType","$getSelection","$isRangeSelection","H1Icon","H2Icon","H3Icon","H4Icon","H5Icon","H6Icon","createClientFeature","slashMenuBasicGroupWithItems","toolbarTextDropdownGroupWithItems","MarkdownTransformer","$setHeading","headingSize","selection","iconImports","h1","h2","h3","h4","h5","h6","HeadingFeatureClient","props","enabledHeadingSizes","toolbarGroups","map","i","ChildComponent","isActive","node","getNodes","getTag","parent","getParent","key","label","i18n","t","headingLevel","charAt","onSelect","editor","update","order","markdownTransformers","nodes","sanitizedClientFeatureProps","slashMenu","groups","length","Icon","keywords","toolbarFixed","toolbarInline"],"sources":["../../../../src/features/heading/client/index.tsx"],"sourcesContent":["'use client'\n\nimport type { HeadingTagType } from '@lexical/rich-text'\n\nimport { $createHeadingNode, $isHeadingNode, HeadingNode } from '@lexical/rich-text'\nimport { $setBlocksType } from '@lexical/selection'\nimport { $getSelection, $isRangeSelection } from 'lexical'\n\nimport type { ToolbarGroup } from '../../toolbars/types.js'\nimport type { HeadingFeatureProps } from '../server/index.js'\n\nimport { H1Icon } from '../../../lexical/ui/icons/H1/index.js'\nimport { H2Icon } from '../../../lexical/ui/icons/H2/index.js'\nimport { H3Icon } from '../../../lexical/ui/icons/H3/index.js'\nimport { H4Icon } from '../../../lexical/ui/icons/H4/index.js'\nimport { H5Icon } from '../../../lexical/ui/icons/H5/index.js'\nimport { H6Icon } from '../../../lexical/ui/icons/H6/index.js'\nimport { createClientFeature } from '../../../utilities/createClientFeature.js'\nimport { slashMenuBasicGroupWithItems } from '../../shared/slashMenu/basicGroup.js'\nimport { toolbarTextDropdownGroupWithItems } from '../../shared/toolbar/textDropdownGroup.js'\nimport { MarkdownTransformer } from '../markdownTransformer.js'\n\nconst $setHeading = (headingSize: HeadingTagType) => {\n const selection = $getSelection()\n $setBlocksType(selection, () => $createHeadingNode(headingSize))\n}\n\nconst iconImports = {\n h1: H1Icon,\n h2: H2Icon,\n h3: H3Icon,\n h4: H4Icon,\n h5: H5Icon,\n h6: H6Icon,\n}\n\nexport const HeadingFeatureClient = createClientFeature<HeadingFeatureProps>(({ props }) => {\n const { enabledHeadingSizes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] } = props\n\n const toolbarGroups: ToolbarGroup[] = [\n toolbarTextDropdownGroupWithItems(\n enabledHeadingSizes.map((headingSize, i) => {\n return {\n ChildComponent: iconImports[headingSize],\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isHeadingNode(node) && node.getTag() === headingSize) {\n continue\n }\n\n const parent = node.getParent()\n if ($isHeadingNode(parent) && parent.getTag() === headingSize) {\n continue\n }\n\n return false\n }\n return true\n },\n key: headingSize,\n label: ({ i18n }) => {\n return i18n.t('lexical:heading:label', { headingLevel: headingSize.charAt(1) })\n },\n onSelect: ({ editor }) => {\n editor.update(() => {\n $setHeading(headingSize)\n })\n },\n order: i + 2,\n }\n }),\n ),\n ]\n\n return {\n markdownTransformers: [MarkdownTransformer(enabledHeadingSizes)],\n nodes: [HeadingNode],\n sanitizedClientFeatureProps: props,\n slashMenu: {\n groups: enabledHeadingSizes?.length\n ? [\n slashMenuBasicGroupWithItems(\n enabledHeadingSizes.map((headingSize) => {\n return {\n Icon: iconImports[headingSize],\n key: `heading-${headingSize.charAt(1)}`,\n keywords: ['heading', headingSize],\n label: ({ i18n }) => {\n return i18n.t('lexical:heading:label', {\n headingLevel: headingSize.charAt(1),\n })\n },\n onSelect: ({ editor }) => {\n editor.update(() => {\n $setHeading(headingSize)\n })\n },\n }\n }),\n ),\n ]\n : [],\n },\n toolbarFixed: {\n groups: enabledHeadingSizes?.length ? toolbarGroups : [],\n },\n toolbarInline: {\n groups: enabledHeadingSizes?.length ? toolbarGroups : [],\n },\n }\n})\n"],"mappings":"AAAA;;AAIA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$createHeadingNode","$isHeadingNode","HeadingNode","$setBlocksType","$getSelection","$isRangeSelection","useEffect","H1Icon","H2Icon","H3Icon","H4Icon","H5Icon","H6Icon","createClientFeature","slashMenuBasicGroupWithItems","toolbarTextDropdownGroupWithItems","MarkdownTransformer","$setHeading","headingSize","selection","iconImports","h1","h2","h3","h4","h5","h6","HeadingFeatureClient","props","enabledHeadingSizes","toolbarGroups","map","i","ChildComponent","isActive","node","getNodes","getTag","parent","getParent","key","label","i18n","t","headingLevel","charAt","onSelect","editor","update","order","markdownTransformers","nodes","plugins","Component","HeadingPlugin","position","sanitizedClientFeatureProps","slashMenu","groups","length","Icon","keywords","toolbarFixed","toolbarInline","t0","$","clientProps","t1","t2","undefined","t3","at","lowestAllowed","t4","t5","registerNodeTransform","includes","setTag"],"sources":["../../../../src/features/heading/client/index.tsx"],"sourcesContent":["'use client'\n\nimport type { HeadingTagType } from '@lexical/rich-text'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $createHeadingNode, $isHeadingNode, HeadingNode } from '@lexical/rich-text'\nimport { $setBlocksType } from '@lexical/selection'\nimport { $getSelection, $isRangeSelection } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { ToolbarGroup } from '../../toolbars/types.js'\nimport type { PluginComponent } from '../../typesClient.js'\nimport type { HeadingFeatureProps } from '../server/index.js'\n\nimport { H1Icon } from '../../../lexical/ui/icons/H1/index.js'\nimport { H2Icon } from '../../../lexical/ui/icons/H2/index.js'\nimport { H3Icon } from '../../../lexical/ui/icons/H3/index.js'\nimport { H4Icon } from '../../../lexical/ui/icons/H4/index.js'\nimport { H5Icon } from '../../../lexical/ui/icons/H5/index.js'\nimport { H6Icon } from '../../../lexical/ui/icons/H6/index.js'\nimport { createClientFeature } from '../../../utilities/createClientFeature.js'\nimport { slashMenuBasicGroupWithItems } from '../../shared/slashMenu/basicGroup.js'\nimport { toolbarTextDropdownGroupWithItems } from '../../shared/toolbar/textDropdownGroup.js'\nimport { MarkdownTransformer } from '../markdownTransformer.js'\n\nconst $setHeading = (headingSize: HeadingTagType) => {\n const selection = $getSelection()\n $setBlocksType(selection, () => $createHeadingNode(headingSize))\n}\n\nconst iconImports = {\n h1: H1Icon,\n h2: H2Icon,\n h3: H3Icon,\n h4: H4Icon,\n h5: H5Icon,\n h6: H6Icon,\n}\n\nexport const HeadingFeatureClient = createClientFeature<HeadingFeatureProps>(({ props }) => {\n const { enabledHeadingSizes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] } = props\n\n const toolbarGroups: ToolbarGroup[] = [\n toolbarTextDropdownGroupWithItems(\n enabledHeadingSizes.map((headingSize, i) => {\n return {\n ChildComponent: iconImports[headingSize],\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isHeadingNode(node) && node.getTag() === headingSize) {\n continue\n }\n\n const parent = node.getParent()\n if ($isHeadingNode(parent) && parent.getTag() === headingSize) {\n continue\n }\n\n return false\n }\n return true\n },\n key: headingSize,\n label: ({ i18n }) => {\n return i18n.t('lexical:heading:label', { headingLevel: headingSize.charAt(1) })\n },\n onSelect: ({ editor }) => {\n editor.update(() => {\n $setHeading(headingSize)\n })\n },\n order: i + 2,\n }\n }),\n ),\n ]\n\n return {\n markdownTransformers: [MarkdownTransformer(enabledHeadingSizes)],\n nodes: [HeadingNode],\n plugins: [\n {\n Component: HeadingPlugin,\n position: 'normal',\n },\n ],\n sanitizedClientFeatureProps: props,\n slashMenu: {\n groups: enabledHeadingSizes?.length\n ? [\n slashMenuBasicGroupWithItems(\n enabledHeadingSizes.map((headingSize) => {\n return {\n Icon: iconImports[headingSize],\n key: `heading-${headingSize.charAt(1)}`,\n keywords: ['heading', headingSize],\n label: ({ i18n }) => {\n return i18n.t('lexical:heading:label', {\n headingLevel: headingSize.charAt(1),\n })\n },\n onSelect: ({ editor }) => {\n editor.update(() => {\n $setHeading(headingSize)\n })\n },\n }\n }),\n ),\n ]\n : [],\n },\n toolbarFixed: {\n groups: enabledHeadingSizes?.length ? toolbarGroups : [],\n },\n toolbarInline: {\n groups: enabledHeadingSizes?.length ? toolbarGroups : [],\n },\n }\n})\n\nconst HeadingPlugin: PluginComponent<HeadingFeatureProps> = ({ clientProps }) => {\n const { enabledHeadingSizes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] } = clientProps\n const lowestAllowed = enabledHeadingSizes.at(-1)\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n if (!lowestAllowed || enabledHeadingSizes.length === 6) {\n return\n }\n return editor.registerNodeTransform(HeadingNode, (node) => {\n if (!enabledHeadingSizes.includes(node.getTag())) {\n node.setTag(lowestAllowed)\n }\n })\n }, [editor, enabledHeadingSizes, lowestAllowed])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,EAAEC,cAAc,EAAEC,WAAW,QAAQ;AAChE,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,EAAEC,iBAAiB,QAAQ;AACjD,SAASC,SAAS,QAAQ;AAM1B,SAASC,MAAM,QAAQ;AACvB,SAASC,MAAM,QAAQ;AACvB,SAASC,MAAM,QAAQ;AACvB,SAASC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AAA,CAEhB;IAAA;IACCE,EAAA,IAAC3B,MAAA,EAAQlB,mBAAA,EAAqB2C,aAAA;IAAcP,CAAA,MAAAlB,MAAA;IAAAkB,CAAA,MAAApC,mBAAA;IAAAoC,CAAA,MAAAO,aAAA;IAAAP,CAAA,MAAAQ,EAAA;IAAAR,CAAA,MAAAS,EAAA;EAAA;IAAAD,EAAA,GAAAR,CAAA;IAAAS,EAAA,GAAAT,CAAA;EAAA;EAT/C3D,SAAA,CAAUmE,EASV,EAAGC,EAA4C;EAAA;AAAA,CAGjD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/heading/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,IAAI,sBAAsB,EAC/C,cAAc,EACf,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAUrC,MAAM,MAAM,qBAAqB,GAAG,MAAM,CACxC;IACE,IAAI,EAAE,SAAS,CAAA;CAChB,EACD,sBAAsB,CACvB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAA;CACvC,CAAA;AAED,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/heading/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,IAAI,sBAAsB,EAC/C,cAAc,EACf,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAUrC,MAAM,MAAM,qBAAqB,GAAG,MAAM,CACxC;IACE,IAAI,EAAE,SAAS,CAAA;CAChB,EACD,sBAAsB,CACvB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAA;CACvC,CAAA;AAED,eAAO,MAAM,cAAc,6HAsEzB,CAAA"}
|
|
@@ -14,6 +14,7 @@ export const HeadingFeature = createServerFeature({
|
|
|
14
14
|
const {
|
|
15
15
|
enabledHeadingSizes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
|
|
16
16
|
} = props;
|
|
17
|
+
enabledHeadingSizes.sort();
|
|
17
18
|
return {
|
|
18
19
|
ClientFeature: '@payloadcms/richtext-lexical/client#HeadingFeatureClient',
|
|
19
20
|
clientFeatureProps: props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["HeadingNode","createServerFeature","convertLexicalNodesToHTML","createNode","MarkdownTransformer","i18n","HeadingFeature","feature","props","enabledHeadingSizes","ClientFeature","clientFeatureProps","markdownTransformers","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","style","format","indent","filter","Boolean","join","tag","nodeTypes","getType","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/heading/server/index.ts"],"sourcesContent":["import type {\n SerializedHeadingNode as _SerializedHeadingNode,\n HeadingTagType,\n} from '@lexical/rich-text'\nimport type { Spread } from 'lexical'\n\nimport { HeadingNode } from '@lexical/rich-text'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../../converters/lexicalToHtml_deprecated/converter/index.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { MarkdownTransformer } from '../markdownTransformer.js'\nimport { i18n } from './i18n.js'\n\nexport type SerializedHeadingNode = Spread<\n {\n type: 'heading'\n },\n _SerializedHeadingNode\n>\n\nexport type HeadingFeatureProps = {\n enabledHeadingSizes?: HeadingTagType[]\n}\n\nexport const HeadingFeature = createServerFeature<\n HeadingFeatureProps,\n HeadingFeatureProps,\n HeadingFeatureProps\n>({\n feature: ({ props }) => {\n if (!props) {\n props = {}\n }\n\n const { enabledHeadingSizes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] } = props\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#HeadingFeatureClient',\n clientFeatureProps: props,\n i18n,\n markdownTransformers: [MarkdownTransformer(enabledHeadingSizes)],\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 const style = [\n node.format ? `text-align: ${node.format};` : '',\n // the unit should be px. Do not change it to rem, em, or something else.\n // The quantity should be 40px. Do not change it either.\n // See rationale in\n // https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085\n node.indent > 0 ? `padding-inline-start: ${node.indent * 40}px;` : '',\n ]\n .filter(Boolean)\n .join(' ')\n return `<${node?.tag}${style ? ` style='${style}'` : ''}>${childrenText}</${node?.tag}>`\n },\n nodeTypes: [HeadingNode.getType()],\n },\n },\n node: HeadingNode,\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'heading',\n})\n"],"mappings":"AAMA,SAASA,WAAW,QAAQ;AAE5B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,IAAI,QAAQ;AAarB,OAAO,MAAMC,cAAA,GAAiBL,mBAAA,CAI5B;EACAM,OAAA,EAASA,CAAC;IAAEC;EAAK,CAAE;IACjB,IAAI,CAACA,KAAA,EAAO;MACVA,KAAA,GAAQ,CAAC;IACX;IAEA,MAAM;MAAEC,mBAAA,GAAsB,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM;IAAK,CAAE,GAAGD,KAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["HeadingNode","createServerFeature","convertLexicalNodesToHTML","createNode","MarkdownTransformer","i18n","HeadingFeature","feature","props","enabledHeadingSizes","sort","ClientFeature","clientFeatureProps","markdownTransformers","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","style","format","indent","filter","Boolean","join","tag","nodeTypes","getType","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/heading/server/index.ts"],"sourcesContent":["import type {\n SerializedHeadingNode as _SerializedHeadingNode,\n HeadingTagType,\n} from '@lexical/rich-text'\nimport type { Spread } from 'lexical'\n\nimport { HeadingNode } from '@lexical/rich-text'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../../converters/lexicalToHtml_deprecated/converter/index.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { MarkdownTransformer } from '../markdownTransformer.js'\nimport { i18n } from './i18n.js'\n\nexport type SerializedHeadingNode = Spread<\n {\n type: 'heading'\n },\n _SerializedHeadingNode\n>\n\nexport type HeadingFeatureProps = {\n enabledHeadingSizes?: HeadingTagType[]\n}\n\nexport const HeadingFeature = createServerFeature<\n HeadingFeatureProps,\n HeadingFeatureProps,\n HeadingFeatureProps\n>({\n feature: ({ props }) => {\n if (!props) {\n props = {}\n }\n\n const { enabledHeadingSizes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] } = props\n\n enabledHeadingSizes.sort()\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#HeadingFeatureClient',\n clientFeatureProps: props,\n i18n,\n markdownTransformers: [MarkdownTransformer(enabledHeadingSizes)],\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 const style = [\n node.format ? `text-align: ${node.format};` : '',\n // the unit should be px. Do not change it to rem, em, or something else.\n // The quantity should be 40px. Do not change it either.\n // See rationale in\n // https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085\n node.indent > 0 ? `padding-inline-start: ${node.indent * 40}px;` : '',\n ]\n .filter(Boolean)\n .join(' ')\n return `<${node?.tag}${style ? ` style='${style}'` : ''}>${childrenText}</${node?.tag}>`\n },\n nodeTypes: [HeadingNode.getType()],\n },\n },\n node: HeadingNode,\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'heading',\n})\n"],"mappings":"AAMA,SAASA,WAAW,QAAQ;AAE5B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,IAAI,QAAQ;AAarB,OAAO,MAAMC,cAAA,GAAiBL,mBAAA,CAI5B;EACAM,OAAA,EAASA,CAAC;IAAEC;EAAK,CAAE;IACjB,IAAI,CAACA,KAAA,EAAO;MACVA,KAAA,GAAQ,CAAC;IACX;IAEA,MAAM;MAAEC,mBAAA,GAAsB,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM;IAAK,CAAE,GAAGD,KAAA;IAEvEC,mBAAA,CAAoBC,IAAI;IAExB,OAAO;MACLC,aAAA,EAAe;MACfC,kBAAA,EAAoBJ,KAAA;MACpBH,IAAA;MACAQ,oBAAA,EAAsB,CAACT,mBAAA,CAAoBK,mBAAA,EAAqB;MAChEK,KAAA,EAAO,CACLX,UAAA,CAAW;QACTY,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,MAAMxB,yBAAA,CAA0B;gBACnDa,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,MAAMI,KAAA,GAAQ,CACZR,IAAA,CAAKS,MAAM,GAAG,eAAeT,IAAA,CAAKS,MAAM,GAAG,GAAG;cAC9C;cACA;cACA;cACA;cACAT,IAAA,CAAKU,MAAM,GAAG,IAAI,yBAAyBV,IAAA,CAAKU,MAAM,GAAG,OAAO,GAAG,GACpE,CACEC,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;cACR,OAAO,IAAIb,IAAA,EAAMc,GAAA,GAAMN,KAAA,GAAQ,WAAWA,KAAA,GAAQ,GAAG,MAAMH,YAAA,KAAiBL,IAAA,EAAMc,GAAA,GAAM;YAC1F;YACAC,SAAA,EAAW,CAACpC,WAAA,CAAYqC,OAAO;UACjC;QACF;QACAhB,IAAA,EAAMrB;MACR,GACD;MACDsC,2BAAA,EAA6B9B;IAC/B;EACF;EACA+B,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -11,7 +11,7 @@ import { RelationshipDrawer } from '../drawer/index.js';
|
|
|
11
11
|
import { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js';
|
|
12
12
|
export const INSERT_RELATIONSHIP_COMMAND = createCommand('INSERT_RELATIONSHIP_COMMAND');
|
|
13
13
|
export const RelationshipPlugin = t0 => {
|
|
14
|
-
const $ = _c(
|
|
14
|
+
const $ = _c(5);
|
|
15
15
|
const {
|
|
16
16
|
clientProps
|
|
17
17
|
} = t0;
|
|
@@ -28,33 +28,24 @@ export const RelationshipPlugin = t0 => {
|
|
|
28
28
|
} else {
|
|
29
29
|
if (clientProps?.disabledCollections) {
|
|
30
30
|
let t2;
|
|
31
|
-
if ($[0] !== clientProps?.disabledCollections
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return !clientProps?.disabledCollections?.includes(slug);
|
|
39
|
-
};
|
|
40
|
-
$[3] = clientProps?.disabledCollections;
|
|
41
|
-
$[4] = t3;
|
|
42
|
-
} else {
|
|
43
|
-
t3 = $[4];
|
|
44
|
-
}
|
|
45
|
-
t2 = collections.filter(t3).map(_temp);
|
|
31
|
+
if ($[0] !== clientProps?.disabledCollections) {
|
|
32
|
+
t2 = t3 => {
|
|
33
|
+
const {
|
|
34
|
+
slug
|
|
35
|
+
} = t3;
|
|
36
|
+
return !clientProps?.disabledCollections?.includes(slug);
|
|
37
|
+
};
|
|
46
38
|
$[0] = clientProps?.disabledCollections;
|
|
47
|
-
$[1] =
|
|
48
|
-
$[2] = t2;
|
|
39
|
+
$[1] = t2;
|
|
49
40
|
} else {
|
|
50
|
-
t2 = $[
|
|
41
|
+
t2 = $[1];
|
|
51
42
|
}
|
|
52
|
-
enabledRelations = t2;
|
|
43
|
+
enabledRelations = collections.filter(t2).map(_temp);
|
|
53
44
|
}
|
|
54
45
|
}
|
|
55
46
|
let t2;
|
|
56
47
|
let t3;
|
|
57
|
-
if ($[
|
|
48
|
+
if ($[2] !== editor) {
|
|
58
49
|
t2 = () => {
|
|
59
50
|
if (!editor.hasNodes([RelationshipNode])) {
|
|
60
51
|
throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");
|
|
@@ -62,25 +53,17 @@ export const RelationshipPlugin = t0 => {
|
|
|
62
53
|
return editor.registerCommand(INSERT_RELATIONSHIP_COMMAND, _temp2, COMMAND_PRIORITY_EDITOR);
|
|
63
54
|
};
|
|
64
55
|
t3 = [editor];
|
|
65
|
-
$[
|
|
66
|
-
$[
|
|
67
|
-
$[
|
|
56
|
+
$[2] = editor;
|
|
57
|
+
$[3] = t2;
|
|
58
|
+
$[4] = t3;
|
|
68
59
|
} else {
|
|
69
|
-
t2 = $[
|
|
70
|
-
t3 = $[
|
|
60
|
+
t2 = $[3];
|
|
61
|
+
t3 = $[4];
|
|
71
62
|
}
|
|
72
63
|
useEffect(t2, t3);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
enabledCollectionSlugs: enabledRelations
|
|
77
|
-
});
|
|
78
|
-
$[8] = enabledRelations;
|
|
79
|
-
$[9] = t4;
|
|
80
|
-
} else {
|
|
81
|
-
t4 = $[9];
|
|
82
|
-
}
|
|
83
|
-
return t4;
|
|
64
|
+
return _jsx(RelationshipDrawer, {
|
|
65
|
+
enabledCollectionSlugs: enabledRelations
|
|
66
|
+
});
|
|
84
67
|
};
|
|
85
68
|
function _temp(t0) {
|
|
86
69
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","useConfig","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","t0","$","clientProps","editor","config","t1","collections","enabledRelations","enabledCollections","disabledCollections","t2","t3","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","useConfig","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","t0","$","clientProps","editor","config","t1","collections","enabledRelations","enabledCollections","disabledCollections","t2","t3","slug","includes","filter","map","_temp","hasNodes","Error","registerCommand","_temp2","_jsx","enabledCollectionSlugs","slug_0","payload","selection","relationshipNode","focus","focusNode","getNode","__first","remove"],"sources":["../../../../../src/features/relationship/client/plugins/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport { useConfig } from '@payloadcms/ui'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { RelationshipFeatureProps } from '../../server/index.js'\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport const RelationshipPlugin: PluginComponent<RelationshipFeatureProps> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n const {\n config: { collections },\n } = useConfig()\n\n let enabledRelations: null | string[] = null\n\n if (clientProps?.enabledCollections) {\n enabledRelations = clientProps?.enabledCollections\n } else if (clientProps?.disabledCollections) {\n enabledRelations = collections\n .filter(({ slug }) => !clientProps?.disabledCollections?.includes(slug))\n .map(({ slug }) => slug)\n }\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const relationshipNode = $createRelationshipNode(payload)\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert relationship node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(relationshipNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer en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