@payloadcms/richtext-lexical 3.28.0-internal.b3cf0a3 → 3.28.0-internal.c4e1bed
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/Field-FLAQN6LU.js +2 -0
- package/dist/exports/client/Field-FLAQN6LU.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-XO6X2M3F.js +12 -0
- package/dist/exports/client/chunk-XO6X2M3F.js.map +7 -0
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blockquote/markdownTransformer.d.ts.map +1 -1
- package/dist/features/blockquote/markdownTransformer.js +1 -2
- package/dist/features/blockquote/markdownTransformer.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +137 -69
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +22 -5
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +9 -5
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +3 -3
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -1
- package/dist/features/experimental_table/markdownTransformer.js +1 -1
- package/dist/features/experimental_table/markdownTransformer.js.map +1 -1
- package/dist/features/indent/client/index.d.ts +1 -1
- package/dist/features/indent/client/index.d.ts.map +1 -1
- package/dist/features/indent/client/index.js.map +1 -1
- package/dist/features/link/nodes/AutoLinkNode.d.ts +3 -2
- package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
- package/dist/features/link/nodes/AutoLinkNode.js +7 -6
- package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
- package/dist/features/link/nodes/LinkNode.d.ts +7 -5
- package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
- package/dist/features/link/nodes/LinkNode.js +13 -7
- package/dist/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/features/link/nodes/types.d.ts +3 -0
- package/dist/features/link/nodes/types.d.ts.map +1 -1
- package/dist/features/link/nodes/types.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +7 -6
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +12 -8
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +1 -2
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +1 -2
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/theme/EditorTheme.d.ts.map +1 -1
- package/dist/lexical/theme/EditorTheme.js +7 -0
- package/dist/lexical/theme/EditorTheme.js.map +1 -1
- package/dist/lexical/utils/guard.d.ts +3 -0
- package/dist/lexical/utils/guard.d.ts.map +1 -1
- package/dist/lexical/utils/guard.js +3 -0
- package/dist/lexical/utils/guard.js.map +1 -1
- package/package.json +18 -23
- package/dist/exports/client/Field-NNWFQETL.js +0 -2
- package/dist/exports/client/Field-NNWFQETL.js.map +0 -7
- package/dist/exports/client/chunk-OZ6Q4DWN.js +0 -12
- package/dist/exports/client/chunk-OZ6Q4DWN.js.map +0 -7
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.d.ts +0 -2
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.d.ts.map +0 -1
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.js +0 -2
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","$createParagraphNode","React","useCallback","useEffect","useRef","useState","createPortal","useEditorConfigContext","isHTMLElement","Point","ENABLE_SLASH_MENU_COMMAND","calculateDistanceFromScrollerElem","getNodeCloseToPoint","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","ADD_BLOCK_MENU_CLASSNAME","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","useAddBlockHandle","editor","anchorElem","isEditable","scrollerElem","parentElement","editorConfig","blockHandleHorizontalOffset","admin","hideGutter","menuRef","hoveredElement","setHoveredElement","onDocumentMouseMove","event","target","distanceFromScrollerElem","pageX","pageY","topLevelNodeKeys","blockElem","_emptyBlockElem","blockNode","foundAtIndex","cache_threshold","horizontalOffset","point","x","y","returnEmptyParagraphs","startIndex","length","useEdgeAsDefault","node","elem","document","addEventListener","removeEventListener","current","handleAddClick","hoveredElementToUse","update","isEmptyParagraph","getType","getTextContent","newParagraph","insertAfter","setTimeout","getElementByKey","getKey","focus","select","dispatchCommand","stopPropagation","preventDefault","_jsx","Fragment","className","onClick","ref","type","AddBlockHandlePlugin","t0","t1","undefined","body","_editable"],"sources":["../../../../../src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor, LexicalNode, ParagraphNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { isHTMLElement } from '../../../utils/guard.js'\nimport { Point } from '../../../utils/point.js'\nimport { ENABLE_SLASH_MENU_COMMAND } from '../../SlashMenu/LexicalTypeaheadMenuPlugin/index.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport './index.scss'\n\nconst ADD_BLOCK_MENU_CLASSNAME = 'add-block-menu'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction useAddBlockHandle(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const { editorConfig } = useEditorConfigContext()\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -24 : 12\n\n const menuRef = useRef<HTMLButtonElement>(null)\n const [hoveredElement, setHoveredElement] = useState<{\n elem: HTMLElement\n node: LexicalNode\n } | null>(null)\n\n useEffect(() => {\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n\n if (distanceFromScrollerElem === -1) {\n setHoveredElement(null)\n return\n }\n\n if (isOnHandleElement(target, ADD_BLOCK_MENU_CLASSNAME)) {\n return\n }\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _emptyBlockElem,\n blockNode,\n foundAtIndex,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n returnEmptyParagraphs: true,\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n })\n\n prevIndex = foundAtIndex\n\n if (!_emptyBlockElem) {\n return\n }\n if (\n blockNode &&\n (hoveredElement?.node !== blockNode || hoveredElement?.elem !== _emptyBlockElem)\n ) {\n setHoveredElement({\n elem: _emptyBlockElem,\n node: blockNode,\n })\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, hoveredElement])\n\n useEffect(() => {\n if (menuRef.current && hoveredElement?.node) {\n setHandlePosition(\n hoveredElement?.elem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, hoveredElement, blockHandleHorizontalOffset])\n\n const handleAddClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n let hoveredElementToUse = hoveredElement\n if (!hoveredElementToUse?.node) {\n return\n }\n\n // 1. Update hoveredElement.node to a new paragraph node if the hoveredElement.node is not a paragraph node\n editor.update(() => {\n // Check if blockNode is an empty text node\n let isEmptyParagraph = true\n if (\n hoveredElementToUse?.node.getType() !== 'paragraph' ||\n hoveredElementToUse.node.getTextContent() !== ''\n ) {\n isEmptyParagraph = false\n }\n\n if (!isEmptyParagraph) {\n const newParagraph = $createParagraphNode()\n hoveredElementToUse?.node.insertAfter(newParagraph)\n\n setTimeout(() => {\n hoveredElementToUse = {\n elem: editor.getElementByKey(newParagraph.getKey())!,\n node: newParagraph,\n }\n setHoveredElement(hoveredElementToUse)\n }, 0)\n }\n })\n\n // 2. Focus on the new paragraph node\n setTimeout(() => {\n editor.update(() => {\n editor.focus()\n\n if (\n hoveredElementToUse?.node &&\n 'select' in hoveredElementToUse.node &&\n typeof hoveredElementToUse.node.select === 'function'\n ) {\n hoveredElementToUse.node.select()\n }\n })\n }, 1)\n\n // Make sure this is called AFTER the focusing has been processed by the browser\n // Otherwise, this won't work\n setTimeout(() => {\n editor.dispatchCommand(ENABLE_SLASH_MENU_COMMAND, {\n node: hoveredElementToUse?.node as ParagraphNode,\n })\n }, 2)\n\n event.stopPropagation()\n event.preventDefault()\n },\n [editor, hoveredElement],\n )\n\n return createPortal(\n <React.Fragment>\n <button\n aria-label=\"Add block\"\n className=\"icon add-block-menu\"\n onClick={(event) => {\n handleAddClick(event)\n }}\n ref={menuRef}\n type=\"button\"\n >\n <div className={isEditable ? 'icon' : ''} />\n </button>\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function AddBlockHandlePlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useAddBlockHandle(editor, anchorElem, editor._editable)\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,YAAYC,KAAA,MAAW;AACvB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AACzD,SAASC,YAAY,QAAQ;AAE7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,KAAK,QAAQ;AACtB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,iCAAiC,QAAQ;AAClD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,iBAAiB,QAAQ;AAGlC,MAAMC,wBAAA,GAA2B;AAEjC,IAAIC,SAAA,GAAYC,QAAA;AAEhB,SAASC,gBAAgBC,UAAkB;EACzC,IAAIA,UAAA,KAAe,GAAG;IACpB,OAAOF,QAAA;EACT;EACA,IAAID,SAAA,IAAa,KAAKA,SAAA,GAAYG,UAAA,EAAY;IAC5C,OAAOH,SAAA;EACT;EAEA,OAAOI,IAAA,CAAKC,KAAK,CAACF,UAAA,GAAa;AACjC;AAEA,SAASG,kBACPC,MAAqB,EACrBC,UAAuB,EACvBC,UAAmB;EAEnB,MAAMC,YAAA,GAAeF,UAAA,CAAWG,aAAa;EAE7C,MAAM;IAAEC;EAAY,CAAE,GAAGtB,s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CAAOwC,MAAM,CAAC;QACZxC,MAAA,CAAOiD,KAAK;QAEZ,IACEV,mBAAA,EAAqBP,IAAA,IACrB,YAAYO,mBAAA,CAAoBP,IAAI,IACpC,OAAOO,mBAAA,CAAoBP,IAAI,CAACkB,MAAM,KAAK,YAC3C;UACAX,mBAAA,CAAoBP,IAAI,CAACkB,MAAM;QACjC;MACF;IACF,GAAG;IAEH;IACA;IACAJ,UAAA,CAAW;MACT9C,MAAA,CAAOmD,eAAe,CAACjE,yBAAA,EAA2B;QAChD8C,IAAA,EAAMO,mBAAA,EAAqBP;MAC7B;IACF,GAAG;IAEHnB,OAAA,CAAMuC,eAAe;IACrBvC,OAAA,CAAMwC,cAAc;EACtB,GACA,CAACrD,MAAA,EAAQU,cAAA,CAAe;EAG1B,oBAAO5B,YAAA,cACLwE,IAAA,CAAC7E,KAAA,CAAM8E,QAAQ;cACb,aAAAD,IAAA,CAAC;MACC,cAAW;MACXE,SAAA,EAAU;MACVC,OAAA,EAAU5C,OAAA;QACRyB,cAAA,CAAezB,OAAA;MACjB;MACA6C,GAAA,EAAKjD,OAAA;MACLkD,IAAA,EAAK;gBAEL,aAAAL,IAAA,CAAC;QAAIE,SAAA,EAAWtD,UAAA,GAAa,SAAS;;;MAG1CD,UAAA;AAEJ;AAEA,OAAO,SAAA2D,qBAAAC,EAAA;EAA8B;IAAA5D,UAAA,EAAA6D;EAAA,IAAAD,EAIpC;EAHC,MAAA5D,UAAA,GAAA6D,EAA0B,KAAAC,SAAA,GAAA7B,QAAA,CAAA8B,IAAA,GAA1BF,EAA0B;EAI1B,OAAA9D,MAAA,IAAiBzB,yBAAA;EAAA,OACVwB,iBAAA,CAAkBC,MAAA,EAAQC,UAAA,EAAYD,MAAA,CAAAiE,SAAgB;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","$createParagraphNode","isHTMLElement","React","useCallback","useEffect","useRef","useState","createPortal","useEditorConfigContext","Point","ENABLE_SLASH_MENU_COMMAND","calculateDistanceFromScrollerElem","getNodeCloseToPoint","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","ADD_BLOCK_MENU_CLASSNAME","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","useAddBlockHandle","editor","anchorElem","isEditable","scrollerElem","parentElement","editorConfig","blockHandleHorizontalOffset","admin","hideGutter","menuRef","hoveredElement","setHoveredElement","onDocumentMouseMove","event","target","distanceFromScrollerElem","pageX","pageY","topLevelNodeKeys","blockElem","_emptyBlockElem","blockNode","foundAtIndex","cache_threshold","horizontalOffset","point","x","y","returnEmptyParagraphs","startIndex","length","useEdgeAsDefault","node","elem","document","addEventListener","removeEventListener","current","handleAddClick","hoveredElementToUse","update","isEmptyParagraph","getType","getTextContent","newParagraph","insertAfter","setTimeout","getElementByKey","getKey","focus","select","dispatchCommand","stopPropagation","preventDefault","_jsx","Fragment","className","onClick","ref","type","AddBlockHandlePlugin","t0","t1","undefined","body","_editable"],"sources":["../../../../../src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor, LexicalNode, ParagraphNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode, isHTMLElement } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { Point } from '../../../utils/point.js'\nimport { ENABLE_SLASH_MENU_COMMAND } from '../../SlashMenu/LexicalTypeaheadMenuPlugin/index.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport './index.scss'\n\nconst ADD_BLOCK_MENU_CLASSNAME = 'add-block-menu'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction useAddBlockHandle(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const { editorConfig } = useEditorConfigContext()\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -24 : 12\n\n const menuRef = useRef<HTMLButtonElement>(null)\n const [hoveredElement, setHoveredElement] = useState<{\n elem: HTMLElement\n node: LexicalNode\n } | null>(null)\n\n useEffect(() => {\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n\n if (distanceFromScrollerElem === -1) {\n setHoveredElement(null)\n return\n }\n\n if (isOnHandleElement(target, ADD_BLOCK_MENU_CLASSNAME)) {\n return\n }\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _emptyBlockElem,\n blockNode,\n foundAtIndex,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n returnEmptyParagraphs: true,\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n })\n\n prevIndex = foundAtIndex\n\n if (!_emptyBlockElem) {\n return\n }\n if (\n blockNode &&\n (hoveredElement?.node !== blockNode || hoveredElement?.elem !== _emptyBlockElem)\n ) {\n setHoveredElement({\n elem: _emptyBlockElem,\n node: blockNode,\n })\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, hoveredElement])\n\n useEffect(() => {\n if (menuRef.current && hoveredElement?.node) {\n setHandlePosition(\n hoveredElement?.elem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, hoveredElement, blockHandleHorizontalOffset])\n\n const handleAddClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n let hoveredElementToUse = hoveredElement\n if (!hoveredElementToUse?.node) {\n return\n }\n\n // 1. Update hoveredElement.node to a new paragraph node if the hoveredElement.node is not a paragraph node\n editor.update(() => {\n // Check if blockNode is an empty text node\n let isEmptyParagraph = true\n if (\n hoveredElementToUse?.node.getType() !== 'paragraph' ||\n hoveredElementToUse.node.getTextContent() !== ''\n ) {\n isEmptyParagraph = false\n }\n\n if (!isEmptyParagraph) {\n const newParagraph = $createParagraphNode()\n hoveredElementToUse?.node.insertAfter(newParagraph)\n\n setTimeout(() => {\n hoveredElementToUse = {\n elem: editor.getElementByKey(newParagraph.getKey())!,\n node: newParagraph,\n }\n setHoveredElement(hoveredElementToUse)\n }, 0)\n }\n })\n\n // 2. Focus on the new paragraph node\n setTimeout(() => {\n editor.update(() => {\n editor.focus()\n\n if (\n hoveredElementToUse?.node &&\n 'select' in hoveredElementToUse.node &&\n typeof hoveredElementToUse.node.select === 'function'\n ) {\n hoveredElementToUse.node.select()\n }\n })\n }, 1)\n\n // Make sure this is called AFTER the focusing has been processed by the browser\n // Otherwise, this won't work\n setTimeout(() => {\n editor.dispatchCommand(ENABLE_SLASH_MENU_COMMAND, {\n node: hoveredElementToUse?.node as ParagraphNode,\n })\n }, 2)\n\n event.stopPropagation()\n event.preventDefault()\n },\n [editor, hoveredElement],\n )\n\n return createPortal(\n <React.Fragment>\n <button\n aria-label=\"Add block\"\n className=\"icon add-block-menu\"\n onClick={(event) => {\n handleAddClick(event)\n }}\n ref={menuRef}\n type=\"button\"\n >\n <div className={isEditable ? 'icon' : ''} />\n </button>\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function AddBlockHandlePlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useAddBlockHandle(editor, anchorElem, editor._editable)\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,EAAEC,aAAa,QAAQ;AACpD,YAAYC,KAAA,MAAW;AACvB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AACzD,SAASC,YAAY,QAAQ;AAE7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,KAAK,QAAQ;AACtB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,iCAAiC,QAAQ;AAClD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,iBAAiB,QAAQ;AAGlC,MAAMC,wBAAA,GAA2B;AAEjC,IAAIC,SAAA,GAAYC,QAAA;AAEhB,SAASC,gBAAgBC,UAAkB;EACzC,IAAIA,UAAA,KAAe,GAAG;IACpB,OAAOF,QAAA;EACT;EACA,IAAID,SAAA,IAAa,KAAKA,SAAA,GAAYG,UAAA,EAAY;IAC5C,OAAOH,SAAA;EACT;EAEA,OAAOI,IAAA,CAAKC,KAAK,CAACF,UAAA,GAAa;AACjC;AAEA,SAASG,kBACPC,MAAqB,EACrBC,UAAuB,EACvBC,UAAmB;EAEnB,MAAMC,YAAA,GAAeF,UAAA,CAAWG,aAAa;EAE7C,MAAM;IAAEC;EAAY,CAAE,GAAGrB,sBAAA;EACzB,MAAMsB,2BAAA,GAA8BD,YAAA,EAAcE,KAAA,EAAOC,UAAA,GAAa,CAAC,KAAK;EAE5E,MAAMC,O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CAAoBP,IAAI,IACpC,OAAOO,mBAAA,CAAoBP,IAAI,CAACkB,MAAM,KAAK,YAC3C;UACAX,mBAAA,CAAoBP,IAAI,CAACkB,MAAM;QACjC;MACF;IACF,GAAG;IAEH;IACA;IACAJ,UAAA,CAAW;MACT9C,MAAA,CAAOmD,eAAe,CAACjE,yBAAA,EAA2B;QAChD8C,IAAA,EAAMO,mBAAA,EAAqBP;MAC7B;IACF,GAAG;IAEHnB,OAAA,CAAMuC,eAAe;IACrBvC,OAAA,CAAMwC,cAAc;EACtB,GACA,CAACrD,MAAA,EAAQU,cAAA,CAAe;EAG1B,oBAAO3B,YAAA,cACLuE,IAAA,CAAC5E,KAAA,CAAM6E,QAAQ;cACb,aAAAD,IAAA,CAAC;MACC,cAAW;MACXE,SAAA,EAAU;MACVC,OAAA,EAAU5C,OAAA;QACRyB,cAAA,CAAezB,OAAA;MACjB;MACA6C,GAAA,EAAKjD,OAAA;MACLkD,IAAA,EAAK;gBAEL,aAAAL,IAAA,CAAC;QAAIE,SAAA,EAAWtD,UAAA,GAAa,SAAS;;;MAG1CD,UAAA;AAEJ;AAEA,OAAO,SAAA2D,qBAAAC,EAAA;EAA8B;IAAA5D,UAAA,EAAA6D;EAAA,IAAAD,EAIpC;EAHC,MAAA5D,UAAA,GAAA6D,EAA0B,KAAAC,SAAA,GAAA7B,QAAA,CAAA8B,IAAA,GAA1BF,EAA0B;EAI1B,OAAA9D,MAAA,IAAiBzB,yBAAA;EAAA,OACVwB,iBAAA,CAAkBC,MAAA,EAAQC,UAAA,EAAYD,MAAA,CAAAiE,SAAgB;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,OAAO,cAAc,CAAA;AAqarB,wBAAgB,oBAAoB,CAAC,EACnC,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,KAAK,CAAC,YAAY,CAGrB"}
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
5
5
|
import { eventFiles } from '@lexical/rich-text';
|
|
6
|
-
import { $getNearestNodeFromDOMNode, $getNodeByKey } from 'lexical';
|
|
6
|
+
import { $getNearestNodeFromDOMNode, $getNodeByKey, isHTMLElement } from 'lexical';
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import { useEffect, useRef, useState } from 'react';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
10
|
import { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js';
|
|
11
|
-
import { isHTMLElement } from '../../../utils/guard.js';
|
|
12
11
|
import { Point } from '../../../utils/point.js';
|
|
13
12
|
import { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js';
|
|
14
13
|
import { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","eventFiles","$getNearestNodeFromDOMNode","$getNodeByKey","React","useEffect","useRef","useState","createPortal","useEditorConfigContext","isHTMLElement","Point","calculateDistanceFromScrollerElem","getNodeCloseToPoint","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","getBoundingClientRectWithoutTransform","setTargetLine","DRAGGABLE_BLOCK_MENU_CLASSNAME","DRAG_DATA_FORMAT","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","setDragImage","dataTransfer","draggableBlockElem","transform","style","setTimeout","hideTargetLine","targetLineElem","lastTargetBlockElem","opacity","marginBottom","marginTop","useDraggableBlockMenu","editor","anchorElem","isEditable","scrollerElem","parentElement","menuRef","targetLineRef","debugHighlightRef","isDraggingBlockRef","setDraggableBlockElem","lastTargetBlock","setLastTargetBlock","editorConfig","blockHandleHorizontalOffset","admin","hideGutter","onDocumentMouseMove","event","target","distanceFromScrollerElem","pageX","pageY","topLevelNodeKeys","blockElem","_draggableBlockElem","foundAtIndex","isFoundNodeEmptyParagraph","cache_threshold","horizontalOffset","point","x","y","startIndex","length","useEdgeAsDefault","verbose","document","addEventListener","removeEventListener","current","onDragover","isFileTransfer","targetBlockElem","fuzzy","isBelow","willStayInSamePosition","getBoundingClientRect","width","preventDefault","boundingBox","elem","onDrop","dragData","getData","update","draggedNode","targetNode","height","targetBlockElemHeight","top","targetBlockElemTop","mouseY","window","scrollY","insertAfter","insertBefore","remove","allPrevHighlighters","querySelectorAll","forEach","highlighter","newInsertedElem","getElementByKey","getKey","newInsertedElemRect","highlightElem","createElement","className","backgroundColor","transition","zIndex","pointerEvents","boxSizing","borderRadius","position","body","appendChild","left","onDragStart","nodeKey","node","setData","onDragEnd","_jsxs","Fragment","_jsx","draggable","ref","DraggableBlockPlugin","t0","t1","undefined","_editable"],"sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\nimport type { DragEvent as ReactDragEvent } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { eventFiles } from '@lexical/rich-text'\nimport { $getNearestNodeFromDOMNode, $getNodeByKey } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { isHTMLElement } from '../../../utils/guard.js'\nimport { Point } from '../../../utils/point.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\nimport './index.scss'\nimport { setTargetLine } from './setTargetLine.js'\n\nconst DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu'\nconst DRAG_DATA_FORMAT = 'application/x-lexical-drag-block'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction setDragImage(dataTransfer: DataTransfer, draggableBlockElem: HTMLElement) {\n const { transform } = draggableBlockElem.style\n\n // Remove dragImage borders\n dataTransfer.setDragImage(draggableBlockElem, 0, 0)\n\n setTimeout(() => {\n draggableBlockElem.style.transform = transform\n })\n}\n\nfunction hideTargetLine(\n targetLineElem: HTMLElement | null,\n lastTargetBlockElem: HTMLElement | null,\n) {\n if (targetLineElem) {\n targetLineElem.style.opacity = '0'\n }\n if (lastTargetBlockElem) {\n lastTargetBlockElem.style.opacity = ''\n // Delete marginBottom and marginTop values we set\n lastTargetBlockElem.style.marginBottom = ''\n lastTargetBlockElem.style.marginTop = ''\n //lastTargetBlock.style.border = 'none'\n }\n}\n\nfunction useDraggableBlockMenu(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const menuRef = useRef<HTMLDivElement>(null)\n const targetLineRef = useRef<HTMLDivElement>(null)\n const debugHighlightRef = useRef<HTMLDivElement>(null)\n const isDraggingBlockRef = useRef<boolean>(false)\n const [draggableBlockElem, setDraggableBlockElem] = useState<HTMLElement | null>(null)\n const [lastTargetBlock, setLastTargetBlock] = useState<{\n boundingBox?: DOMRect\n elem: HTMLElement | null\n isBelow: boolean\n } | null>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -44 : -8\n\n useEffect(() => {\n /**\n * Handles positioning of the drag handle\n */\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n if (distanceFromScrollerElem === -1) {\n setDraggableBlockElem(null)\n return\n }\n\n if (isOnHandleElement(target, DRAGGABLE_BLOCK_MENU_CLASSNAME)) {\n return\n }\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _draggableBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n verbose: false,\n })\n\n prevIndex = foundAtIndex\n\n //if (DEBUG && _draggableBlockElem) {\n //targetBlockElem.style.border = '3px solid red'\n // highlightElemOriginalPosition(debugHighlightRef, _draggableBlockElem, anchorElem)\n //}\n\n if (!_draggableBlockElem && !isFoundNodeEmptyParagraph) {\n return\n }\n\n if (draggableBlockElem !== _draggableBlockElem) {\n setDraggableBlockElem(_draggableBlockElem)\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, draggableBlockElem])\n\n useEffect(() => {\n if (menuRef.current) {\n setHandlePosition(\n draggableBlockElem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, draggableBlockElem, blockHandleHorizontalOffset])\n\n useEffect(() => {\n function onDragover(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n\n const { pageY, target } = event\n if (!isHTMLElement(target)) {\n return false\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: targetBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: true,\n verbose: true,\n })\n\n prevIndex = foundAtIndex\n\n const targetLineElem = targetLineRef.current\n // targetBlockElem === null shouldn't happen\n if (targetBlockElem === null || targetLineElem === null) {\n return false\n }\n\n if (draggableBlockElem !== targetBlockElem) {\n const { isBelow, willStayInSamePosition } = setTargetLine(\n editorConfig?.admin?.hideGutter ? '0px' : '3rem',\n blockHandleHorizontalOffset +\n (editorConfig?.admin?.hideGutter\n ? (menuRef?.current?.getBoundingClientRect()?.width ?? 0)\n : -(menuRef?.current?.getBoundingClientRect()?.width ?? 0)),\n targetLineElem,\n targetBlockElem,\n lastTargetBlock!,\n pageY,\n anchorElem,\n event,\n debugHighlightRef,\n isFoundNodeEmptyParagraph,\n )\n\n // Prevent default event to be able to trigger onDrop events\n // Calling preventDefault() adds the green plus icon to the cursor,\n // indicating that the drop is allowed.\n event.preventDefault()\n\n if (!willStayInSamePosition) {\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow,\n })\n }\n } else if (lastTargetBlock?.elem) {\n hideTargetLine(targetLineElem, lastTargetBlock.elem)\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow: false,\n })\n }\n\n return true\n }\n\n function onDrop(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n const { dataTransfer, pageY, target } = event\n const dragData = dataTransfer?.getData(DRAG_DATA_FORMAT) || ''\n\n editor.update(() => {\n const draggedNode = $getNodeByKey(dragData)\n if (!draggedNode) {\n return false\n }\n if (!isHTMLElement(target)) {\n return false\n }\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const { blockElem: targetBlockElem, isFoundNodeEmptyParagraph } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n useEdgeAsDefault: true,\n })\n\n if (!targetBlockElem) {\n return false\n }\n const targetNode = $getNearestNodeFromDOMNode(targetBlockElem)\n if (!targetNode) {\n return false\n }\n if (targetNode === draggedNode) {\n return true\n }\n\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n getBoundingClientRectWithoutTransform(targetBlockElem)\n\n const mouseY = pageY\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n targetNode.insertAfter(draggedNode)\n } else {\n // above targetBlockElem\n targetNode.insertBefore(draggedNode)\n }\n } else {\n //\n targetNode.insertBefore(draggedNode)\n targetNode.remove()\n }\n\n /*\n if (pageY >= targetBlockElemTop + targetBlockElemHeight / 2) {\n targetNode.insertAfter(draggedNode)\n } else {\n targetNode.insertBefore(draggedNode)\n }*/\n if (draggableBlockElem !== null) {\n setDraggableBlockElem(null)\n }\n\n // find all previous elements with lexical-block-highlighter class and remove them\n const allPrevHighlighters = document.querySelectorAll('.lexical-block-highlighter')\n allPrevHighlighters.forEach((highlighter) => {\n highlighter.remove()\n })\n\n const newInsertedElem = editor.getElementByKey(draggedNode.getKey())\n setTimeout(() => {\n // add new temp html element to newInsertedElem with the same height and width and the class block-selected\n // to highlight the new inserted element\n const newInsertedElemRect = newInsertedElem?.getBoundingClientRect()\n if (!newInsertedElemRect) {\n return\n }\n const highlightElem = document.createElement('div')\n highlightElem.className = 'lexical-block-highlighter'\n\n highlightElem.style.backgroundColor = 'var(--theme-elevation-1000'\n highlightElem.style.transition = 'opacity 0.5s ease-in-out'\n highlightElem.style.zIndex = '1'\n highlightElem.style.pointerEvents = 'none'\n highlightElem.style.boxSizing = 'border-box'\n highlightElem.style.borderRadius = '4px'\n highlightElem.style.position = 'absolute'\n document.body.appendChild(highlightElem)\n\n highlightElem.style.opacity = '0.1'\n\n highlightElem.style.height = `${newInsertedElemRect.height + 8}px`\n highlightElem.style.width = `${newInsertedElemRect.width + 8}px`\n highlightElem.style.top = `${newInsertedElemRect.top + window.scrollY - 4}px`\n highlightElem.style.left = `${newInsertedElemRect.left - 4}px`\n\n setTimeout(() => {\n highlightElem.style.opacity = '0'\n setTimeout(() => {\n highlightElem.remove()\n }, 500)\n }, 1000)\n }, 120)\n })\n\n return true\n }\n\n // register onDragover event listeners:\n document.addEventListener('dragover', onDragover)\n // register onDrop event listeners:\n document.addEventListener('drop', onDrop)\n\n return () => {\n document.removeEventListener('dragover', onDragover)\n document.removeEventListener('drop', onDrop)\n }\n }, [\n scrollerElem,\n blockHandleHorizontalOffset,\n anchorElem,\n editor,\n lastTargetBlock,\n draggableBlockElem,\n editorConfig?.admin?.hideGutter,\n ])\n\n function onDragStart(event: ReactDragEvent<HTMLDivElement>): void {\n const dataTransfer = event.dataTransfer\n if (!dataTransfer || !draggableBlockElem) {\n return\n }\n setDragImage(dataTransfer, draggableBlockElem)\n let nodeKey = ''\n editor.update(() => {\n const node = $getNearestNodeFromDOMNode(draggableBlockElem)\n if (node) {\n nodeKey = node.getKey()\n }\n })\n isDraggingBlockRef.current = true\n dataTransfer.setData(DRAG_DATA_FORMAT, nodeKey)\n }\n\n function onDragEnd(): void {\n isDraggingBlockRef.current = false\n if (lastTargetBlock?.elem) {\n hideTargetLine(targetLineRef.current, lastTargetBlock?.elem)\n }\n }\n\n return createPortal(\n <React.Fragment>\n <div\n className=\"icon draggable-block-menu\"\n draggable\n onDragEnd={onDragEnd}\n onDragStart={onDragStart}\n ref={menuRef}\n >\n <div className={isEditable ? 'icon' : ''} />\n </div>\n <div className=\"draggable-block-target-line\" ref={targetLineRef} />\n <div className=\"debug-highlight\" ref={debugHighlightRef} />\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function DraggableBlockPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useDraggableBlockMenu(editor, anchorElem, editor._editable)\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,0BAA0B,EAAEC,aAAa,QAAQ;AAC1D,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAC5C,SAASC,YAAY,QAAQ;AAE7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,KAAK,QAAQ;AACtB,SAASC,iCAAiC,QAAQ;AAClD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,qCAAqC,QAAQ;AAEtD,SAASC,aAAa,QAAQ;AAE9B,MAAMC,8BAAA,GAAiC;AACvC,MAAMC,gBAAA,GAAmB;AAEzB,IAAIC,SAAA,GAAYC,QAAA;AAEhB,SAASC,g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QACRD,OAAA,GAAUC,IAAA,CAAKjB,MAAM;MACvB;IACF;IACAjE,kBAAA,CAAmB+B,OAAO,GAAG;IAC7BnD,cAAA,CAAauG,OAAO,CAAC/G,gBAAA,EAAkB6G,OAAA;EACzC;EAEA,SAASG,UAAA;IACPpF,kBAAA,CAAmB+B,OAAO,GAAG;IAC7B,IAAI7B,eAAA,EAAiBwC,IAAA,EAAM;MACzBzD,cAAA,CAAea,aAAA,CAAciC,OAAO,EAAE7B,eAAA,EAAiBwC,IAAA;IACzD;EACF;EAEA,oBAAOlF,YAAA,cACL6H,KAAA,CAACjI,KAAA,CAAMkI,QAAQ;4BACbC,IAAA,CAAC;MACClB,SAAA,EAAU;MACVmB,SAAS;MACTJ,SAAA,EAAWA,SAAA;MACXJ,WAAA,EAAaA,WAAA;MACbS,GAAA,EAAK5F,OAAA;gBAEL,aAAA0F,IAAA,CAAC;QAAIlB,SAAA,EAAW3E,UAAA,GAAa,SAAS;;qBAExC6F,IAAA,CAAC;MAAIlB,SAAA,EAAU;MAA8BoB,GAAA,EAAK3F;qBAClDyF,IAAA,CAAC;MAAIlB,SAAA,EAAU;MAAkBoB,GAAA,EAAK1F;;MAExCN,UAAA;AAEJ;AAEA,OAAO,SAAAiG,qBAAAC,EAAA;EAA8B;IAAAlG,UAAA,EAAAmG;EAAA,IAAAD,EAIpC;EAHC,MAAAlG,UAAA,GAAAmG,EAA0B,KAAAC,SAAA,GAAAjE,QAAA,CAAAiD,IAAA,GAA1Be,EAA0B;EAI1B,OAAApG,MAAA,IAAiBxC,yBAAA;EAAA,OACVuC,qBAAA,CAAsBC,MAAA,EAAQC,UAAA,EAAYD,MAAA,CAAAsG,SAAgB;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","eventFiles","$getNearestNodeFromDOMNode","$getNodeByKey","isHTMLElement","React","useEffect","useRef","useState","createPortal","useEditorConfigContext","Point","calculateDistanceFromScrollerElem","getNodeCloseToPoint","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","getBoundingClientRectWithoutTransform","setTargetLine","DRAGGABLE_BLOCK_MENU_CLASSNAME","DRAG_DATA_FORMAT","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","setDragImage","dataTransfer","draggableBlockElem","transform","style","setTimeout","hideTargetLine","targetLineElem","lastTargetBlockElem","opacity","marginBottom","marginTop","useDraggableBlockMenu","editor","anchorElem","isEditable","scrollerElem","parentElement","menuRef","targetLineRef","debugHighlightRef","isDraggingBlockRef","setDraggableBlockElem","lastTargetBlock","setLastTargetBlock","editorConfig","blockHandleHorizontalOffset","admin","hideGutter","onDocumentMouseMove","event","target","distanceFromScrollerElem","pageX","pageY","topLevelNodeKeys","blockElem","_draggableBlockElem","foundAtIndex","isFoundNodeEmptyParagraph","cache_threshold","horizontalOffset","point","x","y","startIndex","length","useEdgeAsDefault","verbose","document","addEventListener","removeEventListener","current","onDragover","isFileTransfer","targetBlockElem","fuzzy","isBelow","willStayInSamePosition","getBoundingClientRect","width","preventDefault","boundingBox","elem","onDrop","dragData","getData","update","draggedNode","targetNode","height","targetBlockElemHeight","top","targetBlockElemTop","mouseY","window","scrollY","insertAfter","insertBefore","remove","allPrevHighlighters","querySelectorAll","forEach","highlighter","newInsertedElem","getElementByKey","getKey","newInsertedElemRect","highlightElem","createElement","className","backgroundColor","transition","zIndex","pointerEvents","boxSizing","borderRadius","position","body","appendChild","left","onDragStart","nodeKey","node","setData","onDragEnd","_jsxs","Fragment","_jsx","draggable","ref","DraggableBlockPlugin","t0","t1","undefined","_editable"],"sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\nimport type { DragEvent as ReactDragEvent } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { eventFiles } from '@lexical/rich-text'\nimport { $getNearestNodeFromDOMNode, $getNodeByKey, isHTMLElement } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { Point } from '../../../utils/point.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\nimport './index.scss'\nimport { setTargetLine } from './setTargetLine.js'\n\nconst DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu'\nconst DRAG_DATA_FORMAT = 'application/x-lexical-drag-block'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction setDragImage(dataTransfer: DataTransfer, draggableBlockElem: HTMLElement) {\n const { transform } = draggableBlockElem.style\n\n // Remove dragImage borders\n dataTransfer.setDragImage(draggableBlockElem, 0, 0)\n\n setTimeout(() => {\n draggableBlockElem.style.transform = transform\n })\n}\n\nfunction hideTargetLine(\n targetLineElem: HTMLElement | null,\n lastTargetBlockElem: HTMLElement | null,\n) {\n if (targetLineElem) {\n targetLineElem.style.opacity = '0'\n }\n if (lastTargetBlockElem) {\n lastTargetBlockElem.style.opacity = ''\n // Delete marginBottom and marginTop values we set\n lastTargetBlockElem.style.marginBottom = ''\n lastTargetBlockElem.style.marginTop = ''\n //lastTargetBlock.style.border = 'none'\n }\n}\n\nfunction useDraggableBlockMenu(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const menuRef = useRef<HTMLDivElement>(null)\n const targetLineRef = useRef<HTMLDivElement>(null)\n const debugHighlightRef = useRef<HTMLDivElement>(null)\n const isDraggingBlockRef = useRef<boolean>(false)\n const [draggableBlockElem, setDraggableBlockElem] = useState<HTMLElement | null>(null)\n const [lastTargetBlock, setLastTargetBlock] = useState<{\n boundingBox?: DOMRect\n elem: HTMLElement | null\n isBelow: boolean\n } | null>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -44 : -8\n\n useEffect(() => {\n /**\n * Handles positioning of the drag handle\n */\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n if (distanceFromScrollerElem === -1) {\n setDraggableBlockElem(null)\n return\n }\n\n if (isOnHandleElement(target, DRAGGABLE_BLOCK_MENU_CLASSNAME)) {\n return\n }\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _draggableBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n verbose: false,\n })\n\n prevIndex = foundAtIndex\n\n //if (DEBUG && _draggableBlockElem) {\n //targetBlockElem.style.border = '3px solid red'\n // highlightElemOriginalPosition(debugHighlightRef, _draggableBlockElem, anchorElem)\n //}\n\n if (!_draggableBlockElem && !isFoundNodeEmptyParagraph) {\n return\n }\n\n if (draggableBlockElem !== _draggableBlockElem) {\n setDraggableBlockElem(_draggableBlockElem)\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, draggableBlockElem])\n\n useEffect(() => {\n if (menuRef.current) {\n setHandlePosition(\n draggableBlockElem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, draggableBlockElem, blockHandleHorizontalOffset])\n\n useEffect(() => {\n function onDragover(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n\n const { pageY, target } = event\n if (!isHTMLElement(target)) {\n return false\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: targetBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: true,\n verbose: true,\n })\n\n prevIndex = foundAtIndex\n\n const targetLineElem = targetLineRef.current\n // targetBlockElem === null shouldn't happen\n if (targetBlockElem === null || targetLineElem === null) {\n return false\n }\n\n if (draggableBlockElem !== targetBlockElem) {\n const { isBelow, willStayInSamePosition } = setTargetLine(\n editorConfig?.admin?.hideGutter ? '0px' : '3rem',\n blockHandleHorizontalOffset +\n (editorConfig?.admin?.hideGutter\n ? (menuRef?.current?.getBoundingClientRect()?.width ?? 0)\n : -(menuRef?.current?.getBoundingClientRect()?.width ?? 0)),\n targetLineElem,\n targetBlockElem,\n lastTargetBlock!,\n pageY,\n anchorElem,\n event,\n debugHighlightRef,\n isFoundNodeEmptyParagraph,\n )\n\n // Prevent default event to be able to trigger onDrop events\n // Calling preventDefault() adds the green plus icon to the cursor,\n // indicating that the drop is allowed.\n event.preventDefault()\n\n if (!willStayInSamePosition) {\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow,\n })\n }\n } else if (lastTargetBlock?.elem) {\n hideTargetLine(targetLineElem, lastTargetBlock.elem)\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow: false,\n })\n }\n\n return true\n }\n\n function onDrop(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n const { dataTransfer, pageY, target } = event\n const dragData = dataTransfer?.getData(DRAG_DATA_FORMAT) || ''\n\n editor.update(() => {\n const draggedNode = $getNodeByKey(dragData)\n if (!draggedNode) {\n return false\n }\n if (!isHTMLElement(target)) {\n return false\n }\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const { blockElem: targetBlockElem, isFoundNodeEmptyParagraph } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n useEdgeAsDefault: true,\n })\n\n if (!targetBlockElem) {\n return false\n }\n const targetNode = $getNearestNodeFromDOMNode(targetBlockElem)\n if (!targetNode) {\n return false\n }\n if (targetNode === draggedNode) {\n return true\n }\n\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n getBoundingClientRectWithoutTransform(targetBlockElem)\n\n const mouseY = pageY\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n targetNode.insertAfter(draggedNode)\n } else {\n // above targetBlockElem\n targetNode.insertBefore(draggedNode)\n }\n } else {\n //\n targetNode.insertBefore(draggedNode)\n targetNode.remove()\n }\n\n /*\n if (pageY >= targetBlockElemTop + targetBlockElemHeight / 2) {\n targetNode.insertAfter(draggedNode)\n } else {\n targetNode.insertBefore(draggedNode)\n }*/\n if (draggableBlockElem !== null) {\n setDraggableBlockElem(null)\n }\n\n // find all previous elements with lexical-block-highlighter class and remove them\n const allPrevHighlighters = document.querySelectorAll('.lexical-block-highlighter')\n allPrevHighlighters.forEach((highlighter) => {\n highlighter.remove()\n })\n\n const newInsertedElem = editor.getElementByKey(draggedNode.getKey())\n setTimeout(() => {\n // add new temp html element to newInsertedElem with the same height and width and the class block-selected\n // to highlight the new inserted element\n const newInsertedElemRect = newInsertedElem?.getBoundingClientRect()\n if (!newInsertedElemRect) {\n return\n }\n const highlightElem = document.createElement('div')\n highlightElem.className = 'lexical-block-highlighter'\n\n highlightElem.style.backgroundColor = 'var(--theme-elevation-1000'\n highlightElem.style.transition = 'opacity 0.5s ease-in-out'\n highlightElem.style.zIndex = '1'\n highlightElem.style.pointerEvents = 'none'\n highlightElem.style.boxSizing = 'border-box'\n highlightElem.style.borderRadius = '4px'\n highlightElem.style.position = 'absolute'\n document.body.appendChild(highlightElem)\n\n highlightElem.style.opacity = '0.1'\n\n highlightElem.style.height = `${newInsertedElemRect.height + 8}px`\n highlightElem.style.width = `${newInsertedElemRect.width + 8}px`\n highlightElem.style.top = `${newInsertedElemRect.top + window.scrollY - 4}px`\n highlightElem.style.left = `${newInsertedElemRect.left - 4}px`\n\n setTimeout(() => {\n highlightElem.style.opacity = '0'\n setTimeout(() => {\n highlightElem.remove()\n }, 500)\n }, 1000)\n }, 120)\n })\n\n return true\n }\n\n // register onDragover event listeners:\n document.addEventListener('dragover', onDragover)\n // register onDrop event listeners:\n document.addEventListener('drop', onDrop)\n\n return () => {\n document.removeEventListener('dragover', onDragover)\n document.removeEventListener('drop', onDrop)\n }\n }, [\n scrollerElem,\n blockHandleHorizontalOffset,\n anchorElem,\n editor,\n lastTargetBlock,\n draggableBlockElem,\n editorConfig?.admin?.hideGutter,\n ])\n\n function onDragStart(event: ReactDragEvent<HTMLDivElement>): void {\n const dataTransfer = event.dataTransfer\n if (!dataTransfer || !draggableBlockElem) {\n return\n }\n setDragImage(dataTransfer, draggableBlockElem)\n let nodeKey = ''\n editor.update(() => {\n const node = $getNearestNodeFromDOMNode(draggableBlockElem)\n if (node) {\n nodeKey = node.getKey()\n }\n })\n isDraggingBlockRef.current = true\n dataTransfer.setData(DRAG_DATA_FORMAT, nodeKey)\n }\n\n function onDragEnd(): void {\n isDraggingBlockRef.current = false\n if (lastTargetBlock?.elem) {\n hideTargetLine(targetLineRef.current, lastTargetBlock?.elem)\n }\n }\n\n return createPortal(\n <React.Fragment>\n <div\n className=\"icon draggable-block-menu\"\n draggable\n onDragEnd={onDragEnd}\n onDragStart={onDragStart}\n ref={menuRef}\n >\n <div className={isEditable ? 'icon' : ''} />\n </div>\n <div className=\"draggable-block-target-line\" ref={targetLineRef} />\n <div className=\"debug-highlight\" ref={debugHighlightRef} />\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function DraggableBlockPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useDraggableBlockMenu(editor, anchorElem, editor._editable)\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,0BAA0B,EAAEC,aAAa,EAAEC,aAAa,QAAQ;AACzE,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAC5C,SAASC,YAAY,QAAQ;AAE7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,KAAK,QAAQ;AACtB,SAASC,iCAAiC,QAAQ;AAClD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,qCAAqC,QAAQ;A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file":"EditorTheme.d.ts","sourceRoot":"","sources":["../../../src/lexical/theme/EditorTheme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"EditorTheme.d.ts","sourceRoot":"","sources":["../../../src/lexical/theme/EditorTheme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,eAAO,MAAM,kBAAkB,EAAE,kBA6GhC,CAAA"}
|
|
@@ -49,6 +49,7 @@ export const LexicalEditorTheme = {
|
|
|
49
49
|
h6: 'LexicalEditorTheme__h6'
|
|
50
50
|
},
|
|
51
51
|
hr: 'LexicalEditorTheme__hr',
|
|
52
|
+
hrSelected: 'LexicalEditorTheme__hrSelected',
|
|
52
53
|
indent: 'LexicalEditorTheme__indent',
|
|
53
54
|
inlineImage: 'LexicalEditor__inline-image',
|
|
54
55
|
link: 'LexicalEditorTheme__link',
|
|
@@ -70,15 +71,21 @@ export const LexicalEditorTheme = {
|
|
|
70
71
|
quote: 'LexicalEditorTheme__quote',
|
|
71
72
|
relationship: 'LexicalEditorTheme__relationship',
|
|
72
73
|
rtl: 'LexicalEditorTheme__rtl',
|
|
74
|
+
tab: 'LexicalEditorTheme__tabNode',
|
|
73
75
|
table: 'LexicalEditorTheme__table',
|
|
74
76
|
tableAddColumns: 'LexicalEditorTheme__tableAddColumns',
|
|
75
77
|
tableAddRows: 'LexicalEditorTheme__tableAddRows',
|
|
78
|
+
tableAlignment: {
|
|
79
|
+
center: 'LexicalEditorTheme__tableAlignmentCenter',
|
|
80
|
+
right: 'LexicalEditorTheme__tableAlignmentRight'
|
|
81
|
+
},
|
|
76
82
|
tableCell: 'LexicalEditorTheme__tableCell',
|
|
77
83
|
tableCellActionButton: 'LexicalEditorTheme__tableCellActionButton',
|
|
78
84
|
tableCellActionButtonContainer: 'LexicalEditorTheme__tableCellActionButtonContainer',
|
|
79
85
|
tableCellHeader: 'LexicalEditorTheme__tableCellHeader',
|
|
80
86
|
tableCellResizer: 'LexicalEditorTheme__tableCellResizer',
|
|
81
87
|
tableCellSelected: 'LexicalEditorTheme__tableCellSelected',
|
|
88
|
+
tableFrozenColumn: 'LexicalEditorTheme__tableFrozenColumn',
|
|
82
89
|
tableRowStriping: 'LexicalEditorTheme__tableRowStriping',
|
|
83
90
|
tableScrollableWrapper: 'LexicalEditorTheme__tableScrollableWrapper',
|
|
84
91
|
tableSelected: 'LexicalEditorTheme__tableSelected',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorTheme.js","names":["LexicalEditorTheme","block","blockCursor","characterLimit","code","codeHighlight","atrule","attr","boolean","builtin","cdata","char","class","comment","constant","deleted","doctype","entity","function","important","inserted","keyword","namespace","number","operator","prolog","property","punctuation","regex","selector","string","symbol","tag","url","variable","embedBlock","base","focus","hashtag","heading","h1","h2","h3","h4","h5","h6","hr","indent","inlineImage","link","list","checklist","listitem","listitemChecked","listitemUnchecked","nested","olDepth","ul","ltr","mark","markOverlap","paragraph","quote","relationship","rtl","table","tableAddColumns","tableAddRows","tableCell","tableCellActionButton","tableCellActionButtonContainer","tableCellHeader","tableCellResizer","tableCellSelected","tableRowStriping","tableScrollableWrapper","tableSelected","tableSelection","text","bold","italic","strikethrough","subscript","superscript","underline","underlineStrikethrough","upload"],"sources":["../../../src/lexical/theme/EditorTheme.tsx"],"sourcesContent":["import type { EditorThemeClasses } from 'lexical'\n\nexport const LexicalEditorTheme: EditorThemeClasses = {\n block: 'LexicalEditorTheme__block',\n blockCursor: 'LexicalEditorTheme__blockCursor',\n characterLimit: 'LexicalEditorTheme__characterLimit',\n code: 'LexicalEditorTheme__code',\n codeHighlight: {\n atrule: 'LexicalEditorTheme__tokenAttr',\n attr: 'LexicalEditorTheme__tokenAttr',\n boolean: 'LexicalEditorTheme__tokenProperty',\n builtin: 'LexicalEditorTheme__tokenSelector',\n cdata: 'LexicalEditorTheme__tokenComment',\n char: 'LexicalEditorTheme__tokenSelector',\n class: 'LexicalEditorTheme__tokenFunction',\n 'class-name': 'LexicalEditorTheme__tokenFunction',\n comment: 'LexicalEditorTheme__tokenComment',\n constant: 'LexicalEditorTheme__tokenProperty',\n deleted: 'LexicalEditorTheme__tokenProperty',\n doctype: 'LexicalEditorTheme__tokenComment',\n entity: 'LexicalEditorTheme__tokenOperator',\n function: 'LexicalEditorTheme__tokenFunction',\n important: 'LexicalEditorTheme__tokenVariable',\n inserted: 'LexicalEditorTheme__tokenSelector',\n keyword: 'LexicalEditorTheme__tokenAttr',\n namespace: 'LexicalEditorTheme__tokenVariable',\n number: 'LexicalEditorTheme__tokenProperty',\n operator: 'LexicalEditorTheme__tokenOperator',\n prolog: 'LexicalEditorTheme__tokenComment',\n property: 'LexicalEditorTheme__tokenProperty',\n punctuation: 'LexicalEditorTheme__tokenPunctuation',\n regex: 'LexicalEditorTheme__tokenVariable',\n selector: 'LexicalEditorTheme__tokenSelector',\n string: 'LexicalEditorTheme__tokenSelector',\n symbol: 'LexicalEditorTheme__tokenProperty',\n tag: 'LexicalEditorTheme__tokenProperty',\n url: 'LexicalEditorTheme__tokenOperator',\n variable: 'LexicalEditorTheme__tokenVariable',\n },\n embedBlock: {\n base: 'LexicalEditorTheme__embedBlock',\n focus: 'LexicalEditorTheme__embedBlockFocus',\n },\n hashtag: 'LexicalEditorTheme__hashtag',\n heading: {\n h1: 'LexicalEditorTheme__h1',\n h2: 'LexicalEditorTheme__h2',\n h3: 'LexicalEditorTheme__h3',\n h4: 'LexicalEditorTheme__h4',\n h5: 'LexicalEditorTheme__h5',\n h6: 'LexicalEditorTheme__h6',\n },\n hr: 'LexicalEditorTheme__hr',\n indent: 'LexicalEditorTheme__indent',\n inlineImage: 'LexicalEditor__inline-image',\n link: 'LexicalEditorTheme__link',\n list: {\n checklist: 'LexicalEditorTheme__checklist',\n listitem: 'LexicalEditorTheme__listItem',\n listitemChecked: 'LexicalEditorTheme__listItemChecked',\n listitemUnchecked: 'LexicalEditorTheme__listItemUnchecked',\n nested: {\n listitem: 'LexicalEditorTheme__nestedListItem',\n },\n olDepth: [\n 'LexicalEditorTheme__ol1',\n 'LexicalEditorTheme__ol2',\n 'LexicalEditorTheme__ol3',\n 'LexicalEditorTheme__ol4',\n 'LexicalEditorTheme__ol5',\n ],\n ul: 'LexicalEditorTheme__ul',\n },\n ltr: 'LexicalEditorTheme__ltr',\n mark: 'LexicalEditorTheme__mark',\n markOverlap: 'LexicalEditorTheme__markOverlap',\n paragraph: 'LexicalEditorTheme__paragraph',\n quote: 'LexicalEditorTheme__quote',\n relationship: 'LexicalEditorTheme__relationship',\n rtl: 'LexicalEditorTheme__rtl',\n table: 'LexicalEditorTheme__table',\n tableAddColumns: 'LexicalEditorTheme__tableAddColumns',\n tableAddRows: 'LexicalEditorTheme__tableAddRows',\n tableCell: 'LexicalEditorTheme__tableCell',\n tableCellActionButton: 'LexicalEditorTheme__tableCellActionButton',\n tableCellActionButtonContainer: 'LexicalEditorTheme__tableCellActionButtonContainer',\n tableCellHeader: 'LexicalEditorTheme__tableCellHeader',\n tableCellResizer: 'LexicalEditorTheme__tableCellResizer',\n tableCellSelected: 'LexicalEditorTheme__tableCellSelected',\n tableRowStriping: 'LexicalEditorTheme__tableRowStriping',\n tableScrollableWrapper: 'LexicalEditorTheme__tableScrollableWrapper',\n tableSelected: 'LexicalEditorTheme__tableSelected',\n tableSelection: 'LexicalEditorTheme__tableSelection',\n text: {\n bold: 'LexicalEditorTheme__textBold',\n code: 'LexicalEditorTheme__textCode',\n italic: 'LexicalEditorTheme__textItalic',\n strikethrough: 'LexicalEditorTheme__textStrikethrough',\n subscript: 'LexicalEditorTheme__textSubscript',\n superscript: 'LexicalEditorTheme__textSuperscript',\n underline: 'LexicalEditorTheme__textUnderline',\n underlineStrikethrough: 'LexicalEditorTheme__textUnderlineStrikethrough',\n },\n upload: 'editor-upload',\n}\n"],"mappings":"AAEA,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EAAW;EACXC,KAAA,EAAO;EACPC,YAAA,EAAc;EACdC,GAAA,EAAK;EACLC,KAAA,EAAO;EACPC,eAAA,EAAiB;EACjBC,YAAA,EAAc;EACdC,SAAA,EAAW;EACXC,qBAAA,EAAuB;EACvBC,8BAAA,EAAgC;EAChCC,eAAA,EAAiB;EACjBC,gBAAA,EAAkB;EAClBC,iBAAA,EAAmB;EACnBC,gBAAA,EAAkB;EAClBC,sBAAA,EAAwB;EACxBC,aAAA,EAAe;EACfC,cAAA,EAAgB;EAChBC,IAAA,EAAM;IACJC,IAAA,EAAM;
|
|
1
|
+
{"version":3,"file":"EditorTheme.js","names":["LexicalEditorTheme","block","blockCursor","characterLimit","code","codeHighlight","atrule","attr","boolean","builtin","cdata","char","class","comment","constant","deleted","doctype","entity","function","important","inserted","keyword","namespace","number","operator","prolog","property","punctuation","regex","selector","string","symbol","tag","url","variable","embedBlock","base","focus","hashtag","heading","h1","h2","h3","h4","h5","h6","hr","hrSelected","indent","inlineImage","link","list","checklist","listitem","listitemChecked","listitemUnchecked","nested","olDepth","ul","ltr","mark","markOverlap","paragraph","quote","relationship","rtl","tab","table","tableAddColumns","tableAddRows","tableAlignment","center","right","tableCell","tableCellActionButton","tableCellActionButtonContainer","tableCellHeader","tableCellResizer","tableCellSelected","tableFrozenColumn","tableRowStriping","tableScrollableWrapper","tableSelected","tableSelection","text","bold","italic","strikethrough","subscript","superscript","underline","underlineStrikethrough","upload"],"sources":["../../../src/lexical/theme/EditorTheme.tsx"],"sourcesContent":["import type { EditorThemeClasses } from 'lexical'\n\nexport const LexicalEditorTheme: EditorThemeClasses = {\n block: 'LexicalEditorTheme__block',\n blockCursor: 'LexicalEditorTheme__blockCursor',\n characterLimit: 'LexicalEditorTheme__characterLimit',\n code: 'LexicalEditorTheme__code',\n codeHighlight: {\n atrule: 'LexicalEditorTheme__tokenAttr',\n attr: 'LexicalEditorTheme__tokenAttr',\n boolean: 'LexicalEditorTheme__tokenProperty',\n builtin: 'LexicalEditorTheme__tokenSelector',\n cdata: 'LexicalEditorTheme__tokenComment',\n char: 'LexicalEditorTheme__tokenSelector',\n class: 'LexicalEditorTheme__tokenFunction',\n 'class-name': 'LexicalEditorTheme__tokenFunction',\n comment: 'LexicalEditorTheme__tokenComment',\n constant: 'LexicalEditorTheme__tokenProperty',\n deleted: 'LexicalEditorTheme__tokenProperty',\n doctype: 'LexicalEditorTheme__tokenComment',\n entity: 'LexicalEditorTheme__tokenOperator',\n function: 'LexicalEditorTheme__tokenFunction',\n important: 'LexicalEditorTheme__tokenVariable',\n inserted: 'LexicalEditorTheme__tokenSelector',\n keyword: 'LexicalEditorTheme__tokenAttr',\n namespace: 'LexicalEditorTheme__tokenVariable',\n number: 'LexicalEditorTheme__tokenProperty',\n operator: 'LexicalEditorTheme__tokenOperator',\n prolog: 'LexicalEditorTheme__tokenComment',\n property: 'LexicalEditorTheme__tokenProperty',\n punctuation: 'LexicalEditorTheme__tokenPunctuation',\n regex: 'LexicalEditorTheme__tokenVariable',\n selector: 'LexicalEditorTheme__tokenSelector',\n string: 'LexicalEditorTheme__tokenSelector',\n symbol: 'LexicalEditorTheme__tokenProperty',\n tag: 'LexicalEditorTheme__tokenProperty',\n url: 'LexicalEditorTheme__tokenOperator',\n variable: 'LexicalEditorTheme__tokenVariable',\n },\n embedBlock: {\n base: 'LexicalEditorTheme__embedBlock',\n focus: 'LexicalEditorTheme__embedBlockFocus',\n },\n hashtag: 'LexicalEditorTheme__hashtag',\n heading: {\n h1: 'LexicalEditorTheme__h1',\n h2: 'LexicalEditorTheme__h2',\n h3: 'LexicalEditorTheme__h3',\n h4: 'LexicalEditorTheme__h4',\n h5: 'LexicalEditorTheme__h5',\n h6: 'LexicalEditorTheme__h6',\n },\n hr: 'LexicalEditorTheme__hr',\n hrSelected: 'LexicalEditorTheme__hrSelected',\n indent: 'LexicalEditorTheme__indent',\n inlineImage: 'LexicalEditor__inline-image',\n link: 'LexicalEditorTheme__link',\n list: {\n checklist: 'LexicalEditorTheme__checklist',\n listitem: 'LexicalEditorTheme__listItem',\n listitemChecked: 'LexicalEditorTheme__listItemChecked',\n listitemUnchecked: 'LexicalEditorTheme__listItemUnchecked',\n nested: {\n listitem: 'LexicalEditorTheme__nestedListItem',\n },\n olDepth: [\n 'LexicalEditorTheme__ol1',\n 'LexicalEditorTheme__ol2',\n 'LexicalEditorTheme__ol3',\n 'LexicalEditorTheme__ol4',\n 'LexicalEditorTheme__ol5',\n ],\n ul: 'LexicalEditorTheme__ul',\n },\n ltr: 'LexicalEditorTheme__ltr',\n mark: 'LexicalEditorTheme__mark',\n markOverlap: 'LexicalEditorTheme__markOverlap',\n paragraph: 'LexicalEditorTheme__paragraph',\n quote: 'LexicalEditorTheme__quote',\n relationship: 'LexicalEditorTheme__relationship',\n rtl: 'LexicalEditorTheme__rtl',\n tab: 'LexicalEditorTheme__tabNode',\n table: 'LexicalEditorTheme__table',\n tableAddColumns: 'LexicalEditorTheme__tableAddColumns',\n tableAddRows: 'LexicalEditorTheme__tableAddRows',\n tableAlignment: {\n center: 'LexicalEditorTheme__tableAlignmentCenter',\n right: 'LexicalEditorTheme__tableAlignmentRight',\n },\n tableCell: 'LexicalEditorTheme__tableCell',\n tableCellActionButton: 'LexicalEditorTheme__tableCellActionButton',\n tableCellActionButtonContainer: 'LexicalEditorTheme__tableCellActionButtonContainer',\n tableCellHeader: 'LexicalEditorTheme__tableCellHeader',\n tableCellResizer: 'LexicalEditorTheme__tableCellResizer',\n tableCellSelected: 'LexicalEditorTheme__tableCellSelected',\n tableFrozenColumn: 'LexicalEditorTheme__tableFrozenColumn',\n tableRowStriping: 'LexicalEditorTheme__tableRowStriping',\n tableScrollableWrapper: 'LexicalEditorTheme__tableScrollableWrapper',\n tableSelected: 'LexicalEditorTheme__tableSelected',\n tableSelection: 'LexicalEditorTheme__tableSelection',\n text: {\n bold: 'LexicalEditorTheme__textBold',\n code: 'LexicalEditorTheme__textCode',\n italic: 'LexicalEditorTheme__textItalic',\n strikethrough: 'LexicalEditorTheme__textStrikethrough',\n subscript: 'LexicalEditorTheme__textSubscript',\n superscript: 'LexicalEditorTheme__textSuperscript',\n underline: 'LexicalEditorTheme__textUnderline',\n underlineStrikethrough: 'LexicalEditorTheme__textUnderlineStrikethrough',\n },\n upload: 'editor-upload',\n}\n"],"mappings":"AAEA,OAAO,MAAMA,kBAAA,GAAyC;EACpDC,KAAA,EAAO;EACPC,WAAA,EAAa;EACbC,cAAA,EAAgB;EAChBC,IAAA,EAAM;EACNC,aAAA,EAAe;IACbC,MAAA,EAAQ;IACRC,IAAA,EAAM;IACNC,OAAA,EAAS;IACTC,OAAA,EAAS;IACTC,KAAA,EAAO;IACPC,IAAA,EAAM;IACNC,KAAA,EAAO;IACP,cAAc;IACdC,OAAA,EAAS;IACTC,QAAA,EAAU;IACVC,OAAA,EAAS;IACTC,OAAA,EAAS;IACTC,MAAA,EAAQ;IACRC,QAAA,EAAU;IACVC,SAAA,EAAW;IACXC,QAAA,EAAU;IACVC,OAAA,EAAS;IACTC,SAAA,EAAW;IACXC,MAAA,EAAQ;IACRC,QAAA,EAAU;IACVC,MAAA,EAAQ;IACRC,QAAA,EAAU;IACVC,WAAA,EAAa;IACbC,KAAA,EAAO;IACPC,QAAA,EAAU;IACVC,MAAA,EAAQ;IACRC,MAAA,EAAQ;IACRC,GAAA,EAAK;IACLC,GAAA,EAAK;IACLC,QAAA,EAAU;EACZ;EACAC,UAAA,EAAY;IACVC,IAAA,EAAM;IACNC,KAAA,EAAO;EACT;EACAC,OAAA,EAAS;EACTC,OAAA,EAAS;IACPC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;EACN;EACAC,EAAA,EAAI;EACJC,UAAA,EAAY;EACZC,MAAA,EAAQ;EACRC,WAAA,EAAa;EACbC,IAAA,EAAM;EACNC,IAAA,EAAM;IACJC,SAAA,EAAW;IACXC,QAAA,EAAU;IACVC,eAAA,EAAiB;IACjBC,iBAAA,EAAmB;IACnBC,MAAA,EAAQ;MACNH,QAAA,EAAU;IACZ;IACAI,OAAA,EAAS,CACP,2BACA,2BACA,2BACA,2BACA,0BACD;IACDC,EAAA,EAAI;EACN;EACAC,GAAA,EAAK;EACLC,IAAA,EAAM;EACNC,WAAA,EAAa;EACbC,SAAA,EAAW;EACXC,KAAA,EAAO;EACPC,YAAA,EAAc;EACdC,GAAA,EAAK;EACLC,GAAA,EAAK;EACLC,KAAA,EAAO;EACPC,eAAA,EAAiB;EACjBC,YAAA,EAAc;EACdC,cAAA,EAAgB;IACdC,MAAA,EAAQ;IACRC,KAAA,EAAO;EACT;EACAC,SAAA,EAAW;EACXC,qBAAA,EAAuB;EACvBC,8BAAA,EAAgC;EAChCC,eAAA,EAAiB;EACjBC,gBAAA,EAAkB;EAClBC,iBAAA,EAAmB;EACnBC,iBAAA,EAAmB;EACnBC,gBAAA,EAAkB;EAClBC,sBAAA,EAAwB;EACxBC,aAAA,EAAe;EACfC,cAAA,EAAgB;EAChBC,IAAA,EAAM;IACJC,IAAA,EAAM;IACNjF,IAAA,EAAM;IACNkF,MAAA,EAAQ;IACRC,aAAA,EAAe;IACfC,SAAA,EAAW;IACXC,WAAA,EAAa;IACbC,SAAA,EAAW;IACXC,sBAAA,EAAwB;EAC1B;EACAC,MAAA,EAAQ;AACV","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/guard.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,WAAW,CAE1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.js","names":["isHTMLElement","x","HTMLElement"],"sources":["../../../src/lexical/utils/guard.ts"],"sourcesContent":["'use client'\nexport function isHTMLElement(x: unknown): x is HTMLElement {\n return x instanceof HTMLElement\n}\n"],"mappings":"AAAA;;
|
|
1
|
+
{"version":3,"file":"guard.js","names":["isHTMLElement","x","HTMLElement"],"sources":["../../../src/lexical/utils/guard.ts"],"sourcesContent":["'use client'\n\n/**\n * @deprecated - remove in 4.0. lexical already exports an isHTMLElement utility\n */\nexport function isHTMLElement(x: unknown): x is HTMLElement {\n return x instanceof HTMLElement\n}\n"],"mappings":"AAAA;;AAEA;;;AAGA,OAAO,SAASA,cAAcC,CAAU;EACtC,OAAOA,CAAA,YAAaC,WAAA;AACtB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.28.0-internal.
|
|
3
|
+
"version": "3.28.0-internal.c4e1bed",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -265,11 +265,6 @@
|
|
|
265
265
|
"types": "./dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.d.ts",
|
|
266
266
|
"default": "./dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.js"
|
|
267
267
|
},
|
|
268
|
-
"./lexical/react/LexicalTableOfContents": {
|
|
269
|
-
"import": "./dist/lexical-proxy/@lexical-react/LexicalTableOfContents.js",
|
|
270
|
-
"types": "./dist/lexical-proxy/@lexical-react/LexicalTableOfContents.d.ts",
|
|
271
|
-
"default": "./dist/lexical-proxy/@lexical-react/LexicalTableOfContents.js"
|
|
272
|
-
},
|
|
273
268
|
"./lexical/react/LexicalTableOfContentsPlugin": {
|
|
274
269
|
"import": "./dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.js",
|
|
275
270
|
"types": "./dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.d.ts",
|
|
@@ -340,23 +335,23 @@
|
|
|
340
335
|
]
|
|
341
336
|
},
|
|
342
337
|
"dependencies": {
|
|
343
|
-
"@lexical/headless": "0.
|
|
344
|
-
"@lexical/html": "0.
|
|
345
|
-
"@lexical/link": "0.
|
|
346
|
-
"@lexical/list": "0.
|
|
347
|
-
"@lexical/mark": "0.
|
|
348
|
-
"@lexical/react": "0.
|
|
349
|
-
"@lexical/rich-text": "0.
|
|
350
|
-
"@lexical/selection": "0.
|
|
351
|
-
"@lexical/table": "0.
|
|
352
|
-
"@lexical/utils": "0.
|
|
338
|
+
"@lexical/headless": "0.27.1",
|
|
339
|
+
"@lexical/html": "0.27.1",
|
|
340
|
+
"@lexical/link": "0.27.1",
|
|
341
|
+
"@lexical/list": "0.27.1",
|
|
342
|
+
"@lexical/mark": "0.27.1",
|
|
343
|
+
"@lexical/react": "0.27.1",
|
|
344
|
+
"@lexical/rich-text": "0.27.1",
|
|
345
|
+
"@lexical/selection": "0.27.1",
|
|
346
|
+
"@lexical/table": "0.27.1",
|
|
347
|
+
"@lexical/utils": "0.27.1",
|
|
353
348
|
"@types/uuid": "10.0.0",
|
|
354
349
|
"acorn": "8.12.1",
|
|
355
350
|
"bson-objectid": "2.0.4",
|
|
356
351
|
"dequal": "2.0.3",
|
|
357
352
|
"escape-html": "1.0.3",
|
|
358
353
|
"jsox": "1.2.121",
|
|
359
|
-
"lexical": "0.
|
|
354
|
+
"lexical": "0.27.1",
|
|
360
355
|
"mdast-util-from-markdown": "2.0.2",
|
|
361
356
|
"mdast-util-mdx-jsx": "3.1.3",
|
|
362
357
|
"micromark-extension-mdx-jsx": "3.0.1",
|
|
@@ -364,8 +359,8 @@
|
|
|
364
359
|
"react-error-boundary": "4.1.2",
|
|
365
360
|
"ts-essentials": "10.0.3",
|
|
366
361
|
"uuid": "10.0.0",
|
|
367
|
-
"@payloadcms/translations": "3.28.0-internal.
|
|
368
|
-
"@payloadcms/ui": "3.28.0-internal.
|
|
362
|
+
"@payloadcms/translations": "3.28.0-internal.c4e1bed",
|
|
363
|
+
"@payloadcms/ui": "3.28.0-internal.c4e1bed"
|
|
369
364
|
},
|
|
370
365
|
"devDependencies": {
|
|
371
366
|
"@babel/cli": "7.26.4",
|
|
@@ -373,7 +368,7 @@
|
|
|
373
368
|
"@babel/preset-env": "7.26.7",
|
|
374
369
|
"@babel/preset-react": "7.26.3",
|
|
375
370
|
"@babel/preset-typescript": "7.26.0",
|
|
376
|
-
"@lexical/eslint-plugin": "0.
|
|
371
|
+
"@lexical/eslint-plugin": "0.27.1",
|
|
377
372
|
"@types/escape-html": "1.0.4",
|
|
378
373
|
"@types/json-schema": "7.0.15",
|
|
379
374
|
"@types/node": "22.5.4",
|
|
@@ -386,15 +381,15 @@
|
|
|
386
381
|
"eslint-plugin-react-compiler": "19.0.0-beta-714736e-20250131",
|
|
387
382
|
"swc-plugin-transform-remove-imports": "3.1.0",
|
|
388
383
|
"@payloadcms/eslint-config": "3.9.0",
|
|
389
|
-
"payload": "3.28.0-internal.
|
|
384
|
+
"payload": "3.28.0-internal.c4e1bed"
|
|
390
385
|
},
|
|
391
386
|
"peerDependencies": {
|
|
392
387
|
"@faceless-ui/modal": "3.0.0-beta.2",
|
|
393
388
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
394
389
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
395
390
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
396
|
-
"@payloadcms/next": "3.28.0-internal.
|
|
397
|
-
"payload": "3.28.0-internal.
|
|
391
|
+
"@payloadcms/next": "3.28.0-internal.c4e1bed",
|
|
392
|
+
"payload": "3.28.0-internal.c4e1bed"
|
|
398
393
|
},
|
|
399
394
|
"engines": {
|
|
400
395
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{c as Re,f as G,g as _,i as ke,j as we,k as Te,l as ve,m as De}from"./chunk-OZ6Q4DWN.js";import{a as Se,b as P}from"./chunk-3LGFOM34.js";import{jsx as F,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as nn,FieldError as rn,FieldLabel as sn,RenderCustomComponent as gt,useEditDepth as ln,useEffectEvent as an,useField as cn}from"@payloadcms/ui";import{mergeFieldStyles as un}from"@payloadcms/ui/shared";import ht,{useCallback as yt,useEffect as xt,useMemo as dn,useState as Et}from"react";import{ErrorBoundary as mn}from"react-error-boundary";import"./bundled.css";import{jsx as O}from"react/jsx-runtime";import{LexicalComposer as en}from"@lexical/react/LexicalComposer.js";import{useEditDepth as tn}from"@payloadcms/ui";import*as mt from"react";import{useMemo as on}from"react";import{c as $o}from"react/compiler-runtime";import{jsx as b,jsxs as oe}from"react/jsx-runtime";import{useLexicalComposerContext as Ko}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Ho}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as jo}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as zo}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Wo}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Yo,COMMAND_PRIORITY_LOW as ut,FOCUS_COMMAND as Go}from"lexical";import*as X from"react";import{useEffect as Vo,useState as Uo}from"react";import{jsx as Me}from"react/jsx-runtime";import"react";var K=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Me(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Me(o.Component,{clientProps:e});import{c as Pt}from"react/compiler-runtime";import{useLexicalComposerContext as St}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as Rt}from"@lexical/utils";import{$createNodeSelection as kt,$getEditor as Z,$getNearestNodeFromDOMNode as wt,$getSelection as re,$isDecoratorNode as H,$isElementNode as Ee,$isLineBreakNode as Tt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as vt,$isTextNode as Dt,$setSelection as Le,CLICK_COMMAND as Mt,COMMAND_PRIORITY_LOW as V,KEY_ARROW_DOWN_COMMAND as Bt,KEY_ARROW_UP_COMMAND as Lt,KEY_BACKSPACE_COMMAND as It,KEY_DELETE_COMMAND as At,SELECTION_CHANGE_COMMAND as _t}from"lexical";import{useEffect as Ot}from"react";function Ie(){let t=Pt(3),[e]=St(),o=Wt,r,n;return t[0]!==e?(r=()=>Rt(e.registerCommand(Mt,zt,V),e.registerCommand(At,o,V),e.registerCommand(It,o,V),e.registerCommand(_t,jt,V),e.registerCommand(Lt,Kt,V),e.registerCommand(Bt,Ft,V)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),Ot(r,n),null}function Ft(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(H(i)){let p=Z().getElementByKey(i.getKey());return p&&ee({element:p,node:i}),!0}if(!Ee(i))return!0;let l=i.getFirstDescendant()??i;return l&&(ne(l,se)?.selectEnd(),t.preventDefault()),!0}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,$t),c=n?.getNextSibling();if(!n||c!==Ae(n))return!1;if(H(c)){let i=Z().getElementByKey(c.getKey());if(i)return ee({element:i,node:c}),t.preventDefault(),!0}return!1}function $t(t){return Ae(t)!==null}function Kt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(H(i)){let p=Z().getElementByKey(i.getKey());return p?(ee({element:p,node:i}),t.preventDefault(),!0):!1}if(!Ee(i))return!1;let l=i.getLastDescendant()??i;return l?(ne(l,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Ht),c=n?.getPreviousSibling();if(!n||c!==_e(n))return!1;if(H(c)){let i=Z().getElementByKey(c.getKey());if(i)return ee({element:i,node:c}),t.preventDefault(),!0}return!1}function Ht(t){return _e(t)!==null}function jt(){let t=Vt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function zt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=Gt(t);if(!e)return!0;let{target:o}=t;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Le(null):ee(e),!0}function Wt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Yt),!0):!1}function Yt(t){t.remove()}function Gt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=wt(e);return H(o)?{element:e,node:o}:void 0}function Vt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return H(o)?{decorator:o,element:Z().getElementByKey(o.getKey())}:void 0}function ee({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=kt();o.add(e.getKey()),Le(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(H(t)&&!t.isInline())return!0;if(!Ee(t)||vt(t))return!1;let e=t.getFirstChild(),o=e===null||Tt(e)||Dt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function Ae(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function _e(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as Ce}from"react/jsx-runtime";import{useLexicalComposerContext as Zt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as eo}from"lexical";import*as Ke from"react";import{useCallback as to,useEffect as $e,useRef as oo,useState as no}from"react";import{createPortal as ro}from"react-dom";var U=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:l,left:u,right:p,top:h}=t.getBoundingClientRect(),a=h+window.scrollY,s=l+window.scrollY;if(o<a-c||o>s+c||e<u-n||e>p+n)return-1;(e<u||e>p)&&(i=e<u?e-u:e-p)}return i};import{$getNodeByKey as ae}from"lexical";function q(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function le(t){let e=(u,p)=>u?parseFloat(window.getComputedStyle(u)[p]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as Ut}from"lexical";function j(t){return t.getEditorState().read(()=>Ut().getChildrenKeys())}var qt=1,Jt=-1,Oe=0,B={props:null,result:null};function Qt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function J(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:l},startIndex:u=0,useEdgeAsDefault:p=!1}=t;if(o>0&&B.props&&B.result&&B.props.fuzzy===t.fuzzy&&B.props.horizontalOffset===t.horizontalOffset&&B.props.useEdgeAsDefault===t.useEdgeAsDefault&&Qt(B.props.point,t.point,o))return B.result;let h=e.getBoundingClientRect(),a=j(r),s={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(p){let m=r.getElementByKey(a[0]),y=r.getElementByKey(a[a.length-1]);if(m&&y){let[d,f]=[q(m),q(y)];if(l<d.top?(s.blockElem=m,s.distance=d.top-l,s.blockNode=ae(a[0]),s.foundAtIndex=0):l>f.bottom&&(s.distance=l-f.bottom,s.blockNode=ae(a[a.length-1]),s.blockElem=y,s.foundAtIndex=a.length-1),s?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let g=u,x=Oe;for(;g>=0&&g<a.length;){let m=a[g],y=r.getElementByKey(m);if(y===null)break;let d=new _(i+c,l),f=ve.fromDOMRect(q(y)),{marginBottom:E,marginTop:k}=le(y),R=f.generateNewRect({bottom:f.bottom+E,left:h.left,right:h.right,top:f.top-k}),{distance:S,isOnBottomSide:w,isOnTopSide:C}=R.distanceFromPoint(d);if(S===0){s.blockElem=y,s.blockNode=ae(m),s.foundAtIndex=g,s.distance=S,s.blockNode&&s.blockNode.getType()==="paragraph"&&s.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(s.blockElem=null,s.blockNode=null),s.isFoundNodeEmptyParagraph=!0);break}else n&&S<s.distance&&(s.blockElem=y,s.blockNode=ae(m),s.distance=S,s.foundAtIndex=g);x===Oe&&(C?x=Jt:w?x=qt:x=1/0),g+=x}}),B.props=t,B.result={blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph},{blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var Xt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Fe(t){if(!t||Xt.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function ue(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),l=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))u=n.top+8-l.top;else{let a=Fe(t)?parseInt(c.lineHeight,10):0;u=n.top+(a-i.height)/2-l.top}let h=r;e.style.opacity="1",e.style.transform=`translate(${h}px, ${u}px)`}var io="add-block-menu",de=1/0;function so(t){return t===0?1/0:de>=0&&de<t?de:Math.floor(t/2)}function lo(t,e,o){let r=e.parentElement,{editorConfig:n}=P(),c=n?.admin?.hideGutter?-24:12,i=oo(null),[l,u]=no(null);$e(()=>{function h(a){let s=a.target;if(!G(s))return;let g=U(r,a.pageX,a.pageY,s);if(g===-1){u(null);return}if(ce(s,io))return;let x=j(t),{blockElem:m,blockNode:y,foundAtIndex:d}=J({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-g,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:so(x.length),useEdgeAsDefault:!1});de=d,m&&y&&(l?.node!==y||l?.elem!==m)&&u({elem:m,node:y})}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,l]),$e(()=>{i.current&&l?.node&&ue(l?.elem,i.current,e,c)},[e,l,c]);let p=to(h=>{let a=l;a?.node&&(t.update(()=>{let s=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(s=!1),!s){let g=eo();a?.node.insertAfter(g),setTimeout(()=>{a={elem:t.getElementByKey(g.getKey()),node:g},u(a)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{t.dispatchCommand(we,{node:a?.node})},2),h.stopPropagation(),h.preventDefault())},[t,l]);return ro(Ce(Ke.Fragment,{children:Ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:h=>{p(h)},ref:i,type:"button",children:Ce("div",{className:o?"icon":""})})}),e)}function He(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=Zt();return lo(r,o,r._editable)}import{jsx as me,jsxs as co}from"react/jsx-runtime";import{useLexicalComposerContext as uo}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as We}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ye,$getNodeByKey as mo}from"lexical";import*as Je from"react";import{useEffect as be,useRef as fe,useState as Ge}from"react";import{createPortal as fo}from"react-dom";var je=0,ao=-24;var z=0;function ze(t,e,o,r,n,c,i,l,u,p=!1){let{height:h,top:a}=r.getBoundingClientRect(),{top:s,width:g}=i.getBoundingClientRect(),{marginBottom:x,marginTop:m}=le(r),y=a,d=c>=a+h/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(d&&n?.elem&&n?.elem===r.nextElementSibling||!d&&n?.elem&&n?.elem===r.previousElementSibling)&&(z++,z<200&&(f=!0));else{z++;let S=n?.boundingBox?.y,w=r.getBoundingClientRect().y;(d===n?.isBelow&&S===w||z<200)&&(f=!1)}if(f)return{isBelow:d,willStayInSamePosition:f};p?y+=h/2:d?y+=h+x/2:y-=m/2;let E=0;p||(d?E=-je:E=je);let k=y-s+E,R=ao-e;return o.style.width=`calc(${g}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${R}px, calc(${k}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?d?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),z=0,{isBelow:d,willStayInSamePosition:f}}var po="draggable-block-menu",Ve="application/x-lexical-drag-block",te=1/0;function Ue(t){return t===0?1/0:te>=0&&te<t?te:Math.floor(t/2)}function go(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function qe(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function ho(t,e,o){let r=e.parentElement,n=fe(null),c=fe(null),i=fe(null),l=fe(!1),[u,p]=Ge(null),[h,a]=Ge(null),{editorConfig:s}=P(),g=s?.admin?.hideGutter?-44:-8;be(()=>{function y(d){let f=d.target;if(!G(f))return;let E=U(r,d.pageX,d.pageY,f);if(E===-1){p(null);return}if(ce(f,po))return;let k=j(t),{blockElem:R,foundAtIndex:S,isFoundNodeEmptyParagraph:w}=J({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new _(d.x,d.y),startIndex:Ue(k.length),useEdgeAsDefault:!1,verbose:!1});te=S,!(!R&&!w)&&u!==R&&p(R)}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,u]),be(()=>{n.current&&ue(u,n.current,e,g)},[e,u,g]),be(()=>{function y(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{pageY:k,target:R}=f;if(!G(R))return!1;let S=U(r,f.pageX,f.pageY,R,100,50),w=j(t),{blockElem:C,foundAtIndex:W,isFoundNodeEmptyParagraph:I}=J({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-S,point:new _(f.x,f.y),startIndex:Ue(w.length),useEdgeAsDefault:!0,verbose:!0});te=W;let T=c.current;if(C===null||T===null)return!1;if(u!==C){let{isBelow:v,willStayInSamePosition:A}=ze(s?.admin?.hideGutter?"0px":"3rem",g+(s?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),T,C,h,k,e,f,i,I);f.preventDefault(),A||a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:v})}else h?.elem&&(qe(T,h.elem),a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:!1}));return!0}function d(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{dataTransfer:k,pageY:R,target:S}=f,w=k?.getData(Ve)||"";return t.update(()=>{let C=mo(w);if(!C||!G(S))return!1;let W=U(r,f.pageX,f.pageY,S,100,50),{blockElem:I,isFoundNodeEmptyParagraph:T}=J({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-W,point:new _(f.x,f.y),useEdgeAsDefault:!0});if(!I)return!1;let v=Ye(I);if(!v)return!1;if(v===C)return!0;let{height:A,top:he}=q(I),ye=R>=he+A/2+window.scrollY;T?(v.insertBefore(C),v.remove()):ye?v.insertAfter(C):v.insertBefore(C),u!==null&&p(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let Y=t.getElementByKey(C.getKey());setTimeout(()=>{let D=Y?.getBoundingClientRect();if(!D)return;let N=document.createElement("div");N.className="lexical-block-highlighter",N.style.backgroundColor="var(--theme-elevation-1000",N.style.transition="opacity 0.5s ease-in-out",N.style.zIndex="1",N.style.pointerEvents="none",N.style.boxSizing="border-box",N.style.borderRadius="4px",N.style.position="absolute",document.body.appendChild(N),N.style.opacity="0.1",N.style.height=`${D.height+8}px`,N.style.width=`${D.width+8}px`,N.style.top=`${D.top+window.scrollY-4}px`,N.style.left=`${D.left-4}px`,setTimeout(()=>{N.style.opacity="0",setTimeout(()=>{N.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",y),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",y),document.removeEventListener("drop",d)}},[r,g,e,t,h,u,s?.admin?.hideGutter]);function x(y){let d=y.dataTransfer;if(!d||!u)return;go(d,u);let f="";t.update(()=>{let E=Ye(u);E&&(f=E.getKey())}),l.current=!0,d.setData(Ve,f)}function m(){l.current=!1,h?.elem&&qe(c.current,h?.elem)}return fo(co(Je.Fragment,{children:[me("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:m,onDragStart:x,ref:n,children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:i})]}),e)}function Qe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=uo();return ho(r,o,r._editable)}import{c as yo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as xo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Eo,$getRoot as Co}from"lexical";import"react";var Xe="insert-paragraph-at-end",Ze=()=>{let t=yo(4),[e]=xo(),{editorConfig:o}=P();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(bo)},t[0]=e,t[1]=r):r=t[1];let n=r,c;return t[2]!==n?(c=Ne("div",{"aria-label":"Insert Paragraph",className:Xe,onClick:n,role:"button",tabIndex:0,children:Ne("div",{className:`${Xe}-inside`,children:Ne("span",{children:"+"})})}),t[2]=n,t[3]=c):c=t[3],c};function bo(){let t=Eo();Co().append(t),t.select()}import{c as No}from"react/compiler-runtime";import{useLexicalComposerContext as Po}from"@lexical/react/LexicalComposerContext";import*as et from"react";var tt=()=>{let t=No(4),{editorConfig:e}=P(),[o]=Po(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>Re(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),et.useEffect(r,n),null};import{jsx as Q,jsxs as nt}from"react/jsx-runtime";import{useLexicalComposerContext as Ro}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as rt}from"@payloadcms/ui";import{useCallback as ko,useMemo as wo,useState as To}from"react";import"react";import*as it from"react-dom";import{c as So}from"react/compiler-runtime";import"react";function ot(t,e){let o=So(4),{maxLength:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,l;return o[0]!==c||o[1]!==i||o[2]!==t?(l=u=>{let{query:p}=u,h="[^"+t+ke+"\\s]",s=new RegExp("(^|\\s|\\()(["+t+"]((?:"+h+"){0,"+c+"}))$").exec(p);if(s!==null){let g=s[1],x=s[3];if(x.length>=i)return{leadOffset:s.index+g.length,matchingString:x,replaceableString:s[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=l):l=o[3],l}var L="slash-menu-popup";function vo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=P(),{i18n:l}=rt(),u=`${L}__item ${L}__item-${e.key}`;t&&(u+=` ${L}__item--selected`);let p=e.key;return e.label&&(p=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:l,schemaPath:i}):e.label),p.length>25&&(p=p.substring(0,25)+"..."),nt("button",{"aria-selected":t,className:u,id:L+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&Q(e.Icon,{}),Q("span",{className:`${L}__item-text`,children:p})]},e.key)}function st({anchorElem:t=document.body}){let[e]=Ro(),[o,r]=To(null),{editorConfig:n}=P(),{i18n:c}=rt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:l}}=P(),u=ot("/",{minLength:0}),p=ko(()=>{let a=[];for(let s of n.features.slashMenu.dynamicGroups)if(o){let g=s({editor:e,queryString:o});a=a.concat(g)}return a},[e,o,n?.features]),h=wo(()=>{let a=[];for(let s of n?.features.slashMenu.groups??[])a.push(s);if(o){a=a.map(g=>{let x=g.items.filter(m=>{let y=m.key;return m.label&&(y=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):m.label),new RegExp(o,"gi").exec(y)?!0:m.keywords!=null?m.keywords.some(d=>new RegExp(o,"gi").exec(d)):!1});return x.length?{...g,items:x}:null}),a=a.filter(g=>g!=null);let s=p();for(let g of s){let x=a.find(m=>m.key===g.key);x?a=a.filter(m=>m.key!==g.key):x={...g,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,n?.features.slashMenu.groups,p,i,c,l]);return Q(Te,{anchorElem:t,groups:h,menuRenderFn:(a,{selectedItemKey:s,selectItemAndCleanUp:g,setSelectedItemKey:x})=>a.current&&h.length?it.createPortal(Q("div",{className:L,children:h.map(m=>{let y=m.key;return m.label&&i&&(y=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):m.label),nt("div",{className:`${L}__group ${L}__group-${m.key}`,children:[Q("div",{className:`${L}__group-title`,children:y}),m.items.map((d,f)=>Q(vo,{index:f,isSelected:s===d.key,item:d,onClick:()=>{x(d.key),g(d)},onMouseEnter:()=>{x(d.key)},ref:E=>{d.ref={current:E}}},d.key))]},m.key)})}),a.current):null,onQueryChange:r,triggerFn:u})}import{c as Do}from"react/compiler-runtime";import{useLexicalComposerContext as Mo}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Bo,TextNode as Lo}from"lexical";import{useEffect as Io}from"react";function lt(t){let e=Do(6),{features:o}=t,[r]=Mo(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=Ao(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Lo,l=>{i.forEach(u=>{l.hasFormat(u)&&l.toggleFormat(u)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let c;return e[3]!==r||e[4]!==o?(c=[r,o],e[3]=r,e[4]=o,e[5]=c):c=e[5],Io(n,c),null}function Ao(t){let e=Object.keys(Bo),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as _o}from"react/compiler-runtime";import{jsx as at}from"react/jsx-runtime";import{ContentEditable as Oo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Fo}from"@payloadcms/ui";import"react";function ct(t){let e=_o(7),{className:o,editorConfig:r}=t,{t:n}=Fo(),c;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let i;e[4]!==r?.admin?.placeholder||e[5]!==n?(i=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=i):i=e[6],c=at(Oo,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:at("p",{className:"editor-placeholder",children:i})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=c}else c=e[3];return c}var dt=t=>{let e=$o(19),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=P(),[l]=Ko(),[u,p]=Uo(null),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=m=>{m!==null&&p(m)},e[0]=h):h=e[0];let a=h,s,g;e[1]!==l||e[2]!==i?(s=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let m=()=>{i.focusEditor(i)},y=()=>{i.blurEditor(i)},d=l.registerCommand(Go,()=>(m(),!0),ut),f=l.registerCommand(Yo,()=>(y(),!0),ut);return()=>{d(),f(),i.parentEditor?.unregisterChild?.(i.uuid)}},g=[l,i],e[1]=l,e[2]=i,e[3]=s,e[4]=g):(s=e[3],g=e[4]),Vo(s,g);let x;if(e[5]!==l||e[6]!==o||e[7]!==r||e[8]!==u||e[9]!==n||e[10]!==c){let m;e[12]!==c?(m=(d,f,E)=>{(!E.has("focus")||E.size>1)&&c?.(d,f,E)},e[12]=c,e[13]=m):m=e[13];let y;e[14]!==l||e[15]!==o.features.plugins||e[16]!==u||e[17]!==n?(y=u&&oe(X.Fragment,{children:[!n&&l.isEditable()&&oe(X.Fragment,{children:[b(Qe,{anchorElem:u}),b(He,{anchorElem:u})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&n))return b(K,{anchorElem:u,clientProps:d.clientProps,plugin:d},d.key)}),l.isEditable()&&b(X.Fragment,{children:b(st,{anchorElem:u})})]}),e[14]=l,e[15]=o.features.plugins,e[16]=u,e[17]=n,e[18]=y):y=e[18],x=oe(X.Fragment,{children:[o.features.plugins?.map(qo),oe("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Jo),b(Wo,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:a,children:b(ct,{editorConfig:o})})}),ErrorBoundary:Ho}),b(Ze,{}),b(Ie,{}),b(lt,{features:o.features}),b(zo,{ignoreSelectionChange:!0,onChange:m}),y,l.isEditable()&&oe(X.Fragment,{children:[b(jo,{}),o?.features?.markdownTransformers?.length>0&&b(tt,{})]}),o.features.plugins?.map(Qo),o.features.plugins?.map(Xo)]}),o.features.plugins?.map(Zo)]}),e[5]=l,e[6]=o,e[7]=r,e[8]=u,e[9]=n,e[10]=c,e[11]=x}else x=e[11];return x};function qo(t){if(t.position==="aboveContainer")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Jo(t){if(t.position==="top")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Qo(t){if(t.position==="normal")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Xo(t){if(t.position==="bottom")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Zo(t){if(t.position==="belowContainer")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}var ft=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?O(o,{children:O(ft,{providers:e.slice(1),children:t})}):O(o,{children:t})},pt=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:l}=t,u=P(),p=tn(),h=mt.useRef(null),a=on(()=>{if(l&&typeof l!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(l));if(l&&Array.isArray(l)&&!("root"in l))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(l&&"jsonContent"in l)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:i!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:De({editorConfig:o}),onError:s=>{throw s},theme:o.lexical.theme}},[o]);return a?O(en,{initialConfig:a,children:O(Se,{editorConfig:o,editorContainerRef:h,fieldProps:r,parentContext:u?.editDepth===p?u:void 0,children:O(ft,{providers:o.features.providers,children:O(dt,{editorConfig:o,editorContainerRef:h,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",fn=t=>{let{editorConfig:e,field:o,field:{name:r,admin:{className:n,description:c,readOnly:i}={},label:l,localized:u,required:p},path:h,readOnly:a,validate:s}=t,g=a||i,x=h??r,m=ln(),y=yt((M,$)=>typeof s=="function"?s(M,{...$,required:p}):!0,[s,p]),{customComponents:{AfterInput:d,BeforeInput:f,Description:E,Error:k,Label:R}={},formInitializing:S,formProcessing:w,initialValue:C,setValue:W,showError:I,value:T}=cn({path:x,validate:y}),v=g||w||S,[A,he]=Et(!1),[Pe,ye]=Et(),xe=ht.useRef(C),Y=ht.useRef(T);xt(()=>{let M=()=>{let $=window.matchMedia("(max-width: 768px)").matches;$!==A&&he($)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[A]);let D=[pe,"field-type",n,I&&"error",v&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!A?`${pe}--show-gutter`:null].filter(Boolean).join(" "),N=`${x}.${m}`,Ct=yt(M=>{let $=M.toJSON();Y.current=$,W($)},[W]),bt=dn(()=>un(o),[o]),Nt=an(M=>{Y.current!==T&&JSON.stringify(Y.current)!==JSON.stringify(T)&&(xe.current=M,Y.current=T,ye(new Date))});return xt(()=>{Object.is(C,xe.current)||Nt(C)},[C]),ge("div",{className:D,style:bt,children:[F(gt,{CustomComponent:k,Fallback:F(rn,{path:x,showError:I})}),R||F(sn,{label:l,localized:u,path:x,required:p}),ge("div",{className:`${pe}__wrap`,children:[ge(mn,{fallbackRender:pn,onReset:()=>{},children:[f,F(pt,{composerKey:N,editorConfig:e,fieldProps:t,isSmallWidthViewport:A,onChange:Ct,readOnly:v,value:T},JSON.stringify({path:x,rerenderProviderKey:Pe})),d]}),E,F(gt,{CustomComponent:E,Fallback:F(nn,{description:c,path:x})})]})]},N)};function pn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var Ki=fn;export{Ki as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-NNWFQETL.js.map
|