@payloadcms/richtext-lexical 3.63.0-internal.dc01f92 → 3.64.0-canary.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-QUXIGJRC.js +2 -0
- package/dist/exports/client/Field-QUXIGJRC.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-AFXLIYGL.js +12 -0
- package/dist/exports/client/chunk-AFXLIYGL.js.map +7 -0
- package/dist/exports/client/chunk-TRHFMZ3F.js +2 -0
- package/dist/exports/client/chunk-TRHFMZ3F.js.map +7 -0
- package/dist/exports/client/componentInline-5OVPQNQH.js +2 -0
- package/dist/exports/client/index.d.ts +0 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +20 -20
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/react/index.d.ts +1 -1
- package/dist/exports/react/index.d.ts.map +1 -1
- package/dist/exports/react/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +14 -1
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts +14 -2
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +2 -4
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts +1 -16
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +4 -76
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +10 -14
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +22 -24
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts +0 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +29 -47
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +0 -12
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +1 -2
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +3 -12
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.d.ts +1 -1
- package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/client/sanitize.js +2 -3
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/types.d.ts +0 -4
- package/dist/lexical/config/types.d.ts.map +1 -1
- package/dist/lexical/config/types.js.map +1 -1
- package/dist/lexical/nodes/index.d.ts +2 -12
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +2 -195
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/types.d.ts +2 -139
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +0 -1
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/validate/hasText.d.ts +1 -6
- package/dist/validate/hasText.d.ts.map +1 -1
- package/dist/validate/hasText.js +4 -10
- package/dist/validate/hasText.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/Field-SYJC2DBU.js +0 -2
- package/dist/exports/client/Field-SYJC2DBU.js.map +0 -7
- package/dist/exports/client/chunk-52JG5GGJ.js +0 -2
- package/dist/exports/client/chunk-52JG5GGJ.js.map +0 -7
- package/dist/exports/client/chunk-6NIGQP6A.js +0 -12
- package/dist/exports/client/chunk-6NIGQP6A.js.map +0 -7
- package/dist/exports/client/componentInline-QEXUNJU4.js +0 -2
- package/dist/field/RichTextViewProvider.d.ts +0 -83
- package/dist/field/RichTextViewProvider.d.ts.map +0 -1
- package/dist/field/RichTextViewProvider.js +0 -87
- package/dist/field/RichTextViewProvider.js.map +0 -1
- package/dist/field/ViewSelector.d.ts +0 -4
- package/dist/field/ViewSelector.d.ts.map +0 -1
- package/dist/field/ViewSelector.js +0 -89
- package/dist/field/ViewSelector.js.map +0 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +0 -2
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +0 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +0 -48
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +0 -1
- /package/dist/exports/client/{componentInline-QEXUNJU4.js.map → componentInline-5OVPQNQH.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateImportMap.js","names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","
|
|
1
|
+
{"version":3,"file":"generateImportMap.js","names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","resolvedFeature","resolvedFeatureMap","values","componentImports","Array","isArray","Object","ClientFeature","nodes","length","node","getSubFields","subFields","fields"],"sources":["../../src/utilities/generateImportMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport { genImportMapIterateFields } from 'payload'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\nimport type { LexicalEditorProps } from '../types.js'\n\nexport const getGenerateImportMap =\n (args: {\n lexicalEditorArgs?: LexicalEditorProps\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateImportMap'] =>\n ({ addToImportMap, baseDir, config, importMap, imports }) => {\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell')\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField')\n addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent')\n\n for (const resolvedFeature of args.resolvedFeatureMap.values()) {\n if ('componentImports' in resolvedFeature) {\n if (typeof resolvedFeature.componentImports === 'function') {\n resolvedFeature.componentImports({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n } else if (Array.isArray(resolvedFeature.componentImports)) {\n addToImportMap(resolvedFeature.componentImports)\n } else if (typeof resolvedFeature.componentImports === 'object') {\n addToImportMap(Object.values(resolvedFeature.componentImports))\n }\n }\n\n addToImportMap(resolvedFeature.ClientFeature)\n\n /*\n * Now run for all possible sub-fields\n */\n if (resolvedFeature.nodes?.length) {\n for (const node of resolvedFeature.nodes) {\n if (typeof node?.getSubFields !== 'function') {\n continue\n }\n const subFields = node.getSubFields({})\n if (subFields?.length) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: subFields,\n importMap,\n imports,\n })\n }\n }\n }\n }\n }\n"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ;AAK1C,OAAO,MAAMC,oBAAA,GACVC,IAAA,IAID,CAAC;EAAEC,cAAc;EAAEC,OAAO;EAAEC,MAAM;EAAEC,SAAS;EAAEC;AAAO,CAAE;EACtDJ,cAAA,CAAe;EACfA,cAAA,CAAe;EACfA,cAAA,CAAe;EAEf,KAAK,MAAMK,eAAA,IAAmBN,IAAA,CAAKO,kBAAkB,CAACC,MAAM,IAAI;IAC9D,IAAI,sBAAsBF,eAAA,EAAiB;MACzC,IAAI,OAAOA,eAAA,CAAgBG,gBAAgB,KAAK,YAAY;QAC1DH,eAAA,CAAgBG,gBAAgB,CAAC;UAC/BR,cAAA;UACAC,OAAA;UACAC,MAAA;UACAC,SAAA;UACAC;QACF;MACF,OAAO,IAAIK,KAAA,CAAMC,OAAO,CAACL,eAAA,CAAgBG,gBAAgB,GAAG;QAC1DR,cAAA,CAAeK,eAAA,CAAgBG,gBAAgB;MACjD,OAAO,IAAI,OAAOH,eAAA,CAAgBG,gBAAgB,KAAK,UAAU;QAC/DR,cAAA,CAAeW,MAAA,CAAOJ,MAAM,CAACF,eAAA,CAAgBG,gBAAgB;MAC/D;IACF;IAEAR,cAAA,CAAeK,eAAA,CAAgBO,aAAa;IAE5C;;;IAGA,IAAIP,eAAA,CAAgBQ,KAAK,EAAEC,MAAA,EAAQ;MACjC,KAAK,MAAMC,IAAA,IAAQV,eAAA,CAAgBQ,KAAK,EAAE;QACxC,IAAI,OAAOE,IAAA,EAAMC,YAAA,KAAiB,YAAY;UAC5C;QACF;QACA,MAAMC,SAAA,GAAYF,IAAA,CAAKC,YAAY,CAAC,CAAC;QACrC,IAAIC,SAAA,EAAWH,MAAA,EAAQ;UACrBjB,yBAAA,CAA0B;YACxBG,cAAA;YACAC,OAAA;YACAC,MAAA;YACAgB,MAAA,EAAQD,SAAA;YACRd,SAAA;YACAC;UACF;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import type { SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
2
|
-
|
|
3
|
-
* This function checks if the editor state is empty (has any text). If the editor state has no nodes,
|
|
4
|
-
* or only an empty paragraph node (no TextNode with length > 0), it returns false.
|
|
5
|
-
* Otherwise, it returns true.
|
|
6
|
-
*/
|
|
7
|
-
export declare function hasText(value: null | SerializedEditorState<SerializedLexicalNode> | undefined): value is SerializedEditorState<SerializedLexicalNode>;
|
|
2
|
+
export declare function hasText(value: null | SerializedEditorState<SerializedLexicalNode> | undefined): boolean;
|
|
8
3
|
//# sourceMappingURL=hasText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasText.d.ts","sourceRoot":"","sources":["../../src/validate/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAGtB,MAAM,SAAS,CAAA;AAEhB
|
|
1
|
+
{"version":3,"file":"hasText.d.ts","sourceRoot":"","sources":["../../src/validate/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAGtB,MAAM,SAAS,CAAA;AAEhB,wBAAgB,OAAO,CACrB,KAAK,EAAE,IAAI,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,SAAS,GACrE,OAAO,CA0BT"}
|
package/dist/validate/hasText.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
* This function checks if the editor state is empty (has any text). If the editor state has no nodes,
|
|
3
|
-
* or only an empty paragraph node (no TextNode with length > 0), it returns false.
|
|
4
|
-
* Otherwise, it returns true.
|
|
5
|
-
*/export function hasText(value) {
|
|
1
|
+
export function hasText(value) {
|
|
6
2
|
const hasChildren = !!value?.root?.children?.length;
|
|
7
|
-
if (!hasChildren) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
3
|
let hasOnlyEmptyParagraph = false;
|
|
11
4
|
if (value?.root?.children?.length === 1) {
|
|
12
5
|
if (value?.root?.children[0]?.type === 'paragraph') {
|
|
@@ -23,9 +16,10 @@
|
|
|
23
16
|
}
|
|
24
17
|
}
|
|
25
18
|
}
|
|
26
|
-
if (hasOnlyEmptyParagraph) {
|
|
19
|
+
if (!hasChildren || hasOnlyEmptyParagraph) {
|
|
27
20
|
return false;
|
|
21
|
+
} else {
|
|
22
|
+
return true;
|
|
28
23
|
}
|
|
29
|
-
return true;
|
|
30
24
|
}
|
|
31
25
|
//# sourceMappingURL=hasText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasText.js","names":["hasText","value","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild"],"sources":["../../src/validate/hasText.ts"],"sourcesContent":["import type {\n SerializedEditorState,\n SerializedLexicalNode,\n SerializedParagraphNode,\n SerializedTextNode,\n} from 'lexical'\n\
|
|
1
|
+
{"version":3,"file":"hasText.js","names":["hasText","value","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild"],"sources":["../../src/validate/hasText.ts"],"sourcesContent":["import type {\n SerializedEditorState,\n SerializedLexicalNode,\n SerializedParagraphNode,\n SerializedTextNode,\n} from 'lexical'\n\nexport function hasText(\n value: null | SerializedEditorState<SerializedLexicalNode> | undefined,\n): boolean {\n const hasChildren = !!value?.root?.children?.length\n\n let hasOnlyEmptyParagraph = false\n if (value?.root?.children?.length === 1) {\n if (value?.root?.children[0]?.type === 'paragraph') {\n const paragraphNode = value?.root?.children[0] as SerializedParagraphNode\n\n if (!paragraphNode?.children || paragraphNode?.children?.length === 0) {\n hasOnlyEmptyParagraph = true\n } else if (paragraphNode?.children?.length === 1) {\n const paragraphNodeChild = paragraphNode?.children[0]\n if (paragraphNodeChild?.type === 'text') {\n if (!(paragraphNodeChild as SerializedTextNode | undefined)?.['text']?.length) {\n hasOnlyEmptyParagraph = true\n }\n }\n }\n }\n }\n\n if (!hasChildren || hasOnlyEmptyParagraph) {\n return false\n } else {\n return true\n }\n}\n"],"mappings":"AAOA,OAAO,SAASA,QACdC,KAAsE;EAEtE,MAAMC,WAAA,GAAc,CAAC,CAACD,KAAA,EAAOE,IAAA,EAAMC,QAAA,EAAUC,MAAA;EAE7C,IAAIC,qBAAA,GAAwB;EAC5B,IAAIL,KAAA,EAAOE,IAAA,EAAMC,QAAA,EAAUC,MAAA,KAAW,GAAG;IACvC,IAAIJ,KAAA,EAAOE,IAAA,EAAMC,QAAQ,CAAC,EAAE,EAAEG,IAAA,KAAS,aAAa;MAClD,MAAMC,aAAA,GAAgBP,KAAA,EAAOE,IAAA,EAAMC,QAAQ,CAAC,EAAE;MAE9C,IAAI,CAACI,aAAA,EAAeJ,QAAA,IAAYI,aAAA,EAAeJ,QAAA,EAAUC,MAAA,KAAW,GAAG;QACrEC,qBAAA,GAAwB;MAC1B,OAAO,IAAIE,aAAA,EAAeJ,QAAA,EAAUC,MAAA,KAAW,GAAG;QAChD,MAAMI,kBAAA,GAAqBD,aAAA,EAAeJ,QAAQ,CAAC,EAAE;QACrD,IAAIK,kBAAA,EAAoBF,IAAA,KAAS,QAAQ;UACvC,IAAI,CAAEE,kBAAA,GAAwD,OAAO,EAAEJ,MAAA,EAAQ;YAC7EC,qBAAA,GAAwB;UAC1B;QACF;MACF;IACF;EACF;EAEA,IAAI,CAACJ,WAAA,IAAeI,qBAAA,EAAuB;IACzC,OAAO;EACT,OAAO;IACL,OAAO;EACT;AACF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.64.0-canary.0",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -374,8 +374,8 @@
|
|
|
374
374
|
"react-error-boundary": "4.1.2",
|
|
375
375
|
"ts-essentials": "10.0.3",
|
|
376
376
|
"uuid": "10.0.0",
|
|
377
|
-
"@payloadcms/translations": "3.
|
|
378
|
-
"@payloadcms/ui": "3.
|
|
377
|
+
"@payloadcms/translations": "3.64.0-canary.0",
|
|
378
|
+
"@payloadcms/ui": "3.64.0-canary.0"
|
|
379
379
|
},
|
|
380
380
|
"devDependencies": {
|
|
381
381
|
"@babel/cli": "7.27.2",
|
|
@@ -395,15 +395,15 @@
|
|
|
395
395
|
"esbuild-sass-plugin": "3.3.1",
|
|
396
396
|
"swc-plugin-transform-remove-imports": "4.0.4",
|
|
397
397
|
"@payloadcms/eslint-config": "3.28.0",
|
|
398
|
-
"payload": "3.
|
|
398
|
+
"payload": "3.64.0-canary.0"
|
|
399
399
|
},
|
|
400
400
|
"peerDependencies": {
|
|
401
401
|
"@faceless-ui/modal": "3.0.0",
|
|
402
402
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
403
403
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
404
404
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
405
|
-
"@payloadcms/next": "3.
|
|
406
|
-
"payload": "3.
|
|
405
|
+
"@payloadcms/next": "3.64.0-canary.0",
|
|
406
|
+
"payload": "3.64.0-canary.0"
|
|
407
407
|
},
|
|
408
408
|
"engines": {
|
|
409
409
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{a as _e,e as De,g as z,h as F,j as Le,k as Me,l as Ae,m as Be,n as be,o as Ce,p as Ie}from"./chunk-6NIGQP6A.js";import{a as ve,b as S}from"./chunk-BZZVLW4U.js";import{jsx as B,jsxs as ie}from"react/jsx-runtime";import{FieldDescription as Wn,FieldError as Yn,FieldLabel as Gn,RenderCustomComponent as Tt,useEditDepth as Un,useEffectEvent as qn,useField as Jn}from"@payloadcms/ui";import{mergeFieldStyles as Qn}from"@payloadcms/ui/shared";import{dequal as Xn}from"dequal/lite";import vt,{useCallback as _t,useEffect as Dt,useMemo as Zn,useState as Lt}from"react";import{ErrorBoundary as er}from"react-error-boundary";import"./bundled.css";import{jsx as $}from"react/jsx-runtime";import{LexicalComposer as In}from"@lexical/react/LexicalComposer.js";import{useEditDepth as On}from"@payloadcms/ui";import*as wt from"react";import{useMemo as Fn}from"react";import{c as bn}from"react/compiler-runtime";import{jsx as E,jsxs as ne}from"react/jsx-runtime";import{useLexicalComposerContext as Cn}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Nn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as wn}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Pn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Sn}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as Rn}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as kn,COMMAND_PRIORITY_LOW as Ct,FOCUS_COMMAND as Tn}from"lexical";import*as J from"react";import{useEffect as vn,useState as _n}from"react";import{jsx as Oe}from"react/jsx-runtime";import"react";var K=({anchorElem:e,clientProps:t,plugin:o})=>o.position==="floatingAnchorElem"&&e?o.Component&&Oe(o.Component,{anchorElem:e,clientProps:t}):o.Component&&Oe(o.Component,{clientProps:t});import{c as Bt}from"react/compiler-runtime";import{copyToClipboard as It}from"@lexical/clipboard";import{useLexicalComposerContext as Ot}from"@lexical/react/LexicalComposerContext.js";import{objectKlassEquals as Ft}from"@lexical/utils";import Fe from"bson-objectid";import{COMMAND_PRIORITY_LOW as $t,COPY_COMMAND as Kt}from"lexical";import{useEffect as jt}from"react";function $e(){let e=Bt(3),[t]=Ot(),o,n;return e[0]!==t?(o=()=>t.registerCommand(Kt,r=>(It(t,Ft(r,ClipboardEvent)?r:null).then(()=>{if(!(r instanceof ClipboardEvent)||!r.clipboardData)throw new Error("No clipboard event");let c=r.clipboardData.getData("application/x-lexical-editor");if(!c)return!0;let i=JSON.parse(c),l=d=>{if("fields"in d&&typeof d.fields=="object"&&d.fields!==null&&"id"in d.fields?d.fields.id=new Fe.default().toHexString():"id"in d&&(d.id=new Fe.default().toHexString()),d.children)for(let y of d.children)l(y)};for(let d of i.nodes)l(d);let u=JSON.stringify(i);r.clipboardData.setData("application/x-lexical-editor",u)}).catch(c=>{throw r instanceof ClipboardEvent&&r.clipboardData?.setData("application/x-lexical-editor",""),c}),!0),$t),n=[t],e[0]=t,e[1]=o,e[2]=n):(o=e[1],n=e[2]),jt(o,n),null}import{c as Ht}from"react/compiler-runtime";import{useLexicalComposerContext as Vt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as le,mergeRegister as zt}from"@lexical/utils";import{$createNodeSelection as Wt,$getEditor as ee,$getNearestNodeFromDOMNode as Yt,$getSelection as ae,$isDecoratorNode as j,$isElementNode as Ne,$isLineBreakNode as Gt,$isNodeSelection as ce,$isRangeSelection as Ke,$isRootOrShadowRoot as Ut,$isTextNode as qt,$setSelection as je,CLICK_COMMAND as Jt,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as Qt,KEY_ARROW_UP_COMMAND as Xt,KEY_BACKSPACE_COMMAND as Zt,KEY_DELETE_COMMAND as eo,SELECTION_CHANGE_COMMAND as to}from"lexical";import{useEffect as oo}from"react";function He(){let e=Ht(3),[t]=Vt(),o=co,n,r;return e[0]!==t?(n=()=>zt(t.registerCommand(Jt,ao,W),t.registerCommand(eo,o,W),t.registerCommand(Zt,o,W),t.registerCommand(to,lo,W),t.registerCommand(Xt,io,W),t.registerCommand(Qt,no,W)),r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),oo(n,r),null}function no(e){let t=ae();if(ce(t)){e.preventDefault();let i=t.getNodes()[0]?.getNextSibling();if(j(i)){let d=ee().getElementByKey(i.getKey());return d&&te({element:d,node:i}),!0}if(!Ne(i))return!0;let l=i.getFirstDescendant()??i;return l&&(le(l,ue)?.selectEnd(),e.preventDefault()),!0}if(!Ke(t))return!1;let n=(t.isBackward()?t.anchor:t.focus).getNode(),r=le(n,ro),c=r?.getNextSibling();if(!r||c!==Ve(r))return!1;if(j(c)){let i=ee().getElementByKey(c.getKey());if(i)return te({element:i,node:c}),e.preventDefault(),!0}return!1}function ro(e){return Ve(e)!==null}function io(e){let t=ae();if(ce(t)){let i=t.getNodes()[0]?.getPreviousSibling();if(j(i)){let d=ee().getElementByKey(i.getKey());return d?(te({element:d,node:i}),e.preventDefault(),!0):!1}if(!Ne(i))return!1;let l=i.getLastDescendant()??i;return l?(le(l,ue)?.selectStart(),e.preventDefault(),!0):!1}if(!Ke(t))return!1;let n=(t.isBackward()?t.anchor:t.focus).getNode(),r=le(n,so),c=r?.getPreviousSibling();if(!r||c!==ze(r))return!1;if(j(c)){let i=ee().getElementByKey(c.getKey());if(i)return te({element:i,node:c}),e.preventDefault(),!0}return!1}function so(e){return ze(e)!==null}function lo(){let e=fo();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),e?(e.element?.classList.add("decorator-selected"),!0):!1}function ao(e){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let t=mo(e);if(!t)return!0;let{target:o}=e;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?je(null):te(t),!0}function co(e){let t=ae();return ce(t)?(e.preventDefault(),t.getNodes().forEach(uo),!0):!1}function uo(e){e.remove()}function mo(e){if(!(e.target instanceof HTMLElement))return;let t=e.target.closest('[data-lexical-decorator="true"]');if(!(t instanceof HTMLElement))return;let o=Yt(t);return j(o)?{element:t,node:o}:void 0}function fo(){let e=ae();if(!ce(e))return;let t=e.getNodes();if(t.length!==1)return;let o=t[0];return j(o)?{decorator:o,element:ee().getElementByKey(o.getKey())}:void 0}function te({element:e,node:t}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=Wt();o.add(t.getKey()),je(o),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.classList.add("decorator-selected")}function ue(e){if(j(e)&&!e.isInline())return!0;if(!Ne(e)||Ut(e))return!1;let t=e.getFirstChild(),o=t===null||Gt(t)||qt(t)||t.isInline();return!e.isInline()&&e.canBeEmpty()!==!1&&o}function Ve(e){let t=e.getNextSibling();for(;t!==null;){if(ue(t))return t;t=t.getNextSibling()}return null}function ze(e){let t=e.getPreviousSibling();for(;t!==null;){if(ue(t))return t;t=t.getPreviousSibling()}return null}import{jsx as we}from"react/jsx-runtime";import{useLexicalComposerContext as Eo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as bo,isHTMLElement as Co}from"lexical";import*as Ue from"react";import{useCallback as No,useEffect as Ge,useRef as wo,useState as Po}from"react";import{createPortal as So}from"react-dom";var Y=(e,t,o,n,r=50,c=25)=>{let i=0;if(e&&!e.contains(n)){let{bottom:l,left:u,right:d,top:y}=e.getBoundingClientRect(),a=y+window.scrollY,s=l+window.scrollY;if(o<a-c||o>s+c||t<u-r||t>d+r)return-1;(t<u||t>d)&&(i=t<u?t-u:t-d)}return i};import{$getNodeByKey as me}from"lexical";function G(e){let t=e.getBoundingClientRect(),o=getComputedStyle(e).getPropertyValue("transform");if(!o||o==="none")return t;let n=o.split(",").pop();return t.y=t.y-Number(n?.replace(")","")),t}function de(e){let t=(u,d)=>u?parseFloat(window.getComputedStyle(u)[d]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(e),r=t(e.previousElementSibling,"marginBottom"),c=t(e.nextElementSibling,"marginTop"),i=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as po}from"lexical";function H(e){return e.getEditorState().read(()=>po().getChildrenKeys())}var go=1,ho=-1,We=0,M={props:null,result:null};function yo(e,t,o=20){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=o*o}function U(e){let{anchorElem:t,cache_threshold:o=20,editor:n,fuzzy:r=!1,horizontalOffset:c=0,point:{x:i,y:l},startIndex:u=0,useEdgeAsDefault:d=!1}=e;if(o>0&&M.props&&M.result&&M.props.fuzzy===e.fuzzy&&M.props.horizontalOffset===e.horizontalOffset&&M.props.useEdgeAsDefault===e.useEdgeAsDefault&&yo(M.props.point,e.point,o))return M.result;let y=t.getBoundingClientRect(),a=H(n),s={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(d){let g=n.getElementByKey(a[0]),f=n.getElementByKey(a[a.length-1]);if(g&&f){let[h,p]=[G(g),G(f)];if(l<h.top?(s.blockElem=g,s.distance=h.top-l,s.blockNode=me(a[0]),s.foundAtIndex=0):l>p.bottom&&(s.distance=l-p.bottom,s.blockNode=me(a[a.length-1]),s.blockElem=f,s.foundAtIndex=a.length-1),s?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let m=u,x=We;for(;m>=0&&m<a.length;){let g=a[m],f=n.getElementByKey(g);if(f===null)break;let h=new F(i+c,l),p=Be.fromDOMRect(G(f)),{marginBottom:b,marginTop:k}=de(f),P=p.generateNewRect({bottom:p.bottom+b,left:y.left,right:y.right,top:p.top-k}),{distance:C,isOnBottomSide:R,isOnTopSide:N}=P.distanceFromPoint(h);if(C===0){s.blockElem=f,s.blockNode=me(g),s.foundAtIndex=m,s.distance=C,s.blockNode&&s.blockNode.getType()==="paragraph"&&s.blockNode.getTextContent()===""&&(!r&&!e.returnEmptyParagraphs&&(s.blockElem=null,s.blockNode=null),s.isFoundNodeEmptyParagraph=!0);break}else r&&C<s.distance&&(s.blockElem=f,s.blockNode=me(g),s.distance=C,s.foundAtIndex=m);x===We&&(N?x=ho:R?x=go:x=1/0),m+=x}}),M.props=e,M.result={blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph},{blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph}}function fe(e,t){return!!e.closest(`.${t}`)}var xo=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ye(e){if(!e||xo.includes(e.tagName)||e.offsetHeight===0||e.offsetWidth===0)return!1;let t=window.getComputedStyle(e);return!(t.display==="table-cell"||t.position==="absolute"||t.visibility==="hidden"||t.opacity==="0")}function pe(e,t,o,n=0){if(!e){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)";return}let r=e.getBoundingClientRect(),c=window.getComputedStyle(e),i=t.getBoundingClientRect(),l=o.getBoundingClientRect(),u;if(["LexicalEditorTheme__block","LexicalEditorTheme__upload","LexicalEditorTheme__relationship"].some(a=>e.classList.contains(a)||e.firstElementChild?.classList.contains(a)))u=r.top+8-l.top;else{let a=Ye(e)?parseInt(c.lineHeight,10):0;u=r.top+(a-i.height)/2-l.top}let y=n;t.style.opacity="1",t.style.transform=`translate(${y}px, ${u}px)`}var Ro="add-block-menu",ge=1/0;function ko(e){return e===0?1/0:ge>=0&&ge<e?ge:Math.floor(e/2)}function To(e,t,o){let n=t.parentElement,{editorConfig:r}=S(),c=r?.admin?.hideGutter?-24:12,i=wo(null),[l,u]=Po(null);Ge(()=>{function y(a){let s=a.target;if(!Co(s))return;let m=Y(n,a.pageX,a.pageY,s);if(m===-1){u(null);return}if(fe(s,Ro))return;let x=H(e),{blockElem:g,blockNode:f,foundAtIndex:h}=U({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-m,point:new F(a.x,a.y),returnEmptyParagraphs:!0,startIndex:ko(x.length),useEdgeAsDefault:!1});ge=h,g&&f&&(l?.node!==f||l?.elem!==g)&&u({elem:g,node:f})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[n,t,e,l]),Ge(()=>{i.current&&l?.node&&pe(l?.elem,i.current,t,c)},[t,l,c]);let d=No(y=>{let a=l;a?.node&&(e.update(()=>{let s=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(s=!1),!s){let m=bo();a?.node.insertAfter(m),setTimeout(()=>{a={elem:e.getElementByKey(m.getKey()),node:m},u(a)},0)}}),setTimeout(()=>{e.update(()=>{e.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{e.dispatchCommand(Me,{node:a?.node})},2),y.stopPropagation(),y.preventDefault())},[e,l]);return So(we(Ue.Fragment,{children:we("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{d(y)},ref:i,type:"button",children:we("div",{className:o?"icon":""})})}),t)}function qe(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[n]=Eo();return To(n,o,n._editable)}import{jsx as he,jsxs as _o}from"react/jsx-runtime";import{useLexicalComposerContext as Do}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Xe}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ze,$getNodeByKey as Lo,isHTMLElement as Pe}from"lexical";import*as rt from"react";import{useEffect as Se,useRef as ye,useState as et}from"react";import{createPortal as Mo}from"react-dom";var Je=0,vo=-24;var V=0;function Qe(e,t,o,n,r,c,i,l,u,d=!1){let{height:y,top:a}=n.getBoundingClientRect(),{top:s,width:m}=i.getBoundingClientRect(),{marginBottom:x,marginTop:g}=de(n),f=a,h=c>=a+y/2+window.scrollY,p=!1;if(r?.elem)if(n!==r?.elem)(h&&r?.elem&&r?.elem===n.nextElementSibling||!h&&r?.elem&&r?.elem===n.previousElementSibling)&&(V++,V<200&&(p=!0));else{V++;let C=r?.boundingBox?.y,R=n.getBoundingClientRect().y;(h===r?.isBelow&&C===R||V<200)&&(p=!1)}if(p)return{isBelow:h,willStayInSamePosition:p};d?f+=y/2:h?f+=y+x/2:f-=g/2;let b=0;d||(h?b=-Je:b=Je);let k=f-s+b,P=vo-t;return o.style.width=`calc(${m}px - ${e})`,o.style.opacity=".8",o.style.transform=`translate(${P}px, calc(${k}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===n?h?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),V=0,{isBelow:h,willStayInSamePosition:p}}var Ao="draggable-block-menu",tt="application/x-lexical-drag-block",oe=1/0;function ot(e){return e===0?1/0:oe>=0&&oe<e?oe:Math.floor(e/2)}function Bo(e,t){let{transform:o}=t.style;e.setDragImage(t,0,0),setTimeout(()=>{t.style.transform=o})}function nt(e,t){e&&(e.style.opacity="0"),t&&(t.style.opacity="",t.style.marginBottom="",t.style.marginTop="")}function Io(e,t,o){let n=t.parentElement,r=ye(null),c=ye(null),i=ye(null),l=ye(!1),[u,d]=et(null),[y,a]=et(null),{editorConfig:s}=S(),m=s?.admin?.hideGutter?-44:-8;Se(()=>{function f(h){let p=h.target;if(!Pe(p))return;let b=Y(n,h.pageX,h.pageY,p);if(b===-1){d(null);return}if(fe(p,Ao))return;let k=H(e),{blockElem:P,foundAtIndex:C,isFoundNodeEmptyParagraph:R}=U({anchorElem:t,cache_threshold:0,editor:e,horizontalOffset:-b,point:new F(h.x,h.y),startIndex:ot(k.length),useEdgeAsDefault:!1,verbose:!1});oe=C,!(!P&&!R)&&u!==P&&d(P)}return document?.addEventListener("mousemove",f),()=>{document?.removeEventListener("mousemove",f)}},[n,t,e,u]),Se(()=>{r.current&&pe(u,r.current,t,m)},[t,u,m]),Se(()=>{function f(p){if(!l.current)return!1;let[b]=Xe(p);if(b)return!1;let{pageY:k,target:P}=p;if(!Pe(P))return!1;let C=Y(n,p.pageX,p.pageY,P,100,50),R=H(e),{blockElem:N,foundAtIndex:D,isFoundNodeEmptyParagraph:I}=U({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-C,point:new F(p.x,p.y),startIndex:ot(R.length),useEdgeAsDefault:!0,verbose:!0});oe=D;let T=c.current;if(N===null||T===null)return!1;if(u!==N){let{isBelow:v,willStayInSamePosition:X}=Qe(s?.admin?.hideGutter?"0px":"3rem",m+(s?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),T,N,y,k,t,p,i,I);p.preventDefault(),X||a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:v})}else y?.elem&&(nt(T,y.elem),a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function h(p){if(!l.current)return!1;let[b]=Xe(p);if(b)return!1;let{dataTransfer:k,pageY:P,target:C}=p,R=k?.getData(tt)||"";return e.update(()=>{let N=Lo(R);if(!N||!Pe(C))return!1;let D=Y(n,p.pageX,p.pageY,C,100,50),{blockElem:I,isFoundNodeEmptyParagraph:T}=U({anchorElem:t,editor:e,fuzzy:!0,horizontalOffset:-D,point:new F(p.x,p.y),useEdgeAsDefault:!0});if(!I)return!1;let v=Ze(I);if(!v)return!1;if(v===N)return!0;let{height:X,top:xe}=G(I),O=P>=xe+X/2+window.scrollY;T?(v.insertBefore(N),v.remove()):O?v.insertAfter(N):v.insertBefore(N),u!==null&&d(null),document.querySelectorAll(".lexical-block-highlighter").forEach(_=>{_.remove()});let se=e.getElementByKey(N.getKey());setTimeout(()=>{let _=se?.getBoundingClientRect();if(!_)return;let w=document.createElement("div");w.className="lexical-block-highlighter",w.style.backgroundColor="var(--theme-elevation-1000",w.style.transition="opacity 0.5s ease-in-out",w.style.zIndex="1",w.style.pointerEvents="none",w.style.boxSizing="border-box",w.style.borderRadius="4px",w.style.position="absolute",document.body.appendChild(w),w.style.opacity="0.1",w.style.height=`${_.height+8}px`,w.style.width=`${_.width+8}px`,w.style.top=`${_.top+window.scrollY-4}px`,w.style.left=`${_.left-4}px`,setTimeout(()=>{w.style.opacity="0",setTimeout(()=>{w.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",f),document.addEventListener("drop",h),()=>{document.removeEventListener("dragover",f),document.removeEventListener("drop",h)}},[n,m,t,e,y,u,s?.admin?.hideGutter]);function x(f){let h=f.dataTransfer;if(!h||!u)return;Bo(h,u);let p="";e.update(()=>{let b=Ze(u);b&&(p=b.getKey())}),l.current=!0,h.setData(tt,p)}function g(){l.current=!1,y?.elem&&nt(c.current,y?.elem)}return Mo(_o(rt.Fragment,{children:[he("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:g,onDragStart:x,ref:r,type:"button",children:he("div",{className:o?"icon":""})}),he("div",{className:"draggable-block-target-line",ref:c}),he("div",{className:"debug-highlight",ref:i})]}),t)}function it(e){let{anchorElem:t}=e,o=t===void 0?document.body:t,[n]=Do();return Io(n,o,n._editable)}import{c as Oo}from"react/compiler-runtime";import{jsx as Re}from"react/jsx-runtime";import{useLexicalComposerContext as Fo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as $o,$getRoot as Ko}from"lexical";import"react";var st="insert-paragraph-at-end",lt=()=>{let e=Oo(2),[t]=Fo(),{editorConfig:o}=S();if(o?.admin?.hideInsertParagraphAtEnd)return null;let n;return e[0]!==t?(n=Re("div",{"aria-label":"Insert Paragraph",className:st,onClick:()=>{t.update(jo)},role:"button",tabIndex:0,children:Re("div",{className:`${st}-inside`,children:Re("span",{children:"+"})})}),e[0]=t,e[1]=n):n=e[1],n};function jo(){let e=$o();Ko().append(e),e.select()}import{c as Ho}from"react/compiler-runtime";import{useLexicalComposerContext as Vo}from"@lexical/react/LexicalComposerContext";import*as at from"react";var ct=()=>{let e=Ho(4),{editorConfig:t}=S(),[o]=Vo(),n,r;return e[0]!==o||e[1]!==t.features.markdownTransformers?(n=()=>_e(o,t.features.markdownTransformers??[]),r=[o,t.features.markdownTransformers],e[0]=o,e[1]=t.features.markdownTransformers,e[2]=n,e[3]=r):(n=e[2],r=e[3]),at.useEffect(n,r),null};import{c as zo}from"react/compiler-runtime";import{useLexicalComposerContext as Wo}from"@lexical/react/LexicalComposerContext.js";import{useEffect as Yo}from"react";function ut(){let e=zo(5),[t]=Wo(),{currentView:o,views:n}=z(),r,c;return e[0]!==o||e[1]!==t||e[2]!==n?(r=()=>{n&&(o==="default"?n.default?be(t,n.default?.nodes):Ce(t):n[o]&&(Ce(t),be(t,n[o]?.nodes)))},c=[t,n,o],e[0]=o,e[1]=t,e[2]=n,e[3]=r,e[4]=c):(r=e[3],c=e[4]),Yo(r,c),null}import{useLexicalComposerContext as Go}from"@lexical/react/LexicalComposerContext";import{$getSelection as Uo,$isRangeSelection as qo,RootNode as Jo}from"lexical";import{useEffect as Qo}from"react";function dt(){let[e]=Go();return Qo(()=>e.registerNodeTransform(Jo,t=>{let o=Uo();if(qo(o)){let n=o.anchor.getNode(),r=o.focus.getNode();(!n.isAttached()||!r.isAttached())&&(t.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}),[e]),null}import{useLexicalComposerContext as Xo}from"@lexical/react/LexicalComposerContext";import{$getSelection as Zo,COMMAND_PRIORITY_LOW as en,SELECT_ALL_COMMAND as tn}from"lexical";import{useEffect as on}from"react";function mt(){let[e]=Xo();return on(()=>e.registerCommand(tn,()=>{if(Zo())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},en),[e]),null}import{jsx as q,jsxs as pt}from"react/jsx-runtime";import{useLexicalComposerContext as rn}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as gt}from"@payloadcms/ui";import{useCallback as sn,useMemo as ln,useState as an}from"react";import"react";import*as ht from"react-dom";import{c as nn}from"react/compiler-runtime";import"react";function ft(e,t){let o=nn(4),{maxLength:n,minLength:r}=t,c=n===void 0?75:n,i=r===void 0?1:r,l;return o[0]!==c||o[1]!==i||o[2]!==e?(l=u=>{let{query:d}=u,y="[^"+e+Le+"\\s]",s=new RegExp("(^|\\s|\\()(["+e+"]((?:"+y+"){0,"+c+"}))$").exec(d);if(s!==null){let m=s[1],x=s[3];if(x.length>=i)return{leadOffset:s.index+m.length,matchingString:x,replaceableString:s[2]}}return null},o[0]=c,o[1]=i,o[2]=e,o[3]=l):l=o[3],l}var A="slash-menu-popup";function cn({isSelected:e,item:t,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=S(),{i18n:l}=gt(),u=`${A}__item ${A}__item-${t.key}`;e&&(u+=` ${A}__item--selected`);let d=t.key;return t.label&&(d=typeof t.label=="function"?t.label({featureClientSchemaMap:c,i18n:l,schemaPath:i}):t.label),d.length>25&&(d=d.substring(0,25)+"..."),pt("button",{"aria-selected":e,className:u,id:A+"__item-"+t.key,onClick:o,onMouseEnter:n,ref:r,role:"option",tabIndex:-1,type:"button",children:[t?.Icon&&q(t.Icon,{}),q("span",{className:`${A}__item-text`,children:d})]},t.key)}function yt({anchorElem:e=document.body}){let[t]=rn(),[o,n]=an(null),{editorConfig:r}=S(),{i18n:c}=gt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:l}}=S(),u=ft("/",{minLength:0}),d=sn(()=>{let a=[];for(let s of r.features.slashMenu.dynamicGroups)if(o){let m=s({editor:t,queryString:o});a=a.concat(m)}return a},[t,o,r?.features]),y=ln(()=>{let a=[];for(let s of r?.features.slashMenu.groups??[])a.push(s);if(o){a=a.map(m=>{let x=m.items.filter(g=>{let f=g.key;return g.label&&(f=typeof g.label=="function"?g.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):g.label),new RegExp(o,"gi").exec(f)?!0:g.keywords!=null?g.keywords.some(h=>new RegExp(o,"gi").exec(h)):!1});return x.length?{...m,items:x}:null}),a=a.filter(m=>m!=null);let s=d();for(let m of s){let x=a.find(g=>g.key===m.key);x?a=a.filter(g=>g.key!==m.key):x={...m,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,r?.features.slashMenu.groups,d,i,c,l]);return q(Ae,{anchorElem:e,groups:y,menuRenderFn:(a,{selectedItemKey:s,selectItemAndCleanUp:m,setSelectedItemKey:x})=>a.current&&y.length?ht.createPortal(q("div",{className:A,children:y.map(g=>{let f=g.key;return g.label&&i&&(f=typeof g.label=="function"?g.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):g.label),pt("div",{className:`${A}__group ${A}__group-${g.key}`,children:[q("div",{className:`${A}__group-title`,children:f}),g.items.map((h,p)=>q(cn,{index:p,isSelected:s===h.key,item:h,onClick:()=>{x(h.key),m(h)},onMouseEnter:()=>{x(h.key)},ref:b=>{h.ref={current:b}}},h.key))]},g.key)})}),a.current):null,onQueryChange:n,triggerFn:u})}import{c as un}from"react/compiler-runtime";import{useLexicalComposerContext as dn}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as mn,TextNode as fn}from"lexical";import{useEffect as pn}from"react";function xt(e){let t=un(6),{features:o}=e,[n]=dn(),r;t[0]!==n||t[1]!==o.enabledFormats?(r=()=>{let i=gn(o.enabledFormats);if(i.length!==0)return n.registerNodeTransform(fn,l=>{i.forEach(u=>{l.hasFormat(u)&&l.toggleFormat(u)})})},t[0]=n,t[1]=o.enabledFormats,t[2]=r):r=t[2];let c;return t[3]!==n||t[4]!==o?(c=[n,o],t[3]=n,t[4]=o,t[5]=c):c=t[5],pn(r,c),null}function gn(e){let t=Object.keys(mn),o=new Set(e);return t.filter(n=>!o.has(n))}import{c as hn}from"react/compiler-runtime";import{jsx as Et}from"react/jsx-runtime";import{useLexicalComposerContext as yn}from"@lexical/react/LexicalComposerContext";import{ContentEditable as xn}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as En}from"@payloadcms/ui";import"react";function bt(e){let t=hn(5),{className:o,editorConfig:n}=e,{t:r}=En(),[,c]=yn(),{getTheme:i}=c,l;if(t[0]!==o||t[1]!==n?.admin?.placeholder||t[2]!==i||t[3]!==r){let u=i();l=Et(xn,{"aria-placeholder":r("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Et("p",{className:u?.placeholder,children:n?.admin?.placeholder??r("lexical:general:placeholder")})}),t[0]=o,t[1]=n?.admin?.placeholder,t[2]=i,t[3]=r,t[4]=l}else l=t[4];return l}var Nt=e=>{let t=bn(12),{editorConfig:o,editorContainerRef:n,isSmallWidthViewport:r,onChange:c}=e,i=S(),[l]=Cn(),u=Rn(),[d,y]=_n(null),a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=f=>{f!==null&&y(f)},t[0]=a):a=t[0];let s=a,m,x;t[1]!==l||t[2]!==i?(m=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let f=()=>{i.focusEditor(i)},h=()=>{i.blurEditor(i)},p=l.registerCommand(Tn,()=>(f(),!0),Ct),b=l.registerCommand(kn,()=>(h(),!0),Ct);return()=>{p(),b(),i.parentEditor?.unregisterChild?.(i.uuid)}},x=[l,i],t[1]=l,t[2]=i,t[3]=m,t[4]=x):(m=t[3],x=t[4]),vn(m,x);let g;return t[5]!==o||t[6]!==n||t[7]!==d||t[8]!==u||t[9]!==r||t[10]!==c?(g=ne(J.Fragment,{children:[o.features.plugins?.map(Dn),ne("div",{className:"editor-container",ref:n,children:[o.features.plugins?.map(Ln),E(Sn,{contentEditable:E("div",{className:"editor-scroller",children:E("div",{className:"editor",ref:s,children:E(bt,{editorConfig:o})})}),ErrorBoundary:Nn}),E(dt,{}),u&&E(lt,{}),E(He,{}),E($e,{}),E(xt,{features:o.features}),E(mt,{}),E(ut,{}),u&&E(Pn,{ignoreSelectionChange:!0,onChange:(f,h,p)=>{(!p.has("focus")||p.size>1)&&c?.(f,h,p)}}),d&&ne(J.Fragment,{children:[!r&&u&&ne(J.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:E(it,{anchorElem:d}),o.admin?.hideAddBlockButton?null:E(qe,{anchorElem:d})]}),o.features.plugins?.map(f=>{if(f.position==="floatingAnchorElem"&&!(f.desktopOnly===!0&&r))return E(K,{anchorElem:d,clientProps:f.clientProps,plugin:f},f.key)}),u&&E(J.Fragment,{children:E(yt,{anchorElem:d})})]}),u&&ne(J.Fragment,{children:[E(wn,{}),o?.features?.markdownTransformers?.length>0&&E(ct,{})]}),o.features.plugins?.map(Mn),o.features.plugins?.map(An)]}),o.features.plugins?.map(Bn)]}),t[5]=o,t[6]=n,t[7]=d,t[8]=u,t[9]=r,t[10]=c,t[11]=g):g=t[11],g};function Dn(e){if(e.position==="aboveContainer")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function Ln(e){if(e.position==="top")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function Mn(e){if(e.position==="normal")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function An(e){if(e.position==="bottom")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}function Bn(e){if(e.position==="belowContainer")return E(K,{clientProps:e.clientProps,plugin:e},e.key)}var Pt=({children:e,providers:t})=>{if(!t?.length)return e;let o=t[0];return t.length>1?$(o,{children:$(Pt,{providers:t.slice(1),children:e})}):$(o,{children:e})},St=e=>{let{composerKey:t,editorConfig:o,fieldProps:n,isSmallWidthViewport:r,onChange:c,readOnly:i,value:l}=e,{currentView:u,views:d}=z(),y=S(),a=On(),s=wt.useRef(null),m=Fn(()=>{if(l&&typeof l!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(l));if(l&&Array.isArray(l)&&!("root"in l))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(l&&"jsonContent"in l)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");let x=d?.[u]?.nodes;return{editable:i!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:Ie({editorConfig:o,nodeViews:x}),onError:g=>{throw g},theme:o.lexical.theme}},[o,d,u]);return m?$(In,{initialConfig:m,children:$(ve,{editorConfig:o,editorContainerRef:s,fieldProps:n,parentContext:y?.editDepth===a?y:void 0,children:$(Pt,{providers:o.features.providers,children:$(Nt,{editorConfig:o,editorContainerRef:s,isSmallWidthViewport:r,onChange:c})})})},t+m.editable+u):$("p",{children:"Loading..."})};import{c as $n}from"react/compiler-runtime";import{jsx as Q,jsxs as Kn}from"react/jsx-runtime";import{ChevronIcon as jn,Popup as Hn,PopupList as Rt}from"@payloadcms/ui";import"react";function kt(){let e=$n(5),{currentView:t,setCurrentView:o,views:n}=z();if(!n||Object.keys(n).length===0)return null;let r,c;if(e[0]!==t||e[1]!==o||e[2]!==n){c=Symbol.for("react.early_return_sentinel");e:{let i=Object.keys(n);if(!i.some(zn)){c=null;break e}let u=["default",...i.filter(Vn)],d=t.charAt(0).toUpperCase()+t.slice(1);r=Q("div",{className:"lexical-view-selector",children:Q(Hn,{button:Kn("button",{className:"lexical-view-selector__button",type:"button",children:[Q("span",{className:"lexical-view-selector__label",children:d}),Q(jn,{className:"lexical-view-selector__icon"})]}),buttonType:"custom",horizontalAlign:"left",render:y=>{let{close:a}=y;return Q(Rt.ButtonGroup,{children:u.map(s=>{let m=s.charAt(0).toUpperCase()+s.slice(1);return Q(Rt.Button,{active:s===t,disabled:s===t,onClick:()=>{o?.(s),a()},children:m},s)})})},size:"large"})})}e[0]=t,e[1]=o,e[2]=n,e[3]=r,e[4]=c}else r=e[3],c=e[4];return c!==Symbol.for("react.early_return_sentinel")?c:r}function Vn(e){return e!=="default"}function zn(e){return e!=="default"}var re="rich-text-lexical",tr=e=>{let{editorConfig:t,field:o,field:{admin:{className:n,description:r,readOnly:c}={},label:i,localized:l,required:u},path:d,readOnly:y,validate:a}=e,s=y||c,m=Un(),x=_t((L,Z)=>typeof a=="function"?a(L,{...Z,required:u}):!0,[a,u]),{customComponents:{AfterInput:g,BeforeInput:f,Description:h,Error:p,Label:b}={},disabled:k,initialValue:P,path:C,setValue:R,showError:N,value:D}=Jn({potentiallyStalePath:d,validate:x}),I=s||k,[T,v]=Lt(!1),[X,xe]=Lt(),Ee=vt.useRef(P),O=vt.useRef(D);Dt(()=>{let L=()=>{let Z=window.matchMedia("(max-width: 768px)").matches;Z!==T&&v(Z)};return L(),window.addEventListener("resize",L),()=>{window.removeEventListener("resize",L)}},[T]);let ke=["field-type",re,n,N&&"error",I&&`${re}--read-only`,t?.admin?.hideGutter!==!0&&!T?`${re}--show-gutter`:null].filter(Boolean).join(" "),se=`${C}.${m}`,_=De(),w=_t(L=>{_(()=>{let Te=L.toJSON();O.current=Te,R(Te)})},[R,_]),Mt=Zn(()=>Qn(o),[o]),At=qn(L=>{O.current!==D&&!Xn(O.current!=null?JSON.parse(JSON.stringify(O.current)):O.current,D)&&(Ee.current=L,O.current=D,xe(new Date))});return Dt(()=>{Object.is(P,Ee.current)||At(P)},[P]),ie("div",{className:ke,"data-lexical-view":t?.view,style:Mt,children:[B(Tt,{CustomComponent:p,Fallback:B(Yn,{path:C,showError:N})}),ie("div",{className:`${re}__label-row`,children:[b||B(Gn,{label:i,localized:l,path:C,required:u}),B(kt,{})]}),ie("div",{className:`${re}__wrap`,children:[ie(er,{fallbackRender:or,onReset:()=>{},children:[f,B(St,{composerKey:se,editorConfig:t,fieldProps:e,isSmallWidthViewport:T,onChange:w,readOnly:I,value:D},JSON.stringify({path:C,rerenderProviderKey:X})),g]}),B(Tt,{CustomComponent:h,Fallback:B(Wn,{description:r,path:C})})]})]},se)};function or({error:e}){return ie("div",{className:"errorBoundary",role:"alert",children:[B("p",{children:"Something went wrong:"}),B("pre",{style:{color:"red"},children:e.message})]})}var dl=tr;export{dl as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-SYJC2DBU.js.map
|