@payloadcms/richtext-lexical 3.68.0-internal-debug.2eb12b9 → 3.68.0-internal-debug.185cc5f
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/features/blocks/client/component/index.js +1 -0
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +1 -0
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.js +1 -0
- package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.js +1 -0
- package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -0
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.js +1 -0
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/debug/treeView/client/plugin/index.js +1 -0
- package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +1 -0
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +1 -0
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +1 -0
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/horizontalRule/client/plugin/index.js +1 -0
- package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.js +3 -0
- package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js +1 -0
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/features/link/server/baseFields.js +1 -0
- package/dist/features/link/server/baseFields.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +1 -0
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +1 -0
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +1 -0
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +1 -0
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +1 -0
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +1 -0
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +1 -0
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/upload/client/component/index.js +1 -0
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/component/pending/index.js +1 -0
- package/dist/features/upload/client/component/pending/index.js.map +1 -1
- package/dist/field/Diff/converters/listitem/index.js +1 -0
- package/dist/field/Diff/converters/listitem/index.js.map +1 -1
- package/dist/field/Diff/converters/relationship/index.js +1 -0
- package/dist/field/Diff/converters/relationship/index.js.map +1 -1
- package/dist/field/Diff/converters/unknown/index.js +1 -0
- package/dist/field/Diff/converters/unknown/index.js.map +1 -1
- package/dist/field/Diff/converters/upload/index.js +1 -0
- package/dist/field/Diff/converters/upload/index.js.map +1 -1
- package/dist/field/Diff/index.js +1 -0
- package/dist/field/Diff/index.js.map +1 -1
- package/dist/field/Field.js +2 -0
- package/dist/field/Field.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.js +1 -0
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.js +1 -0
- package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +1 -0
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +2 -0
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +2 -0
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +1 -0
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +1 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +1 -0
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +2 -0
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +1 -1
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +2 -0
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +1 -1
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +2 -0
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +2 -0
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +2 -0
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableCellNode, TableDOMCell, TableMapType } from '@lexical/table'\nimport type { LexicalEditor, NodeKey } from 'lexical'\nimport type { JSX, MouseEventHandler } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $computeTableMapSkipCellCheck,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $isTableCellNode,\n $isTableRowNode,\n getDOMCellFromTarget,\n getTableElement,\n TableNode,\n} from '@lexical/table'\nimport { calculateZoomLevel, mergeRegister } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode, isHTMLElement, SKIP_SCROLL_INTO_VIEW_TAG } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport './index.scss'\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\n\ntype MousePosition = {\n x: number\n y: number\n}\n\ntype MouseDraggingDirection = 'bottom' | 'right'\n\nconst MIN_ROW_HEIGHT = 33\nconst MIN_COLUMN_WIDTH = 92\n\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\n const targetRef = useRef<HTMLElement | null>(null)\n const resizerRef = useRef<HTMLDivElement | null>(null)\n const tableRectRef = useRef<ClientRect | null>(null)\n const [hasTable, setHasTable] = useState(false)\n const editorConfig = useEditorConfigContext()\n\n const mouseStartPosRef = useRef<MousePosition | null>(null)\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null)\n\n const [activeCell, updateActiveCell] = useState<null | TableDOMCell>(null)\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false)\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null)\n\n const resetState = useCallback(() => {\n updateActiveCell(null)\n targetRef.current = null\n updateDraggingDirection(null)\n mouseStartPosRef.current = null\n tableRectRef.current = null\n }, [])\n\n const isMouseDownOnEvent = (event: MouseEvent) => {\n return (event.buttons & 1) === 1\n }\n\n useEffect(() => {\n const tableKeys = new Set<NodeKey>()\n return mergeRegister(\n editor.registerMutationListener(TableNode, (nodeMutations) => {\n for (const [nodeKey, mutation] of nodeMutations) {\n if (mutation === 'destroyed') {\n tableKeys.delete(nodeKey)\n } else {\n tableKeys.add(nodeKey)\n }\n }\n setHasTable(tableKeys.size > 0)\n }),\n editor.registerNodeTransform(TableNode, (tableNode) => {\n if (tableNode.getColWidths()) {\n return tableNode\n }\n\n const numColumns = tableNode.getColumnCount()\n const columnWidth = MIN_COLUMN_WIDTH\n\n tableNode.setColWidths(Array(numColumns).fill(columnWidth))\n return tableNode\n }),\n )\n }, [editor])\n\n useEffect(() => {\n if (!hasTable) {\n return\n }\n\n const onMouseMove = (event: MouseEvent) => {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n if (draggingDirection) {\n updateMouseCurrentPos({\n x: event.clientX,\n y: event.clientY,\n })\n return\n }\n updateIsMouseDown(isMouseDownOnEvent(event))\n if (resizerRef.current && resizerRef.current.contains(target)) {\n return\n }\n\n if (targetRef.current !== target) {\n targetRef.current = target\n const cell = getDOMCellFromTarget(target)\n\n if (cell && activeCell !== cell) {\n editor.getEditorState().read(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem)\n\n if (!tableCellNode) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const tableElement = getTableElement(\n tableNode,\n editor.getElementByKey(tableNode.getKey()),\n )\n if (!tableElement) {\n throw new Error('TableCellResizer: Table element not found.')\n }\n\n targetRef.current = target\n tableRectRef.current = tableElement.getBoundingClientRect()\n updateActiveCell(cell)\n },\n { editor },\n )\n } else if (cell == null) {\n resetState()\n }\n }\n }\n\n const onMouseDown = (event: MouseEvent) => {\n updateIsMouseDown(true)\n }\n\n const onMouseUp = (event: MouseEvent) => {\n updateIsMouseDown(false)\n }\n\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\n prevRootElement?.removeEventListener('mousemove', onMouseMove)\n prevRootElement?.removeEventListener('mousedown', onMouseDown)\n prevRootElement?.removeEventListener('mouseup', onMouseUp)\n rootElement?.addEventListener('mousemove', onMouseMove)\n rootElement?.addEventListener('mousedown', onMouseDown)\n rootElement?.addEventListener('mouseup', onMouseUp)\n })\n\n return () => {\n removeRootListener()\n }\n }, [activeCell, draggingDirection, editor, hasTable, resetState])\n\n const isHeightChanging = (direction: MouseDraggingDirection) => {\n if (direction === 'bottom') {\n return true\n }\n return false\n }\n\n const updateRowHeight = useCallback(\n (heightChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const baseRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode)\n const tableRows = tableNode.getChildren()\n\n // Determine if this is a full row merge by checking colspan\n const isFullRowMerge = tableCellNode.getColSpan() === tableNode.getColumnCount()\n\n // For full row merges, apply to first row. For partial merges, apply to last row\n const tableRowIndex = isFullRowMerge\n ? baseRowIndex\n : baseRowIndex + tableCellNode.getRowSpan() - 1\n\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\n throw new Error('Expected table cell to be inside of table row.')\n }\n\n const tableRow = tableRows[tableRowIndex]\n\n if (!$isTableRowNode(tableRow)) {\n throw new Error('Expected table row')\n }\n\n let height = tableRow.getHeight()\n if (height === undefined) {\n const rowCells = tableRow.getChildren<TableCellNode>()\n height = Math.min(\n ...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity),\n )\n }\n\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT)\n tableRow.setHeight(newHeight)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const getCellNodeHeight = (\n cell: TableCellNode,\n activeEditor: LexicalEditor,\n ): number | undefined => {\n const domCellNode = activeEditor.getElementByKey(cell.getKey())\n return domCellNode?.clientHeight\n }\n\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\n let columnIndex: number | undefined\n tableMap.forEach((row) => {\n row.forEach((cell, columnIndexInner) => {\n if (cell.cell === tableCellNode) {\n columnIndex = columnIndexInner\n }\n })\n })\n return columnIndex\n }\n\n const updateColumnWidth = useCallback(\n (widthChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap)\n if (columnIndex === undefined) {\n throw new Error('TableCellResizer: Table column not found.')\n }\n\n const colWidths = tableNode.getColWidths()\n if (!colWidths) {\n return\n }\n const width = colWidths[columnIndex]\n if (width === undefined) {\n return\n }\n const newColWidths = [...colWidths]\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH)\n newColWidths[columnIndex] = newWidth\n tableNode.setColWidths(newColWidths)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const mouseUpHandler = useCallback(\n (direction: MouseDraggingDirection) => {\n const handler = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n if (mouseStartPosRef.current) {\n const { x, y } = mouseStartPosRef.current\n\n if (activeCell === null) {\n return\n }\n const zoom = calculateZoomLevel(event.target as Element)\n\n if (isHeightChanging(direction)) {\n const heightChange = (event.clientY - y) / zoom\n updateRowHeight(heightChange)\n } else {\n const widthChange = (event.clientX - x) / zoom\n updateColumnWidth(widthChange)\n }\n\n resetState()\n document.removeEventListener('mouseup', handler)\n }\n }\n return handler\n },\n [activeCell, resetState, updateColumnWidth, updateRowHeight],\n )\n\n const toggleResize = useCallback(\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\n (event) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n mouseStartPosRef.current = {\n x: event.clientX,\n y: event.clientY,\n }\n updateMouseCurrentPos(mouseStartPosRef.current)\n updateDraggingDirection(direction)\n\n document.addEventListener('mouseup', mouseUpHandler(direction))\n },\n [activeCell, mouseUpHandler],\n )\n\n const [resizerStyles, setResizerStyles] = useState<{\n bottom?: null | React.CSSProperties\n left?: null | React.CSSProperties\n right?: null | React.CSSProperties\n top?: null | React.CSSProperties\n }>({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n\n useEffect(() => {\n if (activeCell) {\n const { height, left, top, width } = activeCell.elem.getBoundingClientRect()\n const zoom = calculateZoomLevel(activeCell.elem)\n const zoneWidth = 10 // Pixel width of the zone where you can drag the edge\n const styles = {\n bottom: {\n backgroundColor: 'none',\n cursor: 'row-resize',\n height: `${zoneWidth}px`,\n left: `${window.scrollX + left}px`,\n top: `${window.scrollY + top + height - zoneWidth / 2}px`,\n width: `${width}px`,\n },\n right: {\n backgroundColor: 'none',\n cursor: 'col-resize',\n height: `${height}px`,\n left: `${window.scrollX + left + width - zoneWidth / 2}px`,\n top: `${window.scrollY + top}px`,\n width: `${zoneWidth}px`,\n },\n }\n\n const tableRect = tableRectRef.current\n\n if (draggingDirection && mouseCurrentPos && tableRect) {\n if (isHeightChanging(draggingDirection)) {\n styles[draggingDirection].left = `${window.scrollX + tableRect.left}px`\n styles[draggingDirection].top = `${window.scrollY + mouseCurrentPos.y / zoom}px`\n styles[draggingDirection].height = '3px'\n styles[draggingDirection].width = `${tableRect.width}px`\n } else {\n styles[draggingDirection].top = `${window.scrollY + tableRect.top}px`\n styles[draggingDirection].left = `${window.scrollX + mouseCurrentPos.x / zoom}px`\n styles[draggingDirection].width = '3px'\n styles[draggingDirection].height = `${tableRect.height}px`\n }\n\n styles[draggingDirection].backgroundColor = '#adf'\n }\n\n setResizerStyles(styles)\n } else {\n setResizerStyles({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n }\n }, [activeCell, draggingDirection, mouseCurrentPos])\n\n return (\n <div ref={resizerRef}>\n {activeCell != null && !isMouseDown && (\n <React.Fragment>\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('right')}\n style={resizerStyles.right || undefined}\n />\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('bottom')}\n style={resizerStyles.bottom || undefined}\n />\n </React.Fragment>\n )}\n </div>\n )\n}\n\nexport const TableCellResizerPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n return useMemo(\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\n [editor, isEditable],\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$isTableCellNode","$isTableRowNode","getDOMCellFromTarget","getTableElement","TableNode","calculateZoomLevel","mergeRegister","$getNearestNodeFromDOMNode","isHTMLElement","SKIP_SCROLL_INTO_VIEW_TAG","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","useEditorConfigContext","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","TableCellResizer","editor","targetRef","resizerRef","tableRectRef","hasTable","setHasTable","editorConfig","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","current","isMouseDownOnEvent","event","buttons","tableKeys","Set","registerMutationListener","nodeMutations","nodeKey","mutation","delete","add","size","registerNodeTransform","tableNode","getColWidths","numColumns","getColumnCount","columnWidth","setColWidths","Array","fill","onMouseMove","target","x","clientX","y","clientY","contains","cell","getEditorState","read","tableCellNode","elem","Error","tableElement","getElementByKey","getKey","getBoundingClientRect","onMouseDown","onMouseUp","removeRootListener","registerRootListener","rootElement","prevRootElement","removeEventListener","addEventListener","isHeightChanging","direction","updateRowHeight","heightChange","update","baseRowIndex","tableRows","getChildren","isFullRowMerge","getColSpan","tableRowIndex","getRowSpan","length","tableRow","height","getHeight","undefined","rowCells","Math","min","map","getCellNodeHeight","Infinity","newHeight","max","setHeight","tag","activeEditor","domCellNode","clientHeight","getCellColumnIndex","tableMap","columnIndex","forEach","row","columnIndexInner","updateColumnWidth","widthChange","colWidths","width","newColWidths","newWidth","mouseUpHandler","handler","preventDefault","stopPropagation","zoom","document","toggleResize","resizerStyles","setResizerStyles","bottom","left","right","top","zoneWidth","styles","backgroundColor","cursor","window","scrollX","scrollY","tableRect","div","ref","Fragment","className","lexical","theme","tableCellResizer","style","TableCellResizerPlugin","isEditable","body"],"mappings":"AAAA;;AAMA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SACEC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AAIC,KAAK9H;kBACPQ,cAAc,QAAQ,CAACE,6BACtB,MAACvB,MAAM4I,QAAQ;;8BACb,KAACF;oBACCG,WAAW,GAAG5H,aAAaA,YAAY,CAAC6H,OAAO,CAACC,KAAK,CAACC,gBAAgB,CAAC,qBAAqB,CAAC;oBAC7F7E,aAAawD,aAAa;oBAC1BsB,OAAOrB,cAAcI,KAAK,IAAIrC;;8BAEhC,KAAC+C;oBACCG,WAAW,GAAG5H,aAAaA,YAAY,CAAC6H,OAAO,CAACC,KAAK,CAACC,gBAAgB,CAAC,qBAAqB,CAAC;oBAC7F7E,aAAawD,aAAa;oBAC1BsB,OAAOrB,cAAcE,MAAM,IAAInC;;;;;AAM3C;AAEA,OAAO,MAAMuD,yBAA0C;IACrD,MAAM,CAACvI,OAAO,GAAG1B;IACjB,MAAMkK,aAAajK;IAEnB,OAAOiB,QACL,IAAOgJ,2BAAa7I,2BAAa,KAACI;YAAiBC,QAAQA;YAAY+G,SAAS0B,IAAI,IAAI,MACxF;QAACzI;QAAQwI;KAAW;AAExB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TableCellResizerPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableCellNode, TableDOMCell, TableMapType } from '@lexical/table'\nimport type { LexicalEditor, NodeKey } from 'lexical'\nimport type { JSX, MouseEventHandler } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $computeTableMapSkipCellCheck,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $isTableCellNode,\n $isTableRowNode,\n getDOMCellFromTarget,\n getTableElement,\n TableNode,\n} from '@lexical/table'\nimport { calculateZoomLevel, mergeRegister } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode, isHTMLElement, SKIP_SCROLL_INTO_VIEW_TAG } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport './index.scss'\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\n\ntype MousePosition = {\n x: number\n y: number\n}\n\ntype MouseDraggingDirection = 'bottom' | 'right'\n\nconst MIN_ROW_HEIGHT = 33\nconst MIN_COLUMN_WIDTH = 92\n\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\n const targetRef = useRef<HTMLElement | null>(null)\n const resizerRef = useRef<HTMLDivElement | null>(null)\n const tableRectRef = useRef<ClientRect | null>(null)\n const [hasTable, setHasTable] = useState(false)\n const editorConfig = useEditorConfigContext()\n\n const mouseStartPosRef = useRef<MousePosition | null>(null)\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null)\n\n const [activeCell, updateActiveCell] = useState<null | TableDOMCell>(null)\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false)\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null)\n\n const resetState = useCallback(() => {\n updateActiveCell(null)\n targetRef.current = null\n updateDraggingDirection(null)\n mouseStartPosRef.current = null\n tableRectRef.current = null\n }, [])\n\n const isMouseDownOnEvent = (event: MouseEvent) => {\n return (event.buttons & 1) === 1\n }\n\n useEffect(() => {\n const tableKeys = new Set<NodeKey>()\n return mergeRegister(\n editor.registerMutationListener(TableNode, (nodeMutations) => {\n for (const [nodeKey, mutation] of nodeMutations) {\n if (mutation === 'destroyed') {\n tableKeys.delete(nodeKey)\n } else {\n tableKeys.add(nodeKey)\n }\n }\n setHasTable(tableKeys.size > 0)\n }),\n editor.registerNodeTransform(TableNode, (tableNode) => {\n if (tableNode.getColWidths()) {\n return tableNode\n }\n\n const numColumns = tableNode.getColumnCount()\n const columnWidth = MIN_COLUMN_WIDTH\n\n tableNode.setColWidths(Array(numColumns).fill(columnWidth))\n return tableNode\n }),\n )\n }, [editor])\n\n useEffect(() => {\n if (!hasTable) {\n return\n }\n\n const onMouseMove = (event: MouseEvent) => {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n if (draggingDirection) {\n updateMouseCurrentPos({\n x: event.clientX,\n y: event.clientY,\n })\n return\n }\n updateIsMouseDown(isMouseDownOnEvent(event))\n if (resizerRef.current && resizerRef.current.contains(target)) {\n return\n }\n\n if (targetRef.current !== target) {\n targetRef.current = target\n const cell = getDOMCellFromTarget(target)\n\n if (cell && activeCell !== cell) {\n editor.getEditorState().read(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem)\n\n if (!tableCellNode) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const tableElement = getTableElement(\n tableNode,\n editor.getElementByKey(tableNode.getKey()),\n )\n if (!tableElement) {\n throw new Error('TableCellResizer: Table element not found.')\n }\n\n targetRef.current = target\n tableRectRef.current = tableElement.getBoundingClientRect()\n updateActiveCell(cell)\n },\n { editor },\n )\n } else if (cell == null) {\n resetState()\n }\n }\n }\n\n const onMouseDown = (event: MouseEvent) => {\n updateIsMouseDown(true)\n }\n\n const onMouseUp = (event: MouseEvent) => {\n updateIsMouseDown(false)\n }\n\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\n prevRootElement?.removeEventListener('mousemove', onMouseMove)\n prevRootElement?.removeEventListener('mousedown', onMouseDown)\n prevRootElement?.removeEventListener('mouseup', onMouseUp)\n rootElement?.addEventListener('mousemove', onMouseMove)\n rootElement?.addEventListener('mousedown', onMouseDown)\n rootElement?.addEventListener('mouseup', onMouseUp)\n })\n\n return () => {\n removeRootListener()\n }\n }, [activeCell, draggingDirection, editor, hasTable, resetState])\n\n const isHeightChanging = (direction: MouseDraggingDirection) => {\n if (direction === 'bottom') {\n return true\n }\n return false\n }\n\n const updateRowHeight = useCallback(\n (heightChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const baseRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode)\n const tableRows = tableNode.getChildren()\n\n // Determine if this is a full row merge by checking colspan\n const isFullRowMerge = tableCellNode.getColSpan() === tableNode.getColumnCount()\n\n // For full row merges, apply to first row. For partial merges, apply to last row\n const tableRowIndex = isFullRowMerge\n ? baseRowIndex\n : baseRowIndex + tableCellNode.getRowSpan() - 1\n\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\n throw new Error('Expected table cell to be inside of table row.')\n }\n\n const tableRow = tableRows[tableRowIndex]\n\n if (!$isTableRowNode(tableRow)) {\n throw new Error('Expected table row')\n }\n\n let height = tableRow.getHeight()\n if (height === undefined) {\n const rowCells = tableRow.getChildren<TableCellNode>()\n height = Math.min(\n ...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity),\n )\n }\n\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT)\n tableRow.setHeight(newHeight)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const getCellNodeHeight = (\n cell: TableCellNode,\n activeEditor: LexicalEditor,\n ): number | undefined => {\n const domCellNode = activeEditor.getElementByKey(cell.getKey())\n return domCellNode?.clientHeight\n }\n\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\n let columnIndex: number | undefined\n tableMap.forEach((row) => {\n row.forEach((cell, columnIndexInner) => {\n if (cell.cell === tableCellNode) {\n columnIndex = columnIndexInner\n }\n })\n })\n return columnIndex\n }\n\n const updateColumnWidth = useCallback(\n (widthChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap)\n if (columnIndex === undefined) {\n throw new Error('TableCellResizer: Table column not found.')\n }\n\n const colWidths = tableNode.getColWidths()\n if (!colWidths) {\n return\n }\n const width = colWidths[columnIndex]\n if (width === undefined) {\n return\n }\n const newColWidths = [...colWidths]\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH)\n newColWidths[columnIndex] = newWidth\n tableNode.setColWidths(newColWidths)\n },\n { tag: SKIP_SCROLL_INTO_VIEW_TAG },\n )\n },\n [activeCell, editor],\n )\n\n const mouseUpHandler = useCallback(\n (direction: MouseDraggingDirection) => {\n const handler = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n if (mouseStartPosRef.current) {\n const { x, y } = mouseStartPosRef.current\n\n if (activeCell === null) {\n return\n }\n const zoom = calculateZoomLevel(event.target as Element)\n\n if (isHeightChanging(direction)) {\n const heightChange = (event.clientY - y) / zoom\n updateRowHeight(heightChange)\n } else {\n const widthChange = (event.clientX - x) / zoom\n updateColumnWidth(widthChange)\n }\n\n resetState()\n document.removeEventListener('mouseup', handler)\n }\n }\n return handler\n },\n [activeCell, resetState, updateColumnWidth, updateRowHeight],\n )\n\n const toggleResize = useCallback(\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\n (event) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n mouseStartPosRef.current = {\n x: event.clientX,\n y: event.clientY,\n }\n updateMouseCurrentPos(mouseStartPosRef.current)\n updateDraggingDirection(direction)\n\n document.addEventListener('mouseup', mouseUpHandler(direction))\n },\n [activeCell, mouseUpHandler],\n )\n\n const [resizerStyles, setResizerStyles] = useState<{\n bottom?: null | React.CSSProperties\n left?: null | React.CSSProperties\n right?: null | React.CSSProperties\n top?: null | React.CSSProperties\n }>({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n\n useEffect(() => {\n if (activeCell) {\n const { height, left, top, width } = activeCell.elem.getBoundingClientRect()\n const zoom = calculateZoomLevel(activeCell.elem)\n const zoneWidth = 10 // Pixel width of the zone where you can drag the edge\n const styles = {\n bottom: {\n backgroundColor: 'none',\n cursor: 'row-resize',\n height: `${zoneWidth}px`,\n left: `${window.scrollX + left}px`,\n top: `${window.scrollY + top + height - zoneWidth / 2}px`,\n width: `${width}px`,\n },\n right: {\n backgroundColor: 'none',\n cursor: 'col-resize',\n height: `${height}px`,\n left: `${window.scrollX + left + width - zoneWidth / 2}px`,\n top: `${window.scrollY + top}px`,\n width: `${zoneWidth}px`,\n },\n }\n\n const tableRect = tableRectRef.current\n\n if (draggingDirection && mouseCurrentPos && tableRect) {\n if (isHeightChanging(draggingDirection)) {\n styles[draggingDirection].left = `${window.scrollX + tableRect.left}px`\n styles[draggingDirection].top = `${window.scrollY + mouseCurrentPos.y / zoom}px`\n styles[draggingDirection].height = '3px'\n styles[draggingDirection].width = `${tableRect.width}px`\n } else {\n styles[draggingDirection].top = `${window.scrollY + tableRect.top}px`\n styles[draggingDirection].left = `${window.scrollX + mouseCurrentPos.x / zoom}px`\n styles[draggingDirection].width = '3px'\n styles[draggingDirection].height = `${tableRect.height}px`\n }\n\n styles[draggingDirection].backgroundColor = '#adf'\n }\n\n setResizerStyles(styles)\n } else {\n setResizerStyles({\n bottom: null,\n left: null,\n right: null,\n top: null,\n })\n }\n }, [activeCell, draggingDirection, mouseCurrentPos])\n\n return (\n <div ref={resizerRef}>\n {activeCell != null && !isMouseDown && (\n <React.Fragment>\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('right')}\n style={resizerStyles.right || undefined}\n />\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('bottom')}\n style={resizerStyles.bottom || undefined}\n />\n </React.Fragment>\n )}\n </div>\n )\n}\n\nexport const TableCellResizerPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n return useMemo(\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\n [editor, isEditable],\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$isTableCellNode","$isTableRowNode","getDOMCellFromTarget","getTableElement","TableNode","calculateZoomLevel","mergeRegister","$getNearestNodeFromDOMNode","isHTMLElement","SKIP_SCROLL_INTO_VIEW_TAG","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","useEditorConfigContext","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","TableCellResizer","editor","targetRef","resizerRef","tableRectRef","hasTable","setHasTable","editorConfig","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","current","isMouseDownOnEvent","event","buttons","tableKeys","Set","registerMutationListener","nodeMutations","nodeKey","mutation","delete","add","size","registerNodeTransform","tableNode","getColWidths","numColumns","getColumnCount","columnWidth","setColWidths","Array","fill","onMouseMove","target","x","clientX","y","clientY","contains","cell","getEditorState","read","tableCellNode","elem","Error","tableElement","getElementByKey","getKey","getBoundingClientRect","onMouseDown","onMouseUp","removeRootListener","registerRootListener","rootElement","prevRootElement","removeEventListener","addEventListener","isHeightChanging","direction","updateRowHeight","heightChange","update","baseRowIndex","tableRows","getChildren","isFullRowMerge","getColSpan","tableRowIndex","getRowSpan","length","tableRow","height","getHeight","undefined","rowCells","Math","min","map","getCellNodeHeight","Infinity","newHeight","max","setHeight","tag","activeEditor","domCellNode","clientHeight","getCellColumnIndex","tableMap","columnIndex","forEach","row","columnIndexInner","updateColumnWidth","widthChange","colWidths","width","newColWidths","newWidth","mouseUpHandler","handler","preventDefault","stopPropagation","zoom","document","toggleResize","resizerStyles","setResizerStyles","bottom","left","right","top","zoneWidth","styles","backgroundColor","cursor","window","scrollX","scrollY","tableRect","div","ref","Fragment","className","lexical","theme","tableCellResizer","style","TableCellResizerPlugin","isEditable","body"],"mappings":"AAAA;;AAMA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SACEC,6BAA6B,EAC7BC,mCAAmC,EACnCC,kCAAkC,EAClCC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,EACpBC,eAAe,EACfC,SAAS,QACJ,iBAAgB;AACvB,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,iBAAgB;AAClE,SAASC,0BAA0B,EAAEC,aAAa,EAAEC,yBAAyB,QAAQ,UAAS;AAC9F,YAAYC,WAAW,QAAO;AAC9B,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACzE,SAASC,YAAY,QAAQ,YAAW;AAIxC,OAAO,eAAc;AACrB,SAASC,sBAAsB,QAAQ,+DAA8D;AASrG,MAAMC,iBAAiB;AACvB,MAAMC,mBAAmB;AAEzB,SAASC,iBAAiB,EAAEC,MAAM,EAA6B;IAC7D,MAAMC,YAAYR,OAA2B;IAC7C,MAAMS,aAAaT,OAA8B;IACjD,MAAMU,eAAeV,OAA0B;IAC/C,MAAM,CAACW,UAAUC,YAAY,GAAGX,SAAS;IACzC,MAAMY,eAAeV;IAErB,MAAMW,mBAAmBd,OAA6B;IACtD,MAAM,CAACe,iBAAiBC,sBAAsB,GAAGf,SAA+B;IAEhF,MAAM,CAACgB,YAAYC,iBAAiB,GAAGjB,SAA8B;IACrE,MAAM,CAACkB,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BAAgBiC,CAAC,GAAGqE,KAAK,EAAE,CAAC;oBACjFU,MAAM,CAAC1G,kBAAkB,CAACyF,KAAK,GAAG;oBAClCiB,MAAM,CAAC1G,kBAAkB,CAACgE,MAAM,GAAG,GAAGgD,UAAUhD,MAAM,CAAC,EAAE,CAAC;gBAC5D;gBAEA0C,MAAM,CAAC1G,kBAAkB,CAAC2G,eAAe,GAAG;YAC9C;YAEAP,iBAAiBM;QACnB,OAAO;YACLN,iBAAiB;gBACfC,QAAQ;gBACRC,MAAM;gBACNC,OAAO;gBACPC,KAAK;YACP;QACF;IACF,GAAG;QAAC5G;QAAYI;QAAmBN;KAAgB;IAEnD,qBACE,KAACuH;QAAIC,KAAK9H;kBACPQ,cAAc,QAAQ,CAACE,6BACtB,MAACvB,MAAM4I,QAAQ;;8BACb,KAACF;oBACCG,WAAW,GAAG5H,aAAaA,YAAY,CAAC6H,OAAO,CAACC,KAAK,CAACC,gBAAgB,CAAC,qBAAqB,CAAC;oBAC7F7E,aAAawD,aAAa;oBAC1BsB,OAAOrB,cAAcI,KAAK,IAAIrC;;8BAEhC,KAAC+C;oBACCG,WAAW,GAAG5H,aAAaA,YAAY,CAAC6H,OAAO,CAACC,KAAK,CAACC,gBAAgB,CAAC,qBAAqB,CAAC;oBAC7F7E,aAAawD,aAAa;oBAC1BsB,OAAOrB,cAAcE,MAAM,IAAInC;;;;;AAM3C;AAEA,OAAO,MAAMuD,yBAA0C;IACrD,MAAM,CAACvI,OAAO,GAAG1B;IACjB,MAAMkK,aAAajK;IAEnB,OAAOiB,QACL,IAAOgJ,2BAAa7I,2BAAa,KAACI;YAAiBC,QAAQA;YAAY+G,SAAS0B,IAAI,IAAI,MACxF;QAACzI;QAAQwI;KAAW;AAExB,EAAC"}
|
|
@@ -11,6 +11,7 @@ import * as React from 'react';
|
|
|
11
11
|
import { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js';
|
|
12
12
|
import { FieldsDrawer } from '../../../../../utilities/fieldsDrawer/Drawer.js';
|
|
13
13
|
import { useLexicalDrawer } from '../../../../../utilities/fieldsDrawer/useLexicalDrawer.js';
|
|
14
|
+
import './index.scss';
|
|
14
15
|
export const OPEN_TABLE_DRAWER_COMMAND = createCommand('OPEN_EMBED_DRAWER_COMMAND');
|
|
15
16
|
export const CellContext = /*#__PURE__*/ createContext({
|
|
16
17
|
cellEditorConfig: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TablePlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n EditorThemeClasses,\n Klass,\n LexicalCommand,\n LexicalEditor,\n LexicalNode,\n RangeSelection,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TablePlugin as LexicalReactTablePlugin } from '@lexical/react/LexicalTablePlugin'\nimport { INSERT_TABLE_COMMAND, TableCellNode, TableNode, TableRowNode } from '@lexical/table'\nimport { mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth } from '@payloadcms/ui'\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical'\nimport { createContext, use, useEffect, useMemo, useState } from 'react'\nimport * as React from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../../utilities/fieldsDrawer/Drawer.js'\nimport { useLexicalDrawer } from '../../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport './index.scss'\n\nexport type CellContextShape = {\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n set: (\n cellEditorConfig: CellEditorConfig | null,\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null,\n ) => void\n}\n\nexport type CellEditorConfig = Readonly<{\n namespace: string\n nodes?: ReadonlyArray<Klass<LexicalNode>>\n onError: (error: Error, editor: LexicalEditor) => void\n readOnly?: boolean\n theme?: EditorThemeClasses\n}>\n\nexport const OPEN_TABLE_DRAWER_COMMAND: LexicalCommand<{}> = createCommand(\n 'OPEN_EMBED_DRAWER_COMMAND',\n)\n\nexport const CellContext = createContext<CellContextShape>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n set: () => {\n // Empty\n },\n})\n\nexport function TableContext({ children }: { children: JSX.Element }) {\n const [contextValue, setContextValue] = useState<{\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n }>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n })\n return (\n <CellContext\n value={useMemo(\n () => ({\n cellEditorConfig: contextValue.cellEditorConfig,\n cellEditorPlugins: contextValue.cellEditorPlugins,\n set: (cellEditorConfig, cellEditorPlugins) => {\n setContextValue({ cellEditorConfig, cellEditorPlugins })\n },\n }),\n [contextValue.cellEditorConfig, contextValue.cellEditorPlugins],\n )}\n >\n {children}\n </CellContext>\n )\n}\n\nexport const TablePlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const cellContext = use(CellContext)\n const editDepth = useEditDepth()\n const {\n fieldProps: { schemaPath },\n uuid,\n } = useEditorConfigContext()\n\n const drawerSlug = formatDrawerSlug({\n slug: 'lexical-table-create-' + uuid,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n useEffect(() => {\n if (!editor.hasNodes([TableNode, TableRowNode, TableCellNode])) {\n throw new Error(\n 'TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor',\n )\n }\n\n return mergeRegister(\n editor.registerCommand(\n OPEN_TABLE_DRAWER_COMMAND,\n () => {\n let rangeSelection: null | RangeSelection = null\n\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n rangeSelection = selection\n }\n })\n\n if (rangeSelection) {\n toggleDrawer()\n }\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [cellContext, editor, toggleDrawer])\n\n return (\n <React.Fragment>\n <FieldsDrawer\n drawerSlug={drawerSlug}\n drawerTitle=\"Create Table\"\n featureKey=\"experimental_table\"\n handleDrawerSubmit={(_fields, data) => {\n if (!data.columns || !data.rows) {\n return\n }\n\n editor.dispatchCommand(INSERT_TABLE_COMMAND, {\n columns: String(data.columns),\n rows: String(data.rows),\n })\n }}\n schemaPath={schemaPath}\n schemaPathSuffix=\"fields\"\n />\n <LexicalReactTablePlugin\n hasCellBackgroundColor={false}\n hasCellMerge\n hasHorizontalScroll={true}\n />\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","TablePlugin","LexicalReactTablePlugin","INSERT_TABLE_COMMAND","TableCellNode","TableNode","TableRowNode","mergeRegister","formatDrawerSlug","useEditDepth","$getSelection","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","createContext","use","useEffect","useMemo","useState","React","useEditorConfigContext","FieldsDrawer","useLexicalDrawer","OPEN_TABLE_DRAWER_COMMAND","CellContext","cellEditorConfig","cellEditorPlugins","set","TableContext","children","contextValue","setContextValue","value","editor","cellContext","editDepth","fieldProps","schemaPath","uuid","drawerSlug","slug","depth","toggleDrawer","hasNodes","Error","registerCommand","rangeSelection","getEditorState","read","selection","Fragment","drawerTitle","featureKey","handleDrawerSubmit","_fields","data","columns","rows","dispatchCommand","String","schemaPathSuffix","hasCellBackgroundColor","hasCellMerge","hasHorizontalScroll"],"mappings":"AAAA;;AAYA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,eAAeC,uBAAuB,QAAQ,oCAAmC;AAC1F,SAASC,oBAAoB,EAAEC,aAAa,EAAEC,SAAS,EAAEC,YAAY,QAAQ,iBAAgB;AAC7F,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,iBAAgB;AAC/D,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,uBAAuB,EAAEC,aAAa,QAAQ,UAAS;AAClG,SAASC,aAAa,EAAEC,GAAG,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACxE,YAAYC,WAAW,QAAO;AAI9B,SAASC,sBAAsB,QAAQ,+DAA8D;AACrG,SAASC,YAAY,QAAQ,kDAAiD;AAC9E,SAASC,gBAAgB,QAAQ,4DAA2D;
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/experimental_table/client/plugins/TablePlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n EditorThemeClasses,\n Klass,\n LexicalCommand,\n LexicalEditor,\n LexicalNode,\n RangeSelection,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TablePlugin as LexicalReactTablePlugin } from '@lexical/react/LexicalTablePlugin'\nimport { INSERT_TABLE_COMMAND, TableCellNode, TableNode, TableRowNode } from '@lexical/table'\nimport { mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth } from '@payloadcms/ui'\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical'\nimport { createContext, use, useEffect, useMemo, useState } from 'react'\nimport * as React from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../../utilities/fieldsDrawer/Drawer.js'\nimport { useLexicalDrawer } from '../../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport './index.scss'\n\nexport type CellContextShape = {\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n set: (\n cellEditorConfig: CellEditorConfig | null,\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null,\n ) => void\n}\n\nexport type CellEditorConfig = Readonly<{\n namespace: string\n nodes?: ReadonlyArray<Klass<LexicalNode>>\n onError: (error: Error, editor: LexicalEditor) => void\n readOnly?: boolean\n theme?: EditorThemeClasses\n}>\n\nexport const OPEN_TABLE_DRAWER_COMMAND: LexicalCommand<{}> = createCommand(\n 'OPEN_EMBED_DRAWER_COMMAND',\n)\n\nexport const CellContext = createContext<CellContextShape>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n set: () => {\n // Empty\n },\n})\n\nexport function TableContext({ children }: { children: JSX.Element }) {\n const [contextValue, setContextValue] = useState<{\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n }>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n })\n return (\n <CellContext\n value={useMemo(\n () => ({\n cellEditorConfig: contextValue.cellEditorConfig,\n cellEditorPlugins: contextValue.cellEditorPlugins,\n set: (cellEditorConfig, cellEditorPlugins) => {\n setContextValue({ cellEditorConfig, cellEditorPlugins })\n },\n }),\n [contextValue.cellEditorConfig, contextValue.cellEditorPlugins],\n )}\n >\n {children}\n </CellContext>\n )\n}\n\nexport const TablePlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const cellContext = use(CellContext)\n const editDepth = useEditDepth()\n const {\n fieldProps: { schemaPath },\n uuid,\n } = useEditorConfigContext()\n\n const drawerSlug = formatDrawerSlug({\n slug: 'lexical-table-create-' + uuid,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n useEffect(() => {\n if (!editor.hasNodes([TableNode, TableRowNode, TableCellNode])) {\n throw new Error(\n 'TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor',\n )\n }\n\n return mergeRegister(\n editor.registerCommand(\n OPEN_TABLE_DRAWER_COMMAND,\n () => {\n let rangeSelection: null | RangeSelection = null\n\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n rangeSelection = selection\n }\n })\n\n if (rangeSelection) {\n toggleDrawer()\n }\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [cellContext, editor, toggleDrawer])\n\n return (\n <React.Fragment>\n <FieldsDrawer\n drawerSlug={drawerSlug}\n drawerTitle=\"Create Table\"\n featureKey=\"experimental_table\"\n handleDrawerSubmit={(_fields, data) => {\n if (!data.columns || !data.rows) {\n return\n }\n\n editor.dispatchCommand(INSERT_TABLE_COMMAND, {\n columns: String(data.columns),\n rows: String(data.rows),\n })\n }}\n schemaPath={schemaPath}\n schemaPathSuffix=\"fields\"\n />\n <LexicalReactTablePlugin\n hasCellBackgroundColor={false}\n hasCellMerge\n hasHorizontalScroll={true}\n />\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","TablePlugin","LexicalReactTablePlugin","INSERT_TABLE_COMMAND","TableCellNode","TableNode","TableRowNode","mergeRegister","formatDrawerSlug","useEditDepth","$getSelection","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","createContext","use","useEffect","useMemo","useState","React","useEditorConfigContext","FieldsDrawer","useLexicalDrawer","OPEN_TABLE_DRAWER_COMMAND","CellContext","cellEditorConfig","cellEditorPlugins","set","TableContext","children","contextValue","setContextValue","value","editor","cellContext","editDepth","fieldProps","schemaPath","uuid","drawerSlug","slug","depth","toggleDrawer","hasNodes","Error","registerCommand","rangeSelection","getEditorState","read","selection","Fragment","drawerTitle","featureKey","handleDrawerSubmit","_fields","data","columns","rows","dispatchCommand","String","schemaPathSuffix","hasCellBackgroundColor","hasCellMerge","hasHorizontalScroll"],"mappings":"AAAA;;AAYA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,eAAeC,uBAAuB,QAAQ,oCAAmC;AAC1F,SAASC,oBAAoB,EAAEC,aAAa,EAAEC,SAAS,EAAEC,YAAY,QAAQ,iBAAgB;AAC7F,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,iBAAgB;AAC/D,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,uBAAuB,EAAEC,aAAa,QAAQ,UAAS;AAClG,SAASC,aAAa,EAAEC,GAAG,EAAEC,SAAS,EAAEC,O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B,2BACA;YACE,IAAIuB,iBAAwC;YAE5Cb,OAAOc,cAAc,GAAGC,IAAI,CAAC;gBAC3B,MAAMC,YAAYvC;gBAClB,IAAIC,kBAAkBsC,YAAY;oBAChCH,iBAAiBG;gBACnB;YACF;YAEA,IAAIH,gBAAgB;gBAClBJ;YACF;YACA,OAAO;QACT,GACA9B;IAGN,GAAG;QAACsB;QAAaD;QAAQS;KAAa;IAEtC,qBACE,MAACvB,MAAM+B,QAAQ;;0BACb,KAAC7B;gBACCkB,YAAYA;gBACZY,aAAY;gBACZC,YAAW;gBACXC,oBAAoB,CAACC,SAASC;oBAC5B,IAAI,CAACA,KAAKC,OAAO,IAAI,CAACD,KAAKE,IAAI,EAAE;wBAC/B;oBACF;oBAEAxB,OAAOyB,eAAe,CAACvD,sBAAsB;wBAC3CqD,SAASG,OAAOJ,KAAKC,OAAO;wBAC5BC,MAAME,OAAOJ,KAAKE,IAAI;oBACxB;gBACF;gBACApB,YAAYA;gBACZuB,kBAAiB;;0BAEnB,KAAC1D;gBACC2D,wBAAwB;gBACxBC,YAAY;gBACZC,qBAAqB;;;;AAI7B,EAAC"}
|
|
@@ -5,6 +5,7 @@ import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexic
|
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
import { INSERT_HORIZONTAL_RULE_COMMAND } from '../../server/nodes/HorizontalRuleNode.js';
|
|
7
7
|
import { $createHorizontalRuleNode } from '../nodes/HorizontalRuleNode.js';
|
|
8
|
+
import './index.scss';
|
|
8
9
|
/**
|
|
9
10
|
* Registers the INSERT_HORIZONTAL_RULE_COMMAND lexical command and defines the behavior for when it is called.
|
|
10
11
|
*/ export const HorizontalRulePlugin = ()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/horizontalRule/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\n\nimport { INSERT_HORIZONTAL_RULE_COMMAND } from '../../server/nodes/HorizontalRuleNode.js'\nimport { $createHorizontalRuleNode } from '../nodes/HorizontalRuleNode.js'\nimport './index.scss'\n\n/**\n * Registers the INSERT_HORIZONTAL_RULE_COMMAND lexical command and defines the behavior for when it is called.\n */\nexport const HorizontalRulePlugin: PluginComponent<undefined> = () => {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerCommand(\n INSERT_HORIZONTAL_RULE_COMMAND,\n (type) => {\n const selection = $getSelection()\n\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n const focusNode = selection.focus.getNode()\n\n if (focusNode !== null) {\n const horizontalRuleNode = $createHorizontalRuleNode()\n $insertNodeToNearestRoot(horizontalRuleNode)\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return null\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","$getSelection","$isRangeSelection","COMMAND_PRIORITY_EDITOR","useEffect","INSERT_HORIZONTAL_RULE_COMMAND","$createHorizontalRuleNode","HorizontalRulePlugin","editor","registerCommand","type","selection","focusNode","focus","getNode","horizontalRuleNode"],"mappings":"AAAA;AAEA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,QAAQ,iBAAgB;AACzD,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,uBAAuB,QAAQ,UAAS;AACnF,SAASC,SAAS,QAAQ,QAAO;AAIjC,SAASC,8BAA8B,QAAQ,2CAA0C;AACzF,SAASC,yBAAyB,QAAQ,iCAAgC;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/horizontalRule/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\n\nimport { INSERT_HORIZONTAL_RULE_COMMAND } from '../../server/nodes/HorizontalRuleNode.js'\nimport { $createHorizontalRuleNode } from '../nodes/HorizontalRuleNode.js'\nimport './index.scss'\n\n/**\n * Registers the INSERT_HORIZONTAL_RULE_COMMAND lexical command and defines the behavior for when it is called.\n */\nexport const HorizontalRulePlugin: PluginComponent<undefined> = () => {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerCommand(\n INSERT_HORIZONTAL_RULE_COMMAND,\n (type) => {\n const selection = $getSelection()\n\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n const focusNode = selection.focus.getNode()\n\n if (focusNode !== null) {\n const horizontalRuleNode = $createHorizontalRuleNode()\n $insertNodeToNearestRoot(horizontalRuleNode)\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return null\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","$getSelection","$isRangeSelection","COMMAND_PRIORITY_EDITOR","useEffect","INSERT_HORIZONTAL_RULE_COMMAND","$createHorizontalRuleNode","HorizontalRulePlugin","editor","registerCommand","type","selection","focusNode","focus","getNode","horizontalRuleNode"],"mappings":"AAAA;AAEA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,QAAQ,iBAAgB;AACzD,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,uBAAuB,QAAQ,UAAS;AACnF,SAASC,SAAS,QAAQ,QAAO;AAIjC,SAASC,8BAA8B,QAAQ,2CAA0C;AACzF,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,OAAO,eAAc;AAErB;;CAEC,GACD,OAAO,MAAMC,uBAAmD;IAC9D,MAAM,CAACC,OAAO,GAAGT;IAEjBK,UAAU;QACR,OAAOI,OAAOC,eAAe,CAC3BJ,gCACA,CAACK;YACC,MAAMC,YAAYV;YAElB,IAAI,CAACC,kBAAkBS,YAAY;gBACjC,OAAO;YACT;YAEA,MAAMC,YAAYD,UAAUE,KAAK,CAACC,OAAO;YAEzC,IAAIF,cAAc,MAAM;gBACtB,MAAMG,qBAAqBT;gBAC3BN,yBAAyBe;YAC3B;YAEA,OAAO;QACT,GACAZ;IAEJ,GAAG;QAACK;KAAO;IAEX,OAAO;AACT,EAAC"}
|
|
@@ -119,8 +119,10 @@ function $createAutoLinkNode_(nodes, startIndex, endIndex, match) {
|
|
|
119
119
|
const remainingTextNode = nodes[0];
|
|
120
120
|
let linkTextNode;
|
|
121
121
|
if (startIndex === 0) {
|
|
122
|
+
;
|
|
122
123
|
[linkTextNode] = remainingTextNode.splitText(endIndex);
|
|
123
124
|
} else {
|
|
125
|
+
;
|
|
124
126
|
[, linkTextNode] = remainingTextNode.splitText(startIndex, endIndex);
|
|
125
127
|
}
|
|
126
128
|
if (linkTextNode) {
|
|
@@ -139,6 +141,7 @@ function $createAutoLinkNode_(nodes, startIndex, endIndex, match) {
|
|
|
139
141
|
if (startIndex === 0) {
|
|
140
142
|
firstLinkTextNode = firstTextNode;
|
|
141
143
|
} else {
|
|
144
|
+
;
|
|
142
145
|
[, firstLinkTextNode] = firstTextNode.splitText(startIndex);
|
|
143
146
|
}
|
|
144
147
|
const linkNodes = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/link/client/plugins/autoLink/index.tsx"],"sourcesContent":["'use client'\nimport type { ElementNode, LexicalEditor, LexicalNode, TextNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $createTextNode,\n $getSelection,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isTextNode,\n TextNode as TextNodeValue,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { LinkFields } from '../../../nodes/types.js'\nimport type { ClientProps } from '../../index.js'\n\nimport { $createAutoLinkNode, $isAutoLinkNode, AutoLinkNode } from '../../../nodes/AutoLinkNode.js'\nimport { $isLinkNode } from '../../../nodes/LinkNode.js'\n\ntype ChangeHandler = (url: null | string, prevUrl: null | string) => void\n\ninterface LinkMatcherResult {\n fields?: LinkFields\n index: number\n length: number\n text: string\n url: string\n}\n\nexport type LinkMatcher = (text: string) => LinkMatcherResult | null\n\nexport function createLinkMatcherWithRegExp(\n regExp: RegExp,\n urlTransformer: (text: string) => string = (text) => text,\n) {\n return (text: string) => {\n const match = regExp.exec(text)\n if (match === null) {\n return null\n }\n return {\n index: match.index,\n length: match[0].length,\n text: match[0],\n url: urlTransformer(match[0]),\n }\n }\n}\n\nfunction findFirstMatch(text: string, matchers: LinkMatcher[]): LinkMatcherResult | null {\n for (const matcher of matchers) {\n const match = matcher(text)\n\n if (match != null) {\n return match\n }\n }\n\n return null\n}\n\nconst PUNCTUATION_OR_SPACE = /[.,;\\s]/\n\nfunction isSeparator(char: string | undefined): boolean {\n return char !== undefined && PUNCTUATION_OR_SPACE.test(char)\n}\n\nfunction endsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[textContent.length - 1])\n}\n\nfunction startsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[0])\n}\n\n/**\n * Check if the text content starts with a fullstop followed by a top-level domain.\n * Meaning if the text content can be a beginning of a top level domain.\n * @param textContent\n * @param isEmail\n * @returns boolean\n */\nfunction startsWithTLD(textContent: string, isEmail: boolean): boolean {\n if (isEmail) {\n return /^\\.[a-z]{2,}/i.test(textContent)\n } else {\n return /^\\.[a-z0-9]+/i.test(textContent)\n }\n}\n\nfunction isPreviousNodeValid(node: LexicalNode): boolean {\n let previousNode = node.getPreviousSibling()\n if ($isElementNode(previousNode)) {\n previousNode = previousNode.getLastDescendant()\n }\n return (\n previousNode === null ||\n $isLineBreakNode(previousNode) ||\n ($isTextNode(previousNode) && endsWithSeparator(previousNode.getTextContent()))\n )\n}\n\nfunction isNextNodeValid(node: LexicalNode): boolean {\n let nextNode = node.getNextSibling()\n if ($isElementNode(nextNode)) {\n nextNode = nextNode.getFirstDescendant()\n }\n return (\n nextNode === null ||\n $isLineBreakNode(nextNode) ||\n ($isTextNode(nextNode) && startsWithSeparator(nextNode.getTextContent()))\n )\n}\n\nfunction isContentAroundIsValid(\n matchStart: number,\n matchEnd: number,\n text: string,\n nodes: TextNode[],\n): boolean {\n const contentBeforeIsValid =\n matchStart > 0 ? isSeparator(text[matchStart - 1]) : isPreviousNodeValid(nodes[0]!)\n if (!contentBeforeIsValid) {\n return false\n }\n\n const contentAfterIsValid =\n matchEnd < text.length ? isSeparator(text[matchEnd]) : isNextNodeValid(nodes[nodes.length - 1]!)\n return contentAfterIsValid\n}\n\nfunction extractMatchingNodes(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n): [\n matchingOffset: number,\n unmodifiedBeforeNodes: TextNode[],\n matchingNodes: TextNode[],\n unmodifiedAfterNodes: TextNode[],\n] {\n const unmodifiedBeforeNodes: TextNode[] = []\n const matchingNodes: TextNode[] = []\n const unmodifiedAfterNodes: TextNode[] = []\n let matchingOffset = 0\n\n let currentOffset = 0\n const currentNodes = [...nodes]\n\n while (currentNodes.length > 0) {\n const currentNode = currentNodes[0]!\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = currentOffset\n const currentNodeEnd = currentOffset + currentNodeLength\n\n if (currentNodeEnd <= startIndex) {\n unmodifiedBeforeNodes.push(currentNode)\n matchingOffset += currentNodeLength\n } else if (currentNodeStart >= endIndex) {\n unmodifiedAfterNodes.push(currentNode)\n } else {\n matchingNodes.push(currentNode)\n }\n currentOffset += currentNodeLength\n currentNodes.shift()\n }\n return [matchingOffset, unmodifiedBeforeNodes, matchingNodes, unmodifiedAfterNodes]\n}\n\nfunction $createAutoLinkNode_(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n match: LinkMatcherResult,\n): TextNode | undefined {\n const fields = {\n linkType: 'custom',\n url: match.url,\n ...match.fields,\n } as LinkFields\n\n const linkNode = $createAutoLinkNode({ fields })\n if (nodes.length === 1) {\n const remainingTextNode = nodes[0]!\n let linkTextNode: TextNode | undefined\n if (startIndex === 0) {\n ;[linkTextNode] = remainingTextNode.splitText(endIndex)\n } else {\n ;[, linkTextNode] = remainingTextNode.splitText(startIndex, endIndex)\n }\n if (linkTextNode) {\n const textNode = $createTextNode(match.text)\n textNode.setFormat(linkTextNode.getFormat())\n textNode.setDetail(linkTextNode.getDetail())\n textNode.setStyle(linkTextNode.getStyle())\n linkNode.append(textNode)\n linkTextNode.replace(linkNode)\n }\n return remainingTextNode\n } else if (nodes.length > 1) {\n const firstTextNode = nodes[0]!\n let offset = firstTextNode.getTextContent().length\n let firstLinkTextNode\n if (startIndex === 0) {\n firstLinkTextNode = firstTextNode\n } else {\n ;[, firstLinkTextNode] = firstTextNode.splitText(startIndex)\n }\n const linkNodes: LexicalNode[] = []\n let remainingTextNode\n nodes.forEach((currentNode) => {\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = offset\n const currentNodeEnd = offset + currentNodeLength\n if (currentNodeStart < endIndex) {\n if (currentNodeEnd <= endIndex) {\n linkNodes.push(currentNode)\n } else {\n const [linkTextNode, endNode] = currentNode.splitText(endIndex - currentNodeStart)\n if (linkTextNode) {\n linkNodes.push(linkTextNode)\n }\n remainingTextNode = endNode\n }\n }\n offset += currentNodeLength\n })\n\n if (firstLinkTextNode) {\n const selection = $getSelection()\n const selectedTextNode = selection ? selection.getNodes().find($isTextNode) : undefined\n const textNode = $createTextNode(firstLinkTextNode.getTextContent())\n textNode.setFormat(firstLinkTextNode.getFormat())\n textNode.setDetail(firstLinkTextNode.getDetail())\n textNode.setStyle(firstLinkTextNode.getStyle())\n linkNode.append(textNode, ...linkNodes)\n // it does not preserve caret position if caret was at the first text node\n // so we need to restore caret position\n if (selectedTextNode && selectedTextNode === firstLinkTextNode) {\n if ($isRangeSelection(selection)) {\n textNode.select(selection.anchor.offset, selection.focus.offset)\n } else if ($isNodeSelection(selection)) {\n textNode.select(0, textNode.getTextContent().length)\n }\n }\n firstLinkTextNode.replace(linkNode)\n return remainingTextNode\n }\n }\n return undefined\n}\n\nfunction $handleLinkCreation(\n nodes: TextNode[],\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n let currentNodes = [...nodes]\n const initialText = currentNodes.map((node) => node.getTextContent()).join('')\n let text = initialText\n\n let match\n let invalidMatchEnd = 0\n\n while ((match = findFirstMatch(text, matchers)) != null && match !== null) {\n const matchStart: number = match.index\n const matchLength: number = match.length\n const matchEnd = matchStart + matchLength\n const isValid = isContentAroundIsValid(\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n initialText,\n currentNodes,\n )\n\n if (isValid) {\n const [matchingOffset, , matchingNodes, unmodifiedAfterNodes] = extractMatchingNodes(\n currentNodes,\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n )\n\n const actualMatchStart = invalidMatchEnd + matchStart - matchingOffset\n const actualMatchEnd = invalidMatchEnd + matchEnd - matchingOffset\n const remainingTextNode = $createAutoLinkNode_(\n matchingNodes,\n actualMatchStart,\n actualMatchEnd,\n match,\n )\n currentNodes = remainingTextNode\n ? [remainingTextNode, ...unmodifiedAfterNodes]\n : unmodifiedAfterNodes\n onChange(match.url, null)\n invalidMatchEnd = 0\n } else {\n invalidMatchEnd += matchEnd\n }\n\n text = text.substring(matchEnd)\n }\n}\n\nfunction handleLinkEdit(\n linkNode: AutoLinkNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n // Check children are simple text\n const children = linkNode.getChildren()\n const childrenLength = children.length\n for (let i = 0; i < childrenLength; i++) {\n const child = children[i]\n if (!$isTextNode(child) || !child.isSimpleText()) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n }\n\n // Check text content fully matches\n const text = linkNode.getTextContent()\n const match = findFirstMatch(text, matchers)\n if (match === null || match.text !== text) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n // Check neighbors\n if (!isPreviousNodeValid(linkNode) || !isNextNodeValid(linkNode)) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n const url = linkNode.getFields()?.url\n if (url !== match?.url) {\n const flds = linkNode.getFields()\n flds.url = match?.url\n linkNode.setFields(flds)\n onChange(match.url, url ?? null)\n }\n}\n\n// Bad neighbors are edits in neighbor nodes that make AutoLinks incompatible.\n// Given the creation preconditions, these can only be simple text nodes.\nfunction handleBadNeighbors(\n textNode: TextNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n const previousSibling = textNode.getPreviousSibling()\n const nextSibling = textNode.getNextSibling()\n const text = textNode.getTextContent()\n\n if ($isAutoLinkNode(previousSibling)) {\n const isEmailURI = previousSibling.getFields()?.url\n ? (previousSibling.getFields()?.url?.startsWith('mailto:') ?? false)\n : false\n if (!startsWithSeparator(text) || startsWithTLD(text, isEmailURI)) {\n previousSibling.append(textNode)\n handleLinkEdit(previousSibling, matchers, onChange)\n onChange(null, previousSibling.getFields()?.url ?? null)\n }\n }\n\n if ($isAutoLinkNode(nextSibling) && !endsWithSeparator(text)) {\n replaceWithChildren(nextSibling)\n handleLinkEdit(nextSibling, matchers, onChange)\n onChange(null, nextSibling.getFields()?.url ?? null)\n }\n}\n\nfunction replaceWithChildren(node: ElementNode): LexicalNode[] {\n const children = node.getChildren()\n const childrenLength = children.length\n\n for (let j = childrenLength - 1; j >= 0; j--) {\n node.insertAfter(children[j]!)\n }\n\n node.remove()\n return children.map((child) => child.getLatest())\n}\n\nfunction getTextNodesToMatch(textNode: TextNode): TextNode[] {\n // check if next siblings are simple text nodes till a node contains a space separator\n const textNodesToMatch = [textNode]\n let nextSibling = textNode.getNextSibling()\n while (nextSibling !== null && $isTextNode(nextSibling) && nextSibling.isSimpleText()) {\n textNodesToMatch.push(nextSibling)\n if (/\\s/.test(nextSibling.getTextContent())) {\n break\n }\n nextSibling = nextSibling.getNextSibling()\n }\n return textNodesToMatch\n}\n\nfunction useAutoLink(\n editor: LexicalEditor,\n matchers: LinkMatcher[],\n onChange?: ChangeHandler,\n): void {\n useEffect(() => {\n if (!editor.hasNodes([AutoLinkNode])) {\n throw new Error('LexicalAutoLinkPlugin: AutoLinkNode not registered on editor')\n }\n\n const onChangeWrapped = (url: null | string, prevUrl: null | string): void => {\n if (onChange != null) {\n onChange(url, prevUrl)\n }\n }\n\n return mergeRegister(\n editor.registerNodeTransform(TextNodeValue, (textNode: TextNode) => {\n const parent = textNode.getParentOrThrow()\n const previous = textNode.getPreviousSibling()\n if ($isAutoLinkNode(parent)) {\n handleLinkEdit(parent, matchers, onChangeWrapped)\n } else if (!$isLinkNode(parent)) {\n if (\n textNode.isSimpleText() &&\n (startsWithSeparator(textNode.getTextContent()) || !$isAutoLinkNode(previous))\n ) {\n const textNodesToMatch = getTextNodesToMatch(textNode)\n $handleLinkCreation(textNodesToMatch, matchers, onChangeWrapped)\n }\n\n handleBadNeighbors(textNode, matchers, onChangeWrapped)\n }\n }),\n )\n }, [editor, matchers, onChange])\n}\n\nconst URL_REGEX =\n /((https?:\\/\\/(www\\.)?)|(www\\.))[-\\w@:%.+~#=]{1,256}\\.[a-zA-Z\\d()]{1,6}\\b([-\\w()@:%+.~#?&/=]*)(?<![-.+():%])/\n\nconst EMAIL_REGEX =\n /(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\])|(([a-z\\-\\d]+\\.)+[a-z]{2,}))/i\n\nconst MATCHERS = [\n createLinkMatcherWithRegExp(URL_REGEX, (text) => {\n return text.startsWith('http') ? text : `https://${text}`\n }),\n createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => {\n return `mailto:${text}`\n }),\n]\n\nexport const AutoLinkPlugin: PluginComponent<ClientProps> = () => {\n const [editor] = useLexicalComposerContext()\n\n useAutoLink(editor, MATCHERS)\n\n return null\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$createTextNode","$getSelection","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isTextNode","TextNode","TextNodeValue","useEffect","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$isLinkNode","createLinkMatcherWithRegExp","regExp","urlTransformer","text","match","exec","index","length","url","findFirstMatch","matchers","matcher","PUNCTUATION_OR_SPACE","isSeparator","char","undefined","test","endsWithSeparator","textContent","startsWithSeparator","startsWithTLD","isEmail","isPreviousNodeValid","node","previousNode","getPreviousSibling","getLastDescendant","getTextContent","isNextNodeValid","nextNode","getNextSibling","getFirstDescendant","isContentAroundIsValid","matchStart","matchEnd","nodes","contentBeforeIsValid","contentAfterIsValid","extractMatchingNodes","startIndex","endIndex","unmodifiedBeforeNodes","matchingNodes","unmodifiedAfterNodes","matchingOffset","currentOffset","currentNodes","currentNode","currentNodeText","currentNodeLength","currentNodeStart","currentNodeEnd","push","shift","$createAutoLinkNode_","fields","linkType","linkNode","remainingTextNode","linkTextNode","splitText","textNode","setFormat","getFormat","setDetail","getDetail","setStyle","getStyle","append","replace","firstTextNode","offset","firstLinkTextNode","linkNodes","forEach","endNode","selection","selectedTextNode","getNodes","find","select","anchor","focus","$handleLinkCreation","onChange","initialText","map","join","invalidMatchEnd","matchLength","isValid","actualMatchStart","actualMatchEnd","substring","handleLinkEdit","children","getChildren","childrenLength","i","child","isSimpleText","replaceWithChildren","getFields","flds","setFields","handleBadNeighbors","previousSibling","nextSibling","isEmailURI","startsWith","j","insertAfter","remove","getLatest","getTextNodesToMatch","textNodesToMatch","useAutoLink","editor","hasNodes","Error","onChangeWrapped","prevUrl","registerNodeTransform","parent","getParentOrTh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gBACpBA,SAAS5E,KAAKiH;YAChB;QACF;QAEA,OAAOxI,cACLoI,OAAOK,qBAAqB,CAAChI,eAAe,CAACmE;YAC3C,MAAM8D,SAAS9D,SAAS+D,gBAAgB;YACxC,MAAMC,WAAWhE,SAASpC,kBAAkB;YAC5C,IAAI5B,gBAAgB8H,SAAS;gBAC3B7B,eAAe6B,QAAQjH,UAAU8G;YACnC,OAAO,IAAI,CAACzH,YAAY4H,SAAS;gBAC/B,IACE9D,SAASuC,YAAY,MACpBjF,CAAAA,oBAAoB0C,SAASlC,cAAc,OAAO,CAAC9B,gBAAgBgI,SAAQ,GAC5E;oBACA,MAAMV,mBAAmBD,oBAAoBrD;oBAC7CsB,oBAAoBgC,kBAAkBzG,UAAU8G;gBAClD;gBAEAf,mBAAmB5C,UAAUnD,UAAU8G;YACzC;QACF;IAEJ,GAAG;QAACH;QAAQ3G;QAAU0E;KAAS;AACjC;AAEA,MAAM0C,YACJ;AAEF,MAAMC,cACJ;AAEF,MAAMC,WAAW;IACfhI,4BAA4B8H,WAAW,CAAC3H;QACtC,OAAOA,KAAK0G,UAAU,CAAC,UAAU1G,OAAO,CAAC,QAAQ,EAAEA,MAAM;IAC3D;IACAH,4BAA4B+H,aAAa,CAAC5H;QACxC,OAAO,CAAC,OAAO,EAAEA,MAAM;IACzB;CACD;AAED,OAAO,MAAM8H,iBAA+C;IAC1D,MAAM,CAACZ,OAAO,GAAGrI;IAEjBoI,YAAYC,QAAQW;IAEpB,OAAO;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/link/client/plugins/autoLink/index.tsx"],"sourcesContent":["'use client'\nimport type { ElementNode, LexicalEditor, LexicalNode, TextNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $createTextNode,\n $getSelection,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isTextNode,\n TextNode as TextNodeValue,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { LinkFields } from '../../../nodes/types.js'\nimport type { ClientProps } from '../../index.js'\n\nimport { $createAutoLinkNode, $isAutoLinkNode, AutoLinkNode } from '../../../nodes/AutoLinkNode.js'\nimport { $isLinkNode } from '../../../nodes/LinkNode.js'\n\ntype ChangeHandler = (url: null | string, prevUrl: null | string) => void\n\ninterface LinkMatcherResult {\n fields?: LinkFields\n index: number\n length: number\n text: string\n url: string\n}\n\nexport type LinkMatcher = (text: string) => LinkMatcherResult | null\n\nexport function createLinkMatcherWithRegExp(\n regExp: RegExp,\n urlTransformer: (text: string) => string = (text) => text,\n) {\n return (text: string) => {\n const match = regExp.exec(text)\n if (match === null) {\n return null\n }\n return {\n index: match.index,\n length: match[0].length,\n text: match[0],\n url: urlTransformer(match[0]),\n }\n }\n}\n\nfunction findFirstMatch(text: string, matchers: LinkMatcher[]): LinkMatcherResult | null {\n for (const matcher of matchers) {\n const match = matcher(text)\n\n if (match != null) {\n return match\n }\n }\n\n return null\n}\n\nconst PUNCTUATION_OR_SPACE = /[.,;\\s]/\n\nfunction isSeparator(char: string | undefined): boolean {\n return char !== undefined && PUNCTUATION_OR_SPACE.test(char)\n}\n\nfunction endsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[textContent.length - 1])\n}\n\nfunction startsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[0])\n}\n\n/**\n * Check if the text content starts with a fullstop followed by a top-level domain.\n * Meaning if the text content can be a beginning of a top level domain.\n * @param textContent\n * @param isEmail\n * @returns boolean\n */\nfunction startsWithTLD(textContent: string, isEmail: boolean): boolean {\n if (isEmail) {\n return /^\\.[a-z]{2,}/i.test(textContent)\n } else {\n return /^\\.[a-z0-9]+/i.test(textContent)\n }\n}\n\nfunction isPreviousNodeValid(node: LexicalNode): boolean {\n let previousNode = node.getPreviousSibling()\n if ($isElementNode(previousNode)) {\n previousNode = previousNode.getLastDescendant()\n }\n return (\n previousNode === null ||\n $isLineBreakNode(previousNode) ||\n ($isTextNode(previousNode) && endsWithSeparator(previousNode.getTextContent()))\n )\n}\n\nfunction isNextNodeValid(node: LexicalNode): boolean {\n let nextNode = node.getNextSibling()\n if ($isElementNode(nextNode)) {\n nextNode = nextNode.getFirstDescendant()\n }\n return (\n nextNode === null ||\n $isLineBreakNode(nextNode) ||\n ($isTextNode(nextNode) && startsWithSeparator(nextNode.getTextContent()))\n )\n}\n\nfunction isContentAroundIsValid(\n matchStart: number,\n matchEnd: number,\n text: string,\n nodes: TextNode[],\n): boolean {\n const contentBeforeIsValid =\n matchStart > 0 ? isSeparator(text[matchStart - 1]) : isPreviousNodeValid(nodes[0]!)\n if (!contentBeforeIsValid) {\n return false\n }\n\n const contentAfterIsValid =\n matchEnd < text.length ? isSeparator(text[matchEnd]) : isNextNodeValid(nodes[nodes.length - 1]!)\n return contentAfterIsValid\n}\n\nfunction extractMatchingNodes(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n): [\n matchingOffset: number,\n unmodifiedBeforeNodes: TextNode[],\n matchingNodes: TextNode[],\n unmodifiedAfterNodes: TextNode[],\n] {\n const unmodifiedBeforeNodes: TextNode[] = []\n const matchingNodes: TextNode[] = []\n const unmodifiedAfterNodes: TextNode[] = []\n let matchingOffset = 0\n\n let currentOffset = 0\n const currentNodes = [...nodes]\n\n while (currentNodes.length > 0) {\n const currentNode = currentNodes[0]!\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = currentOffset\n const currentNodeEnd = currentOffset + currentNodeLength\n\n if (currentNodeEnd <= startIndex) {\n unmodifiedBeforeNodes.push(currentNode)\n matchingOffset += currentNodeLength\n } else if (currentNodeStart >= endIndex) {\n unmodifiedAfterNodes.push(currentNode)\n } else {\n matchingNodes.push(currentNode)\n }\n currentOffset += currentNodeLength\n currentNodes.shift()\n }\n return [matchingOffset, unmodifiedBeforeNodes, matchingNodes, unmodifiedAfterNodes]\n}\n\nfunction $createAutoLinkNode_(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n match: LinkMatcherResult,\n): TextNode | undefined {\n const fields = {\n linkType: 'custom',\n url: match.url,\n ...match.fields,\n } as LinkFields\n\n const linkNode = $createAutoLinkNode({ fields })\n if (nodes.length === 1) {\n const remainingTextNode = nodes[0]!\n let linkTextNode: TextNode | undefined\n if (startIndex === 0) {\n ;[linkTextNode] = remainingTextNode.splitText(endIndex)\n } else {\n ;[, linkTextNode] = remainingTextNode.splitText(startIndex, endIndex)\n }\n if (linkTextNode) {\n const textNode = $createTextNode(match.text)\n textNode.setFormat(linkTextNode.getFormat())\n textNode.setDetail(linkTextNode.getDetail())\n textNode.setStyle(linkTextNode.getStyle())\n linkNode.append(textNode)\n linkTextNode.replace(linkNode)\n }\n return remainingTextNode\n } else if (nodes.length > 1) {\n const firstTextNode = nodes[0]!\n let offset = firstTextNode.getTextContent().length\n let firstLinkTextNode\n if (startIndex === 0) {\n firstLinkTextNode = firstTextNode\n } else {\n ;[, firstLinkTextNode] = firstTextNode.splitText(startIndex)\n }\n const linkNodes: LexicalNode[] = []\n let remainingTextNode\n nodes.forEach((currentNode) => {\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = offset\n const currentNodeEnd = offset + currentNodeLength\n if (currentNodeStart < endIndex) {\n if (currentNodeEnd <= endIndex) {\n linkNodes.push(currentNode)\n } else {\n const [linkTextNode, endNode] = currentNode.splitText(endIndex - currentNodeStart)\n if (linkTextNode) {\n linkNodes.push(linkTextNode)\n }\n remainingTextNode = endNode\n }\n }\n offset += currentNodeLength\n })\n\n if (firstLinkTextNode) {\n const selection = $getSelection()\n const selectedTextNode = selection ? selection.getNodes().find($isTextNode) : undefined\n const textNode = $createTextNode(firstLinkTextNode.getTextContent())\n textNode.setFormat(firstLinkTextNode.getFormat())\n textNode.setDetail(firstLinkTextNode.getDetail())\n textNode.setStyle(firstLinkTextNode.getStyle())\n linkNode.append(textNode, ...linkNodes)\n // it does not preserve caret position if caret was at the first text node\n // so we need to restore caret position\n if (selectedTextNode && selectedTextNode === firstLinkTextNode) {\n if ($isRangeSelection(selection)) {\n textNode.select(selection.anchor.offset, selection.focus.offset)\n } else if ($isNodeSelection(selection)) {\n textNode.select(0, textNode.getTextContent().length)\n }\n }\n firstLinkTextNode.replace(linkNode)\n return remainingTextNode\n }\n }\n return undefined\n}\n\nfunction $handleLinkCreation(\n nodes: TextNode[],\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n let currentNodes = [...nodes]\n const initialText = currentNodes.map((node) => node.getTextContent()).join('')\n let text = initialText\n\n let match\n let invalidMatchEnd = 0\n\n while ((match = findFirstMatch(text, matchers)) != null && match !== null) {\n const matchStart: number = match.index\n const matchLength: number = match.length\n const matchEnd = matchStart + matchLength\n const isValid = isContentAroundIsValid(\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n initialText,\n currentNodes,\n )\n\n if (isValid) {\n const [matchingOffset, , matchingNodes, unmodifiedAfterNodes] = extractMatchingNodes(\n currentNodes,\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n )\n\n const actualMatchStart = invalidMatchEnd + matchStart - matchingOffset\n const actualMatchEnd = invalidMatchEnd + matchEnd - matchingOffset\n const remainingTextNode = $createAutoLinkNode_(\n matchingNodes,\n actualMatchStart,\n actualMatchEnd,\n match,\n )\n currentNodes = remainingTextNode\n ? [remainingTextNode, ...unmodifiedAfterNodes]\n : unmodifiedAfterNodes\n onChange(match.url, null)\n invalidMatchEnd = 0\n } else {\n invalidMatchEnd += matchEnd\n }\n\n text = text.substring(matchEnd)\n }\n}\n\nfunction handleLinkEdit(\n linkNode: AutoLinkNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n // Check children are simple text\n const children = linkNode.getChildren()\n const childrenLength = children.length\n for (let i = 0; i < childrenLength; i++) {\n const child = children[i]\n if (!$isTextNode(child) || !child.isSimpleText()) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n }\n\n // Check text content fully matches\n const text = linkNode.getTextContent()\n const match = findFirstMatch(text, matchers)\n if (match === null || match.text !== text) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n // Check neighbors\n if (!isPreviousNodeValid(linkNode) || !isNextNodeValid(linkNode)) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n const url = linkNode.getFields()?.url\n if (url !== match?.url) {\n const flds = linkNode.getFields()\n flds.url = match?.url\n linkNode.setFields(flds)\n onChange(match.url, url ?? null)\n }\n}\n\n// Bad neighbors are edits in neighbor nodes that make AutoLinks incompatible.\n// Given the creation preconditions, these can only be simple text nodes.\nfunction handleBadNeighbors(\n textNode: TextNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n const previousSibling = textNode.getPreviousSibling()\n const nextSibling = textNode.getNextSibling()\n const text = textNode.getTextContent()\n\n if ($isAutoLinkNode(previousSibling)) {\n const isEmailURI = previousSibling.getFields()?.url\n ? (previousSibling.getFields()?.url?.startsWith('mailto:') ?? false)\n : false\n if (!startsWithSeparator(text) || startsWithTLD(text, isEmailURI)) {\n previousSibling.append(textNode)\n handleLinkEdit(previousSibling, matchers, onChange)\n onChange(null, previousSibling.getFields()?.url ?? null)\n }\n }\n\n if ($isAutoLinkNode(nextSibling) && !endsWithSeparator(text)) {\n replaceWithChildren(nextSibling)\n handleLinkEdit(nextSibling, matchers, onChange)\n onChange(null, nextSibling.getFields()?.url ?? null)\n }\n}\n\nfunction replaceWithChildren(node: ElementNode): LexicalNode[] {\n const children = node.getChildren()\n const childrenLength = children.length\n\n for (let j = childrenLength - 1; j >= 0; j--) {\n node.insertAfter(children[j]!)\n }\n\n node.remove()\n return children.map((child) => child.getLatest())\n}\n\nfunction getTextNodesToMatch(textNode: TextNode): TextNode[] {\n // check if next siblings are simple text nodes till a node contains a space separator\n const textNodesToMatch = [textNode]\n let nextSibling = textNode.getNextSibling()\n while (nextSibling !== null && $isTextNode(nextSibling) && nextSibling.isSimpleText()) {\n textNodesToMatch.push(nextSibling)\n if (/\\s/.test(nextSibling.getTextContent())) {\n break\n }\n nextSibling = nextSibling.getNextSibling()\n }\n return textNodesToMatch\n}\n\nfunction useAutoLink(\n editor: LexicalEditor,\n matchers: LinkMatcher[],\n onChange?: ChangeHandler,\n): void {\n useEffect(() => {\n if (!editor.hasNodes([AutoLinkNode])) {\n throw new Error('LexicalAutoLinkPlugin: AutoLinkNode not registered on editor')\n }\n\n const onChangeWrapped = (url: null | string, prevUrl: null | string): void => {\n if (onChange != null) {\n onChange(url, prevUrl)\n }\n }\n\n return mergeRegister(\n editor.registerNodeTransform(TextNodeValue, (textNode: TextNode) => {\n const parent = textNode.getParentOrThrow()\n const previous = textNode.getPreviousSibling()\n if ($isAutoLinkNode(parent)) {\n handleLinkEdit(parent, matchers, onChangeWrapped)\n } else if (!$isLinkNode(parent)) {\n if (\n textNode.isSimpleText() &&\n (startsWithSeparator(textNode.getTextContent()) || !$isAutoLinkNode(previous))\n ) {\n const textNodesToMatch = getTextNodesToMatch(textNode)\n $handleLinkCreation(textNodesToMatch, matchers, onChangeWrapped)\n }\n\n handleBadNeighbors(textNode, matchers, onChangeWrapped)\n }\n }),\n )\n }, [editor, matchers, onChange])\n}\n\nconst URL_REGEX =\n /((https?:\\/\\/(www\\.)?)|(www\\.))[-\\w@:%.+~#=]{1,256}\\.[a-zA-Z\\d()]{1,6}\\b([-\\w()@:%+.~#?&/=]*)(?<![-.+():%])/\n\nconst EMAIL_REGEX =\n /(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\])|(([a-z\\-\\d]+\\.)+[a-z]{2,}))/i\n\nconst MATCHERS = [\n createLinkMatcherWithRegExp(URL_REGEX, (text) => {\n return text.startsWith('http') ? text : `https://${text}`\n }),\n createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => {\n return `mailto:${text}`\n }),\n]\n\nexport const AutoLinkPlugin: PluginComponent<ClientProps> = () => {\n const [editor] = useLexicalComposerContext()\n\n useAutoLink(editor, MATCHERS)\n\n return null\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$createTextNode","$getSelection","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isTextNode","TextNode","TextNodeValue","useEffect","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$isLinkNode","createLinkMatcherWithRegExp","regExp","urlTransformer","text","match","exec","index","length","url","findFirstMatch","matchers","matcher","PUNCTUATION_OR_SPACE","isSeparator","char","undefined","test","endsWithSeparator","textContent","startsWithSeparator","startsWithTLD","isEmail","isPreviousNodeValid","node","previousNode","getPreviousSibling","getLastDescendant","getTextContent","isNextNodeValid","nextNode","getNextSibling","getFirstDescendant","isContentAroundIsValid","matchStart","matchEnd","nodes","contentBeforeIsValid","contentAfterIsValid","extractMatchingNodes","startIndex","endIndex","unmodifiedBeforeNodes","matchingNodes","unmodifiedAfterNodes","matchingOffset","currentOffset","currentNodes","currentNode","currentNodeText","currentNodeLength","currentNodeStart","currentNodeEnd","push","shift","$createAutoLinkNode_","fields","linkType","linkNode","remainingTextNode","linkTextNode","splitText","textNode","setFormat","getFormat","setDetail","getDetail","setStyle","getStyle","append","replace","firstTextNode","offset","firstLinkTextNode","linkNodes","forEach","endNode","selection","selectedTextNode","getNodes","find","select","anchor","focus","$handleLinkCreation","onChange","initialText","map","join","invalidMatchEnd","matchLength","isValid","actualMatchStart","actualMatchEnd","substring","handleLinkEdit","children","getChildren","childrenLength","i","child","isSimpleText","replaceWithChildren","getFields","flds","setFields","handleBadNeighbors","previousSibling","nextSibling","isEmailURI","startsWith","j","insertAfter","remove","getLatest","getTextNodesToMatch","textNodesToMatch","useAutoLink","editor","hasNodes","Error","onChangeWrapped","prevUrl","registerNodeTransform","parent","getParentOrThrow","previous","URL_REGEX","EMAIL_REGEX","MATCHERS","AutoLinkPlugin"],"mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SACEC,eAAe,EACfC,aAAa,EACbC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,WAAW,EACXC,YAAYC,aAAa,QACpB,UAAS;AAChB,SAASC,SAAS,QAAQ,QAAO;AAMjC,SAASC,mBAAmB,EAAEC,eAAe,EAAEC,YAAY,QAAQ,iCAAgC;AACnG,SAASC,WAAW,QAAQ,6BAA4B;AAcxD,OAAO,SAASC,4BACdC,MAAc,EACdC,iBAA2C,CAACC,OAASA,IAAI;IAEzD,OAAO,CAACA;QACN,MAAMC,QAAQH,OAAOI,IAAI,CAACF;QAC1B,IAAIC,UAAU,MAAM;YAClB,OAAO;QACT;QACA,OAAO;YACLE,OAAOF,MAAME,KAAK;YAClBC,QAAQH,KAAK,CAAC,EAAE,CAACG,MAAM;YACvBJ,MAAMC,KAAK,CAAC,EAAE;YACdI,KAAKN,eAAeE,KAAK,CAAC,EAAE;QAC9B;IACF;AACF;AAEA,SAASK,eAAeN,IAAY,EAAEO,QAAuB;IAC3D,KAAK,MAAMC,WAAWD,SAAU;QAC9B,MAAMN,QAAQO,QAAQR;QAEtB,IAAIC,SAAS,MAAM;YACjB,OAAOA;QACT;IACF;IAEA,OAAO;AACT;AAEA,MAAMQ,uBAAuB;AAE7B,SAASC,YAAYC,IAAwB;IAC3C,OAAOA,SAASC,aAAaH,qBAAqBI,IAAI,CAACF;AACzD;AAEA,SAASG,kBAAkBC,WAAmB;IAC5C,OAAOL,YAAYK,WAAW,CAACA,YAAYX,MAAM,GAAG,EAAE;AACxD;AAEA,SAASY,oBAAoBD,WAAmB;IAC9C,OAAOL,YAAYK,WAAW,CAAC,EAAE;AACnC;AAEA;;;;;;CAMC,GACD,SA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oBiH;YAC3C,IAAIrC,YAAY,MAAM;gBACpBA,SAAS5E,KAAKiH;YAChB;QACF;QAEA,OAAOxI,cACLoI,OAAOK,qBAAqB,CAAChI,eAAe,CAACmE;YAC3C,MAAM8D,SAAS9D,SAAS+D,gBAAgB;YACxC,MAAMC,WAAWhE,SAASpC,kBAAkB;YAC5C,IAAI5B,gBAAgB8H,SAAS;gBAC3B7B,eAAe6B,QAAQjH,UAAU8G;YACnC,OAAO,IAAI,CAACzH,YAAY4H,SAAS;gBAC/B,IACE9D,SAASuC,YAAY,MACpBjF,CAAAA,oBAAoB0C,SAASlC,cAAc,OAAO,CAAC9B,gBAAgBgI,SAAQ,GAC5E;oBACA,MAAMV,mBAAmBD,oBAAoBrD;oBAC7CsB,oBAAoBgC,kBAAkBzG,UAAU8G;gBAClD;gBAEAf,mBAAmB5C,UAAUnD,UAAU8G;YACzC;QACF;IAEJ,GAAG;QAACH;QAAQ3G;QAAU0E;KAAS;AACjC;AAEA,MAAM0C,YACJ;AAEF,MAAMC,cACJ;AAEF,MAAMC,WAAW;IACfhI,4BAA4B8H,WAAW,CAAC3H;QACtC,OAAOA,KAAK0G,UAAU,CAAC,UAAU1G,OAAO,CAAC,QAAQ,EAAEA,MAAM;IAC3D;IACAH,4BAA4B+H,aAAa,CAAC5H;QACxC,OAAO,CAAC,OAAO,EAAEA,MAAM;IACzB;CACD;AAED,OAAO,MAAM8H,iBAA+C;IAC1D,MAAM,CAACZ,OAAO,GAAGrI;IAEjBoI,YAAYC,QAAQW;IAEpB,OAAO;AACT,EAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
|
+
import './index.scss';
|
|
5
6
|
import { LinkEditor } from './LinkEditor/index.js';
|
|
6
7
|
export const FloatingLinkEditorPlugin = (props)=>{
|
|
7
8
|
const { anchorElem = document.body } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/link/client/plugins/floatingLinkEditor/index.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponentWithAnchor } from '../../../../typesClient.js'\nimport type { ClientProps } from '../../index.js'\n\nimport './index.scss'\nimport { LinkEditor } from './LinkEditor/index.js'\n\nexport const FloatingLinkEditorPlugin: PluginComponentWithAnchor<ClientProps> = (props) => {\n const { anchorElem = document.body } = props\n\n return createPortal(<LinkEditor anchorElem={anchorElem} />, anchorElem)\n}\n"],"names":["React","createPortal","LinkEditor","FloatingLinkEditorPlugin","props","anchorElem","document","body"],"mappings":"AAAA;;AACA,YAAYA,WAAW,QAAO;AAC9B,SAASC,YAAY,QAAQ,YAAW;
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/link/client/plugins/floatingLinkEditor/index.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponentWithAnchor } from '../../../../typesClient.js'\nimport type { ClientProps } from '../../index.js'\n\nimport './index.scss'\nimport { LinkEditor } from './LinkEditor/index.js'\n\nexport const FloatingLinkEditorPlugin: PluginComponentWithAnchor<ClientProps> = (props) => {\n const { anchorElem = document.body } = props\n\n return createPortal(<LinkEditor anchorElem={anchorElem} />, anchorElem)\n}\n"],"names":["React","createPortal","LinkEditor","FloatingLinkEditorPlugin","props","anchorElem","document","body"],"mappings":"AAAA;;AACA,YAAYA,WAAW,QAAO;AAC9B,SAASC,YAAY,QAAQ,YAAW;AAKxC,OAAO,eAAc;AACrB,SAASC,UAAU,QAAQ,wBAAuB;AAElD,OAAO,MAAMC,2BAAmE,CAACC;IAC/E,MAAM,EAAEC,aAAaC,SAASC,IAAI,EAAE,GAAGH;IAEvC,qBAAOH,2BAAa,KAACC;QAAWG,YAAYA;QAAgBA;AAC9D,EAAC"}
|
|
@@ -70,6 +70,7 @@ export const getBaseFields = (config, enabledCollections, disabledCollections, m
|
|
|
70
70
|
];
|
|
71
71
|
// Only display internal link-specific fields / options / conditions if there are enabled relations
|
|
72
72
|
if (enabledRelations?.length) {
|
|
73
|
+
;
|
|
73
74
|
baseFields[1].options.push({
|
|
74
75
|
label: ({ t })=>t('fields:internalLink'),
|
|
75
76
|
value: 'internal'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/link/server/baseFields.ts"],"sourcesContent":["import type {\n CollectionSlug,\n FieldAffectingData,\n RadioField,\n SanitizedConfig,\n TextField,\n TextFieldSingleValidation,\n TypedUser,\n} from 'payload'\n\nimport type { LinkFields } from '../nodes/types.js'\n\nimport { validateUrl, validateUrlMinimal } from '../../../lexical/utils/url.js'\n\nexport const getBaseFields = (\n config: SanitizedConfig,\n enabledCollections?: CollectionSlug[],\n disabledCollections?: CollectionSlug[],\n maxDepth?: number,\n): FieldAffectingData[] => {\n let enabledRelations: CollectionSlug[]\n\n /**\n * Figure out which relations should be enabled (enabledRelations) based on a collection's admin.enableRichTextLink property,\n * or the Link Feature's enabledCollections and disabledCollections properties which override it.\n */\n if (enabledCollections) {\n enabledRelations = enabledCollections\n } else if (disabledCollections) {\n enabledRelations = config.collections\n .filter(({ slug }) => !disabledCollections.includes(slug))\n .map(({ slug }) => slug)\n } else {\n enabledRelations = config.collections\n .filter(({ admin: { enableRichTextLink, hidden } }) => {\n if (typeof hidden !== 'function' && hidden) {\n return false\n }\n return enableRichTextLink\n })\n .map(({ slug }) => slug)\n }\n\n const baseFields: FieldAffectingData[] = [\n {\n name: 'text',\n type: 'text',\n label: ({ t }) => t('fields:textToDisplay'),\n required: true,\n },\n {\n name: 'linkType',\n type: 'radio',\n admin: {\n description: ({ t }) => t('fields:chooseBetweenCustomTextOrDocument'),\n },\n defaultValue: 'custom',\n label: ({ t }) => t('fields:linkType'),\n options: [\n {\n label: ({ t }) => t('fields:customURL'),\n value: 'custom',\n },\n ],\n required: true,\n } as RadioField,\n {\n name: 'url',\n type: 'text',\n hooks: {\n beforeChange: [\n ({ value }) => {\n if (!value) {\n return\n }\n\n if (!validateUrl(value)) {\n return encodeURIComponent(value)\n }\n return value\n },\n ],\n },\n label: ({ t }) => t('fields:enterURL'),\n required: true,\n validate: ((value: string, options) => {\n if ((options?.siblingData as LinkFields)?.linkType === 'internal') {\n return // no validation needed, as no url should exist for internal links\n }\n if (!validateUrlMinimal(value)) {\n return 'Invalid URL'\n }\n }) as TextFieldSingleValidation,\n },\n ]\n\n // Only display internal link-specific fields / options / conditions if there are enabled relations\n if (enabledRelations?.length) {\n ;(baseFields[1] as RadioField).options.push({\n label: ({ t }) => t('fields:internalLink'),\n value: 'internal',\n })\n ;(baseFields[2] as TextField).admin = {\n condition: (_data, _siblingData) => {\n return _siblingData.linkType !== 'internal'\n },\n }\n\n baseFields.push({\n name: 'doc',\n admin: {\n condition: (_data, _siblingData) => {\n return _siblingData.linkType === 'internal'\n },\n },\n // when admin.hidden is a function we need to dynamically call hidden with the user to know if the collection should be shown\n type: 'relationship',\n filterOptions:\n !enabledCollections && !disabledCollections\n ? async ({ relationTo, req, user }) => {\n const admin = config.collections.find(({ slug }) => slug === relationTo)?.admin\n\n const hidden = admin?.hidden\n if (typeof hidden === 'function' && hidden({ user } as { user: TypedUser })) {\n return false\n }\n\n const baseFilter = admin?.baseFilter ?? admin?.baseListFilter\n return (\n (await baseFilter?.({\n limit: 0,\n page: 1,\n req,\n sort: 'id',\n })) ?? true\n )\n }\n : null,\n label: ({ t }) => t('fields:chooseDocumentToLink'),\n maxDepth,\n relationTo: enabledRelations,\n required: true,\n })\n }\n\n baseFields.push({\n name: 'newTab',\n type: 'checkbox',\n label: ({ t }) => t('fields:openInNewTab'),\n })\n\n return baseFields\n}\n"],"names":["validateUrl","validateUrlMinimal","getBaseFields","config","enabledCollections","disabledCollections","maxDepth","enabledRelations","collections","filter","slug","includes","map","admin","enableRichTextLink","hidden","baseFields","name","type","label","t","required","description","defaultValue","options","value","hooks","beforeChange","encodeURIComponent","validate","siblingData","linkType","length","push","condition","_data","_siblingData","filterOptions","relationTo","req","user","find","baseFilter","baseListFilter","limit","page","sort"],"mappings":"AAYA,SAASA,WAAW,EAAEC,kBAAkB,QAAQ,gCAA+B;AAE/E,OAAO,MAAMC,gBAAgB,CAC3BC,QACAC,oBACAC,qBACAC;IAEA,IAAIC;IAEJ;;;GAGC,GACD,IAAIH,oBAAoB;QACtBG,mBAAmBH;IACrB,OAAO,IAAIC,qBAAqB;QAC9BE,mBAAmBJ,OAAOK,WAAW,CAClCC,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAK,CAACL,oBAAoBM,QAAQ,CAACD,OACnDE,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAE,GAAKA;IACvB,OAAO;QACLH,mBAAmBJ,OAAOK,WAAW,CAClCC,MAAM,CAAC,CAAC,EAAEI,OAAO,EAAEC,kBAAkB,EAAEC,MAAM,EAAE,EAAE;YAChD,IAAI,OAAOA,WAAW,cAAcA,QAAQ;gBAC1C,OAAO;YACT;YACA,OAAOD;QACT,GACCF,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAE,GAAKA;IACvB;IAEA,MAAMM,aAAmC;QACvC;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;YACpBC,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNL,OAAO;gBACLS,aAAa,CAAC,EAAEF,CAAC,EAAE,GAAKA,EAAE;YAC5B;YACAG,cAAc;YACdJ,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;YACpBI,SAAS;gBACP;oBACEL,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBACpBK,OAAO;gBACT;aACD;YACDJ,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNQ,OAAO;gBACLC,cAAc;oBACZ,CAAC,EAAEF,KAAK,EAAE;wBACR,IAAI,CAACA,OAAO;4BACV;wBACF;wBAEA,IAAI,CAACzB,YAAYyB,QAAQ;4BACvB,OAAOG,mBAAmBH;wBAC5B;wBACA,OAAOA;oBACT;iBACD;YACH;YACAN,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;YACpBC,UAAU;YACVQ,UAAW,CAACJ,OAAeD;gBACzB,IAAI,AAACA,SAASM,aAA4BC,aAAa,YAAY;oBACjE;gBACF;gBADS,kEAAkE;gBAE3E,IAAI,CAAC9B,mBAAmBwB,QAAQ;oBAC9B,OAAO;gBACT;YACF;QACF;KACD;IAED,mGAAmG;IACnG,IAAIlB,kBAAkByB,QAAQ
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/link/server/baseFields.ts"],"sourcesContent":["import type {\n CollectionSlug,\n FieldAffectingData,\n RadioField,\n SanitizedConfig,\n TextField,\n TextFieldSingleValidation,\n TypedUser,\n} from 'payload'\n\nimport type { LinkFields } from '../nodes/types.js'\n\nimport { validateUrl, validateUrlMinimal } from '../../../lexical/utils/url.js'\n\nexport const getBaseFields = (\n config: SanitizedConfig,\n enabledCollections?: CollectionSlug[],\n disabledCollections?: CollectionSlug[],\n maxDepth?: number,\n): FieldAffectingData[] => {\n let enabledRelations: CollectionSlug[]\n\n /**\n * Figure out which relations should be enabled (enabledRelations) based on a collection's admin.enableRichTextLink property,\n * or the Link Feature's enabledCollections and disabledCollections properties which override it.\n */\n if (enabledCollections) {\n enabledRelations = enabledCollections\n } else if (disabledCollections) {\n enabledRelations = config.collections\n .filter(({ slug }) => !disabledCollections.includes(slug))\n .map(({ slug }) => slug)\n } else {\n enabledRelations = config.collections\n .filter(({ admin: { enableRichTextLink, hidden } }) => {\n if (typeof hidden !== 'function' && hidden) {\n return false\n }\n return enableRichTextLink\n })\n .map(({ slug }) => slug)\n }\n\n const baseFields: FieldAffectingData[] = [\n {\n name: 'text',\n type: 'text',\n label: ({ t }) => t('fields:textToDisplay'),\n required: true,\n },\n {\n name: 'linkType',\n type: 'radio',\n admin: {\n description: ({ t }) => t('fields:chooseBetweenCustomTextOrDocument'),\n },\n defaultValue: 'custom',\n label: ({ t }) => t('fields:linkType'),\n options: [\n {\n label: ({ t }) => t('fields:customURL'),\n value: 'custom',\n },\n ],\n required: true,\n } as RadioField,\n {\n name: 'url',\n type: 'text',\n hooks: {\n beforeChange: [\n ({ value }) => {\n if (!value) {\n return\n }\n\n if (!validateUrl(value)) {\n return encodeURIComponent(value)\n }\n return value\n },\n ],\n },\n label: ({ t }) => t('fields:enterURL'),\n required: true,\n validate: ((value: string, options) => {\n if ((options?.siblingData as LinkFields)?.linkType === 'internal') {\n return // no validation needed, as no url should exist for internal links\n }\n if (!validateUrlMinimal(value)) {\n return 'Invalid URL'\n }\n }) as TextFieldSingleValidation,\n },\n ]\n\n // Only display internal link-specific fields / options / conditions if there are enabled relations\n if (enabledRelations?.length) {\n ;(baseFields[1] as RadioField).options.push({\n label: ({ t }) => t('fields:internalLink'),\n value: 'internal',\n })\n ;(baseFields[2] as TextField).admin = {\n condition: (_data, _siblingData) => {\n return _siblingData.linkType !== 'internal'\n },\n }\n\n baseFields.push({\n name: 'doc',\n admin: {\n condition: (_data, _siblingData) => {\n return _siblingData.linkType === 'internal'\n },\n },\n // when admin.hidden is a function we need to dynamically call hidden with the user to know if the collection should be shown\n type: 'relationship',\n filterOptions:\n !enabledCollections && !disabledCollections\n ? async ({ relationTo, req, user }) => {\n const admin = config.collections.find(({ slug }) => slug === relationTo)?.admin\n\n const hidden = admin?.hidden\n if (typeof hidden === 'function' && hidden({ user } as { user: TypedUser })) {\n return false\n }\n\n const baseFilter = admin?.baseFilter ?? admin?.baseListFilter\n return (\n (await baseFilter?.({\n limit: 0,\n page: 1,\n req,\n sort: 'id',\n })) ?? true\n )\n }\n : null,\n label: ({ t }) => t('fields:chooseDocumentToLink'),\n maxDepth,\n relationTo: enabledRelations,\n required: true,\n })\n }\n\n baseFields.push({\n name: 'newTab',\n type: 'checkbox',\n label: ({ t }) => t('fields:openInNewTab'),\n })\n\n return baseFields\n}\n"],"names":["validateUrl","validateUrlMinimal","getBaseFields","config","enabledCollections","disabledCollections","maxDepth","enabledRelations","collections","filter","slug","includes","map","admin","enableRichTextLink","hidden","baseFields","name","type","label","t","required","description","defaultValue","options","value","hooks","beforeChange","encodeURIComponent","validate","siblingData","linkType","length","push","condition","_data","_siblingData","filterOptions","relationTo","req","user","find","baseFilter","baseListFilter","limit","page","sort"],"mappings":"AAYA,SAASA,WAAW,EAAEC,kBAAkB,QAAQ,gCAA+B;AAE/E,OAAO,MAAMC,gBAAgB,CAC3BC,QACAC,oBACAC,qBACAC;IAEA,IAAIC;IAEJ;;;GAGC,GACD,IAAIH,oBAAoB;QACtBG,mBAAmBH;IACrB,OAAO,IAAIC,qBAAqB;QAC9BE,mBAAmBJ,OAAOK,WAAW,CAClCC,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAK,CAACL,oBAAoBM,QAAQ,CAACD,OACnDE,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAE,GAAKA;IACvB,OAAO;QACLH,mBAAmBJ,OAAOK,WAAW,CAClCC,MAAM,CAAC,CAAC,EAAEI,OAAO,EAAEC,kBAAkB,EAAEC,MAAM,EAAE,EAAE;YAChD,IAAI,OAAOA,WAAW,cAAcA,QAAQ;gBAC1C,OAAO;YACT;YACA,OAAOD;QACT,GACCF,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAE,GAAKA;IACvB;IAEA,MAAMM,aAAmC;QACvC;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;YACpBC,UAAU;QACZ;QACA;YACEJ,MAAM;YACNC,MAAM;YACNL,OAAO;gBACLS,aAAa,CAAC,EAAEF,CAAC,EAAE,GAAKA,EAAE;YAC5B;YACAG,cAAc;YACdJ,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;YACpBI,SAAS;gBACP;oBACEL,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBAC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B;gBAAK,IAA2B;oBAC3E,OAAO;gBACT;gBAEA,MAAME,aAAa7B,OAAO6B,cAAc7B,OAAO8B;gBAC/C,OACE,AAAC,MAAMD,aAAa;oBAClBE,OAAO;oBACPC,MAAM;oBACNN;oBACAO,MAAM;gBACR,MAAO;YAEX,IACA;YACN3B,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;YACpBd;YACAgC,YAAY/B;YACZc,UAAU;QACZ;IACF;IAEAL,WAAWiB,IAAI,CAAC;QACdhB,MAAM;QACNC,MAAM;QACNC,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;IACtB;IAEA,OAAOJ;AACT,EAAC"}
|
package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport type { UnknownConvertedNodeData } from './index.js'\n\nimport './index.scss'\n\ntype Props = {\n data: UnknownConvertedNodeData\n}\n\nexport const UnknownConvertedNodeComponent: React.FC<Props> = (props) => {\n const { data } = props\n\n return (\n <div>\n Unknown converted payload-plugin-lexical node: <strong>{data?.nodeType}</strong>\n </div>\n )\n}\n"],"names":["React","UnknownConvertedNodeComponent","props","data","div","strong","nodeType"],"mappings":"AAAA;;AACA,OAAOA,WAAW,QAAO;
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport type { UnknownConvertedNodeData } from './index.js'\n\nimport './index.scss'\n\ntype Props = {\n data: UnknownConvertedNodeData\n}\n\nexport const UnknownConvertedNodeComponent: React.FC<Props> = (props) => {\n const { data } = props\n\n return (\n <div>\n Unknown converted payload-plugin-lexical node: <strong>{data?.nodeType}</strong>\n </div>\n )\n}\n"],"names":["React","UnknownConvertedNodeComponent","props","data","div","strong","nodeType"],"mappings":"AAAA;;AACA,OAAOA,WAAW,QAAO;AAIzB,OAAO,eAAc;AAMrB,OAAO,MAAMC,gCAAiD,CAACC;IAC7D,MAAM,EAAEC,IAAI,EAAE,GAAGD;IAEjB,qBACE,MAACE;;YAAI;0BAC4C,KAACC;0BAAQF,MAAMG;;;;AAGpE,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport type { UnknownConvertedNodeData } from './index.js'\n\nimport './index.scss'\n\ntype Props = {\n data: UnknownConvertedNodeData\n}\n\nexport const UnknownConvertedNodeComponent: React.FC<Props> = (props) => {\n const { data } = props\n\n return (\n <div>\n Unknown converted Slate node: <strong>{data?.nodeType}</strong>\n </div>\n )\n}\n"],"names":["React","UnknownConvertedNodeComponent","props","data","div","strong","nodeType"],"mappings":"AAAA;;AACA,OAAOA,WAAW,QAAO;
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport type { UnknownConvertedNodeData } from './index.js'\n\nimport './index.scss'\n\ntype Props = {\n data: UnknownConvertedNodeData\n}\n\nexport const UnknownConvertedNodeComponent: React.FC<Props> = (props) => {\n const { data } = props\n\n return (\n <div>\n Unknown converted Slate node: <strong>{data?.nodeType}</strong>\n </div>\n )\n}\n"],"names":["React","UnknownConvertedNodeComponent","props","data","div","strong","nodeType"],"mappings":"AAAA;;AACA,OAAOA,WAAW,QAAO;AAIzB,OAAO,eAAc;AAMrB,OAAO,MAAMC,gCAAiD,CAACC;IAC7D,MAAM,EAAEC,IAAI,EAAE,GAAGD;IAEjB,qBACE,MAACE;;YAAI;0BAC2B,KAACC;0BAAQF,MAAMG;;;;AAGnD,EAAC"}
|
|
@@ -7,6 +7,7 @@ import { Button, useConfig, usePayloadAPI, useTranslation } from '@payloadcms/ui
|
|
|
7
7
|
import { $getNodeByKey } from 'lexical';
|
|
8
8
|
import React, { useCallback, useReducer, useRef, useState } from 'react';
|
|
9
9
|
import { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js';
|
|
10
|
+
import './index.scss';
|
|
10
11
|
import { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js';
|
|
11
12
|
const initialParams = {
|
|
12
13
|
depth: 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/relationship/client/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useConfig, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport './index.scss'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n className: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nexport const RelationshipComponent: React.FC<Props> = (props) => {\n const {\n className: baseClass,\n data: { relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.',\n )\n }\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const [relatedCollection] = useState(() => getEntityConfig({ collectionSlug: relationTo }))\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey!)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(() => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDocumentDrawer()\n dispatchCacheBust()\n }, [cacheBust, setParams, closeDocumentDrawer])\n\n return (\n <div className={`${baseClass}__contents`} contentEditable={false} ref={relationshipElemRef}>\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: relatedCollection.labels?.singular\n ? getTranslation(relatedCollection.labels?.singular, i18n)\n : relatedCollection.slug,\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : value}\n </p>\n </DocumentDrawerToggler>\n </div>\n {isEditable && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n if (nodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {!!value && <DocumentDrawer onSave={updateRelationship} />}\n </div>\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","useConfig","usePayloadAPI","useTranslation","$getNodeByKey","React","useCallback","useReducer","useRef","useState","useLexicalDocumentDrawer","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","initialParams","depth","RelationshipComponent","props","className","baseClass","data","relationTo","value","nodeKey","Error","relationshipElemRef","editor","isEditable","config","routes","api","serverURL","getEntityConfig","relatedCollection","collectionSlug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","slug","closeDocumentDrawer","DocumentDrawer","DocumentDrawerToggler","id","removeRelationship","update","remove","updateRelationship","div","contentEditable","ref","p","label","labels","singular","admin","useAsTitle","buttonStyle","disabled","el","icon","onClick","dispatchCommand","replace","round","tooltip","e","preventDefault","onSave"],"mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,EAAEC,SAAS,EAAEC,aAAa,EAAEC,cAAc,QAAQ,iBAAgB;AACjF,SAASC,aAAa,QAAQ,UAAS;AACvC,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAIxE,SAASC,wBAAwB,QAAQ,iEAAgE;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/relationship/client/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useConfig, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport './index.scss'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n className: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nexport const RelationshipComponent: React.FC<Props> = (props) => {\n const {\n className: baseClass,\n data: { relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.',\n )\n }\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const [relatedCollection] = useState(() => getEntityConfig({ collectionSlug: relationTo }))\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey!)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(() => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDocumentDrawer()\n dispatchCacheBust()\n }, [cacheBust, setParams, closeDocumentDrawer])\n\n return (\n <div className={`${baseClass}__contents`} contentEditable={false} ref={relationshipElemRef}>\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: relatedCollection.labels?.singular\n ? getTranslation(relatedCollection.labels?.singular, i18n)\n : relatedCollection.slug,\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : value}\n </p>\n </DocumentDrawerToggler>\n </div>\n {isEditable && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n if (nodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {!!value && <DocumentDrawer onSave={updateRelationship} />}\n </div>\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","useConfig","usePayloadAPI","useTranslation","$getNodeByKey","React","useCallback","useReducer","useRef","useState","useLexicalDocumentDrawer","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","initialParams","depth","RelationshipComponent","props","className","baseClass","data","relationTo","value","nodeKey","Error","relationshipElemRef","editor","isEditable","config","routes","api","serverURL","getEntityConfig","relatedCollection","collectionSlug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","slug","closeDocumentDrawer","DocumentDrawer","DocumentDrawerToggler","id","removeRelationship","update","remove","updateRelationship","div","contentEditable","ref","p","label","labels","singular","admin","useAsTitle","buttonStyle","disabled","el","icon","onClick","dispatchCommand","replace","round","tooltip","e","preventDefault","onSave"],"mappings":"AAAA;;AAGA,SAASA,yBAAyB,QAAQ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ACA2C,KAAK;wBACLC,SAAS/B,EAAE;;kCAEb,KAAClC;wBACCyD,aAAY;wBACZzC,WAAW,GAAGC,UAAU,cAAc,CAAC;wBACvCyC,UAAU,CAACjC;wBACXmC,MAAK;wBACLC,SAAS,CAACK;4BACRA,EAAEC,cAAc;4BAChBvB;wBACF;wBACAoB,KAAK;wBACLC,SAAS/B,EAAE;;;;YAKhB,CAAC,CAACd,uBAAS,KAACqB;gBAAe2B,QAAQrB;;;;AAG1C,EAAC"}
|
|
@@ -7,6 +7,7 @@ import * as React from 'react';
|
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
import { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js';
|
|
9
9
|
import { ToolbarButton } from '../../../shared/ToolbarButton/index.js';
|
|
10
|
+
import './index.scss';
|
|
10
11
|
import { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js';
|
|
11
12
|
function ButtonGroupItem({ anchorElem, editor, item }) {
|
|
12
13
|
if (item.Component) {
|