@payloadcms/richtext-lexical 3.36.0-canary.8 → 3.36.0
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-QFHWUA2L.js +2 -0
- package/dist/exports/client/Field-QFHWUA2L.js.map +7 -0
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/index.js +5 -8
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
- package/dist/features/relationship/client/plugins/index.js +4 -7
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
- package/dist/features/upload/client/plugin/index.js +2 -2
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +2 -1
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/plugins/NormalizeSelection/index.d.ts +9 -0
- package/dist/lexical/plugins/NormalizeSelection/index.d.ts.map +1 -0
- package/dist/lexical/plugins/NormalizeSelection/index.js +30 -0
- package/dist/lexical/plugins/NormalizeSelection/index.js.map +1 -0
- package/package.json +7 -7
- package/dist/exports/client/Field-VKDIZQ73.js +0 -2
- package/dist/exports/client/Field-VKDIZQ73.js.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAe,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAQ1F,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,CAAA;AAEtD,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAe,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAQ1F,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,CAAA;AAEtD,eAAO,MAAM,YAAY,EAAE,eA8E1B,CAAA"}
|
|
@@ -48,12 +48,12 @@ export const BlocksPlugin = () => {
|
|
|
48
48
|
const selection = $getSelection() || $getPreviousSelection();
|
|
49
49
|
if ($isRangeSelection(selection)) {
|
|
50
50
|
const blockNode = $createBlockNode(payload);
|
|
51
|
-
$insertNodeToNearestRoot(blockNode);
|
|
52
51
|
const {
|
|
53
52
|
focus
|
|
54
53
|
} = selection;
|
|
55
54
|
const focusNode = focus.getNode();
|
|
56
|
-
|
|
55
|
+
$insertNodeToNearestRoot(blockNode);
|
|
56
|
+
if ($isParagraphNode(focusNode) && !focusNode.__first) {
|
|
57
57
|
focusNode.remove();
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -61,11 +61,11 @@ export const BlocksPlugin = () => {
|
|
|
61
61
|
return true;
|
|
62
62
|
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(INSERT_INLINE_BLOCK_COMMAND, fields => {
|
|
63
63
|
if (targetNodeKey) {
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
64
|
+
const node = $getNodeByKey(targetNodeKey);
|
|
65
|
+
if (!node || !$isInlineBlockNode(node)) {
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
node.setFields(fields);
|
|
69
69
|
setTargetNodeKey(null);
|
|
70
70
|
return true;
|
|
71
71
|
}
|
|
@@ -99,7 +99,4 @@ export const BlocksPlugin = () => {
|
|
|
99
99
|
useEffect(t2, t3);
|
|
100
100
|
return null;
|
|
101
101
|
};
|
|
102
|
-
function _temp(node) {
|
|
103
|
-
return $isParagraphNode(node);
|
|
104
|
-
}
|
|
105
102
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","$wrapNodeInElement","mergeRegister","formatDrawerSlug","useEditDepth","$createParagraphNode","$getNodeByKey","$getPreviousSelection","$getSelection","$insertNodes","$isParagraphNode","$isRangeSelection","$isRootOrShadowRoot","COMMAND_PRIORITY_EDITOR","useEffect","useState","useEditorConfigContext","useLexicalDrawer","$createBlockNode","BlockNode","$createInlineBlockNode","$isInlineBlockNode","INSERT_BLOCK_COMMAND","INSERT_INLINE_BLOCK_COMMAND","BlocksPlugin","$","editor","targetNodeKey","setTargetNodeKey","setCreatedInlineBlock","uuid","editDepth","t0","t1","slug","depth","drawerSlug","toggleDrawer","t2","hasNodes","Error","registerCommand","payload","update","selection","blockNode","focus","focusNode","getNode","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","$wrapNodeInElement","mergeRegister","formatDrawerSlug","useEditDepth","$createParagraphNode","$getNodeByKey","$getPreviousSelection","$getSelection","$insertNodes","$isParagraphNode","$isRangeSelection","$isRootOrShadowRoot","COMMAND_PRIORITY_EDITOR","useEffect","useState","useEditorConfigContext","useLexicalDrawer","$createBlockNode","BlockNode","$createInlineBlockNode","$isInlineBlockNode","INSERT_BLOCK_COMMAND","INSERT_INLINE_BLOCK_COMMAND","BlocksPlugin","$","editor","targetNodeKey","setTargetNodeKey","setCreatedInlineBlock","uuid","editDepth","t0","t1","slug","depth","drawerSlug","toggleDrawer","t2","hasNodes","Error","registerCommand","payload","update","selection","blockNode","focus","focusNode","getNode","__first","remove","fields","node","setFields","inlineBlockNode","getParentOrThrow","selectEnd","t3"],"sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth } from '@payloadcms/ui'\nimport {\n $createParagraphNode,\n $getNodeByKey,\n $getPreviousSelection,\n $getSelection,\n $insertNodes,\n $isParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n COMMAND_PRIORITY_EDITOR,\n} from 'lexical'\nimport { useEffect, useState } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { BlockFields, BlockFieldsOptionalID } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { $createInlineBlockNode, $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport { INSERT_BLOCK_COMMAND, INSERT_INLINE_BLOCK_COMMAND } from './commands.js'\n\nexport type InsertBlockPayload = BlockFieldsOptionalID\n\nexport const BlocksPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n\n const [targetNodeKey, setTargetNodeKey] = useState<null | string>(null)\n\n const { setCreatedInlineBlock, uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-` + uuid,\n depth: editDepth,\n })\n\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const blockNode = $createBlockNode(payload)\n\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert blocks node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(blockNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n INSERT_INLINE_BLOCK_COMMAND,\n (fields) => {\n if (targetNodeKey) {\n const node = $getNodeByKey(targetNodeKey)\n\n if (!node || !$isInlineBlockNode(node)) {\n return false\n }\n\n node.setFields(fields as BlockFields)\n\n setTargetNodeKey(null)\n return true\n }\n\n const inlineBlockNode = $createInlineBlockNode(fields as BlockFields)\n setCreatedInlineBlock?.(inlineBlockNode)\n $insertNodes([inlineBlockNode])\n if ($isRootOrShadowRoot(inlineBlockNode.getParentOrThrow())) {\n $wrapNodeInElement(inlineBlockNode, $createParagraphNode).selectEnd()\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor, setCreatedInlineBlock, targetNodeKey, toggleDrawer])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,EAAEC,kBAAkB,EAAEC,aAAa,QAAQ;AAC5E,SAASC,gBAAgB,EAAEC,YAAY,QAAQ;AAC/C,SACEC,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,uBAAuB,QAClB;AACP,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAKpC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,EAAEC,SAAS,QAAQ;AAC5C,SAASC,sBAAsB,EAAEC,kBAAkB,QAAQ;AAC3D,SAASC,oBAA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IAAAZ,CAAA,OAAAgC,EAAA;EAAA;IAAAA,EAAA,GAAAhC,CAAA;EAAA;EA5D/DX,SAAA,CAAUwB,EA4DV,EAAGmB,EAA4D;EAAA;AAAA,CAGjE","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/plugins/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAe7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAK9E,eAAO,MAAM,2BAA2B,EAAE,cAAc,CAAC,gBAAgB,CAExE,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/plugins/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAe7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAK9E,eAAO,MAAM,2BAA2B,EAAE,cAAc,CAAC,gBAAgB,CAExE,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,wBAAwB,CA+CxE,CAAA"}
|
|
@@ -59,7 +59,7 @@ export const RelationshipPlugin = t0 => {
|
|
|
59
59
|
if (!editor.hasNodes([RelationshipNode])) {
|
|
60
60
|
throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");
|
|
61
61
|
}
|
|
62
|
-
return editor.registerCommand(INSERT_RELATIONSHIP_COMMAND,
|
|
62
|
+
return editor.registerCommand(INSERT_RELATIONSHIP_COMMAND, _temp2, COMMAND_PRIORITY_EDITOR);
|
|
63
63
|
};
|
|
64
64
|
t3 = [editor];
|
|
65
65
|
$[5] = editor;
|
|
@@ -88,19 +88,16 @@ function _temp(t0) {
|
|
|
88
88
|
} = t0;
|
|
89
89
|
return slug_0;
|
|
90
90
|
}
|
|
91
|
-
function _temp2(
|
|
92
|
-
return $isParagraphNode(node);
|
|
93
|
-
}
|
|
94
|
-
function _temp3(payload) {
|
|
91
|
+
function _temp2(payload) {
|
|
95
92
|
const selection = $getSelection() || $getPreviousSelection();
|
|
96
93
|
if ($isRangeSelection(selection)) {
|
|
97
94
|
const relationshipNode = $createRelationshipNode(payload);
|
|
98
|
-
$insertNodeToNearestRoot(relationshipNode);
|
|
99
95
|
const {
|
|
100
96
|
focus
|
|
101
97
|
} = selection;
|
|
102
98
|
const focusNode = focus.getNode();
|
|
103
|
-
|
|
99
|
+
$insertNodeToNearestRoot(relationshipNode);
|
|
100
|
+
if ($isParagraphNode(focusNode) && !focusNode.__first) {
|
|
104
101
|
focusNode.remove();
|
|
105
102
|
}
|
|
106
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","useConfig","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","t0","$","clientProps","editor","config","t1","collections","enabledRelations","enabledCollections","disabledCollections","t2","t3","t4","slug","includes","filter","map","_temp","hasNodes","Error","registerCommand","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","useConfig","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","t0","$","clientProps","editor","config","t1","collections","enabledRelations","enabledCollections","disabledCollections","t2","t3","t4","slug","includes","filter","map","_temp","hasNodes","Error","registerCommand","_temp2","_jsx","enabledCollectionSlugs","slug_0","payload","selection","relationshipNode","focus","focusNode","getNode","__first","remove"],"sources":["../../../../../src/features/relationship/client/plugins/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport { useConfig } from '@payloadcms/ui'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { RelationshipFeatureProps } from '../../server/index.js'\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport const RelationshipPlugin: PluginComponent<RelationshipFeatureProps> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n const {\n config: { collections },\n } = useConfig()\n\n let enabledRelations: null | string[] = null\n\n if (clientProps?.enabledCollections) {\n enabledRelations = clientProps?.enabledCollections\n } else if (clientProps?.disabledCollections) {\n enabledRelations = collections\n .filter(({ slug }) => !clientProps?.disabledCollections?.includes(slug))\n .map(({ slug }) => slug)\n }\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const relationshipNode = $createRelationshipNode(payload)\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert relationship node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(relationshipNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledRelations} />\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,QAAQ;AACzC,SAASC,SAAS,QAAQ;AAC1B,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,QACR;AACP,SAASC,SAAS,QAAQ;AAM1B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ;AAE1D,OAAO,MAAMC,2BAAA,GAAgEL,aAAA,CAC3E;AAGF,OAAO,MAAMM,kBAAA,GAAgEC,EAAA;EAAA,MAAAC,CAAA,GAAAjB,EAAA;EAAC;IAAAkB;EAAA,IAAAF,EAAe;EAC3F,OAAAG,MAAA,IAAiBlB,yBAAA;EACjB;IAAAmB,MAAA,EAAAC;EAAA,IAEIlB,SAAA;EADM;IAAAmB;EAAA,IAAAD,EAAe;EAGzB,IAAAE,gBAAA;EAAwC,IAEpCL,WAAA,EAAAM,kBAAA;IACFD,gBAAA,CAAAA,CAAA,CAAmBL,WAAA,EAAAM,kBAAA;EAAnB;IAAA,IACSN,WAAA,EAAAO,mBAAA;MAAA,IAAAC,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;MAAA4B,sBAAA,EAA4ChB;IAAA,C;;;;;;SAA5CK,E;CACT;AA/C6E,SAAAK,MAAAjB,EAAA;EAajE;IAAAa,IAAA,EAAAW;EAAA,IAAAxB,EAAQ;EAAA,OAAKa,MAAA;AAAA;AAboD,SAAAQ,OAAAI,OAAA;EAwBrE,MAAAC,SAAA,GAAkBrC,aAAA,MAAmBD,qBAAA;EAAA,IAEjCG,iBAAA,CAAkBmC,SAAA;IACpB,MAAAC,gBAAA,GAAyB/B,uBAAA,CAAwB6B,OAAA;IAEjD;MAAAG;IAAA,IAAkBF,SAAA;IAClB,MAAAG,SAAA,GAAkBD,KAAA,CAAAE,OAAA,CAAa;IAE/B5C,wBAAA,CAAyByC,gBAAA;IAAA,IAGrBrC,gBAAA,CAAiBuC,SAAA,MAAeA,SAAA,CAAAE,OAAiB;MACnDF,SAAA,CAAAG,MAAA,CAAgB;IAAA;EAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/client/plugin/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAe7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAK3D,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;AAEpG,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,mBAAmB,CAC9B,CAAA;AAExC,eAAO,MAAM,YAAY,EAAE,eAAe,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/client/plugin/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAe7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAK3D,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;AAEpG,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,mBAAmB,CAC9B,CAAA;AAExC,eAAO,MAAM,YAAY,EAAE,eAAe,CAAC,wBAAwB,CAgDlE,CAAA"}
|
|
@@ -38,12 +38,12 @@ export const UploadPlugin = t0 => {
|
|
|
38
38
|
value: payload.value
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
-
$insertNodeToNearestRoot(uploadNode);
|
|
42
41
|
const {
|
|
43
42
|
focus
|
|
44
43
|
} = selection;
|
|
45
44
|
const focusNode = focus.getNode();
|
|
46
|
-
|
|
45
|
+
$insertNodeToNearestRoot(uploadNode);
|
|
46
|
+
if ($isParagraphNode(focusNode) && !focusNode.__first) {
|
|
47
47
|
focusNode.remove();
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","mergeRegister","useConfig","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","React","useEffect","UploadDrawer","$createUploadNode","UploadNode","INSERT_UPLOAD_COMMAND","UploadPlugin","t0","$","editor","config","t1","collections","t2","t3","hasNodes","Error","registerCommand","payload","update","selection","uploadNode","data","id","fields","relationTo","value","focus","focusNode","getNode","__first","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","mergeRegister","useConfig","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","React","useEffect","UploadDrawer","$createUploadNode","UploadNode","INSERT_UPLOAD_COMMAND","UploadPlugin","t0","$","editor","config","t1","collections","t2","t3","hasNodes","Error","registerCommand","payload","update","selection","uploadNode","data","id","fields","relationTo","value","focus","focusNode","getNode","__first","remove","t4","_jsx","enabledCollectionSlugs","map","_temp","slug"],"sources":["../../../../../src/features/upload/client/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils'\nimport { useConfig } from '@payloadcms/ui'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport React, { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\n\nimport { UploadDrawer } from '../drawer/index.js'\nimport { $createUploadNode, UploadNode } from '../nodes/UploadNode.js'\n\nexport type InsertUploadPayload = Readonly<Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>>\n\nexport const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload> =\n createCommand('INSERT_UPLOAD_COMMAND')\n\nexport const UploadPlugin: PluginComponent<UploadFeaturePropsClient> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n const {\n config: { collections },\n } = useConfig()\n\n useEffect(() => {\n if (!editor.hasNodes([UploadNode])) {\n throw new Error('UploadPlugin: UploadNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertUploadPayload>(\n INSERT_UPLOAD_COMMAND,\n (payload: InsertUploadPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const uploadNode = $createUploadNode({\n data: {\n id: payload.id,\n fields: payload.fields,\n relationTo: payload.relationTo,\n value: payload.value,\n },\n })\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert upload node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(uploadNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor])\n\n return <UploadDrawer enabledCollectionSlugs={collections.map(({ slug }) => slug)} />\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,EAAEC,aAAa,QAAQ;AACxD,SAASC,SAAS,QAAQ;AAC1B,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,QACR;AACP,OAAOC,KAAA,IAASC,SAAS,QAAQ;AAMjC,SAASC,YAAY,QAAQ;AAC7B,SAASC,iBAAiB,EAAEC,UAAU,QAAQ;AAI9C,OAAO,MAAMC,qBAAA,GACXN,aAAA,CAAc;AAEhB,OAAO,MAAMO,YAAA,GAA0DC,EAAA;EAAA,MAAAC,CAAA,GAAAnB,EAAA;EACrE,OAAAoB,MAAA,IAAiBnB,yBAAA;EACjB;IAAAoB,MAAA,EAAAC;EAAA,IAEIlB,SAAA;EADM;IAAAmB;EAAA,IAAAD,EAAe;EAAA,IAAAE,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAN,CAAA,QAAAC,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,EAAA;EA+CP;IAAA8B;EAAA,IAAA9B,EAAQ;EAAA,OAAK8B,IAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LexicalEditor.d.ts","sourceRoot":"","sources":["../../src/lexical/LexicalEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LexicalEditor.d.ts","sourceRoot":"","sources":["../../src/lexical/LexicalEditor.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAIhE,OAAO,sBAAsB,CAAA;AAW7B,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC;IACE,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IAC1D,oBAAoB,EAAE,OAAO,CAAA;CAC9B,GAAG,IAAI,CAAC,oBAAoB,EAAE,cAAc,GAAG,UAAU,CAAC,CA4J5D,CAAA"}
|
|
@@ -17,6 +17,7 @@ import { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/ind
|
|
|
17
17
|
import { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js';
|
|
18
18
|
import { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js';
|
|
19
19
|
import { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js';
|
|
20
|
+
import { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js';
|
|
20
21
|
import { SlashMenuPlugin } from './plugins/SlashMenu/index.js';
|
|
21
22
|
import { TextPlugin } from './plugins/TextPlugin/index.js';
|
|
22
23
|
import { LexicalContentEditable } from './ui/ContentEditable.js';
|
|
@@ -147,7 +148,7 @@ export const LexicalEditor = props => {
|
|
|
147
148
|
})
|
|
148
149
|
}),
|
|
149
150
|
ErrorBoundary: LexicalErrorBoundary
|
|
150
|
-
}), _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(TextPlugin, {
|
|
151
|
+
}), _jsx(NormalizeSelectionPlugin, {}), _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(TextPlugin, {
|
|
151
152
|
features: editorConfig.features
|
|
152
153
|
}), _jsx(OnChangePlugin, {
|
|
153
154
|
ignoreSelectionChange: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","editorConfigContext","editor","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","t4","editorState","editor_0","tags","has","size","t5","features","plugins","_jsxs","Fragment","children","isEditable","_jsx","anchorElem","map","plugin_1","plugin","position","desktopOnly","clientProps","key","_temp","className","ref","_temp2","contentEditable","ignoreSelectionChange","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport {\n $createParagraphNode,\n $getRoot,\n BLUR_COMMAND,\n COMMAND_PRIORITY_LOW,\n FOCUS_COMMAND,\n} from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <InsertParagraphAtEndPlugin />\n <DecoratorPlugin />\n <TextPlugin features={editorConfig.features} />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAGEC,YAAY,EACZC,oBAAoB,EACpBC,aAAa,QACR;AACP,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAIpC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAE7B,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AACrC,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A6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAjExE,SAAAS,OAAAI,QAAA;EAAA,IAqIUjB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBL,IAAA,CAAAtD,YAAA;MAAA6D,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAvIxE,SAAAU,OAAAI,QAAA;EAAA,IA4IUlB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBL,IAAA,CAAAtD,YAAA;MAAA6D,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AA9IxE,SAAAW,OAAAI,QAAA;EAAA,IAoJQnB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OACfL,IAAA,CAAAtD,YAAA;MAAA6D,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NormalizeSelectionPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","editorConfigContext","editor","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","t4","editorState","editor_0","tags","has","size","t5","features","plugins","_jsxs","Fragment","children","isEditable","_jsx","anchorElem","map","plugin_1","plugin","position","desktopOnly","clientProps","key","_temp","className","ref","_temp2","contentEditable","ignoreSelectionChange","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <NormalizeSelectionPlugin />\n <InsertParagraphAtEndPlugin />\n <DecoratorPlugin />\n <TextPlugin features={editorConfig.features} />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React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|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* By default, Lexical throws an error if the selection ends in deleted nodes.
|
|
3
|
+
* This is very aggressive considering there are reasons why this can happen
|
|
4
|
+
* outside of Payload's control (custom features or conflicting features, for example).
|
|
5
|
+
* In the case of selections on nonexistent nodes, this plugin moves the selection to
|
|
6
|
+
* the end of the editor and displays a warning instead of an error.
|
|
7
|
+
*/
|
|
8
|
+
export declare function NormalizeSelectionPlugin(): null;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lexical/plugins/NormalizeSelection/index.tsx"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,wBAAwB,SAuBvC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { $getSelection, $isRangeSelection, RootNode } from 'lexical';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* By default, Lexical throws an error if the selection ends in deleted nodes.
|
|
6
|
+
* This is very aggressive considering there are reasons why this can happen
|
|
7
|
+
* outside of Payload's control (custom features or conflicting features, for example).
|
|
8
|
+
* In the case of selections on nonexistent nodes, this plugin moves the selection to
|
|
9
|
+
* the end of the editor and displays a warning instead of an error.
|
|
10
|
+
*/
|
|
11
|
+
export function NormalizeSelectionPlugin() {
|
|
12
|
+
const [editor] = useLexicalComposerContext();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
return editor.registerNodeTransform(RootNode, root => {
|
|
15
|
+
const selection = $getSelection();
|
|
16
|
+
if ($isRangeSelection(selection)) {
|
|
17
|
+
const anchorNode = selection.anchor.getNode();
|
|
18
|
+
const focusNode = selection.focus.getNode();
|
|
19
|
+
if (!anchorNode.isAttached() || !focusNode.isAttached()) {
|
|
20
|
+
root.selectEnd();
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
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.");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
});
|
|
27
|
+
}, [editor]);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","$getSelection","$isRangeSelection","RootNode","useEffect","NormalizeSelectionPlugin","editor","registerNodeTransform","root","selection","anchorNode","anchor","getNode","focusNode","focus","isAttached","selectEnd","console","warn"],"sources":["../../../../src/lexical/plugins/NormalizeSelection/index.tsx"],"sourcesContent":["import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $getSelection, $isRangeSelection, RootNode } from 'lexical'\nimport { useEffect } from 'react'\n\n/**\n * By default, Lexical throws an error if the selection ends in deleted nodes.\n * This is very aggressive considering there are reasons why this can happen\n * outside of Payload's control (custom features or conflicting features, for example).\n * In the case of selections on nonexistent nodes, this plugin moves the selection to\n * the end of the editor and displays a warning instead of an error.\n */\nexport function NormalizeSelectionPlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerNodeTransform(RootNode, (root) => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const anchorNode = selection.anchor.getNode()\n const focusNode = selection.focus.getNode()\n if (!anchorNode.isAttached() || !focusNode.isAttached()) {\n root.selectEnd()\n // eslint-disable-next-line no-console\n console.warn(\n 'updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and ' +\n \"selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node.\",\n )\n }\n }\n return false\n })\n }, [editor])\n\n return null\n}\n"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,QAAQ,QAAQ;AAC3D,SAASC,SAAS,QAAQ;AAE1B;;;;;;;AAOA,OAAO,SAASC,yBAAA;EACd,MAAM,CAACC,MAAA,CAAO,GAAGN,yBAAA;EAEjBI,SAAA,CAAU;IACR,OAAOE,MAAA,CAAOC,qBAAqB,CAACJ,QAAA,EAAWK,IAAA;MAC7C,MAAMC,SAAA,GAAYR,aAAA;MAClB,IAAIC,iBAAA,CAAkBO,SAAA,GAAY;QAChC,MAAMC,UAAA,GAAaD,SAAA,CAAUE,MAAM,CAACC,OAAO;QAC3C,MAAMC,SAAA,GAAYJ,SAAA,CAAUK,KAAK,CAACF,OAAO;QACzC,IAAI,CAACF,UAAA,CAAWK,UAAU,MAAM,CAACF,SAAA,CAAUE,UAAU,IAAI;UACvDP,IAAA,CAAKQ,SAAS;UACd;UACAC,OAAA,CAAQC,IAAI,CACV,iIACE;QAEN;MACF;MACA,OAAO;IACT;EACF,GAAG,CAACZ,MAAA,CAAO;EAEX,OAAO;AACT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.36.0
|
|
3
|
+
"version": "3.36.0",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -364,8 +364,8 @@
|
|
|
364
364
|
"react-error-boundary": "4.1.2",
|
|
365
365
|
"ts-essentials": "10.0.3",
|
|
366
366
|
"uuid": "10.0.0",
|
|
367
|
-
"@payloadcms/translations": "3.36.0
|
|
368
|
-
"@payloadcms/ui": "3.36.0
|
|
367
|
+
"@payloadcms/translations": "3.36.0",
|
|
368
|
+
"@payloadcms/ui": "3.36.0"
|
|
369
369
|
},
|
|
370
370
|
"devDependencies": {
|
|
371
371
|
"@babel/cli": "7.26.4",
|
|
@@ -385,16 +385,16 @@
|
|
|
385
385
|
"esbuild-sass-plugin": "3.3.1",
|
|
386
386
|
"eslint-plugin-react-compiler": "19.0.0-beta-e993439-20250405",
|
|
387
387
|
"swc-plugin-transform-remove-imports": "3.1.0",
|
|
388
|
-
"
|
|
389
|
-
"
|
|
388
|
+
"payload": "3.36.0",
|
|
389
|
+
"@payloadcms/eslint-config": "3.28.0"
|
|
390
390
|
},
|
|
391
391
|
"peerDependencies": {
|
|
392
392
|
"@faceless-ui/modal": "3.0.0-beta.2",
|
|
393
393
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
394
394
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
395
395
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
396
|
-
"@payloadcms/next": "3.36.0
|
|
397
|
-
"payload": "3.36.0
|
|
396
|
+
"@payloadcms/next": "3.36.0",
|
|
397
|
+
"payload": "3.36.0"
|
|
398
398
|
},
|
|
399
399
|
"engines": {
|
|
400
400
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{b as ke,e as _,g as Re,h as we,i as Te,j as ve,k as De}from"./chunk-DOZWITPU.js";import{a as Se,b as k}from"./chunk-BZZVLW4U.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 te}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 Vo}from"lexical";import*as J from"react";import{useEffect as Go,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 Nt}from"react/compiler-runtime";import{useLexicalComposerContext as Pt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as St}from"@lexical/utils";import{$createNodeSelection as kt,$getEditor as X,$getNearestNodeFromDOMNode as Rt,$getSelection as re,$isDecoratorNode as H,$isElementNode as xe,$isLineBreakNode as wt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as Tt,$isTextNode as vt,$setSelection as Le,CLICK_COMMAND as Dt,COMMAND_PRIORITY_LOW as Y,KEY_ARROW_DOWN_COMMAND as Mt,KEY_ARROW_UP_COMMAND as Bt,KEY_BACKSPACE_COMMAND as Lt,KEY_DELETE_COMMAND as It,SELECTION_CHANGE_COMMAND as At}from"lexical";import{useEffect as _t}from"react";function Ie(){let t=Nt(3),[e]=Pt(),o=zt,r,n;return t[0]!==e?(r=()=>St(e.registerCommand(Dt,jt,Y),e.registerCommand(It,o,Y),e.registerCommand(Lt,o,Y),e.registerCommand(At,Ht,Y),e.registerCommand(Bt,$t,Y),e.registerCommand(Mt,Ot,Y)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),_t(r,n),null}function Ot(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(H(i)){let y=X().getElementByKey(i.getKey());return y&&Z({element:y,node:i}),!0}if(!xe(i))return!0;let s=i.getFirstDescendant()??i;return s&&(ne(s,se)?.selectEnd(),t.preventDefault()),!0}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Ft),c=n?.getNextSibling();if(!n||c!==Ae(n))return!1;if(H(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Ft(t){return Ae(t)!==null}function $t(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(H(i)){let y=X().getElementByKey(i.getKey());return y?(Z({element:y,node:i}),t.preventDefault(),!0):!1}if(!xe(i))return!1;let s=i.getLastDescendant()??i;return s?(ne(s,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Kt),c=n?.getPreviousSibling();if(!n||c!==_e(n))return!1;if(H(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Kt(t){return _e(t)!==null}function Ht(){let t=Vt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function jt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=Yt(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):Z(e),!0}function zt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Wt),!0):!1}function Wt(t){t.remove()}function Yt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=Rt(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:X().getElementByKey(o.getKey())}:void 0}function Z({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(!xe(t)||Tt(t))return!1;let e=t.getFirstChild(),o=e===null||wt(e)||vt(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 Ee}from"react/jsx-runtime";import{useLexicalComposerContext as Xt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Zt,isHTMLElement 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 V=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:s,left:u,right:y,top:g}=t.getBoundingClientRect(),a=g+window.scrollY,l=s+window.scrollY;if(o<a-c||o>l+c||e<u-n||e>y+n)return-1;(e<u||e>y)&&(i=e<u?e-u:e-y)}return i};import{$getNodeByKey as ae}from"lexical";function G(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,y)=>u?parseFloat(window.getComputedStyle(u)[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 Gt}from"lexical";function j(t){return t.getEditorState().read(()=>Gt().getChildrenKeys())}var Ut=1,qt=-1,Oe=0,L={props:null,result:null};function Jt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function U(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:s},startIndex:u=0,useEdgeAsDefault:y=!1}=t;if(o>0&&L.props&&L.result&&L.props.fuzzy===t.fuzzy&&L.props.horizontalOffset===t.horizontalOffset&&L.props.useEdgeAsDefault===t.useEdgeAsDefault&&Jt(L.props.point,t.point,o))return L.result;let g=e.getBoundingClientRect(),a=j(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[d,f]=[G(m),G(h)];if(s<d.top?(l.blockElem=m,l.distance=d.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=u,x=Oe;for(;p>=0&&p<a.length;){let m=a[p],h=r.getElementByKey(m);if(h===null)break;let d=new _(i+c,s),f=ve.fromDOMRect(G(h)),{marginBottom:E,marginTop:T}=le(h),S=f.generateNewRect({bottom:f.bottom+E,left:g.left,right:g.right,top:f.top-T}),{distance:C,isOnBottomSide:R,isOnTopSide:N}=S.distanceFromPoint(d);if(C===0){l.blockElem=h,l.blockNode=ae(m),l.foundAtIndex=p,l.distance=C,l.blockNode&&l.blockNode.getType()==="paragraph"&&l.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(l.blockElem=null,l.blockNode=null),l.isFoundNodeEmptyParagraph=!0);break}else n&&C<l.distance&&(l.blockElem=h,l.blockNode=ae(m),l.distance=C,l.foundAtIndex=p);x===Oe&&(N?x=qt:R?x=Ut:x=1/0),p+=x}}),L.props=t,L.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 Qt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Fe(t){if(!t||Qt.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(),s=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))u=n.top+8-s.top;else{let a=Fe(t)?parseInt(c.lineHeight,10):0;u=n.top+(a-i.height)/2-s.top}let g=r;e.style.opacity="1",e.style.transform=`translate(${g}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}=k(),c=n?.admin?.hideGutter?-24:12,i=oo(null),[s,u]=no(null);$e(()=>{function g(a){let l=a.target;if(!eo(l))return;let p=V(r,a.pageX,a.pageY,l);if(p===-1){u(null);return}if(ce(l,io))return;let x=j(t),{blockElem:m,blockNode:h,foundAtIndex:d}=U({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-p,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:so(x.length),useEdgeAsDefault:!1});de=d,m&&h&&(s?.node!==h||s?.elem!==m)&&u({elem:m,node:h})}return document?.addEventListener("mousemove",g),()=>{document?.removeEventListener("mousemove",g)}},[r,e,t,s]),$e(()=>{i.current&&s?.node&&ue(s?.elem,i.current,e,c)},[e,s,c]);let y=to(g=>{let a=s;a?.node&&(t.update(()=>{let l=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(l=!1),!l){let p=Zt();a?.node.insertAfter(p),setTimeout(()=>{a={elem:t.getElementByKey(p.getKey()),node:p},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),g.stopPropagation(),g.preventDefault())},[t,s]);return ro(Ee(Ke.Fragment,{children:Ee("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:g=>{y(g)},ref:i,type:"button",children:Ee("div",{className:o?"icon":""})})}),e)}function He(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=Xt();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,isHTMLElement as be}from"lexical";import*as Je from"react";import{useEffect as Ce,useRef as fe,useState as Ve}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,s,u,y=!1){let{height:g,top:a}=r.getBoundingClientRect(),{top:l,width:p}=i.getBoundingClientRect(),{marginBottom:x,marginTop:m}=le(r),h=a,d=c>=a+g/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 C=n?.boundingBox?.y,R=r.getBoundingClientRect().y;(d===n?.isBelow&&C===R||z<200)&&(f=!1)}if(f)return{isBelow:d,willStayInSamePosition:f};y?h+=g/2:d?h+=g+x/2:h-=m/2;let E=0;y||(d?E=-je:E=je);let T=h-l+E,S=ao-e;return o.style.width=`calc(${p}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${T}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",Ge="application/x-lexical-drag-block",ee=1/0;function Ue(t){return t===0?1/0:ee>=0&&ee<t?ee: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),s=fe(!1),[u,y]=Ve(null),[g,a]=Ve(null),{editorConfig:l}=k(),p=l?.admin?.hideGutter?-44:-8;Ce(()=>{function h(d){let f=d.target;if(!be(f))return;let E=V(r,d.pageX,d.pageY,f);if(E===-1){y(null);return}if(ce(f,po))return;let T=j(t),{blockElem:S,foundAtIndex:C,isFoundNodeEmptyParagraph:R}=U({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new _(d.x,d.y),startIndex:Ue(T.length),useEdgeAsDefault:!1,verbose:!1});ee=C,!(!S&&!R)&&u!==S&&y(S)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,u]),Ce(()=>{n.current&&ue(u,n.current,e,p)},[e,u,p]),Ce(()=>{function h(f){if(!s.current)return!1;let[E]=We(f);if(E)return!1;let{pageY:T,target:S}=f;if(!be(S))return!1;let C=V(r,f.pageX,f.pageY,S,100,50),R=j(t),{blockElem:N,foundAtIndex:B,isFoundNodeEmptyParagraph:A}=U({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new _(f.x,f.y),startIndex:Ue(R.length),useEdgeAsDefault:!0,verbose:!0});ee=B;let v=c.current;if(N===null||v===null)return!1;if(u!==N){let{isBelow:D,willStayInSamePosition:Q}=ze(l?.admin?.hideGutter?"0px":"3rem",p+(l?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),v,N,g,T,e,f,i,A);f.preventDefault(),Q||a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:D})}else g?.elem&&(qe(v,g.elem),a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function d(f){if(!s.current)return!1;let[E]=We(f);if(E)return!1;let{dataTransfer:T,pageY:S,target:C}=f,R=T?.getData(Ge)||"";return t.update(()=>{let N=mo(R);if(!N||!be(C))return!1;let B=V(r,f.pageX,f.pageY,C,100,50),{blockElem:A,isFoundNodeEmptyParagraph:v}=U({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-B,point:new _(f.x,f.y),useEdgeAsDefault:!0});if(!A)return!1;let D=Ye(A);if(!D)return!1;if(D===N)return!0;let{height:Q,top:he}=G(A),W=S>=he+Q/2+window.scrollY;v?(D.insertBefore(N),D.remove()):W?D.insertAfter(N):D.insertBefore(N),u!==null&&y(null),document.querySelectorAll(".lexical-block-highlighter").forEach(M=>{M.remove()});let oe=t.getElementByKey(N.getKey());setTimeout(()=>{let M=oe?.getBoundingClientRect();if(!M)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=`${M.height+8}px`,P.style.width=`${M.width+8}px`,P.style.top=`${M.top+window.scrollY-4}px`,P.style.left=`${M.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",d)}},[r,p,e,t,g,u,l?.admin?.hideGutter]);function x(h){let d=h.dataTransfer;if(!d||!u)return;go(d,u);let f="";t.update(()=>{let E=Ye(u);E&&(f=E.getKey())}),s.current=!0,d.setData(Ge,f)}function m(){s.current=!1,g?.elem&&qe(c.current,g?.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 bo}from"lexical";import"react";var Xe="insert-paragraph-at-end",Ze=()=>{let t=yo(4),[e]=xo(),{editorConfig:o}=k();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(Co)},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 Co(){let t=Eo();bo().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}=k(),[o]=Po(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>ke(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 ko}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as rt}from"@payloadcms/ui";import{useCallback as Ro,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,s;return o[0]!==c||o[1]!==i||o[2]!==t?(s=u=>{let{query:y}=u,g="[^"+t+Re+"\\s]",l=new RegExp("(^|\\s|\\()(["+t+"]((?:"+g+"){0,"+c+"}))$").exec(y);if(l!==null){let p=l[1],x=l[3];if(x.length>=i)return{leadOffset:l.index+p.length,matchingString:x,replaceableString:l[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=s):s=o[3],s}var I="slash-menu-popup";function vo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=k(),{i18n:s}=rt(),u=`${I}__item ${I}__item-${e.key}`;t&&(u+=` ${I}__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)+"..."),nt("button",{"aria-selected":t,className:u,id:I+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&q(e.Icon,{}),q("span",{className:`${I}__item-text`,children:y})]},e.key)}function st({anchorElem:t=document.body}){let[e]=ko(),[o,r]=To(null),{editorConfig:n}=k(),{i18n:c}=rt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=k(),u=ot("/",{minLength:0}),y=Ro(()=>{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=wo(()=>{let a=[];for(let l of n?.features.slashMenu.groups??[])a.push(l);if(o){a=a.map(p=>{let x=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(d=>new RegExp(o,"gi").exec(d)):!1});return x.length?{...p,items:x}:null}),a=a.filter(p=>p!=null);let l=y();for(let p of l){let x=a.find(m=>m.key===p.key);x?a=a.filter(m=>m.key!==p.key):x={...p,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,n?.features.slashMenu.groups,y,i,c,s]);return q(Te,{anchorElem:t,groups:g,menuRenderFn:(a,{selectedItemKey:l,selectItemAndCleanUp:p,setSelectedItemKey:x})=>a.current&&g.length?it.createPortal(q("div",{className:I,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),nt("div",{className:`${I}__group ${I}__group-${m.key}`,children:[q("div",{className:`${I}__group-title`,children:h}),m.items.map((d,f)=>q(vo,{index:f,isSelected:l===d.key,item:d,onClick:()=>{x(d.key),p(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,s=>{i.forEach(u=>{s.hasFormat(u)&&s.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=k(),[s]=Ko(),[u,y]=Uo(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)},d=s.registerCommand(Vo,()=>(m(),!0),ut),f=s.registerCommand(Yo,()=>(h(),!0),ut);return()=>{d(),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]),Go(l,p);let x;if(e[5]!==s||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 h;e[14]!==s||e[15]!==o.features.plugins||e[16]!==u||e[17]!==n?(h=u&&te(J.Fragment,{children:[!n&&s.isEditable()&&te(J.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)}),s.isEditable()&&b(J.Fragment,{children:b(st,{anchorElem:u})})]}),e[14]=s,e[15]=o.features.plugins,e[16]=u,e[17]=n,e[18]=h):h=e[18],x=te(J.Fragment,{children:[o.features.plugins?.map(qo),te("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}),h,s.isEditable()&&te(J.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]=s,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:s}=t,u=k(),y=tn(),g=mt.useRef(null),a=on(()=>{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:De({editorConfig:o}),onError:l=>{throw l},theme:o.lexical.theme}},[o]);return a?O(en,{initialConfig:a,children:O(Se,{editorConfig:o,editorContainerRef:g,fieldProps:r,parentContext:u?.editDepth===y?u:void 0,children:O(ft,{providers:o.features.providers,children:O(dt,{editorConfig:o,editorContainerRef:g,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",fn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:c}={},label:i,localized:s,required:u},path:y,readOnly:g,validate:a}=t,l=g||c,p=ln(),x=yt((w,$)=>typeof a=="function"?a(w,{...$,required:u}):!0,[a,u]),{customComponents:{AfterInput:m,BeforeInput:h,Description:d,Error:f,Label:E}={},disabled:T,initialValue:S,path:C,setValue:R,showError:N,value:B}=cn({potentiallyStalePath:y,validate:x}),A=l||T,[v,D]=Et(!1),[Q,he]=Et(),ye=ht.useRef(S),W=ht.useRef(B);xt(()=>{let w=()=>{let $=window.matchMedia("(max-width: 768px)").matches;$!==v&&D($)};return w(),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w)}},[v]);let Pe=[pe,"field-type",r,N&&"error",A&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!v?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${C}.${p}`,M=w=>{let $=w.toJSON();W.current=$,R($)},P=yt(w=>{typeof window.requestIdleCallback=="function"?requestIdleCallback(()=>M(w)):M(w)},[R]),bt=dn(()=>un(o),[o]),Ct=an(w=>{W.current!==B&&JSON.stringify(W.current)!==JSON.stringify(B)&&(ye.current=w,W.current=B,he(new Date))});return xt(()=>{Object.is(S,ye.current)||Ct(S)},[S]),ge("div",{className:Pe,style:bt,children:[F(gt,{CustomComponent:f,Fallback:F(rn,{path:C,showError:N})}),E||F(sn,{label:i,localized:s,path:C,required:u}),ge("div",{className:`${pe}__wrap`,children:[ge(mn,{fallbackRender:pn,onReset:()=>{},children:[h,F(pt,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:v,onChange:P,readOnly:A,value:B},JSON.stringify({path:C,rerenderProviderKey:Q})),m]}),d,F(gt,{CustomComponent:d,Fallback:F(nn,{description:n,path:C})})]})]},oe)};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 Fi=fn;export{Fi as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-VKDIZQ73.js.map
|