@payloadcms/richtext-lexical 3.23.0 → 3.24.0-canary.05013b2

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.
Files changed (123) hide show
  1. package/dist/cell/rscEntry.d.ts.map +1 -1
  2. package/dist/cell/rscEntry.js +1 -2
  3. package/dist/cell/rscEntry.js.map +1 -1
  4. package/dist/dependencyChecker.spec.js +0 -2
  5. package/dist/dependencyChecker.spec.js.map +1 -1
  6. package/dist/exports/client/{Field-ZQTPXWY3.js → Field-NNWFQETL.js} +2 -2
  7. package/dist/exports/client/bundled.css +1 -1
  8. package/dist/exports/client/chunk-EE27FURT.js +2 -0
  9. package/dist/exports/client/chunk-EE27FURT.js.map +7 -0
  10. package/dist/exports/client/chunk-OZ6Q4DWN.js +12 -0
  11. package/dist/exports/client/chunk-OZ6Q4DWN.js.map +7 -0
  12. package/dist/exports/client/componentInline-XEH2GDVO.js +2 -0
  13. package/dist/exports/client/index.d.ts +1 -0
  14. package/dist/exports/client/index.d.ts.map +1 -1
  15. package/dist/exports/client/index.js +10 -10
  16. package/dist/exports/client/index.js.map +3 -3
  17. package/dist/exports/react/components/RichText/converter/converters/table.d.ts.map +1 -1
  18. package/dist/exports/react/components/RichText/converter/converters/table.js +10 -7
  19. package/dist/exports/react/components/RichText/converter/converters/table.js.map +1 -1
  20. package/dist/exports/react/components/RichText/converter/converters/upload.d.ts.map +1 -1
  21. package/dist/exports/react/components/RichText/converter/converters/upload.js +14 -10
  22. package/dist/exports/react/components/RichText/converter/converters/upload.js.map +1 -1
  23. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  24. package/dist/features/blocks/client/component/index.js +5 -2
  25. package/dist/features/blocks/client/component/index.js.map +1 -1
  26. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  27. package/dist/features/blocks/client/componentInline/index.js +5 -2
  28. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  29. package/dist/features/blocks/client/index.d.ts.map +1 -1
  30. package/dist/features/blocks/client/index.js +3 -2
  31. package/dist/features/blocks/client/index.js.map +1 -1
  32. package/dist/features/blocks/server/graphQLPopulationPromise.d.ts.map +1 -1
  33. package/dist/features/blocks/server/graphQLPopulationPromise.js +3 -0
  34. package/dist/features/blocks/server/graphQLPopulationPromise.js.map +1 -1
  35. package/dist/features/blocks/server/index.d.ts +3 -3
  36. package/dist/features/blocks/server/index.d.ts.map +1 -1
  37. package/dist/features/blocks/server/index.js +58 -38
  38. package/dist/features/blocks/server/index.js.map +1 -1
  39. package/dist/features/blocks/server/validate.d.ts +5 -0
  40. package/dist/features/blocks/server/validate.d.ts.map +1 -1
  41. package/dist/features/blocks/server/validate.js +8 -2
  42. package/dist/features/blocks/server/validate.js.map +1 -1
  43. package/dist/features/converters/html/field/index.d.ts.map +1 -1
  44. package/dist/features/converters/html/field/index.js +3 -43
  45. package/dist/features/converters/html/field/index.js.map +1 -1
  46. package/dist/features/experimental_table/server/index.js +1 -1
  47. package/dist/features/experimental_table/server/index.js.map +1 -1
  48. package/dist/features/indent/client/index.d.ts.map +1 -1
  49. package/dist/features/indent/client/index.js +23 -7
  50. package/dist/features/indent/client/index.js.map +1 -1
  51. package/dist/features/link/server/graphQLPopulationPromise.d.ts.map +1 -1
  52. package/dist/features/link/server/graphQLPopulationPromise.js +3 -0
  53. package/dist/features/link/server/graphQLPopulationPromise.js.map +1 -1
  54. package/dist/features/link/server/validate.d.ts.map +1 -1
  55. package/dist/features/link/server/validate.js +3 -2
  56. package/dist/features/link/server/validate.js.map +1 -1
  57. package/dist/features/typesServer.d.ts +2 -1
  58. package/dist/features/typesServer.d.ts.map +1 -1
  59. package/dist/features/typesServer.js.map +1 -1
  60. package/dist/features/upload/server/feature.server.d.ts.map +1 -1
  61. package/dist/features/upload/server/feature.server.js +4 -3
  62. package/dist/features/upload/server/feature.server.js.map +1 -1
  63. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  64. package/dist/features/upload/server/graphQLPopulationPromise.js +3 -0
  65. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  66. package/dist/features/upload/server/nodes/UploadNode.d.ts +19 -8
  67. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  68. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  69. package/dist/features/upload/server/validate.d.ts.map +1 -1
  70. package/dist/features/upload/server/validate.js +5 -4
  71. package/dist/features/upload/server/validate.js.map +1 -1
  72. package/dist/field/bundled.css +1 -1
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +13 -0
  75. package/dist/index.js.map +1 -1
  76. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +1 -1
  77. package/dist/packages/@lexical/markdown/MarkdownExport.js +5 -5
  78. package/dist/packages/@lexical/markdown/MarkdownExport.js.map +1 -1
  79. package/dist/packages/@lexical/markdown/MarkdownImport.js +6 -5
  80. package/dist/packages/@lexical/markdown/MarkdownImport.js.map +1 -1
  81. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +1 -1
  82. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +6 -4
  83. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +1 -1
  84. package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +1 -1
  85. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +1 -1
  86. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +4 -1
  87. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +1 -1
  88. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +1 -1
  89. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +1 -1
  90. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +1 -1
  91. package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts +2 -1
  92. package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts.map +1 -1
  93. package/dist/populateGraphQL/populateLexicalPopulationPromises.js +2 -0
  94. package/dist/populateGraphQL/populateLexicalPopulationPromises.js.map +1 -1
  95. package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.d.ts +2 -1
  96. package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.d.ts.map +1 -1
  97. package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.js +2 -0
  98. package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.js.map +1 -1
  99. package/dist/utilities/jsx/collectTopLevelJSXInLines.d.ts.map +1 -1
  100. package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -1
  101. package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
  102. package/dist/utilities/migrateSlateToLexical/index.js +8 -4
  103. package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
  104. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts +3 -2
  105. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts.map +1 -1
  106. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +18 -13
  107. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
  108. package/dist/utilities/upgradeLexicalData/index.js +8 -4
  109. package/dist/utilities/upgradeLexicalData/index.js.map +1 -1
  110. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts +3 -2
  111. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -1
  112. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +18 -13
  113. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
  114. package/dist/validate/hasText.js +1 -1
  115. package/dist/validate/hasText.js.map +1 -1
  116. package/package.json +8 -18
  117. package/dist/exports/client/chunk-CIY6PKN6.js +0 -12
  118. package/dist/exports/client/chunk-CIY6PKN6.js.map +0 -7
  119. package/dist/exports/client/chunk-KEEUF5NK.js +0 -2
  120. package/dist/exports/client/chunk-KEEUF5NK.js.map +0 -7
  121. package/dist/exports/client/componentInline-UG3ZWWJY.js +0 -2
  122. /package/dist/exports/client/{Field-ZQTPXWY3.js.map → Field-NNWFQETL.js.map} +0 -0
  123. /package/dist/exports/client/{componentInline-UG3ZWWJY.js.map → componentInline-XEH2GDVO.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"rscEntry.d.ts","sourceRoot":"","sources":["../../src/cell/rscEntry.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAG1E,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAyBnF,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CACxC;IACE,KAAK,EAAE,sBAAsB,CAAA;IAC7B,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,qBAAqB,EAAE,2BAA2B,CAAA;CACnD,GAAG,wBAAwB,CA4E7B,CAAA"}
1
+ {"version":3,"file":"rscEntry.d.ts","sourceRoot":"","sources":["../../src/cell/rscEntry.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAG1E,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAuBnF,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CACxC;IACE,KAAK,EAAE,sBAAsB,CAAA;IAC7B,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,qBAAqB,EAAE,2BAA2B,CAAA;CACnD,GAAG,wBAAwB,CA4E7B,CAAA"}
@@ -1,9 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { getTranslation } from '@payloadcms/translations';
3
+ import { Link } from '@payloadcms/ui';
3
4
  import { formatAdminURL } from '@payloadcms/ui/shared';
4
- import LinkImport from 'next/link.js';
5
5
  import React from 'react';
6
- const Link = LinkImport.default || LinkImport;
7
6
  function recurseEditorState(editorState, textContent, i = 0) {
8
7
  for (const node of editorState) {
9
8
  i++;
@@ -1 +1 @@
1
- {"version":3,"file":"rscEntry.js","names":["getTranslation","formatAdminURL","LinkImport","React","Link","default","recurseEditorState","editorState","textContent","i","node","text","push","_jsxs","type","children","RscEntryLexicalCell","props","cellData","className","classNameFromProps","collectionConfig","field","admin","i18n","link","onClick","onClickFromProps","payload","rowData","sanitizedEditorConfig","classNameFromConfigContext","undefined","adminRoute","config","routes","WrapElement","wrapElementProps","prefetch","href","slug","path","id","collectionSlug","root","length","t","label","_jsx"],"sources":["../../src/cell/rscEntry.tsx"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\nimport type { Payload } from 'payload'\n\nimport { getTranslation, type I18nClient } from '@payloadcms/translations'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport LinkImport from 'next/link.js'\nimport React from 'react'\n\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalFieldAdminProps, LexicalRichTextCellProps } from '../types.js'\n\nconst Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default\n\nfunction recurseEditorState(\n editorState: SerializedLexicalNode[],\n textContent: React.ReactNode[],\n i: number = 0,\n): React.ReactNode[] {\n for (const node of editorState) {\n i++\n if ('text' in node && node.text) {\n textContent.push(node.text as string)\n } else {\n if (!('children' in node)) {\n textContent.push(<code key={i}>&#32;[{node.type}]</code>)\n }\n }\n if ('children' in node && node.children) {\n textContent = recurseEditorState(node.children as SerializedLexicalNode[], textContent, i)\n }\n }\n return textContent\n}\n\nexport const RscEntryLexicalCell: React.FC<\n {\n admin: LexicalFieldAdminProps\n i18n: I18nClient\n payload: Payload\n sanitizedEditorConfig: SanitizedServerEditorConfig\n } & LexicalRichTextCellProps\n> = (props) => {\n const {\n cellData,\n className: classNameFromProps,\n collectionConfig,\n field: { admin },\n field,\n i18n,\n link,\n onClick: onClickFromProps,\n payload,\n rowData,\n sanitizedEditorConfig,\n } = props\n\n const classNameFromConfigContext = admin && 'className' in admin ? admin.className : undefined\n\n const className =\n classNameFromProps ||\n (field.admin && 'className' in field.admin ? field.admin.className : null) ||\n classNameFromConfigContext\n const adminRoute = payload.config.routes.admin\n\n const onClick = onClickFromProps\n\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n prefetch?: false\n type?: 'button'\n } = {\n className,\n }\n\n if (link) {\n wrapElementProps.prefetch = false\n WrapElement = Link\n wrapElementProps.href = collectionConfig?.slug\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig?.slug}/${rowData.id}`,\n })\n : ''\n }\n\n if (typeof onClick === 'function') {\n WrapElement = 'button'\n wrapElementProps.type = 'button'\n wrapElementProps.onClick = () => {\n onClick({\n cellData,\n collectionSlug: collectionConfig?.slug,\n rowData,\n })\n }\n }\n\n let textContent: React.ReactNode[] = []\n\n if (cellData?.root?.children) {\n textContent = recurseEditorState(cellData?.root?.children, textContent)\n }\n\n if (!textContent?.length) {\n textContent = [\n i18n.t('general:noLabel', {\n label: getTranslation(('label' in field ? field.label : null) || 'data', i18n),\n }),\n ]\n }\n\n return <WrapElement {...wrapElementProps}>{textContent}</WrapElement>\n}\n"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"file":"rscEntry.js","names":["getTranslation","Link","formatAdminURL","React","recurseEditorState","editorState","textContent","i","node","text","push","_jsxs","type","children","RscEntryLexicalCell","props","cellData","className","classNameFromProps","collectionConfig","field","admin","i18n","link","onClick","onClickFromProps","payload","rowData","sanitizedEditorConfig","classNameFromConfigContext","undefined","adminRoute","config","routes","WrapElement","wrapElementProps","prefetch","href","slug","path","id","collectionSlug","root","length","t","label","_jsx"],"sources":["../../src/cell/rscEntry.tsx"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\nimport type { Payload } from 'payload'\n\nimport { getTranslation, type I18nClient } from '@payloadcms/translations'\nimport { Link } from '@payloadcms/ui'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport React from 'react'\n\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalFieldAdminProps, LexicalRichTextCellProps } from '../types.js'\n\nfunction recurseEditorState(\n editorState: SerializedLexicalNode[],\n textContent: React.ReactNode[],\n i: number = 0,\n): React.ReactNode[] {\n for (const node of editorState) {\n i++\n if ('text' in node && node.text) {\n textContent.push(node.text as string)\n } else {\n if (!('children' in node)) {\n textContent.push(<code key={i}>&#32;[{node.type}]</code>)\n }\n }\n if ('children' in node && node.children) {\n textContent = recurseEditorState(node.children as SerializedLexicalNode[], textContent, i)\n }\n }\n return textContent\n}\n\nexport const RscEntryLexicalCell: React.FC<\n {\n admin: LexicalFieldAdminProps\n i18n: I18nClient\n payload: Payload\n sanitizedEditorConfig: SanitizedServerEditorConfig\n } & LexicalRichTextCellProps\n> = (props) => {\n const {\n cellData,\n className: classNameFromProps,\n collectionConfig,\n field: { admin },\n field,\n i18n,\n link,\n onClick: onClickFromProps,\n payload,\n rowData,\n sanitizedEditorConfig,\n } = props\n\n const classNameFromConfigContext = admin && 'className' in admin ? admin.className : undefined\n\n const className =\n classNameFromProps ||\n (field.admin && 'className' in field.admin ? field.admin.className : null) ||\n classNameFromConfigContext\n const adminRoute = payload.config.routes.admin\n\n const onClick = onClickFromProps\n\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n prefetch?: false\n type?: 'button'\n } = {\n className,\n }\n\n if (link) {\n wrapElementProps.prefetch = false\n WrapElement = Link\n wrapElementProps.href = collectionConfig?.slug\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig?.slug}/${rowData.id}`,\n })\n : ''\n }\n\n if (typeof onClick === 'function') {\n WrapElement = 'button'\n wrapElementProps.type = 'button'\n wrapElementProps.onClick = () => {\n onClick({\n cellData,\n collectionSlug: collectionConfig?.slug,\n rowData,\n })\n }\n }\n\n let textContent: React.ReactNode[] = []\n\n if (cellData?.root?.children) {\n textContent = recurseEditorState(cellData?.root?.children, textContent)\n }\n\n if (!textContent?.length) {\n textContent = [\n i18n.t('general:noLabel', {\n label: getTranslation(('label' in field ? field.label : null) || 'data', i18n),\n }),\n ]\n }\n\n return <WrapElement {...wrapElementProps}>{textContent}</WrapElement>\n}\n"],"mappings":"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","ignoreList":[]}
@@ -10,8 +10,6 @@ describe('Lexical dependency checker', () => {
10
10
  const packageJson = JSON.parse(packageJsonString);
11
11
  const packageJsonLexicalVersion = packageJson.dependencies['lexical'];
12
12
  expect(packageJsonLexicalVersion).toBe(lexicalTargetVersion);
13
- const packageJsonLexicalPeerDepVersion = packageJson.peerDependencies['lexical'];
14
- expect(packageJsonLexicalPeerDepVersion).toBe(lexicalTargetVersion);
15
13
  });
16
14
  });
17
15
  //# sourceMappingURL=dependencyChecker.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dependencyChecker.spec.js","names":["lexicalTargetVersion","fileURLToPath","path","fs","filename","import","meta","url","dirname","describe","it","packageJsonString","readFile","resolve","packageJson","JSON","parse","packageJsonLexicalVersion","dependencies","expect","toBe","packageJsonLexicalPeerDepVersion","peerDependencies"],"sources":["../src/dependencyChecker.spec.ts"],"sourcesContent":["import { jest } from '@jest/globals'\nimport { lexicalTargetVersion } from './index'\nimport { fileURLToPath } from 'url'\nimport path from 'path'\nimport fs from 'fs/promises'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\ndescribe('Lexical dependency checker', () => {\n it('ensure lexical version installed in package.json matches dependency checker version', async () => {\n const packageJsonString = await fs.readFile(path.resolve(dirname, '../package.json'), 'utf-8')\n const packageJson = JSON.parse(packageJsonString)\n const packageJsonLexicalVersion = packageJson.dependencies['lexical']\n\n expect(packageJsonLexicalVersion).toBe(lexicalTargetVersion)\n\n const packageJsonLexicalPeerDepVersion = packageJson.peerDependencies['lexical']\n expect(packageJsonLexicalPeerDepVersion).toBe(lexicalTargetVersion)\n })\n})\n"],"mappings":"AACA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,OAAOC,IAAA,MAAU;AACjB,OAAOC,EAAA,MAAQ;AAEf,MAAMC,QAAA,GAAWH,aAAA,CAAcI,MAAA,CAAAC,IAAA,CAAYC,GAAG;AAC9C,MAAMC,OAAA,GAAUN,IAAA,CAAKM,OAAO,CAACJ,QAAA;AAE7BK,QAAA,CAAS,8BAA8B;EACrCC,EAAA,CAAG,uFAAuF;IACxF,MAAMC,iBAAA,GAAoB,MAAMR,EAAA,CAAGS,QAAQ,CAACV,IAAA,CAAKW,OAAO,CAACL,OAAA,EAAS,oBAAoB;IACtF,MAAMM,WAAA,GAAcC,IAAA,CAAKC,KAAK,CAACL,iBAAA;IAC/B,MAAMM,yBAAA,GAA4BH,WAAA,CAAYI,YAAY,CAAC,UAAU;IAErEC,MAAA,CAAOF,yBAAA,EAA2BG,IAAI,CAACpB,oBAAA;IAEvC,MAAMqB,gCAAA,GAAmCP,WAAA,CAAYQ,gBAAgB,CAAC,UAAU;IAChFH,MAAA,CAAOE,gCAAA,EAAkCD,IAAI,CAACpB,oBAAA;EAChD;AACF","ignoreList":[]}
1
+ {"version":3,"file":"dependencyChecker.spec.js","names":["lexicalTargetVersion","fileURLToPath","path","fs","filename","import","meta","url","dirname","describe","it","packageJsonString","readFile","resolve","packageJson","JSON","parse","packageJsonLexicalVersion","dependencies","expect","toBe"],"sources":["../src/dependencyChecker.spec.ts"],"sourcesContent":["import { jest } from '@jest/globals'\nimport { lexicalTargetVersion } from './index'\nimport { fileURLToPath } from 'url'\nimport path from 'path'\nimport fs from 'fs/promises'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\ndescribe('Lexical dependency checker', () => {\n it('ensure lexical version installed in package.json matches dependency checker version', async () => {\n const packageJsonString = await fs.readFile(path.resolve(dirname, '../package.json'), 'utf-8')\n const packageJson = JSON.parse(packageJsonString)\n const packageJsonLexicalVersion = packageJson.dependencies['lexical']\n\n expect(packageJsonLexicalVersion).toBe(lexicalTargetVersion)\n })\n})\n"],"mappings":"AACA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,OAAOC,IAAA,MAAU;AACjB,OAAOC,EAAA,MAAQ;AAEf,MAAMC,QAAA,GAAWH,aAAA,CAAcI,MAAA,CAAAC,IAAA,CAAYC,GAAG;AAC9C,MAAMC,OAAA,GAAUN,IAAA,CAAKM,OAAO,CAACJ,QAAA;AAE7BK,QAAA,CAAS,8BAA8B;EACrCC,EAAA,CAAG,uFAAuF;IACxF,MAAMC,iBAAA,GAAoB,MAAMR,EAAA,CAAGS,QAAQ,CAACV,IAAA,CAAKW,OAAO,CAACL,OAAA,EAAS,oBAAoB;IACtF,MAAMM,WAAA,GAAcC,IAAA,CAAKC,KAAK,CAACL,iBAAA;IAC/B,MAAMM,yBAAA,GAA4BH,WAAA,CAAYI,YAAY,CAAC,UAAU;IAErEC,MAAA,CAAOF,yBAAA,EAA2BG,IAAI,CAACpB,oBAAA;EACzC;AACF","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- "use client";import{c as Re,f as G,g as _,i as ke,j as we,k as Te,l as ve,m as De}from"./chunk-CIY6PKN6.js";import{a as Se,b as P}from"./chunk-3LGFOM34.js";import{jsx as F,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as nn,FieldError as rn,FieldLabel as sn,RenderCustomComponent as gt,useEditDepth as ln,useEffectEvent as an,useField as cn}from"@payloadcms/ui";import{mergeFieldStyles as un}from"@payloadcms/ui/shared";import ht,{useCallback as yt,useEffect as xt,useMemo as dn,useState as Et}from"react";import{ErrorBoundary as mn}from"react-error-boundary";import"./bundled.css";import{jsx as O}from"react/jsx-runtime";import{LexicalComposer as en}from"@lexical/react/LexicalComposer.js";import{useEditDepth as tn}from"@payloadcms/ui";import*as mt from"react";import{useMemo as on}from"react";import{c as $o}from"react/compiler-runtime";import{jsx as b,jsxs as oe}from"react/jsx-runtime";import{useLexicalComposerContext as Ko}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Ho}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as jo}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as zo}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Wo}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Yo,COMMAND_PRIORITY_LOW as ut,FOCUS_COMMAND as Go}from"lexical";import*as X from"react";import{useEffect as Vo,useState as Uo}from"react";import{jsx as Me}from"react/jsx-runtime";import"react";var K=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Me(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Me(o.Component,{clientProps:e});import{c as Pt}from"react/compiler-runtime";import{useLexicalComposerContext as St}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as Rt}from"@lexical/utils";import{$createNodeSelection as kt,$getEditor as Z,$getNearestNodeFromDOMNode as wt,$getSelection as re,$isDecoratorNode as H,$isElementNode as Ee,$isLineBreakNode as Tt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as vt,$isTextNode as Dt,$setSelection as Le,CLICK_COMMAND as Mt,COMMAND_PRIORITY_LOW as V,KEY_ARROW_DOWN_COMMAND as Bt,KEY_ARROW_UP_COMMAND as Lt,KEY_BACKSPACE_COMMAND as It,KEY_DELETE_COMMAND as At,SELECTION_CHANGE_COMMAND as _t}from"lexical";import{useEffect as Ot}from"react";function Ie(){let t=Pt(3),[e]=St(),o=Wt,r,n;return t[0]!==e?(r=()=>Rt(e.registerCommand(Mt,zt,V),e.registerCommand(At,o,V),e.registerCommand(It,o,V),e.registerCommand(_t,jt,V),e.registerCommand(Lt,Kt,V),e.registerCommand(Bt,Ft,V)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),Ot(r,n),null}function Ft(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(H(i)){let p=Z().getElementByKey(i.getKey());return p&&ee({element:p,node:i}),!0}if(!Ee(i))return!0;let l=i.getFirstDescendant()??i;return l&&(ne(l,se)?.selectEnd(),t.preventDefault()),!0}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,$t),c=n?.getNextSibling();if(!n||c!==Ae(n))return!1;if(H(c)){let i=Z().getElementByKey(c.getKey());if(i)return ee({element:i,node:c}),t.preventDefault(),!0}return!1}function $t(t){return Ae(t)!==null}function Kt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(H(i)){let p=Z().getElementByKey(i.getKey());return p?(ee({element:p,node:i}),t.preventDefault(),!0):!1}if(!Ee(i))return!1;let l=i.getLastDescendant()??i;return l?(ne(l,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Ht),c=n?.getPreviousSibling();if(!n||c!==_e(n))return!1;if(H(c)){let i=Z().getElementByKey(c.getKey());if(i)return ee({element:i,node:c}),t.preventDefault(),!0}return!1}function Ht(t){return _e(t)!==null}function jt(){let t=Vt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function zt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=Gt(t);if(!e)return!0;let{target:o}=t;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Le(null):ee(e),!0}function Wt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Yt),!0):!1}function Yt(t){t.remove()}function Gt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=wt(e);return H(o)?{element:e,node:o}:void 0}function Vt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return H(o)?{decorator:o,element:Z().getElementByKey(o.getKey())}:void 0}function ee({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=kt();o.add(e.getKey()),Le(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(H(t)&&!t.isInline())return!0;if(!Ee(t)||vt(t))return!1;let e=t.getFirstChild(),o=e===null||Tt(e)||Dt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function Ae(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function _e(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as Ce}from"react/jsx-runtime";import{useLexicalComposerContext as Zt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as eo}from"lexical";import*as Ke from"react";import{useCallback as to,useEffect as $e,useRef as oo,useState as no}from"react";import{createPortal as ro}from"react-dom";var U=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:l,left:u,right:p,top:h}=t.getBoundingClientRect(),a=h+window.scrollY,s=l+window.scrollY;if(o<a-c||o>s+c||e<u-n||e>p+n)return-1;(e<u||e>p)&&(i=e<u?e-u:e-p)}return i};import{$getNodeByKey as ae}from"lexical";function q(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function le(t){let e=(u,p)=>u?parseFloat(window.getComputedStyle(u)[p]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as Ut}from"lexical";function j(t){return t.getEditorState().read(()=>Ut().getChildrenKeys())}var qt=1,Jt=-1,Oe=0,B={props:null,result:null};function Qt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function J(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:l},startIndex:u=0,useEdgeAsDefault:p=!1}=t;if(o>0&&B.props&&B.result&&B.props.fuzzy===t.fuzzy&&B.props.horizontalOffset===t.horizontalOffset&&B.props.useEdgeAsDefault===t.useEdgeAsDefault&&Qt(B.props.point,t.point,o))return B.result;let h=e.getBoundingClientRect(),a=j(r),s={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(p){let m=r.getElementByKey(a[0]),y=r.getElementByKey(a[a.length-1]);if(m&&y){let[d,f]=[q(m),q(y)];if(l<d.top?(s.blockElem=m,s.distance=d.top-l,s.blockNode=ae(a[0]),s.foundAtIndex=0):l>f.bottom&&(s.distance=l-f.bottom,s.blockNode=ae(a[a.length-1]),s.blockElem=y,s.foundAtIndex=a.length-1),s?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let g=u,x=Oe;for(;g>=0&&g<a.length;){let m=a[g],y=r.getElementByKey(m);if(y===null)break;let d=new _(i+c,l),f=ve.fromDOMRect(q(y)),{marginBottom:E,marginTop:k}=le(y),R=f.generateNewRect({bottom:f.bottom+E,left:h.left,right:h.right,top:f.top-k}),{distance:S,isOnBottomSide:w,isOnTopSide:C}=R.distanceFromPoint(d);if(S===0){s.blockElem=y,s.blockNode=ae(m),s.foundAtIndex=g,s.distance=S,s.blockNode&&s.blockNode.getType()==="paragraph"&&s.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(s.blockElem=null,s.blockNode=null),s.isFoundNodeEmptyParagraph=!0);break}else n&&S<s.distance&&(s.blockElem=y,s.blockNode=ae(m),s.distance=S,s.foundAtIndex=g);x===Oe&&(C?x=Jt:w?x=qt:x=1/0),g+=x}}),B.props=t,B.result={blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph},{blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var Xt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Fe(t){if(!t||Xt.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function ue(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),l=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))u=n.top+8-l.top;else{let a=Fe(t)?parseInt(c.lineHeight,10):0;u=n.top+(a-i.height)/2-l.top}let h=r;e.style.opacity="1",e.style.transform=`translate(${h}px, ${u}px)`}var io="add-block-menu",de=1/0;function so(t){return t===0?1/0:de>=0&&de<t?de:Math.floor(t/2)}function lo(t,e,o){let r=e.parentElement,{editorConfig:n}=P(),c=n?.admin?.hideGutter?-24:12,i=oo(null),[l,u]=no(null);$e(()=>{function h(a){let s=a.target;if(!G(s))return;let g=U(r,a.pageX,a.pageY,s);if(g===-1){u(null);return}if(ce(s,io))return;let x=j(t),{blockElem:m,blockNode:y,foundAtIndex:d}=J({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-g,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:so(x.length),useEdgeAsDefault:!1});de=d,m&&y&&(l?.node!==y||l?.elem!==m)&&u({elem:m,node:y})}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,l]),$e(()=>{i.current&&l?.node&&ue(l?.elem,i.current,e,c)},[e,l,c]);let p=to(h=>{let a=l;a?.node&&(t.update(()=>{let s=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(s=!1),!s){let g=eo();a?.node.insertAfter(g),setTimeout(()=>{a={elem:t.getElementByKey(g.getKey()),node:g},u(a)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{t.dispatchCommand(we,{node:a?.node})},2),h.stopPropagation(),h.preventDefault())},[t,l]);return ro(Ce(Ke.Fragment,{children:Ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:h=>{p(h)},ref:i,type:"button",children:Ce("div",{className:o?"icon":""})})}),e)}function He(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=Zt();return lo(r,o,r._editable)}import{jsx as me,jsxs as co}from"react/jsx-runtime";import{useLexicalComposerContext as uo}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as We}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ye,$getNodeByKey as mo}from"lexical";import*as Je from"react";import{useEffect as be,useRef as fe,useState as Ge}from"react";import{createPortal as fo}from"react-dom";var je=0,ao=-24;var z=0;function ze(t,e,o,r,n,c,i,l,u,p=!1){let{height:h,top:a}=r.getBoundingClientRect(),{top:s,width:g}=i.getBoundingClientRect(),{marginBottom:x,marginTop:m}=le(r),y=a,d=c>=a+h/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(d&&n?.elem&&n?.elem===r.nextElementSibling||!d&&n?.elem&&n?.elem===r.previousElementSibling)&&(z++,z<200&&(f=!0));else{z++;let S=n?.boundingBox?.y,w=r.getBoundingClientRect().y;(d===n?.isBelow&&S===w||z<200)&&(f=!1)}if(f)return{isBelow:d,willStayInSamePosition:f};p?y+=h/2:d?y+=h+x/2:y-=m/2;let E=0;p||(d?E=-je:E=je);let k=y-s+E,R=ao-e;return o.style.width=`calc(${g}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${R}px, calc(${k}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?d?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),z=0,{isBelow:d,willStayInSamePosition:f}}var po="draggable-block-menu",Ve="application/x-lexical-drag-block",te=1/0;function Ue(t){return t===0?1/0:te>=0&&te<t?te:Math.floor(t/2)}function go(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function qe(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function ho(t,e,o){let r=e.parentElement,n=fe(null),c=fe(null),i=fe(null),l=fe(!1),[u,p]=Ge(null),[h,a]=Ge(null),{editorConfig:s}=P(),g=s?.admin?.hideGutter?-44:-8;be(()=>{function y(d){let f=d.target;if(!G(f))return;let E=U(r,d.pageX,d.pageY,f);if(E===-1){p(null);return}if(ce(f,po))return;let k=j(t),{blockElem:R,foundAtIndex:S,isFoundNodeEmptyParagraph:w}=J({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new _(d.x,d.y),startIndex:Ue(k.length),useEdgeAsDefault:!1,verbose:!1});te=S,!(!R&&!w)&&u!==R&&p(R)}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,u]),be(()=>{n.current&&ue(u,n.current,e,g)},[e,u,g]),be(()=>{function y(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{pageY:k,target:R}=f;if(!G(R))return!1;let S=U(r,f.pageX,f.pageY,R,100,50),w=j(t),{blockElem:C,foundAtIndex:W,isFoundNodeEmptyParagraph:I}=J({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-S,point:new _(f.x,f.y),startIndex:Ue(w.length),useEdgeAsDefault:!0,verbose:!0});te=W;let T=c.current;if(C===null||T===null)return!1;if(u!==C){let{isBelow:v,willStayInSamePosition:A}=ze(s?.admin?.hideGutter?"0px":"3rem",g+(s?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),T,C,h,k,e,f,i,I);f.preventDefault(),A||a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:v})}else h?.elem&&(qe(T,h.elem),a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:!1}));return!0}function d(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{dataTransfer:k,pageY:R,target:S}=f,w=k?.getData(Ve)||"";return t.update(()=>{let C=mo(w);if(!C||!G(S))return!1;let W=U(r,f.pageX,f.pageY,S,100,50),{blockElem:I,isFoundNodeEmptyParagraph:T}=J({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-W,point:new _(f.x,f.y),useEdgeAsDefault:!0});if(!I)return!1;let v=Ye(I);if(!v)return!1;if(v===C)return!0;let{height:A,top:he}=q(I),ye=R>=he+A/2+window.scrollY;T?(v.insertBefore(C),v.remove()):ye?v.insertAfter(C):v.insertBefore(C),u!==null&&p(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let Y=t.getElementByKey(C.getKey());setTimeout(()=>{let D=Y?.getBoundingClientRect();if(!D)return;let N=document.createElement("div");N.className="lexical-block-highlighter",N.style.backgroundColor="var(--theme-elevation-1000",N.style.transition="opacity 0.5s ease-in-out",N.style.zIndex="1",N.style.pointerEvents="none",N.style.boxSizing="border-box",N.style.borderRadius="4px",N.style.position="absolute",document.body.appendChild(N),N.style.opacity="0.1",N.style.height=`${D.height+8}px`,N.style.width=`${D.width+8}px`,N.style.top=`${D.top+window.scrollY-4}px`,N.style.left=`${D.left-4}px`,setTimeout(()=>{N.style.opacity="0",setTimeout(()=>{N.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",y),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",y),document.removeEventListener("drop",d)}},[r,g,e,t,h,u,s?.admin?.hideGutter]);function x(y){let d=y.dataTransfer;if(!d||!u)return;go(d,u);let f="";t.update(()=>{let E=Ye(u);E&&(f=E.getKey())}),l.current=!0,d.setData(Ve,f)}function m(){l.current=!1,h?.elem&&qe(c.current,h?.elem)}return fo(co(Je.Fragment,{children:[me("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:m,onDragStart:x,ref:n,children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:i})]}),e)}function Qe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=uo();return ho(r,o,r._editable)}import{c as yo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as xo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Eo,$getRoot as Co}from"lexical";import"react";var Xe="insert-paragraph-at-end",Ze=()=>{let t=yo(4),[e]=xo(),{editorConfig:o}=P();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(bo)},t[0]=e,t[1]=r):r=t[1];let n=r,c;return t[2]!==n?(c=Ne("div",{"aria-label":"Insert Paragraph",className:Xe,onClick:n,role:"button",tabIndex:0,children:Ne("div",{className:`${Xe}-inside`,children:Ne("span",{children:"+"})})}),t[2]=n,t[3]=c):c=t[3],c};function bo(){let t=Eo();Co().append(t),t.select()}import{c as No}from"react/compiler-runtime";import{useLexicalComposerContext as Po}from"@lexical/react/LexicalComposerContext";import*as et from"react";var tt=()=>{let t=No(4),{editorConfig:e}=P(),[o]=Po(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>Re(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),et.useEffect(r,n),null};import{jsx as Q,jsxs as nt}from"react/jsx-runtime";import{useLexicalComposerContext as Ro}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as rt}from"@payloadcms/ui";import{useCallback as ko,useMemo as wo,useState as To}from"react";import"react";import*as it from"react-dom";import{c as So}from"react/compiler-runtime";import"react";function ot(t,e){let o=So(4),{maxLength:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,l;return o[0]!==c||o[1]!==i||o[2]!==t?(l=u=>{let{query:p}=u,h="[^"+t+ke+"\\s]",s=new RegExp("(^|\\s|\\()(["+t+"]((?:"+h+"){0,"+c+"}))$").exec(p);if(s!==null){let g=s[1],x=s[3];if(x.length>=i)return{leadOffset:s.index+g.length,matchingString:x,replaceableString:s[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=l):l=o[3],l}var L="slash-menu-popup";function vo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=P(),{i18n:l}=rt(),u=`${L}__item ${L}__item-${e.key}`;t&&(u+=` ${L}__item--selected`);let p=e.key;return e.label&&(p=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:l,schemaPath:i}):e.label),p.length>25&&(p=p.substring(0,25)+"..."),nt("button",{"aria-selected":t,className:u,id:L+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&Q(e.Icon,{}),Q("span",{className:`${L}__item-text`,children:p})]},e.key)}function st({anchorElem:t=document.body}){let[e]=Ro(),[o,r]=To(null),{editorConfig:n}=P(),{i18n:c}=rt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:l}}=P(),u=ot("/",{minLength:0}),p=ko(()=>{let a=[];for(let s of n.features.slashMenu.dynamicGroups)if(o){let g=s({editor:e,queryString:o});a=a.concat(g)}return a},[e,o,n?.features]),h=wo(()=>{let a=[];for(let s of n?.features.slashMenu.groups??[])a.push(s);if(o){a=a.map(g=>{let x=g.items.filter(m=>{let y=m.key;return m.label&&(y=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):m.label),new RegExp(o,"gi").exec(y)?!0:m.keywords!=null?m.keywords.some(d=>new RegExp(o,"gi").exec(d)):!1});return x.length?{...g,items:x}:null}),a=a.filter(g=>g!=null);let s=p();for(let g of s){let x=a.find(m=>m.key===g.key);x?a=a.filter(m=>m.key!==g.key):x={...g,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,n?.features.slashMenu.groups,p,i,c,l]);return Q(Te,{anchorElem:t,groups:h,menuRenderFn:(a,{selectedItemKey:s,selectItemAndCleanUp:g,setSelectedItemKey:x})=>a.current&&h.length?it.createPortal(Q("div",{className:L,children:h.map(m=>{let y=m.key;return m.label&&i&&(y=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):m.label),nt("div",{className:`${L}__group ${L}__group-${m.key}`,children:[Q("div",{className:`${L}__group-title`,children:y}),m.items.map((d,f)=>Q(vo,{index:f,isSelected:s===d.key,item:d,onClick:()=>{x(d.key),g(d)},onMouseEnter:()=>{x(d.key)},ref:E=>{d.ref={current:E}}},d.key))]},m.key)})}),a.current):null,onQueryChange:r,triggerFn:u})}import{c as Do}from"react/compiler-runtime";import{useLexicalComposerContext as Mo}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Bo,TextNode as Lo}from"lexical";import{useEffect as Io}from"react";function lt(t){let e=Do(6),{features:o}=t,[r]=Mo(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=Ao(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Lo,l=>{i.forEach(u=>{l.hasFormat(u)&&l.toggleFormat(u)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let c;return e[3]!==r||e[4]!==o?(c=[r,o],e[3]=r,e[4]=o,e[5]=c):c=e[5],Io(n,c),null}function Ao(t){let e=Object.keys(Bo),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as _o}from"react/compiler-runtime";import{jsx as at}from"react/jsx-runtime";import{ContentEditable as Oo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Fo}from"@payloadcms/ui";import"react";function ct(t){let e=_o(7),{className:o,editorConfig:r}=t,{t:n}=Fo(),c;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let i;e[4]!==r?.admin?.placeholder||e[5]!==n?(i=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=i):i=e[6],c=at(Oo,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:at("p",{className:"editor-placeholder",children:i})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=c}else c=e[3];return c}var dt=t=>{let e=$o(19),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=P(),[l]=Ko(),[u,p]=Uo(null),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=m=>{m!==null&&p(m)},e[0]=h):h=e[0];let a=h,s,g;e[1]!==l||e[2]!==i?(s=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let m=()=>{i.focusEditor(i)},y=()=>{i.blurEditor(i)},d=l.registerCommand(Go,()=>(m(),!0),ut),f=l.registerCommand(Yo,()=>(y(),!0),ut);return()=>{d(),f(),i.parentEditor?.unregisterChild?.(i.uuid)}},g=[l,i],e[1]=l,e[2]=i,e[3]=s,e[4]=g):(s=e[3],g=e[4]),Vo(s,g);let x;if(e[5]!==l||e[6]!==o||e[7]!==r||e[8]!==u||e[9]!==n||e[10]!==c){let m;e[12]!==c?(m=(d,f,E)=>{(!E.has("focus")||E.size>1)&&c?.(d,f,E)},e[12]=c,e[13]=m):m=e[13];let y;e[14]!==l||e[15]!==o.features.plugins||e[16]!==u||e[17]!==n?(y=u&&oe(X.Fragment,{children:[!n&&l.isEditable()&&oe(X.Fragment,{children:[b(Qe,{anchorElem:u}),b(He,{anchorElem:u})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&n))return b(K,{anchorElem:u,clientProps:d.clientProps,plugin:d},d.key)}),l.isEditable()&&b(X.Fragment,{children:b(st,{anchorElem:u})})]}),e[14]=l,e[15]=o.features.plugins,e[16]=u,e[17]=n,e[18]=y):y=e[18],x=oe(X.Fragment,{children:[o.features.plugins?.map(qo),oe("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Jo),b(Wo,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:a,children:b(ct,{editorConfig:o})})}),ErrorBoundary:Ho}),b(Ze,{}),b(Ie,{}),b(lt,{features:o.features}),b(zo,{ignoreSelectionChange:!0,onChange:m}),y,l.isEditable()&&oe(X.Fragment,{children:[b(jo,{}),o?.features?.markdownTransformers?.length>0&&b(tt,{})]}),o.features.plugins?.map(Qo),o.features.plugins?.map(Xo)]}),o.features.plugins?.map(Zo)]}),e[5]=l,e[6]=o,e[7]=r,e[8]=u,e[9]=n,e[10]=c,e[11]=x}else x=e[11];return x};function qo(t){if(t.position==="aboveContainer")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Jo(t){if(t.position==="top")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Qo(t){if(t.position==="normal")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Xo(t){if(t.position==="bottom")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Zo(t){if(t.position==="belowContainer")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}var ft=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?O(o,{children:O(ft,{providers:e.slice(1),children:t})}):O(o,{children:t})},pt=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:l}=t,u=P(),p=tn(),h=mt.useRef(null),a=on(()=>{if(l&&typeof l!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(l));if(l&&Array.isArray(l)&&!("root"in l))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(l&&"jsonContent"in l)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:i!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:De({editorConfig:o}),onError:s=>{throw s},theme:o.lexical.theme}},[o]);return a?O(en,{initialConfig:a,children:O(Se,{editorConfig:o,editorContainerRef:h,fieldProps:r,parentContext:u?.editDepth===p?u:void 0,children:O(ft,{providers:o.features.providers,children:O(dt,{editorConfig:o,editorContainerRef:h,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",fn=t=>{let{editorConfig:e,field:o,field:{name:r,admin:{className:n,description:c,readOnly:i}={},label:l,localized:u,required:p},path:h,readOnly:a,validate:s}=t,g=a||i,x=h??r,m=ln(),y=yt((M,$)=>typeof s=="function"?s(M,{...$,required:p}):!0,[s,p]),{customComponents:{AfterInput:d,BeforeInput:f,Description:E,Error:k,Label:R}={},formInitializing:S,formProcessing:w,initialValue:C,setValue:W,showError:I,value:T}=cn({path:x,validate:y}),v=g||w||S,[A,he]=Et(!1),[Pe,ye]=Et(),xe=ht.useRef(C),Y=ht.useRef(T);xt(()=>{let M=()=>{let $=window.matchMedia("(max-width: 768px)").matches;$!==A&&he($)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[A]);let D=[pe,"field-type",n,I&&"error",v&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!A?`${pe}--show-gutter`:null].filter(Boolean).join(" "),N=`${x}.${m}`,Ct=yt(M=>{let $=M.toJSON();Y.current=$,W($)},[W]),bt=dn(()=>un(o),[o]),Nt=an(M=>{Y.current!==T&&JSON.stringify(Y.current)!==JSON.stringify(T)&&(xe.current=M,Y.current=T,ye(new Date))});return xt(()=>{Object.is(C,xe.current)||Nt(C)},[C]),ge("div",{className:D,style:bt,children:[F(gt,{CustomComponent:k,Fallback:F(rn,{path:x,showError:I})}),R||F(sn,{label:l,localized:u,path:x,required:p}),ge("div",{className:`${pe}__wrap`,children:[ge(mn,{fallbackRender:pn,onReset:()=>{},children:[f,F(pt,{composerKey:N,editorConfig:e,fieldProps:t,isSmallWidthViewport:A,onChange:Ct,readOnly:v,value:T},JSON.stringify({path:x,rerenderProviderKey:Pe})),d]}),E,F(gt,{CustomComponent:E,Fallback:F(nn,{description:c,path:x})})]})]},N)};function pn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var Ki=fn;export{Ki as RichText};
2
- //# sourceMappingURL=Field-ZQTPXWY3.js.map
1
+ "use client";import{c as Re,f as G,g as _,i as ke,j as we,k as Te,l as ve,m as De}from"./chunk-OZ6Q4DWN.js";import{a as Se,b as P}from"./chunk-3LGFOM34.js";import{jsx as F,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as nn,FieldError as rn,FieldLabel as sn,RenderCustomComponent as gt,useEditDepth as ln,useEffectEvent as an,useField as cn}from"@payloadcms/ui";import{mergeFieldStyles as un}from"@payloadcms/ui/shared";import ht,{useCallback as yt,useEffect as xt,useMemo as dn,useState as Et}from"react";import{ErrorBoundary as mn}from"react-error-boundary";import"./bundled.css";import{jsx as O}from"react/jsx-runtime";import{LexicalComposer as en}from"@lexical/react/LexicalComposer.js";import{useEditDepth as tn}from"@payloadcms/ui";import*as mt from"react";import{useMemo as on}from"react";import{c as $o}from"react/compiler-runtime";import{jsx as b,jsxs as oe}from"react/jsx-runtime";import{useLexicalComposerContext as Ko}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Ho}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as jo}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as zo}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Wo}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Yo,COMMAND_PRIORITY_LOW as ut,FOCUS_COMMAND as Go}from"lexical";import*as X from"react";import{useEffect as Vo,useState as Uo}from"react";import{jsx as Me}from"react/jsx-runtime";import"react";var K=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Me(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Me(o.Component,{clientProps:e});import{c as Pt}from"react/compiler-runtime";import{useLexicalComposerContext as St}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as Rt}from"@lexical/utils";import{$createNodeSelection as kt,$getEditor as Z,$getNearestNodeFromDOMNode as wt,$getSelection as re,$isDecoratorNode as H,$isElementNode as Ee,$isLineBreakNode as Tt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as vt,$isTextNode as Dt,$setSelection as Le,CLICK_COMMAND as Mt,COMMAND_PRIORITY_LOW as V,KEY_ARROW_DOWN_COMMAND as Bt,KEY_ARROW_UP_COMMAND as Lt,KEY_BACKSPACE_COMMAND as It,KEY_DELETE_COMMAND as At,SELECTION_CHANGE_COMMAND as _t}from"lexical";import{useEffect as Ot}from"react";function Ie(){let t=Pt(3),[e]=St(),o=Wt,r,n;return t[0]!==e?(r=()=>Rt(e.registerCommand(Mt,zt,V),e.registerCommand(At,o,V),e.registerCommand(It,o,V),e.registerCommand(_t,jt,V),e.registerCommand(Lt,Kt,V),e.registerCommand(Bt,Ft,V)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),Ot(r,n),null}function Ft(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(H(i)){let p=Z().getElementByKey(i.getKey());return p&&ee({element:p,node:i}),!0}if(!Ee(i))return!0;let l=i.getFirstDescendant()??i;return l&&(ne(l,se)?.selectEnd(),t.preventDefault()),!0}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,$t),c=n?.getNextSibling();if(!n||c!==Ae(n))return!1;if(H(c)){let i=Z().getElementByKey(c.getKey());if(i)return ee({element:i,node:c}),t.preventDefault(),!0}return!1}function $t(t){return Ae(t)!==null}function Kt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(H(i)){let p=Z().getElementByKey(i.getKey());return p?(ee({element:p,node:i}),t.preventDefault(),!0):!1}if(!Ee(i))return!1;let l=i.getLastDescendant()??i;return l?(ne(l,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Ht),c=n?.getPreviousSibling();if(!n||c!==_e(n))return!1;if(H(c)){let i=Z().getElementByKey(c.getKey());if(i)return ee({element:i,node:c}),t.preventDefault(),!0}return!1}function Ht(t){return _e(t)!==null}function jt(){let t=Vt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function zt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=Gt(t);if(!e)return!0;let{target:o}=t;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Le(null):ee(e),!0}function Wt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Yt),!0):!1}function Yt(t){t.remove()}function Gt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=wt(e);return H(o)?{element:e,node:o}:void 0}function Vt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return H(o)?{decorator:o,element:Z().getElementByKey(o.getKey())}:void 0}function ee({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=kt();o.add(e.getKey()),Le(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(H(t)&&!t.isInline())return!0;if(!Ee(t)||vt(t))return!1;let e=t.getFirstChild(),o=e===null||Tt(e)||Dt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function Ae(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function _e(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as Ce}from"react/jsx-runtime";import{useLexicalComposerContext as Zt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as eo}from"lexical";import*as Ke from"react";import{useCallback as to,useEffect as $e,useRef as oo,useState as no}from"react";import{createPortal as ro}from"react-dom";var U=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:l,left:u,right:p,top:h}=t.getBoundingClientRect(),a=h+window.scrollY,s=l+window.scrollY;if(o<a-c||o>s+c||e<u-n||e>p+n)return-1;(e<u||e>p)&&(i=e<u?e-u:e-p)}return i};import{$getNodeByKey as ae}from"lexical";function q(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function le(t){let e=(u,p)=>u?parseFloat(window.getComputedStyle(u)[p]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as Ut}from"lexical";function j(t){return t.getEditorState().read(()=>Ut().getChildrenKeys())}var qt=1,Jt=-1,Oe=0,B={props:null,result:null};function Qt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function J(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:l},startIndex:u=0,useEdgeAsDefault:p=!1}=t;if(o>0&&B.props&&B.result&&B.props.fuzzy===t.fuzzy&&B.props.horizontalOffset===t.horizontalOffset&&B.props.useEdgeAsDefault===t.useEdgeAsDefault&&Qt(B.props.point,t.point,o))return B.result;let h=e.getBoundingClientRect(),a=j(r),s={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(p){let m=r.getElementByKey(a[0]),y=r.getElementByKey(a[a.length-1]);if(m&&y){let[d,f]=[q(m),q(y)];if(l<d.top?(s.blockElem=m,s.distance=d.top-l,s.blockNode=ae(a[0]),s.foundAtIndex=0):l>f.bottom&&(s.distance=l-f.bottom,s.blockNode=ae(a[a.length-1]),s.blockElem=y,s.foundAtIndex=a.length-1),s?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let g=u,x=Oe;for(;g>=0&&g<a.length;){let m=a[g],y=r.getElementByKey(m);if(y===null)break;let d=new _(i+c,l),f=ve.fromDOMRect(q(y)),{marginBottom:E,marginTop:k}=le(y),R=f.generateNewRect({bottom:f.bottom+E,left:h.left,right:h.right,top:f.top-k}),{distance:S,isOnBottomSide:w,isOnTopSide:C}=R.distanceFromPoint(d);if(S===0){s.blockElem=y,s.blockNode=ae(m),s.foundAtIndex=g,s.distance=S,s.blockNode&&s.blockNode.getType()==="paragraph"&&s.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(s.blockElem=null,s.blockNode=null),s.isFoundNodeEmptyParagraph=!0);break}else n&&S<s.distance&&(s.blockElem=y,s.blockNode=ae(m),s.distance=S,s.foundAtIndex=g);x===Oe&&(C?x=Jt:w?x=qt:x=1/0),g+=x}}),B.props=t,B.result={blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph},{blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var Xt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Fe(t){if(!t||Xt.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function ue(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),l=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))u=n.top+8-l.top;else{let a=Fe(t)?parseInt(c.lineHeight,10):0;u=n.top+(a-i.height)/2-l.top}let h=r;e.style.opacity="1",e.style.transform=`translate(${h}px, ${u}px)`}var io="add-block-menu",de=1/0;function so(t){return t===0?1/0:de>=0&&de<t?de:Math.floor(t/2)}function lo(t,e,o){let r=e.parentElement,{editorConfig:n}=P(),c=n?.admin?.hideGutter?-24:12,i=oo(null),[l,u]=no(null);$e(()=>{function h(a){let s=a.target;if(!G(s))return;let g=U(r,a.pageX,a.pageY,s);if(g===-1){u(null);return}if(ce(s,io))return;let x=j(t),{blockElem:m,blockNode:y,foundAtIndex:d}=J({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-g,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:so(x.length),useEdgeAsDefault:!1});de=d,m&&y&&(l?.node!==y||l?.elem!==m)&&u({elem:m,node:y})}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,l]),$e(()=>{i.current&&l?.node&&ue(l?.elem,i.current,e,c)},[e,l,c]);let p=to(h=>{let a=l;a?.node&&(t.update(()=>{let s=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(s=!1),!s){let g=eo();a?.node.insertAfter(g),setTimeout(()=>{a={elem:t.getElementByKey(g.getKey()),node:g},u(a)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{t.dispatchCommand(we,{node:a?.node})},2),h.stopPropagation(),h.preventDefault())},[t,l]);return ro(Ce(Ke.Fragment,{children:Ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:h=>{p(h)},ref:i,type:"button",children:Ce("div",{className:o?"icon":""})})}),e)}function He(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=Zt();return lo(r,o,r._editable)}import{jsx as me,jsxs as co}from"react/jsx-runtime";import{useLexicalComposerContext as uo}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as We}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ye,$getNodeByKey as mo}from"lexical";import*as Je from"react";import{useEffect as be,useRef as fe,useState as Ge}from"react";import{createPortal as fo}from"react-dom";var je=0,ao=-24;var z=0;function ze(t,e,o,r,n,c,i,l,u,p=!1){let{height:h,top:a}=r.getBoundingClientRect(),{top:s,width:g}=i.getBoundingClientRect(),{marginBottom:x,marginTop:m}=le(r),y=a,d=c>=a+h/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(d&&n?.elem&&n?.elem===r.nextElementSibling||!d&&n?.elem&&n?.elem===r.previousElementSibling)&&(z++,z<200&&(f=!0));else{z++;let S=n?.boundingBox?.y,w=r.getBoundingClientRect().y;(d===n?.isBelow&&S===w||z<200)&&(f=!1)}if(f)return{isBelow:d,willStayInSamePosition:f};p?y+=h/2:d?y+=h+x/2:y-=m/2;let E=0;p||(d?E=-je:E=je);let k=y-s+E,R=ao-e;return o.style.width=`calc(${g}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${R}px, calc(${k}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?d?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),z=0,{isBelow:d,willStayInSamePosition:f}}var po="draggable-block-menu",Ve="application/x-lexical-drag-block",te=1/0;function Ue(t){return t===0?1/0:te>=0&&te<t?te:Math.floor(t/2)}function go(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function qe(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function ho(t,e,o){let r=e.parentElement,n=fe(null),c=fe(null),i=fe(null),l=fe(!1),[u,p]=Ge(null),[h,a]=Ge(null),{editorConfig:s}=P(),g=s?.admin?.hideGutter?-44:-8;be(()=>{function y(d){let f=d.target;if(!G(f))return;let E=U(r,d.pageX,d.pageY,f);if(E===-1){p(null);return}if(ce(f,po))return;let k=j(t),{blockElem:R,foundAtIndex:S,isFoundNodeEmptyParagraph:w}=J({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new _(d.x,d.y),startIndex:Ue(k.length),useEdgeAsDefault:!1,verbose:!1});te=S,!(!R&&!w)&&u!==R&&p(R)}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,u]),be(()=>{n.current&&ue(u,n.current,e,g)},[e,u,g]),be(()=>{function y(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{pageY:k,target:R}=f;if(!G(R))return!1;let S=U(r,f.pageX,f.pageY,R,100,50),w=j(t),{blockElem:C,foundAtIndex:W,isFoundNodeEmptyParagraph:I}=J({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-S,point:new _(f.x,f.y),startIndex:Ue(w.length),useEdgeAsDefault:!0,verbose:!0});te=W;let T=c.current;if(C===null||T===null)return!1;if(u!==C){let{isBelow:v,willStayInSamePosition:A}=ze(s?.admin?.hideGutter?"0px":"3rem",g+(s?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),T,C,h,k,e,f,i,I);f.preventDefault(),A||a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:v})}else h?.elem&&(qe(T,h.elem),a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:!1}));return!0}function d(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{dataTransfer:k,pageY:R,target:S}=f,w=k?.getData(Ve)||"";return t.update(()=>{let C=mo(w);if(!C||!G(S))return!1;let W=U(r,f.pageX,f.pageY,S,100,50),{blockElem:I,isFoundNodeEmptyParagraph:T}=J({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-W,point:new _(f.x,f.y),useEdgeAsDefault:!0});if(!I)return!1;let v=Ye(I);if(!v)return!1;if(v===C)return!0;let{height:A,top:he}=q(I),ye=R>=he+A/2+window.scrollY;T?(v.insertBefore(C),v.remove()):ye?v.insertAfter(C):v.insertBefore(C),u!==null&&p(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let Y=t.getElementByKey(C.getKey());setTimeout(()=>{let D=Y?.getBoundingClientRect();if(!D)return;let N=document.createElement("div");N.className="lexical-block-highlighter",N.style.backgroundColor="var(--theme-elevation-1000",N.style.transition="opacity 0.5s ease-in-out",N.style.zIndex="1",N.style.pointerEvents="none",N.style.boxSizing="border-box",N.style.borderRadius="4px",N.style.position="absolute",document.body.appendChild(N),N.style.opacity="0.1",N.style.height=`${D.height+8}px`,N.style.width=`${D.width+8}px`,N.style.top=`${D.top+window.scrollY-4}px`,N.style.left=`${D.left-4}px`,setTimeout(()=>{N.style.opacity="0",setTimeout(()=>{N.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",y),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",y),document.removeEventListener("drop",d)}},[r,g,e,t,h,u,s?.admin?.hideGutter]);function x(y){let d=y.dataTransfer;if(!d||!u)return;go(d,u);let f="";t.update(()=>{let E=Ye(u);E&&(f=E.getKey())}),l.current=!0,d.setData(Ve,f)}function m(){l.current=!1,h?.elem&&qe(c.current,h?.elem)}return fo(co(Je.Fragment,{children:[me("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:m,onDragStart:x,ref:n,children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:i})]}),e)}function Qe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=uo();return ho(r,o,r._editable)}import{c as yo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as xo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Eo,$getRoot as Co}from"lexical";import"react";var Xe="insert-paragraph-at-end",Ze=()=>{let t=yo(4),[e]=xo(),{editorConfig:o}=P();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(bo)},t[0]=e,t[1]=r):r=t[1];let n=r,c;return t[2]!==n?(c=Ne("div",{"aria-label":"Insert Paragraph",className:Xe,onClick:n,role:"button",tabIndex:0,children:Ne("div",{className:`${Xe}-inside`,children:Ne("span",{children:"+"})})}),t[2]=n,t[3]=c):c=t[3],c};function bo(){let t=Eo();Co().append(t),t.select()}import{c as No}from"react/compiler-runtime";import{useLexicalComposerContext as Po}from"@lexical/react/LexicalComposerContext";import*as et from"react";var tt=()=>{let t=No(4),{editorConfig:e}=P(),[o]=Po(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>Re(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),et.useEffect(r,n),null};import{jsx as Q,jsxs as nt}from"react/jsx-runtime";import{useLexicalComposerContext as Ro}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as rt}from"@payloadcms/ui";import{useCallback as ko,useMemo as wo,useState as To}from"react";import"react";import*as it from"react-dom";import{c as So}from"react/compiler-runtime";import"react";function ot(t,e){let o=So(4),{maxLength:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,l;return o[0]!==c||o[1]!==i||o[2]!==t?(l=u=>{let{query:p}=u,h="[^"+t+ke+"\\s]",s=new RegExp("(^|\\s|\\()(["+t+"]((?:"+h+"){0,"+c+"}))$").exec(p);if(s!==null){let g=s[1],x=s[3];if(x.length>=i)return{leadOffset:s.index+g.length,matchingString:x,replaceableString:s[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=l):l=o[3],l}var L="slash-menu-popup";function vo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=P(),{i18n:l}=rt(),u=`${L}__item ${L}__item-${e.key}`;t&&(u+=` ${L}__item--selected`);let p=e.key;return e.label&&(p=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:l,schemaPath:i}):e.label),p.length>25&&(p=p.substring(0,25)+"..."),nt("button",{"aria-selected":t,className:u,id:L+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&Q(e.Icon,{}),Q("span",{className:`${L}__item-text`,children:p})]},e.key)}function st({anchorElem:t=document.body}){let[e]=Ro(),[o,r]=To(null),{editorConfig:n}=P(),{i18n:c}=rt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:l}}=P(),u=ot("/",{minLength:0}),p=ko(()=>{let a=[];for(let s of n.features.slashMenu.dynamicGroups)if(o){let g=s({editor:e,queryString:o});a=a.concat(g)}return a},[e,o,n?.features]),h=wo(()=>{let a=[];for(let s of n?.features.slashMenu.groups??[])a.push(s);if(o){a=a.map(g=>{let x=g.items.filter(m=>{let y=m.key;return m.label&&(y=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):m.label),new RegExp(o,"gi").exec(y)?!0:m.keywords!=null?m.keywords.some(d=>new RegExp(o,"gi").exec(d)):!1});return x.length?{...g,items:x}:null}),a=a.filter(g=>g!=null);let s=p();for(let g of s){let x=a.find(m=>m.key===g.key);x?a=a.filter(m=>m.key!==g.key):x={...g,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,n?.features.slashMenu.groups,p,i,c,l]);return Q(Te,{anchorElem:t,groups:h,menuRenderFn:(a,{selectedItemKey:s,selectItemAndCleanUp:g,setSelectedItemKey:x})=>a.current&&h.length?it.createPortal(Q("div",{className:L,children:h.map(m=>{let y=m.key;return m.label&&i&&(y=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):m.label),nt("div",{className:`${L}__group ${L}__group-${m.key}`,children:[Q("div",{className:`${L}__group-title`,children:y}),m.items.map((d,f)=>Q(vo,{index:f,isSelected:s===d.key,item:d,onClick:()=>{x(d.key),g(d)},onMouseEnter:()=>{x(d.key)},ref:E=>{d.ref={current:E}}},d.key))]},m.key)})}),a.current):null,onQueryChange:r,triggerFn:u})}import{c as Do}from"react/compiler-runtime";import{useLexicalComposerContext as Mo}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Bo,TextNode as Lo}from"lexical";import{useEffect as Io}from"react";function lt(t){let e=Do(6),{features:o}=t,[r]=Mo(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=Ao(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Lo,l=>{i.forEach(u=>{l.hasFormat(u)&&l.toggleFormat(u)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let c;return e[3]!==r||e[4]!==o?(c=[r,o],e[3]=r,e[4]=o,e[5]=c):c=e[5],Io(n,c),null}function Ao(t){let e=Object.keys(Bo),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as _o}from"react/compiler-runtime";import{jsx as at}from"react/jsx-runtime";import{ContentEditable as Oo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Fo}from"@payloadcms/ui";import"react";function ct(t){let e=_o(7),{className:o,editorConfig:r}=t,{t:n}=Fo(),c;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let i;e[4]!==r?.admin?.placeholder||e[5]!==n?(i=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=i):i=e[6],c=at(Oo,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:at("p",{className:"editor-placeholder",children:i})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=c}else c=e[3];return c}var dt=t=>{let e=$o(19),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=P(),[l]=Ko(),[u,p]=Uo(null),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=m=>{m!==null&&p(m)},e[0]=h):h=e[0];let a=h,s,g;e[1]!==l||e[2]!==i?(s=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let m=()=>{i.focusEditor(i)},y=()=>{i.blurEditor(i)},d=l.registerCommand(Go,()=>(m(),!0),ut),f=l.registerCommand(Yo,()=>(y(),!0),ut);return()=>{d(),f(),i.parentEditor?.unregisterChild?.(i.uuid)}},g=[l,i],e[1]=l,e[2]=i,e[3]=s,e[4]=g):(s=e[3],g=e[4]),Vo(s,g);let x;if(e[5]!==l||e[6]!==o||e[7]!==r||e[8]!==u||e[9]!==n||e[10]!==c){let m;e[12]!==c?(m=(d,f,E)=>{(!E.has("focus")||E.size>1)&&c?.(d,f,E)},e[12]=c,e[13]=m):m=e[13];let y;e[14]!==l||e[15]!==o.features.plugins||e[16]!==u||e[17]!==n?(y=u&&oe(X.Fragment,{children:[!n&&l.isEditable()&&oe(X.Fragment,{children:[b(Qe,{anchorElem:u}),b(He,{anchorElem:u})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&n))return b(K,{anchorElem:u,clientProps:d.clientProps,plugin:d},d.key)}),l.isEditable()&&b(X.Fragment,{children:b(st,{anchorElem:u})})]}),e[14]=l,e[15]=o.features.plugins,e[16]=u,e[17]=n,e[18]=y):y=e[18],x=oe(X.Fragment,{children:[o.features.plugins?.map(qo),oe("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Jo),b(Wo,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:a,children:b(ct,{editorConfig:o})})}),ErrorBoundary:Ho}),b(Ze,{}),b(Ie,{}),b(lt,{features:o.features}),b(zo,{ignoreSelectionChange:!0,onChange:m}),y,l.isEditable()&&oe(X.Fragment,{children:[b(jo,{}),o?.features?.markdownTransformers?.length>0&&b(tt,{})]}),o.features.plugins?.map(Qo),o.features.plugins?.map(Xo)]}),o.features.plugins?.map(Zo)]}),e[5]=l,e[6]=o,e[7]=r,e[8]=u,e[9]=n,e[10]=c,e[11]=x}else x=e[11];return x};function qo(t){if(t.position==="aboveContainer")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Jo(t){if(t.position==="top")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Qo(t){if(t.position==="normal")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Xo(t){if(t.position==="bottom")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Zo(t){if(t.position==="belowContainer")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}var ft=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?O(o,{children:O(ft,{providers:e.slice(1),children:t})}):O(o,{children:t})},pt=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:l}=t,u=P(),p=tn(),h=mt.useRef(null),a=on(()=>{if(l&&typeof l!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(l));if(l&&Array.isArray(l)&&!("root"in l))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(l&&"jsonContent"in l)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:i!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:De({editorConfig:o}),onError:s=>{throw s},theme:o.lexical.theme}},[o]);return a?O(en,{initialConfig:a,children:O(Se,{editorConfig:o,editorContainerRef:h,fieldProps:r,parentContext:u?.editDepth===p?u:void 0,children:O(ft,{providers:o.features.providers,children:O(dt,{editorConfig:o,editorContainerRef:h,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",fn=t=>{let{editorConfig:e,field:o,field:{name:r,admin:{className:n,description:c,readOnly:i}={},label:l,localized:u,required:p},path:h,readOnly:a,validate:s}=t,g=a||i,x=h??r,m=ln(),y=yt((M,$)=>typeof s=="function"?s(M,{...$,required:p}):!0,[s,p]),{customComponents:{AfterInput:d,BeforeInput:f,Description:E,Error:k,Label:R}={},formInitializing:S,formProcessing:w,initialValue:C,setValue:W,showError:I,value:T}=cn({path:x,validate:y}),v=g||w||S,[A,he]=Et(!1),[Pe,ye]=Et(),xe=ht.useRef(C),Y=ht.useRef(T);xt(()=>{let M=()=>{let $=window.matchMedia("(max-width: 768px)").matches;$!==A&&he($)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[A]);let D=[pe,"field-type",n,I&&"error",v&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!A?`${pe}--show-gutter`:null].filter(Boolean).join(" "),N=`${x}.${m}`,Ct=yt(M=>{let $=M.toJSON();Y.current=$,W($)},[W]),bt=dn(()=>un(o),[o]),Nt=an(M=>{Y.current!==T&&JSON.stringify(Y.current)!==JSON.stringify(T)&&(xe.current=M,Y.current=T,ye(new Date))});return xt(()=>{Object.is(C,xe.current)||Nt(C)},[C]),ge("div",{className:D,style:bt,children:[F(gt,{CustomComponent:k,Fallback:F(rn,{path:x,showError:I})}),R||F(sn,{label:l,localized:u,path:x,required:p}),ge("div",{className:`${pe}__wrap`,children:[ge(mn,{fallbackRender:pn,onReset:()=>{},children:[f,F(pt,{composerKey:N,editorConfig:e,fieldProps:t,isSmallWidthViewport:A,onChange:Ct,readOnly:v,value:T},JSON.stringify({path:x,rerenderProviderKey:Pe})),d]}),E,F(gt,{CustomComponent:E,Fallback:F(nn,{description:c,path:x})})]})]},N)};function pn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var Ki=fn;export{Ki as RichText};
2
+ //# sourceMappingURL=Field-NNWFQETL.js.map