@payloadcms/richtext-lexical 3.55.0-canary.3 → 3.55.0-internal.d44d1d3
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-4DDJ7TQY.js +2 -0
- package/dist/exports/client/Field-4DDJ7TQY.js.map +7 -0
- package/dist/exports/client/chunk-CYLMY5ZJ.js +2 -0
- package/dist/exports/client/{chunk-FSKAVN4P.js.map → chunk-CYLMY5ZJ.js.map} +2 -2
- package/dist/exports/client/chunk-YCH4JNUH.js +12 -0
- package/dist/exports/client/{chunk-KZKGNMS3.js.map → chunk-YCH4JNUH.js.map} +2 -2
- package/dist/exports/client/{component-M3U253XK.js → component-3PENNOM3.js} +2 -2
- package/dist/exports/client/index.d.ts +2 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/server/rsc.d.ts +1 -0
- package/dist/exports/server/rsc.d.ts.map +1 -1
- package/dist/exports/server/rsc.js +1 -0
- package/dist/exports/server/rsc.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +8 -10
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +3 -5
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +20 -37
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +28 -53
- package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +35 -37
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +20 -30
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/field/RenderLexical/renderLexical.d.ts +38 -0
- package/dist/field/RenderLexical/renderLexical.d.ts.map +1 -0
- package/dist/field/RenderLexical/renderLexical.js +96 -0
- package/dist/field/RenderLexical/renderLexical.js.map +1 -0
- package/dist/field/RenderLexical/useRenderEditor.d.ts +15 -0
- package/dist/field/RenderLexical/useRenderEditor.d.ts.map +1 -0
- package/dist/field/RenderLexical/useRenderEditor.js +159 -0
- package/dist/field/RenderLexical/useRenderEditor.js.map +1 -0
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +0 -6
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +22 -35
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +7 -15
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +7 -15
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +75 -141
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +2 -11
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/nodeTypes.d.ts +13 -1
- package/dist/nodeTypes.d.ts.map +1 -1
- package/dist/nodeTypes.js +4 -1
- package/dist/nodeTypes.js.map +1 -1
- package/dist/types.d.ts +0 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/buildEditorState.d.ts +11 -0
- package/dist/utilities/buildEditorState.d.ts.map +1 -0
- package/dist/utilities/buildEditorState.js +76 -0
- package/dist/utilities/buildEditorState.js.map +1 -0
- package/package.json +9 -9
- package/dist/exports/client/Field-YTBICBYV.js +0 -2
- package/dist/exports/client/Field-YTBICBYV.js.map +0 -7
- package/dist/exports/client/chunk-FSKAVN4P.js +0 -2
- package/dist/exports/client/chunk-KZKGNMS3.js +0 -12
- /package/dist/exports/client/{component-M3U253XK.js.map → component-3PENNOM3.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","createCommand","getDOMSelection","useCallback","useEffect","useState","React","LexicalMenu","useMenuAnchorRef","PUNCTUATION","getTextUpToAnchor","selection","anchor","type","anchorNode","getNode","isSimpleText","anchorOffset","offset","getTextContent","slice","tryToPositionRange","leadOffset","range","editorWindow","domSelection","isCollapsed","startOffset","endOffset","setStart","setEnd","error","getQueryTextForSearch","editor","text","getEditorState","read","isSelectionOnEntityBoundary","prevSibling","getPreviousSibling","isTextEntity","startTransition","callback","useDynamicPositioning","ENABLE_SLASH_MENU_COMMAND","LexicalTypeaheadMenuPlugin","t0","$","anchorClassName","anchorElem","groups","menuRenderFn","onClose","onOpen","onQueryChange","triggerFn","resolution","setResolution","anchorElementRef","t1","closeTypeahead","t2","res","openTypeahead","t3","t4","registerCommand","t5","node","match","matchingString","replaceableString","_window","window","document","createRange","isRangePositioned","getRect","getBoundingClientRect","updateListener","editorWindow_0","range_0","undefined","match_0","query","isRangePositioned_0","removeUpdateListener","registerUpdateListener","t6","t7","current","_jsx","close","shouldSplitNodeWithQuery"],"sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand, LexicalEditor, ParagraphNode, RangeSelection } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n createCommand,\n getDOMSelection,\n} from 'lexical'\nimport { type JSX, useCallback, useEffect, useState } from 'react'\nimport * as React from 'react'\n\nimport type { MenuTextMatch, TriggerFn } from '../useMenuTriggerMatch.js'\nimport type { MenuRenderFn, MenuResolution } from './LexicalMenu.js'\nimport type { SlashMenuGroupInternal } from './types.js'\n\nimport { LexicalMenu, useMenuAnchorRef } from './LexicalMenu.js'\n\nexport const PUNCTUATION = '\\\\.,\\\\+\\\\*\\\\?\\\\$\\\\@\\\\|#{}\\\\(\\\\)\\\\^\\\\-\\\\[\\\\]\\\\\\\\/!%\\'\"~=<>_:;'\n\nfunction getTextUpToAnchor(selection: RangeSelection): null | string {\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return null\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return null\n }\n const anchorOffset = anchor.offset\n return anchorNode.getTextContent().slice(0, anchorOffset)\n}\n\nfunction tryToPositionRange(leadOffset: number, range: Range, editorWindow: Window): boolean {\n const domSelection = getDOMSelection(editorWindow)\n if (domSelection === null || !domSelection.isCollapsed) {\n return false\n }\n\n const anchorNode = domSelection.anchorNode\n const startOffset = leadOffset\n const endOffset = domSelection.anchorOffset\n\n if (anchorNode == null || endOffset == null) {\n return false\n }\n\n try {\n range.setStart(anchorNode, startOffset)\n // if endOffset is 0, positioning the range for when you click the plus button to open the slash menu will fial\n range.setEnd(anchorNode, endOffset > 1 ? endOffset : 1)\n } catch (error) {\n return false\n }\n\n return true\n}\n\nfunction getQueryTextForSearch(editor: LexicalEditor): string | undefined {\n let text\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) {\n return\n }\n text = getTextUpToAnchor(selection)\n })\n return text\n}\n\nfunction isSelectionOnEntityBoundary(editor: LexicalEditor, offset: number): boolean {\n if (offset !== 0) {\n return false\n }\n return editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const anchor = selection.anchor\n const anchorNode = anchor.getNode()\n const prevSibling = anchorNode.getPreviousSibling()\n return $isTextNode(prevSibling) && prevSibling.isTextEntity()\n }\n return false\n })\n}\n\nfunction startTransition(callback: () => void) {\n if (React.startTransition) {\n React.startTransition(callback)\n } else {\n callback()\n }\n}\n\nexport { useDynamicPositioning } from './LexicalMenu.js'\n\nexport type TypeaheadMenuPluginProps = {\n anchorClassName?: string\n anchorElem: HTMLElement\n groups: Array<SlashMenuGroupInternal>\n menuRenderFn: MenuRenderFn\n onClose?: () => void\n onOpen?: (resolution: MenuResolution) => void\n onQueryChange: (matchingString: null | string) => void\n triggerFn: TriggerFn\n}\n\nexport const ENABLE_SLASH_MENU_COMMAND: LexicalCommand<{\n node: ParagraphNode\n}> = createCommand('ENABLE_SLASH_MENU_COMMAND')\n\nexport function LexicalTypeaheadMenuPlugin({\n anchorClassName,\n anchorElem,\n groups,\n menuRenderFn,\n onClose,\n onOpen,\n onQueryChange,\n triggerFn,\n}: TypeaheadMenuPluginProps): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n const [resolution, setResolution] = useState<MenuResolution | null>(null)\n const anchorElementRef = useMenuAnchorRef(anchorElem, resolution, setResolution, anchorClassName)\n\n const closeTypeahead = useCallback(() => {\n setResolution(null)\n if (onClose != null && resolution !== null) {\n onClose()\n }\n }, [onClose, resolution])\n\n const openTypeahead = useCallback(\n (res: MenuResolution) => {\n setResolution(res)\n if (onOpen != null && resolution === null) {\n onOpen(res)\n }\n },\n [onOpen, resolution],\n )\n\n // This is mainly used for the AddBlockHandlePlugin, so that the slash menu can be opened from there\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n ENABLE_SLASH_MENU_COMMAND,\n ({ node }) => {\n editor.getEditorState().read(() => {\n const match: MenuTextMatch = {\n leadOffset: 0,\n matchingString: '',\n replaceableString: '',\n }\n if (!isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n if (node !== null) {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n }\n\n return\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, openTypeahead])\n\n useEffect(() => {\n const updateListener = () => {\n editor.getEditorState().read(() => {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n const selection = $getSelection()\n const text = getQueryTextForSearch(editor)\n\n if (\n !$isRangeSelection(selection) ||\n !selection.isCollapsed() ||\n text === undefined ||\n range === null\n ) {\n closeTypeahead()\n return\n }\n\n const match = triggerFn({ editor, query: text })\n onQueryChange(match ? match.matchingString : null)\n\n if (match !== null && !isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n return\n }\n }\n closeTypeahead()\n })\n }\n\n const removeUpdateListener = editor.registerUpdateListener(updateListener)\n\n return () => {\n removeUpdateListener()\n }\n }, [editor, triggerFn, onQueryChange, resolution, closeTypeahead, openTypeahead])\n\n return anchorElementRef.current === null || resolution === null || editor === null ? null : (\n <LexicalMenu\n anchorElementRef={anchorElementRef}\n close={closeTypeahead}\n editor={editor}\n groups={groups}\n menuRenderFn={menuRenderFn}\n resolution={resolution}\n shouldSplitNodeWithQuery\n />\n )\n}\n\nexport type { MenuRenderFn, MenuResolution, MenuTextMatch, TriggerFn }\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,QAAQ;AAC9B,SACEC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,oBAAoB,EACpBC,aAAa,EACbC,eAAe,QACV;AACP,SAAmBC,WAAW,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UAAA;IAAAT,CAAA,OAAAQ,SAAA;IAAAR,CAAA,OAAAyC,EAAA;EAAA;IAAAA,EAAA,GAAAzC,CAAA;EAAA;EA5ChF3C,SAAA,CAAU+D,EA4CV,EAAGqB,EAA6E;EAAA,IAAAC,EAAA;EAAA,IAAA1C,CAAA,SAAAW,gBAAA,IAAAX,CAAA,SAAAa,cAAA,IAAAb,CAAA,SAAAd,MAAA,IAAAc,CAAA,SAAAG,MAAA,IAAAH,CAAA,SAAAI,YAAA,IAAAJ,CAAA,SAAAS,UAAA;IAEzEiC,EAAA,GAAA/B,gBAAA,CAAAgC,OAAA,SAA6B,IAAQlC,UAAA,SAAe,IAAQvB,MAAA,SAAW,UAC5E0D,IAAA,CAAApF,WAAA;MAAAmD,gBAAA;MAAAkC,KAAA,EAEShC,cAAA;MAAA3B,MAAA;MAAAiB,MAAA;MAAAC,YAAA;MAAAK,UAAA;MAAAqC,wBAAA;IAAA,C;;;;;;;;;;;SAHJJ,E","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","createCommand","getDOMSelection","useCallback","useEffect","useState","React","LexicalMenu","useMenuAnchorRef","PUNCTUATION","getTextUpToAnchor","selection","anchor","type","anchorNode","getNode","isSimpleText","anchorOffset","offset","getTextContent","slice","tryToPositionRange","leadOffset","range","editorWindow","domSelection","isCollapsed","startOffset","endOffset","setStart","setEnd","error","getQueryTextForSearch","editor","text","getEditorState","read","isSelectionOnEntityBoundary","prevSibling","getPreviousSibling","isTextEntity","startTransition","callback","useDynamicPositioning","ENABLE_SLASH_MENU_COMMAND","LexicalTypeaheadMenuPlugin","anchorClassName","anchorElem","groups","menuRenderFn","onClose","onOpen","onQueryChange","triggerFn","resolution","setResolution","anchorElementRef","closeTypeahead","openTypeahead","res","registerCommand","node","match","matchingString","replaceableString","_window","window","document","createRange","isRangePositioned","getRect","getBoundingClientRect","updateListener","undefined","query","removeUpdateListener","registerUpdateListener","current","_jsx","close","shouldSplitNodeWithQuery"],"sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand, LexicalEditor, ParagraphNode, RangeSelection } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n createCommand,\n getDOMSelection,\n} from 'lexical'\nimport { type JSX, useCallback, useEffect, useState } from 'react'\nimport * as React from 'react'\n\nimport type { MenuTextMatch, TriggerFn } from '../useMenuTriggerMatch.js'\nimport type { MenuRenderFn, MenuResolution } from './LexicalMenu.js'\nimport type { SlashMenuGroupInternal } from './types.js'\n\nimport { LexicalMenu, useMenuAnchorRef } from './LexicalMenu.js'\n\nexport const PUNCTUATION = '\\\\.,\\\\+\\\\*\\\\?\\\\$\\\\@\\\\|#{}\\\\(\\\\)\\\\^\\\\-\\\\[\\\\]\\\\\\\\/!%\\'\"~=<>_:;'\n\nfunction getTextUpToAnchor(selection: RangeSelection): null | string {\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return null\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return null\n }\n const anchorOffset = anchor.offset\n return anchorNode.getTextContent().slice(0, anchorOffset)\n}\n\nfunction tryToPositionRange(leadOffset: number, range: Range, editorWindow: Window): boolean {\n const domSelection = getDOMSelection(editorWindow)\n if (domSelection === null || !domSelection.isCollapsed) {\n return false\n }\n\n const anchorNode = domSelection.anchorNode\n const startOffset = leadOffset\n const endOffset = domSelection.anchorOffset\n\n if (anchorNode == null || endOffset == null) {\n return false\n }\n\n try {\n range.setStart(anchorNode, startOffset)\n // if endOffset is 0, positioning the range for when you click the plus button to open the slash menu will fial\n range.setEnd(anchorNode, endOffset > 1 ? endOffset : 1)\n } catch (error) {\n return false\n }\n\n return true\n}\n\nfunction getQueryTextForSearch(editor: LexicalEditor): string | undefined {\n let text\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) {\n return\n }\n text = getTextUpToAnchor(selection)\n })\n return text\n}\n\nfunction isSelectionOnEntityBoundary(editor: LexicalEditor, offset: number): boolean {\n if (offset !== 0) {\n return false\n }\n return editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const anchor = selection.anchor\n const anchorNode = anchor.getNode()\n const prevSibling = anchorNode.getPreviousSibling()\n return $isTextNode(prevSibling) && prevSibling.isTextEntity()\n }\n return false\n })\n}\n\nfunction startTransition(callback: () => void) {\n if (React.startTransition) {\n React.startTransition(callback)\n } else {\n callback()\n }\n}\n\nexport { useDynamicPositioning } from './LexicalMenu.js'\n\nexport type TypeaheadMenuPluginProps = {\n anchorClassName?: string\n anchorElem: HTMLElement\n groups: Array<SlashMenuGroupInternal>\n menuRenderFn: MenuRenderFn\n onClose?: () => void\n onOpen?: (resolution: MenuResolution) => void\n onQueryChange: (matchingString: null | string) => void\n triggerFn: TriggerFn\n}\n\nexport const ENABLE_SLASH_MENU_COMMAND: LexicalCommand<{\n node: ParagraphNode\n}> = createCommand('ENABLE_SLASH_MENU_COMMAND')\n\nexport function LexicalTypeaheadMenuPlugin({\n anchorClassName,\n anchorElem,\n groups,\n menuRenderFn,\n onClose,\n onOpen,\n onQueryChange,\n triggerFn,\n}: TypeaheadMenuPluginProps): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n const [resolution, setResolution] = useState<MenuResolution | null>(null)\n const anchorElementRef = useMenuAnchorRef(anchorElem, resolution, setResolution, anchorClassName)\n\n const closeTypeahead = useCallback(() => {\n setResolution(null)\n if (onClose != null && resolution !== null) {\n onClose()\n }\n }, [onClose, resolution])\n\n const openTypeahead = useCallback(\n (res: MenuResolution) => {\n setResolution(res)\n if (onOpen != null && resolution === null) {\n onOpen(res)\n }\n },\n [onOpen, resolution],\n )\n\n // This is mainly used for the AddBlockHandlePlugin, so that the slash menu can be opened from there\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n ENABLE_SLASH_MENU_COMMAND,\n ({ node }) => {\n editor.getEditorState().read(() => {\n const match: MenuTextMatch = {\n leadOffset: 0,\n matchingString: '',\n replaceableString: '',\n }\n if (!isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n if (node !== null) {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n }\n\n return\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, openTypeahead])\n\n useEffect(() => {\n const updateListener = () => {\n editor.getEditorState().read(() => {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n const selection = $getSelection()\n const text = getQueryTextForSearch(editor)\n\n if (\n !$isRangeSelection(selection) ||\n !selection.isCollapsed() ||\n text === undefined ||\n range === null\n ) {\n closeTypeahead()\n return\n }\n\n const match = triggerFn({ editor, query: text })\n onQueryChange(match ? match.matchingString : null)\n\n if (match !== null && !isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n return\n }\n }\n closeTypeahead()\n })\n }\n\n const removeUpdateListener = editor.registerUpdateListener(updateListener)\n\n return () => {\n removeUpdateListener()\n }\n }, [editor, triggerFn, onQueryChange, resolution, closeTypeahead, openTypeahead])\n\n return anchorElementRef.current === null || resolution === null || editor === null ? null : (\n <LexicalMenu\n anchorElementRef={anchorElementRef}\n close={closeTypeahead}\n editor={editor}\n groups={groups}\n menuRenderFn={menuRenderFn}\n resolution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AE3D,OAAO;MACLG,oBAAA;IACF;EACF,GAAG,CAAC1C,MAAA,EAAQoB,SAAA,EAAWD,aAAA,EAAeE,UAAA,EAAYG,cAAA,EAAgBC,aAAA,CAAc;EAEhF,OAAOF,gBAAA,CAAiBqB,OAAO,KAAK,QAAQvB,UAAA,KAAe,QAAQrB,MAAA,KAAW,OAAO,oBACnF6C,IAAA,CAACvE,WAAA;IACCiD,gBAAA,EAAkBA,gBAAA;IAClBuB,KAAA,EAAOtB,cAAA;IACPxB,MAAA,EAAQA,MAAA;IACRe,MAAA,EAAQA,MAAA;IACRC,YAAA,EAAcA,YAAA;IACdK,UAAA,EAAYA,UAAA;IACZ0B,wBAAwB;;AAG9B","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ import { ContentEditable } from '@lexical/react/LexicalContentEditable.js';
|
|
|
6
6
|
import { useTranslation } from '@payloadcms/ui';
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
export function LexicalContentEditable(t0) {
|
|
9
|
-
const $ = _c(
|
|
9
|
+
const $ = _c(4);
|
|
10
10
|
const {
|
|
11
11
|
className,
|
|
12
12
|
editorConfig
|
|
@@ -16,21 +16,12 @@ export function LexicalContentEditable(t0) {
|
|
|
16
16
|
} = useTranslation();
|
|
17
17
|
let t1;
|
|
18
18
|
if ($[0] !== className || $[1] !== editorConfig?.admin?.placeholder || $[2] !== t) {
|
|
19
|
-
let t2;
|
|
20
|
-
if ($[4] !== editorConfig?.admin?.placeholder || $[5] !== t) {
|
|
21
|
-
t2 = editorConfig?.admin?.placeholder ?? t("lexical:general:placeholder");
|
|
22
|
-
$[4] = editorConfig?.admin?.placeholder;
|
|
23
|
-
$[5] = t;
|
|
24
|
-
$[6] = t2;
|
|
25
|
-
} else {
|
|
26
|
-
t2 = $[6];
|
|
27
|
-
}
|
|
28
19
|
t1 = _jsx(ContentEditable, {
|
|
29
20
|
"aria-placeholder": t("lexical:general:placeholder"),
|
|
30
21
|
className: className ?? "ContentEditable__root",
|
|
31
22
|
placeholder: _jsx("p", {
|
|
32
23
|
className: "editor-placeholder",
|
|
33
|
-
children:
|
|
24
|
+
children: editorConfig?.admin?.placeholder ?? t("lexical:general:placeholder")
|
|
34
25
|
})
|
|
35
26
|
});
|
|
36
27
|
$[0] = className;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentEditable.js","names":["c","_c","ContentEditable","useTranslation","React","LexicalContentEditable","t0","$","className","editorConfig","t","t1","admin","placeholder","
|
|
1
|
+
{"version":3,"file":"ContentEditable.js","names":["c","_c","ContentEditable","useTranslation","React","LexicalContentEditable","t0","$","className","editorConfig","t","t1","admin","placeholder","_jsx","children"],"sources":["../../../src/lexical/ui/ContentEditable.tsx"],"sourcesContent":["'use client'\nimport type { JSX } from 'react'\n\nimport { ContentEditable } from '@lexical/react/LexicalContentEditable.js'\nimport { useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\n\nimport './ContentEditable.scss'\nimport type { SanitizedClientEditorConfig } from '../config/types.js'\n\nexport function LexicalContentEditable({\n className,\n editorConfig,\n}: {\n className?: string\n editorConfig: SanitizedClientEditorConfig\n}): JSX.Element {\n const { t } = useTranslation<{}, string>()\n\n return (\n <ContentEditable\n aria-placeholder={t('lexical:general:placeholder')}\n className={className ?? 'ContentEditable__root'}\n placeholder={\n <p className=\"editor-placeholder\">\n {editorConfig?.admin?.placeholder ?? t('lexical:general:placeholder')}\n </p>\n }\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,YAAYC,KAAA,MAAW;AAKvB,OAAO,SAAAC,uBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAN,EAAA;EAAgC;IAAAO,SAAA;IAAAC;EAAA,IAAAH,EAMtC;EACC;IAAAI;EAAA,IAAcP,cAAA;EAAA,IAAAQ,EAAA;EAAA,IAAAJ,CAAA,QAAAC,SAAA,IAAAD,CAAA,QAAAE,YAAA,EAAAG,KAAA,EAAAC,WAAA,IAAAN,CAAA,QAAAG,CAAA;IAGZC,EAAA,GAAAG,IAAA,CAAAZ,eAAA;MAAA,oBACoBQ,CAAA,CAAE;MAAAF,SAAA,EACTA,SAAA,IAAa;MAAAK,WAAA,EAEtBC,IAAA,CAAC;QAAAN,SAAA,EAAY;QAAAO,QAAA,EACVN,YAAA,EAAAG,KAAA,EAAAC,WAAA,IAAoCH,CAAA,CAAE;MAAA,C;;;;;;;;;SAL7CC,E","ignoreList":[]}
|
package/dist/nodeTypes.d.ts
CHANGED
|
@@ -30,7 +30,19 @@ type RecursiveNodes<T extends SerializedLexicalNode, Depth extends number = 4> =
|
|
|
30
30
|
children?: RecursiveNodes<T, DecrementDepth<Depth>>[];
|
|
31
31
|
} & T;
|
|
32
32
|
type DecrementDepth<N extends number> = [0, 0, 1, 2, 3, 4][N];
|
|
33
|
+
/**
|
|
34
|
+
* Alternative type to `SerializedEditorState` that automatically types your nodes
|
|
35
|
+
* more strictly, narrowing down nodes based on the `type` without having to manually
|
|
36
|
+
* type-cast.
|
|
37
|
+
*/
|
|
33
38
|
export type TypedEditorState<T extends SerializedLexicalNode = SerializedLexicalNode> = SerializedEditorState<RecursiveNodes<T>>;
|
|
39
|
+
/**
|
|
40
|
+
* All node types included by default in a lexical editor without configuration.
|
|
41
|
+
*/
|
|
34
42
|
export type DefaultNodeTypes = SerializedAutoLinkNode | SerializedHeadingNode | SerializedHorizontalRuleNode | SerializedLineBreakNode | SerializedLinkNode | SerializedListItemNode | SerializedListNode | SerializedParagraphNode | SerializedQuoteNode | SerializedRelationshipNode | SerializedTabNode | SerializedTextNode | SerializedUploadNode;
|
|
35
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Like `TypedEditorState` but includes all default node types.
|
|
45
|
+
* You can pass *additional* node types as a generic parameter.
|
|
46
|
+
*/
|
|
47
|
+
export type DefaultTypedEditorState<TAdditionalNodeTypes extends null | SerializedLexicalNode = null> = [TAdditionalNodeTypes] extends null ? TypedEditorState<DefaultNodeTypes> : TypedEditorState<DefaultNodeTypes | NonNullable<TAdditionalNodeTypes>>;
|
|
36
48
|
//# sourceMappingURL=nodeTypes.d.ts.map
|
package/dist/nodeTypes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeTypes.d.ts","sourceRoot":"","sources":["../src/nodeTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,IAAI,wBAAwB,EACnD,iBAAiB,IAAI,kBAAkB,EACvC,kBAAkB,IAAI,mBAAmB,EACzC,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAChF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oDAAoD,CAAA;AACnG,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,+CAA+C,CAAA;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8DAA8D,CAAA;AAChH,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAChG,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAClG,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAA;AAC1G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAA;AAExF,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,yBAAyB,EACzB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,mB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AAqB,IAClF,qBAAqB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;AAE1C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,sBAAsB,GAEtB,qBAAqB,GACrB,4BAA4B,GAC5B,uBAAuB,GACvB,kBAAkB,GAClB,sBAAsB,GACtB,kBAAkB,GAClB,uBAAuB,GACvB,mBAAmB,GACnB,0BAA0B,GAC1B,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,CAAA;AAExB;;;GAGG;AACH,MAAM,MAAM,uBAAuB,CACjC,oBAAoB,SAAS,IAAI,GAAG,qBAAqB,GAAG,IAAI,IAC9D,CAAC,oBAAoB,CAAC,SAAS,IAAI,GACnC,gBAAgB,CAAC,gBAAgB,CAAC,GAClC,gBAAgB,CAAC,gBAAgB,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAA"}
|
package/dist/nodeTypes.js
CHANGED
package/dist/nodeTypes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeTypes.js","names":[],"sources":["../src/nodeTypes.ts"],"sourcesContent":["import type {\n SerializedLineBreakNode as _SerializedLineBreakNode,\n SerializedTabNode as _SerializedTabNode,\n SerializedTextNode as _SerializedTextNode,\n SerializedEditorState,\n SerializedElementNode,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\n\nimport type { SerializedQuoteNode } from './features/blockquote/server/index.js'\nimport type { SerializedBlockNode } from './features/blocks/server/nodes/BlocksNode.js'\nimport type { SerializedInlineBlockNode } from './features/blocks/server/nodes/InlineBlocksNode.js'\nimport type {\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n} from './features/experimental_table/server/index.js'\nimport type { SerializedHeadingNode } from './features/heading/server/index.js'\nimport type { SerializedHorizontalRuleNode } from './features/horizontalRule/server/nodes/HorizontalRuleNode.js'\nimport type { SerializedAutoLinkNode, SerializedLinkNode } from './features/link/nodes/types.js'\nimport type { SerializedListItemNode, SerializedListNode } from './features/lists/plugin/index.js'\nimport type { SerializedRelationshipNode } from './features/relationship/server/nodes/RelationshipNode.js'\nimport type { SerializedUploadNode } from './features/upload/server/nodes/UploadNode.js'\n\nexport type {\n SerializedAutoLinkNode,\n SerializedBlockNode,\n SerializedHeadingNode,\n SerializedHorizontalRuleNode,\n SerializedInlineBlockNode,\n SerializedLinkNode,\n SerializedListItemNode,\n SerializedListNode,\n SerializedQuoteNode,\n SerializedRelationshipNode,\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n SerializedUploadNode,\n}\n\nexport type SerializedParagraphNode<T extends SerializedLexicalNode = SerializedLexicalNode> =\n Spread<\n {\n textFormat: number\n type: 'paragraph'\n },\n SerializedElementNode<T>\n >\nexport type SerializedTextNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'text'\n },\n _SerializedTextNode\n>\n\nexport type SerializedTabNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'tab'\n },\n _SerializedTabNode\n>\n\nexport type SerializedLineBreakNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'linebreak'\n },\n _SerializedLineBreakNode\n>\n\ntype RecursiveNodes<T extends SerializedLexicalNode, Depth extends number = 4> = Depth extends 0\n ? T\n : { children?: RecursiveNodes<T, DecrementDepth<Depth>>[] } & T\n\ntype DecrementDepth<N extends number> = [0, 0, 1, 2, 3, 4][N]\n\nexport type TypedEditorState<T extends SerializedLexicalNode = SerializedLexicalNode> =\n SerializedEditorState<RecursiveNodes<T>>\n\nexport type DefaultNodeTypes =\n | SerializedAutoLinkNode\n //| SerializedBlockNode // Not included by default\n | SerializedHeadingNode\n | SerializedHorizontalRuleNode\n | SerializedLineBreakNode\n | SerializedLinkNode\n | SerializedListItemNode\n | SerializedListNode\n | SerializedParagraphNode\n | SerializedQuoteNode\n | SerializedRelationshipNode\n | SerializedTabNode\n | SerializedTextNode\n | SerializedUploadNode\n\nexport type DefaultTypedEditorState
|
|
1
|
+
{"version":3,"file":"nodeTypes.js","names":[],"sources":["../src/nodeTypes.ts"],"sourcesContent":["import type {\n SerializedLineBreakNode as _SerializedLineBreakNode,\n SerializedTabNode as _SerializedTabNode,\n SerializedTextNode as _SerializedTextNode,\n SerializedEditorState,\n SerializedElementNode,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\n\nimport type { SerializedQuoteNode } from './features/blockquote/server/index.js'\nimport type { SerializedBlockNode } from './features/blocks/server/nodes/BlocksNode.js'\nimport type { SerializedInlineBlockNode } from './features/blocks/server/nodes/InlineBlocksNode.js'\nimport type {\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n} from './features/experimental_table/server/index.js'\nimport type { SerializedHeadingNode } from './features/heading/server/index.js'\nimport type { SerializedHorizontalRuleNode } from './features/horizontalRule/server/nodes/HorizontalRuleNode.js'\nimport type { SerializedAutoLinkNode, SerializedLinkNode } from './features/link/nodes/types.js'\nimport type { SerializedListItemNode, SerializedListNode } from './features/lists/plugin/index.js'\nimport type { SerializedRelationshipNode } from './features/relationship/server/nodes/RelationshipNode.js'\nimport type { SerializedUploadNode } from './features/upload/server/nodes/UploadNode.js'\n\nexport type {\n SerializedAutoLinkNode,\n SerializedBlockNode,\n SerializedHeadingNode,\n SerializedHorizontalRuleNode,\n SerializedInlineBlockNode,\n SerializedLinkNode,\n SerializedListItemNode,\n SerializedListNode,\n SerializedQuoteNode,\n SerializedRelationshipNode,\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n SerializedUploadNode,\n}\n\nexport type SerializedParagraphNode<T extends SerializedLexicalNode = SerializedLexicalNode> =\n Spread<\n {\n textFormat: number\n type: 'paragraph'\n },\n SerializedElementNode<T>\n >\nexport type SerializedTextNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'text'\n },\n _SerializedTextNode\n>\n\nexport type SerializedTabNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'tab'\n },\n _SerializedTabNode\n>\n\nexport type SerializedLineBreakNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'linebreak'\n },\n _SerializedLineBreakNode\n>\n\ntype RecursiveNodes<T extends SerializedLexicalNode, Depth extends number = 4> = Depth extends 0\n ? T\n : { children?: RecursiveNodes<T, DecrementDepth<Depth>>[] } & T\n\ntype DecrementDepth<N extends number> = [0, 0, 1, 2, 3, 4][N]\n\n/**\n * Alternative type to `SerializedEditorState` that automatically types your nodes\n * more strictly, narrowing down nodes based on the `type` without having to manually\n * type-cast.\n */\nexport type TypedEditorState<T extends SerializedLexicalNode = SerializedLexicalNode> =\n SerializedEditorState<RecursiveNodes<T>>\n\n/**\n * All node types included by default in a lexical editor without configuration.\n */\nexport type DefaultNodeTypes =\n | SerializedAutoLinkNode\n //| SerializedBlockNode // Not included by default\n | SerializedHeadingNode\n | SerializedHorizontalRuleNode\n | SerializedLineBreakNode\n | SerializedLinkNode\n | SerializedListItemNode\n | SerializedListNode\n | SerializedParagraphNode\n | SerializedQuoteNode\n | SerializedRelationshipNode\n | SerializedTabNode\n | SerializedTextNode\n | SerializedUploadNode\n\n/**\n * Like `TypedEditorState` but includes all default node types.\n * You can pass *additional* node types as a generic parameter.\n */\nexport type DefaultTypedEditorState<\n TAdditionalNodeTypes extends null | SerializedLexicalNode = null,\n> = [TAdditionalNodeTypes] extends null\n ? TypedEditorState<DefaultNodeTypes>\n : TypedEditorState<DefaultNodeTypes | NonNullable<TAdditionalNodeTypes>>\n"],"mappings":"AA2GA;;;GAIA","ignoreList":[]}
|
package/dist/types.d.ts
CHANGED
|
@@ -5,14 +5,6 @@ import type { FeatureProviderServer } from './features/typesServer.js';
|
|
|
5
5
|
import type { SanitizedServerEditorConfig } from './lexical/config/types.js';
|
|
6
6
|
import type { InitialLexicalFormState } from './utilities/buildInitialState.js';
|
|
7
7
|
export type LexicalFieldAdminProps = {
|
|
8
|
-
/**
|
|
9
|
-
* Controls if the add block button should be hidden. @default false
|
|
10
|
-
*/
|
|
11
|
-
hideAddBlockButton?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Controls if the draggable block element should be hidden. @default false
|
|
14
|
-
*/
|
|
15
|
-
hideDraggableBlockElement?: boolean;
|
|
16
8
|
/**
|
|
17
9
|
* Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false
|
|
18
10
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACzF,OAAO,KAAK,EACV,WAAW,EACX,+BAA+B,EAC/B,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B,EAC9B,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAC5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAE/E,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACzF,OAAO,KAAK,EACV,WAAW,EACX,+BAA+B,EAC/B,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B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GAAG;IACzB,YAAY,EAAE,2BAA2B,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC9C,aAAa,EAAE,6BAA6B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACtD,kBAAkB,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAA;CACnD,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n RichTextAdapter,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n RichTextAdapter,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type FeaturesInput =\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: {\n [featureKey: string]: {\n clientFeatureProps?: object\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n }\n featureClientImportMap: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState: InitialLexicalFormState\n lexicalEditorConfig: LexicalEditorConfig | undefined // Undefined if default lexical editor config should be used\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultServerCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n"],"mappings":"AAkIA","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SerializedLexicalNode } from 'lexical';
|
|
2
|
+
import type { DefaultTypedEditorState, TypedEditorState } from '../nodeTypes.js';
|
|
3
|
+
export declare function buildEditorState(args: {
|
|
4
|
+
nodes?: DefaultTypedEditorState['root']['children'];
|
|
5
|
+
text?: string;
|
|
6
|
+
}): DefaultTypedEditorState;
|
|
7
|
+
export declare function buildEditorState<T extends SerializedLexicalNode>(args: {
|
|
8
|
+
nodes?: TypedEditorState<T>['root']['children'];
|
|
9
|
+
text?: string;
|
|
10
|
+
}): TypedEditorState<T>;
|
|
11
|
+
//# sourceMappingURL=buildEditorState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildEditorState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEhF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,KAAK,CAAC,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IACnD,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,uBAAuB,CAAA;AAE3B,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,qBAAqB,EAAE,IAAI,EAAE;IAEtE,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to build lexical editor state JSON from text and/or nodes.
|
|
3
|
+
*
|
|
4
|
+
* @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.
|
|
5
|
+
* @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.
|
|
6
|
+
* @returns The constructed editor state JSON.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* just passing text:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const editorState = buildEditorState({ text: 'Hello world' }) // result typed as DefaultTypedEditorState
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* passing nodes:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)
|
|
22
|
+
* buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes
|
|
23
|
+
* nodes: [
|
|
24
|
+
* {
|
|
25
|
+
* type: 'block',
|
|
26
|
+
* fields: {
|
|
27
|
+
* id: 'id',
|
|
28
|
+
* blockName: 'Cool block',
|
|
29
|
+
* blockType: 'myBlock',
|
|
30
|
+
* },
|
|
31
|
+
* format: 'left',
|
|
32
|
+
* version: 1,
|
|
33
|
+
* }
|
|
34
|
+
* ],
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
*/export function buildEditorState({
|
|
38
|
+
nodes,
|
|
39
|
+
text
|
|
40
|
+
}) {
|
|
41
|
+
const editorJSON = {
|
|
42
|
+
root: {
|
|
43
|
+
type: 'root',
|
|
44
|
+
children: [],
|
|
45
|
+
direction: 'ltr',
|
|
46
|
+
format: '',
|
|
47
|
+
indent: 0,
|
|
48
|
+
version: 1
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
if (text) {
|
|
52
|
+
editorJSON.root.children.push({
|
|
53
|
+
type: 'paragraph',
|
|
54
|
+
children: [{
|
|
55
|
+
type: 'text',
|
|
56
|
+
detail: 0,
|
|
57
|
+
format: 0,
|
|
58
|
+
mode: 'normal',
|
|
59
|
+
style: '',
|
|
60
|
+
text,
|
|
61
|
+
version: 1
|
|
62
|
+
}],
|
|
63
|
+
direction: 'ltr',
|
|
64
|
+
format: '',
|
|
65
|
+
indent: 0,
|
|
66
|
+
textFormat: 0,
|
|
67
|
+
textStyle: '',
|
|
68
|
+
version: 1
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (nodes?.length) {
|
|
72
|
+
editorJSON.root.children.push(...nodes);
|
|
73
|
+
}
|
|
74
|
+
return editorJSON;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=buildEditorState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildEditorState.js","names":["buildEditorState","nodes","text","editorJSON","root","type","children","direction","format","indent","version","push","detail","mode","style","textFormat","textStyle","length"],"sources":["../../src/utilities/buildEditorState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type { DefaultTypedEditorState, TypedEditorState } from '../nodeTypes.js'\n\nexport function buildEditorState(args: {\n nodes?: DefaultTypedEditorState['root']['children']\n text?: string\n}): DefaultTypedEditorState\n\nexport function buildEditorState<T extends SerializedLexicalNode>(args: {\n // If you pass children typed for a specific schema T, the return is TypedEditorState<T>\n nodes?: TypedEditorState<T>['root']['children']\n text?: string\n}): TypedEditorState<T>\n\n/**\n * Helper to build lexical editor state JSON from text and/or nodes.\n *\n * @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.\n * @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.\n * @returns The constructed editor state JSON.\n *\n * @example\n *\n * just passing text:\n *\n * ```ts\n * const editorState = buildEditorState({ text: 'Hello world' }) // result typed as DefaultTypedEditorState\n * ```\n *\n * @example\n *\n * passing nodes:\n *\n * ```ts\n * const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)\n * buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes\n * nodes: [\n * {\n * type: 'block',\n * fields: {\n * id: 'id',\n * blockName: 'Cool block',\n * blockType: 'myBlock',\n * },\n * format: 'left',\n * version: 1,\n * }\n * ],\n * })\n * ```\n */\nexport function buildEditorState<T extends SerializedLexicalNode>({\n nodes,\n text,\n}: {\n nodes?: DefaultTypedEditorState['root']['children'] | TypedEditorState<T>['root']['children']\n text?: string\n}): DefaultTypedEditorState | TypedEditorState<T> {\n const editorJSON: DefaultTypedEditorState = {\n root: {\n type: 'root',\n children: [],\n direction: 'ltr',\n format: '',\n indent: 0,\n version: 1,\n },\n }\n\n if (text) {\n editorJSON.root.children.push({\n type: 'paragraph',\n children: [\n {\n type: 'text',\n detail: 0,\n format: 0,\n mode: 'normal',\n style: '',\n text,\n version: 1,\n },\n ],\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n })\n }\n\n if (nodes?.length) {\n editorJSON.root.children.push(...(nodes as any))\n }\n\n return editorJSON\n}\n"],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCA,OAAO,SAASA,iBAAkD;EAChEC,KAAK;EACLC;AAAI,CAIL;EACC,MAAMC,UAAA,GAAsC;IAC1CC,IAAA,EAAM;MACJC,IAAA,EAAM;MACNC,QAAA,EAAU,EAAE;MACZC,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRC,OAAA,EAAS;IACX;EACF;EAEA,IAAIR,IAAA,EAAM;IACRC,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,CAAC;MAC5BN,IAAA,EAAM;MACNC,QAAA,EAAU,CACR;QACED,IAAA,EAAM;QACNO,MAAA,EAAQ;QACRJ,MAAA,EAAQ;QACRK,IAAA,EAAM;QACNC,KAAA,EAAO;QACPZ,IAAA;QACAQ,OAAA,EAAS;MACX,EACD;MACDH,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRM,UAAA,EAAY;MACZC,SAAA,EAAW;MACXN,OAAA,EAAS;IACX;EACF;EAEA,IAAIT,KAAA,EAAOgB,MAAA,EAAQ;IACjBd,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,IAAKV,KAAA;EACpC;EAEA,OAAOE,UAAA;AACT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.55.0-
|
|
3
|
+
"version": "3.55.0-internal.d44d1d3",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -368,8 +368,8 @@
|
|
|
368
368
|
"react-error-boundary": "4.1.2",
|
|
369
369
|
"ts-essentials": "10.0.3",
|
|
370
370
|
"uuid": "10.0.0",
|
|
371
|
-
"@payloadcms/
|
|
372
|
-
"@payloadcms/
|
|
371
|
+
"@payloadcms/ui": "3.55.0-internal.d44d1d3",
|
|
372
|
+
"@payloadcms/translations": "3.55.0-internal.d44d1d3"
|
|
373
373
|
},
|
|
374
374
|
"devDependencies": {
|
|
375
375
|
"@babel/cli": "7.27.2",
|
|
@@ -381,23 +381,23 @@
|
|
|
381
381
|
"@types/escape-html": "1.0.4",
|
|
382
382
|
"@types/json-schema": "7.0.15",
|
|
383
383
|
"@types/node": "22.15.30",
|
|
384
|
-
"@types/react": "19.1.
|
|
385
|
-
"@types/react-dom": "19.1.
|
|
386
|
-
"babel-plugin-react-compiler": "19.1.0-rc.
|
|
384
|
+
"@types/react": "19.1.12",
|
|
385
|
+
"@types/react-dom": "19.1.9",
|
|
386
|
+
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
|
387
387
|
"babel-plugin-transform-remove-imports": "^1.8.0",
|
|
388
388
|
"esbuild": "0.25.5",
|
|
389
389
|
"esbuild-sass-plugin": "3.3.1",
|
|
390
390
|
"swc-plugin-transform-remove-imports": "4.0.4",
|
|
391
391
|
"@payloadcms/eslint-config": "3.28.0",
|
|
392
|
-
"payload": "3.55.0-
|
|
392
|
+
"payload": "3.55.0-internal.d44d1d3"
|
|
393
393
|
},
|
|
394
394
|
"peerDependencies": {
|
|
395
395
|
"@faceless-ui/modal": "3.0.0-beta.2",
|
|
396
396
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
397
397
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
398
398
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
399
|
-
"@payloadcms/next": "3.55.0-
|
|
400
|
-
"payload": "3.55.0-
|
|
399
|
+
"@payloadcms/next": "3.55.0-internal.d44d1d3",
|
|
400
|
+
"payload": "3.55.0-internal.d44d1d3"
|
|
401
401
|
},
|
|
402
402
|
"engines": {
|
|
403
403
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{b as ke,c as we,f as _,h as ve,i as Te,j as De,k as Be,l as Le}from"./chunk-KZKGNMS3.js";import{a as Re,b as R}from"./chunk-BZZVLW4U.js";import{jsx as F,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as En,FieldError as xn,FieldLabel as Cn,RenderCustomComponent as xt,useEditDepth as bn,useEffectEvent as Nn,useField as Pn}from"@payloadcms/ui";import{mergeFieldStyles as Sn}from"@payloadcms/ui/shared";import Ct,{useCallback as bt,useEffect as Nt,useMemo as Rn,useState as Pt}from"react";import{ErrorBoundary as kn}from"react-error-boundary";import"./bundled.css";import{jsx as O}from"react/jsx-runtime";import{LexicalComposer as gn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as hn}from"@payloadcms/ui";import*as ht from"react";import{useMemo as yn}from"react";import{c as Zo}from"react/compiler-runtime";import{jsx as C,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as en}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as tn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as on}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as nn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as rn}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as sn,COMMAND_PRIORITY_LOW as pt,FOCUS_COMMAND as ln}from"lexical";import*as q from"react";import{useEffect as an,useState as cn}from"react";import{jsx as Me}from"react/jsx-runtime";import"react";var $=({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 kt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as vt}from"@lexical/utils";import{$createNodeSelection as Tt,$getEditor as X,$getNearestNodeFromDOMNode as Dt,$getSelection as re,$isDecoratorNode as K,$isElementNode as Ee,$isLineBreakNode as Bt,$isNodeSelection as ie,$isRangeSelection as Ae,$isRootOrShadowRoot as Lt,$isTextNode as Mt,$setSelection as Ie,CLICK_COMMAND as At,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as It,KEY_ARROW_UP_COMMAND as _t,KEY_BACKSPACE_COMMAND as Ot,KEY_DELETE_COMMAND as Ft,SELECTION_CHANGE_COMMAND as $t}from"lexical";import{useEffect as Kt}from"react";function _e(){let t=kt(3),[e]=wt(),o=Gt,r,n;return t[0]!==e?(r=()=>vt(e.registerCommand(At,Vt,W),e.registerCommand(Ft,o,W),e.registerCommand(Ot,o,W),e.registerCommand($t,Yt,W),e.registerCommand(_t,zt,W),e.registerCommand(It,Ht,W)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),Kt(r,n),null}function Ht(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(K(i)){let y=X().getElementByKey(i.getKey());return y&&Z({element:y,node:i}),!0}if(!Ee(i))return!0;let s=i.getFirstDescendant()??i;return s&&(ne(s,se)?.selectEnd(),t.preventDefault()),!0}if(!Ae(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,jt),c=n?.getNextSibling();if(!n||c!==Oe(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function jt(t){return Oe(t)!==null}function zt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(K(i)){let y=X().getElementByKey(i.getKey());return y?(Z({element:y,node:i}),t.preventDefault(),!0):!1}if(!Ee(i))return!1;let s=i.getLastDescendant()??i;return s?(ne(s,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Ae(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Wt),c=n?.getPreviousSibling();if(!n||c!==Fe(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Wt(t){return Fe(t)!==null}function Yt(){let t=Jt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function Vt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=qt(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"]')?Ie(null):Z(e),!0}function Gt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Ut),!0):!1}function Ut(t){t.remove()}function qt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=Dt(e);return K(o)?{element:e,node:o}:void 0}function Jt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return K(o)?{decorator:o,element:X().getElementByKey(o.getKey())}:void 0}function Z({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=Tt();o.add(e.getKey()),Ie(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(K(t)&&!t.isInline())return!0;if(!Ee(t)||Lt(t))return!1;let e=t.getFirstChild(),o=e===null||Bt(e)||Mt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function Oe(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function Fe(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as xe}from"react/jsx-runtime";import{useLexicalComposerContext as oo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as no,isHTMLElement as ro}from"lexical";import*as je from"react";import{useCallback as io,useEffect as He,useRef as so,useState as lo}from"react";import{createPortal as ao}from"react-dom";var Y=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:s,left:d,right:y,top:g}=t.getBoundingClientRect(),a=g+window.scrollY,l=s+window.scrollY;if(o<a-c||o>l+c||e<d-n||e>y+n)return-1;(e<d||e>y)&&(i=e<d?e-d:e-y)}return i};import{$getNodeByKey as ae}from"lexical";function V(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=(d,y)=>d?parseFloat(window.getComputedStyle(d)[y]):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 Qt}from"lexical";function H(t){return t.getEditorState().read(()=>Qt().getChildrenKeys())}var Xt=1,Zt=-1,$e=0,M={props:null,result:null};function eo(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:s},startIndex:d=0,useEdgeAsDefault:y=!1}=t;if(o>0&&M.props&&M.result&&M.props.fuzzy===t.fuzzy&&M.props.horizontalOffset===t.horizontalOffset&&M.props.useEdgeAsDefault===t.useEdgeAsDefault&&eo(M.props.point,t.point,o))return M.result;let g=e.getBoundingClientRect(),a=H(r),l={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(y){let m=r.getElementByKey(a[0]),h=r.getElementByKey(a[a.length-1]);if(m&&h){let[u,f]=[V(m),V(h)];if(s<u.top?(l.blockElem=m,l.distance=u.top-s,l.blockNode=ae(a[0]),l.foundAtIndex=0):s>f.bottom&&(l.distance=s-f.bottom,l.blockNode=ae(a[a.length-1]),l.blockElem=h,l.foundAtIndex=a.length-1),l?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let p=d,E=$e;for(;p>=0&&p<a.length;){let m=a[p],h=r.getElementByKey(m);if(h===null)break;let u=new _(i+c,s),f=Be.fromDOMRect(V(h)),{marginBottom:x,marginTop:w}=le(h),S=f.generateNewRect({bottom:f.bottom+x,left:g.left,right:g.right,top:f.top-w}),{distance:b,isOnBottomSide:k,isOnTopSide:N}=S.distanceFromPoint(u);if(b===0){l.blockElem=h,l.blockNode=ae(m),l.foundAtIndex=p,l.distance=b,l.blockNode&&l.blockNode.getType()==="paragraph"&&l.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(l.blockElem=null,l.blockNode=null),l.isFoundNodeEmptyParagraph=!0);break}else n&&b<l.distance&&(l.blockElem=h,l.blockNode=ae(m),l.distance=b,l.foundAtIndex=p);E===$e&&(N?E=Zt:k?E=Xt:E=1/0),p+=E}}),M.props=t,M.result={blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph},{blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var to=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ke(t){if(!t||to.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 de(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(),s=o.getBoundingClientRect(),d;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))d=n.top+8-s.top;else{let a=Ke(t)?parseInt(c.lineHeight,10):0;d=n.top+(a-i.height)/2-s.top}let g=r;e.style.opacity="1",e.style.transform=`translate(${g}px, ${d}px)`}var co="add-block-menu",ue=1/0;function uo(t){return t===0?1/0:ue>=0&&ue<t?ue:Math.floor(t/2)}function mo(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),c=n?.admin?.hideGutter?-24:12,i=so(null),[s,d]=lo(null);He(()=>{function g(a){let l=a.target;if(!ro(l))return;let p=Y(r,a.pageX,a.pageY,l);if(p===-1){d(null);return}if(ce(l,co))return;let E=H(t),{blockElem:m,blockNode:h,foundAtIndex:u}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-p,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:uo(E.length),useEdgeAsDefault:!1});ue=u,m&&h&&(s?.node!==h||s?.elem!==m)&&d({elem:m,node:h})}return document?.addEventListener("mousemove",g),()=>{document?.removeEventListener("mousemove",g)}},[r,e,t,s]),He(()=>{i.current&&s?.node&&de(s?.elem,i.current,e,c)},[e,s,c]);let y=io(g=>{let a=s;a?.node&&(t.update(()=>{let l=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(l=!1),!l){let p=no();a?.node.insertAfter(p),setTimeout(()=>{a={elem:t.getElementByKey(p.getKey()),node:p},d(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(Te,{node:a?.node})},2),g.stopPropagation(),g.preventDefault())},[t,s]);return ao(xe(je.Fragment,{children:xe("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:g=>{y(g)},ref:i,type:"button",children:xe("div",{className:o?"icon":""})})}),e)}function ze(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=oo();return mo(r,o,r._editable)}import{jsx as me,jsxs as po}from"react/jsx-runtime";import{useLexicalComposerContext as go}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ve}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ge,$getNodeByKey as ho,isHTMLElement as Ce}from"lexical";import*as Xe from"react";import{useEffect as be,useRef as fe,useState as Ue}from"react";import{createPortal as yo}from"react-dom";var We=0,fo=-24;var j=0;function Ye(t,e,o,r,n,c,i,s,d,y=!1){let{height:g,top:a}=r.getBoundingClientRect(),{top:l,width:p}=i.getBoundingClientRect(),{marginBottom:E,marginTop:m}=le(r),h=a,u=c>=a+g/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(u&&n?.elem&&n?.elem===r.nextElementSibling||!u&&n?.elem&&n?.elem===r.previousElementSibling)&&(j++,j<200&&(f=!0));else{j++;let b=n?.boundingBox?.y,k=r.getBoundingClientRect().y;(u===n?.isBelow&&b===k||j<200)&&(f=!1)}if(f)return{isBelow:u,willStayInSamePosition:f};y?h+=g/2:u?h+=g+E/2:h-=m/2;let x=0;y||(u?x=-We:x=We);let w=h-l+x,S=fo-e;return o.style.width=`calc(${p}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${w}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?u?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),j=0,{isBelow:u,willStayInSamePosition:f}}var Eo="draggable-block-menu",qe="application/x-lexical-drag-block",ee=1/0;function Je(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function xo(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 Co(t,e,o){let r=e.parentElement,n=fe(null),c=fe(null),i=fe(null),s=fe(!1),[d,y]=Ue(null),[g,a]=Ue(null),{editorConfig:l}=R(),p=l?.admin?.hideGutter?-44:-8;be(()=>{function h(u){let f=u.target;if(!Ce(f))return;let x=Y(r,u.pageX,u.pageY,f);if(x===-1){y(null);return}if(ce(f,Eo))return;let w=H(t),{blockElem:S,foundAtIndex:b,isFoundNodeEmptyParagraph:k}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-x,point:new _(u.x,u.y),startIndex:Je(w.length),useEdgeAsDefault:!1,verbose:!1});ee=b,!(!S&&!k)&&d!==S&&y(S)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,d]),be(()=>{n.current&&de(d,n.current,e,p)},[e,d,p]),be(()=>{function h(f){if(!s.current)return!1;let[x]=Ve(f);if(x)return!1;let{pageY:w,target:S}=f;if(!Ce(S))return!1;let b=Y(r,f.pageX,f.pageY,S,100,50),k=H(t),{blockElem:N,foundAtIndex:B,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-b,point:new _(f.x,f.y),startIndex:Je(k.length),useEdgeAsDefault:!0,verbose:!0});ee=B;let v=c.current;if(N===null||v===null)return!1;if(d!==N){let{isBelow:T,willStayInSamePosition:J}=Ye(l?.admin?.hideGutter?"0px":"3rem",p+(l?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),v,N,g,w,e,f,i,I);f.preventDefault(),J||a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:T})}else g?.elem&&(Qe(v,g.elem),a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function u(f){if(!s.current)return!1;let[x]=Ve(f);if(x)return!1;let{dataTransfer:w,pageY:S,target:b}=f,k=w?.getData(qe)||"";return t.update(()=>{let N=ho(k);if(!N||!Ce(b))return!1;let B=Y(r,f.pageX,f.pageY,b,100,50),{blockElem:I,isFoundNodeEmptyParagraph:v}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-B,point:new _(f.x,f.y),useEdgeAsDefault:!0});if(!I)return!1;let T=Ge(I);if(!T)return!1;if(T===N)return!0;let{height:J,top:he}=V(I),z=S>=he+J/2+window.scrollY;v?(T.insertBefore(N),T.remove()):z?T.insertAfter(N):T.insertBefore(N),d!==null&&y(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let oe=t.getElementByKey(N.getKey());setTimeout(()=>{let D=oe?.getBoundingClientRect();if(!D)return;let P=document.createElement("div");P.className="lexical-block-highlighter",P.style.backgroundColor="var(--theme-elevation-1000",P.style.transition="opacity 0.5s ease-in-out",P.style.zIndex="1",P.style.pointerEvents="none",P.style.boxSizing="border-box",P.style.borderRadius="4px",P.style.position="absolute",document.body.appendChild(P),P.style.opacity="0.1",P.style.height=`${D.height+8}px`,P.style.width=`${D.width+8}px`,P.style.top=`${D.top+window.scrollY-4}px`,P.style.left=`${D.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",u),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",u)}},[r,p,e,t,g,d,l?.admin?.hideGutter]);function E(h){let u=h.dataTransfer;if(!u||!d)return;xo(u,d);let f="";t.update(()=>{let x=Ge(d);x&&(f=x.getKey())}),s.current=!0,u.setData(qe,f)}function m(){s.current=!1,g?.elem&&Qe(c.current,g?.elem)}return yo(po(Xe.Fragment,{children:[me("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:m,onDragStart:E,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 Ze(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=go();return Co(r,o,r._editable)}import{c as bo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as No}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Po,$getRoot as So}from"lexical";import"react";var et="insert-paragraph-at-end",tt=()=>{let t=bo(4),[e]=No(),{editorConfig:o}=R();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(Ro)},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:et,onClick:n,role:"button",tabIndex:0,children:Ne("div",{className:`${et}-inside`,children:Ne("span",{children:"+"})})}),t[2]=n,t[3]=c):c=t[3],c};function Ro(){let t=Po();So().append(t),t.select()}import{c as ko}from"react/compiler-runtime";import{useLexicalComposerContext as wo}from"@lexical/react/LexicalComposerContext";import*as ot from"react";var nt=()=>{let t=ko(4),{editorConfig:e}=R(),[o]=wo(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>we(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]),ot.useEffect(r,n),null};import{useLexicalComposerContext as vo}from"@lexical/react/LexicalComposerContext";import{$getSelection as To,$isRangeSelection as Do,RootNode as Bo}from"lexical";import{useEffect as Lo}from"react";function rt(){let[t]=vo();return Lo(()=>t.registerNodeTransform(Bo,e=>{let o=To();if(Do(o)){let r=o.anchor.getNode(),n=o.focus.getNode();(!r.isAttached()||!n.isAttached())&&(e.selectEnd(),console.warn("updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node."))}return!1}),[t]),null}import{useLexicalComposerContext as Mo}from"@lexical/react/LexicalComposerContext";import{$getSelection as Ao,COMMAND_PRIORITY_LOW as Io,SELECT_ALL_COMMAND as _o}from"lexical";import{useEffect as Oo}from"react";function it(){let[t]=Mo();return Oo(()=>t.registerCommand(_o,()=>{if(Ao())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},Io),[t]),null}import{jsx as U,jsxs as lt}from"react/jsx-runtime";import{useLexicalComposerContext as $o}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as at}from"@payloadcms/ui";import{useCallback as Ko,useMemo as Ho,useState as jo}from"react";import"react";import*as ct from"react-dom";import{c as Fo}from"react/compiler-runtime";import"react";function st(t,e){let o=Fo(4),{maxLength:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,s;return o[0]!==c||o[1]!==i||o[2]!==t?(s=d=>{let{query:y}=d,g="[^"+t+ve+"\\s]",l=new RegExp("(^|\\s|\\()(["+t+"]((?:"+g+"){0,"+c+"}))$").exec(y);if(l!==null){let p=l[1],E=l[3];if(E.length>=i)return{leadOffset:l.index+p.length,matchingString:E,replaceableString:l[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=s):s=o[3],s}var A="slash-menu-popup";function zo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=R(),{i18n:s}=at(),d=`${A}__item ${A}__item-${e.key}`;t&&(d+=` ${A}__item--selected`);let y=e.key;return e.label&&(y=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:s,schemaPath:i}):e.label),y.length>25&&(y=y.substring(0,25)+"..."),lt("button",{"aria-selected":t,className:d,id:A+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&U(e.Icon,{}),U("span",{className:`${A}__item-text`,children:y})]},e.key)}function dt({anchorElem:t=document.body}){let[e]=$o(),[o,r]=jo(null),{editorConfig:n}=R(),{i18n:c}=at(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=R(),d=st("/",{minLength:0}),y=Ko(()=>{let a=[];for(let l of n.features.slashMenu.dynamicGroups)if(o){let p=l({editor:e,queryString:o});a=a.concat(p)}return a},[e,o,n?.features]),g=Ho(()=>{let a=[];for(let l of n?.features.slashMenu.groups??[])a.push(l);if(o){a=a.map(p=>{let E=p.items.filter(m=>{let h=m.key;return m.label&&(h=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):m.label),new RegExp(o,"gi").exec(h)?!0:m.keywords!=null?m.keywords.some(u=>new RegExp(o,"gi").exec(u)):!1});return E.length?{...p,items:E}:null}),a=a.filter(p=>p!=null);let l=y();for(let p of l){let E=a.find(m=>m.key===p.key);E?a=a.filter(m=>m.key!==p.key):E={...p,items:[]},E?.items?.length&&(E.items=E.items.concat(E.items)),a.push(E)}}return a},[o,n?.features.slashMenu.groups,y,i,c,s]);return U(De,{anchorElem:t,groups:g,menuRenderFn:(a,{selectedItemKey:l,selectItemAndCleanUp:p,setSelectedItemKey:E})=>a.current&&g.length?ct.createPortal(U("div",{className:A,children:g.map(m=>{let h=m.key;return m.label&&i&&(h=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):m.label),lt("div",{className:`${A}__group ${A}__group-${m.key}`,children:[U("div",{className:`${A}__group-title`,children:h}),m.items.map((u,f)=>U(zo,{index:f,isSelected:l===u.key,item:u,onClick:()=>{E(u.key),p(u)},onMouseEnter:()=>{E(u.key)},ref:x=>{u.ref={current:x}}},u.key))]},m.key)})}),a.current):null,onQueryChange:r,triggerFn:d})}import{c as Wo}from"react/compiler-runtime";import{useLexicalComposerContext as Yo}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Vo,TextNode as Go}from"lexical";import{useEffect as Uo}from"react";function ut(t){let e=Wo(6),{features:o}=t,[r]=Yo(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=qo(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Go,s=>{i.forEach(d=>{s.hasFormat(d)&&s.toggleFormat(d)})})},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],Uo(n,c),null}function qo(t){let e=Object.keys(Vo),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as Jo}from"react/compiler-runtime";import{jsx as mt}from"react/jsx-runtime";import{ContentEditable as Qo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Xo}from"@payloadcms/ui";import"react";function ft(t){let e=Jo(7),{className:o,editorConfig:r}=t,{t:n}=Xo(),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=mt(Qo,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:mt("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 gt=t=>{let e=Zo(21),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=R(),[s]=en(),[d,y]=cn(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=m=>{m!==null&&y(m)},e[0]=g):g=e[0];let a=g,l,p;e[1]!==s||e[2]!==i?(l=()=>{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)},h=()=>{i.blurEditor(i)},u=s.registerCommand(ln,()=>(m(),!0),pt),f=s.registerCommand(sn,()=>(h(),!0),pt);return()=>{u(),f(),i.parentEditor?.unregisterChild?.(i.uuid)}},p=[s,i],e[1]=s,e[2]=i,e[3]=l,e[4]=p):(l=e[3],p=e[4]),an(l,p);let E;if(e[5]!==s||e[6]!==o||e[7]!==r||e[8]!==d||e[9]!==n||e[10]!==c){let m;e[12]!==c?(m=(u,f,x)=>{(!x.has("focus")||x.size>1)&&c?.(u,f,x)},e[12]=c,e[13]=m):m=e[13];let h;e[14]!==s||e[15]!==o.admin?.hideAddBlockButton||e[16]!==o.admin?.hideDraggableBlockElement||e[17]!==o.features.plugins||e[18]!==d||e[19]!==n?(h=d&&te(q.Fragment,{children:[!n&&s.isEditable()&&te(q.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:C(Ze,{anchorElem:d}),o.admin?.hideAddBlockButton?null:C(ze,{anchorElem:d})]}),o.features.plugins?.map(u=>{if(u.position==="floatingAnchorElem"&&!(u.desktopOnly===!0&&n))return C($,{anchorElem:d,clientProps:u.clientProps,plugin:u},u.key)}),s.isEditable()&&C(q.Fragment,{children:C(dt,{anchorElem:d})})]}),e[14]=s,e[15]=o.admin?.hideAddBlockButton,e[16]=o.admin?.hideDraggableBlockElement,e[17]=o.features.plugins,e[18]=d,e[19]=n,e[20]=h):h=e[20],E=te(q.Fragment,{children:[o.features.plugins?.map(dn),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(un),C(rn,{contentEditable:C("div",{className:"editor-scroller",children:C("div",{className:"editor",ref:a,children:C(ft,{editorConfig:o})})}),ErrorBoundary:tn}),C(rt,{}),C(tt,{}),C(_e,{}),C(ut,{features:o.features}),C(it,{}),C(nn,{ignoreSelectionChange:!0,onChange:m}),h,s.isEditable()&&te(q.Fragment,{children:[C(on,{}),o?.features?.markdownTransformers?.length>0&&C(nt,{})]}),o.features.plugins?.map(mn),o.features.plugins?.map(fn)]}),o.features.plugins?.map(pn)]}),e[5]=s,e[6]=o,e[7]=r,e[8]=d,e[9]=n,e[10]=c,e[11]=E}else E=e[11];return E};function dn(t){if(t.position==="aboveContainer")return C($,{clientProps:t.clientProps,plugin:t},t.key)}function un(t){if(t.position==="top")return C($,{clientProps:t.clientProps,plugin:t},t.key)}function mn(t){if(t.position==="normal")return C($,{clientProps:t.clientProps,plugin:t},t.key)}function fn(t){if(t.position==="bottom")return C($,{clientProps:t.clientProps,plugin:t},t.key)}function pn(t){if(t.position==="belowContainer")return C($,{clientProps:t.clientProps,plugin:t},t.key)}var yt=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?O(o,{children:O(yt,{providers:e.slice(1),children:t})}):O(o,{children:t})},Et=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:s}=t,d=R(),y=hn(),g=ht.useRef(null),a=yn(()=>{if(s&&typeof s!="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(s));if(s&&Array.isArray(s)&&!("root"in s))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(s&&"jsonContent"in s)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:s!=null?JSON.stringify(s):void 0,namespace:o.lexical.namespace,nodes:Le({editorConfig:o}),onError:l=>{throw l},theme:o.lexical.theme}},[o]);return a?O(gn,{initialConfig:a,children:O(Re,{editorConfig:o,editorContainerRef:g,fieldProps:r,parentContext:d?.editDepth===y?d:void 0,children:O(yt,{providers:o.features.providers,children:O(gt,{editorConfig:o,editorContainerRef:g,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",wn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:c}={},label:i,localized:s,required:d},path:y,readOnly:g,validate:a}=t,l=g||c,p=bn(),E=bt((L,Q)=>typeof a=="function"?a(L,{...Q,required:d}):!0,[a,d]),{customComponents:{AfterInput:m,BeforeInput:h,Description:u,Error:f,Label:x}={},disabled:w,initialValue:S,path:b,setValue:k,showError:N,value:B}=Pn({potentiallyStalePath:y,validate:E}),I=l||w,[v,T]=Pt(!1),[J,he]=Pt(),ye=Ct.useRef(S),z=Ct.useRef(B);Nt(()=>{let L=()=>{let Q=window.matchMedia("(max-width: 768px)").matches;Q!==v&&T(Q)};return L(),window.addEventListener("resize",L),()=>{window.removeEventListener("resize",L)}},[v]);let Pe=[pe,"field-type",r,N&&"error",I&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!v?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${b}.${p}`,D=ke(),P=bt(L=>{D(()=>{let Se=L.toJSON();z.current=Se,k(Se)})},[k,D]),St=Rn(()=>Sn(o),[o]),Rt=Nn(L=>{z.current!==B&&JSON.stringify(z.current)!==JSON.stringify(B)&&(ye.current=L,z.current=B,he(new Date))});return Nt(()=>{Object.is(S,ye.current)||Rt(S)},[S]),ge("div",{className:Pe,style:St,children:[F(xt,{CustomComponent:f,Fallback:F(xn,{path:b,showError:N})}),x||F(Cn,{label:i,localized:s,path:b,required:d}),ge("div",{className:`${pe}__wrap`,children:[ge(kn,{fallbackRender:vn,onReset:()=>{},children:[h,F(Et,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:v,onChange:P,readOnly:I,value:B},JSON.stringify({path:b,rerenderProviderKey:J})),m]}),u,F(xt,{CustomComponent:u,Fallback:F(En,{description:n,path:b})})]})]},oe)};function vn({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 cs=wn;export{cs as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-YTBICBYV.js.map
|