@payloadcms/richtext-lexical 4.0.0-internal.d1cc1d3 → 4.0.0-internal.d21c039

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 (177) hide show
  1. package/dist/exports/client/Field-QKAL7KMC.js +2 -0
  2. package/dist/exports/client/Field-QKAL7KMC.js.map +7 -0
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/chunk-LN6VX25I.js +2 -0
  5. package/dist/exports/client/{chunk-SSMQFWCQ.js.map → chunk-LN6VX25I.js.map} +4 -4
  6. package/dist/exports/client/index.js +26 -26
  7. package/dist/exports/client/index.js.map +4 -4
  8. package/dist/features/converters/lexicalToHtml/async/converters/heading.js +1 -1
  9. package/dist/features/converters/lexicalToHtml/async/converters/heading.js.map +1 -1
  10. package/dist/features/converters/lexicalToHtml/async/converters/list.d.ts.map +1 -1
  11. package/dist/features/converters/lexicalToHtml/async/converters/list.js +4 -3
  12. package/dist/features/converters/lexicalToHtml/async/converters/list.js.map +1 -1
  13. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.d.ts.map +1 -1
  14. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js +3 -2
  15. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js.map +1 -1
  16. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js +1 -1
  17. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js.map +1 -1
  18. package/dist/features/converters/lexicalToHtml/sync/converters/list.d.ts.map +1 -1
  19. package/dist/features/converters/lexicalToHtml/sync/converters/list.js +4 -3
  20. package/dist/features/converters/lexicalToHtml/sync/converters/list.js.map +1 -1
  21. package/dist/features/converters/lexicalToJSX/converter/converters/heading.d.ts.map +1 -1
  22. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +2 -1
  23. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
  24. package/dist/features/converters/lexicalToJSX/converter/converters/list.d.ts.map +1 -1
  25. package/dist/features/converters/lexicalToJSX/converter/converters/list.js +2 -1
  26. package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
  27. package/dist/features/heading/constants.d.ts +2 -0
  28. package/dist/features/heading/constants.d.ts.map +1 -0
  29. package/dist/features/heading/constants.js +2 -0
  30. package/dist/features/heading/constants.js.map +1 -0
  31. package/dist/features/heading/server/index.d.ts.map +1 -1
  32. package/dist/features/heading/server/index.js +5 -1
  33. package/dist/features/heading/server/index.js.map +1 -1
  34. package/dist/features/heading/server/validate.d.ts +6 -0
  35. package/dist/features/heading/server/validate.d.ts.map +1 -0
  36. package/dist/features/heading/server/validate.js +15 -0
  37. package/dist/features/heading/server/validate.js.map +1 -0
  38. package/dist/features/link/server/baseFields.d.ts.map +1 -1
  39. package/dist/features/link/server/baseFields.js +4 -5
  40. package/dist/features/link/server/baseFields.js.map +1 -1
  41. package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
  42. package/dist/features/lists/checklist/server/index.js +5 -2
  43. package/dist/features/lists/checklist/server/index.js.map +1 -1
  44. package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
  45. package/dist/features/lists/orderedList/server/index.js +5 -2
  46. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  47. package/dist/features/lists/shared/constants.d.ts +2 -0
  48. package/dist/features/lists/shared/constants.d.ts.map +1 -0
  49. package/dist/features/lists/shared/constants.js +2 -0
  50. package/dist/features/lists/shared/constants.js.map +1 -0
  51. package/dist/features/lists/shared/validate.d.ts +5 -0
  52. package/dist/features/lists/shared/validate.d.ts.map +1 -0
  53. package/dist/features/lists/shared/validate.js +15 -0
  54. package/dist/features/lists/shared/validate.js.map +1 -0
  55. package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
  56. package/dist/features/lists/unorderedList/server/index.js +5 -2
  57. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  58. package/dist/features/relationship/client/index.d.ts +2 -2
  59. package/dist/features/relationship/client/index.d.ts.map +1 -1
  60. package/dist/features/relationship/client/index.js.map +1 -1
  61. package/dist/features/relationship/client/plugins/index.d.ts +2 -2
  62. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  63. package/dist/features/relationship/client/plugins/index.js +27 -31
  64. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  65. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts +2 -4
  66. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
  67. package/dist/features/relationship/client/utils/useEnabledRelationships.js +53 -20
  68. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  69. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +2 -2
  70. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
  71. package/dist/features/relationship/server/graphQLPopulationPromise.js +2 -2
  72. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  73. package/dist/features/relationship/server/index.d.ts +8 -1
  74. package/dist/features/relationship/server/index.d.ts.map +1 -1
  75. package/dist/features/relationship/server/index.js +28 -11
  76. package/dist/features/relationship/server/index.js.map +1 -1
  77. package/dist/features/relationship/server/schema.d.ts +2 -2
  78. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  79. package/dist/features/relationship/server/schema.js +5 -10
  80. package/dist/features/relationship/server/schema.js.map +1 -1
  81. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +1 -6
  82. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -1
  83. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +3 -8
  84. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -1
  85. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts +8 -0
  86. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts.map +1 -0
  87. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js +19 -0
  88. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js.map +1 -0
  89. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
  90. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js +16 -43
  91. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  92. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts +8 -0
  93. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts.map +1 -0
  94. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js +80 -0
  95. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js.map +1 -0
  96. package/dist/features/toolbars/fixed/client/Toolbar/index.css +79 -5
  97. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  98. package/dist/features/toolbars/fixed/client/Toolbar/index.js +4 -1
  99. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  100. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +12 -11
  101. package/dist/features/upload/client/index.d.ts +3 -2
  102. package/dist/features/upload/client/index.d.ts.map +1 -1
  103. package/dist/features/upload/client/index.js.map +1 -1
  104. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  105. package/dist/features/upload/client/plugin/index.js +47 -52
  106. package/dist/features/upload/client/plugin/index.js.map +1 -1
  107. package/dist/features/upload/server/graphQLPopulationPromise.d.ts +2 -2
  108. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  109. package/dist/features/upload/server/graphQLPopulationPromise.js +1 -1
  110. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  111. package/dist/features/upload/server/index.d.ts +6 -2
  112. package/dist/features/upload/server/index.d.ts.map +1 -1
  113. package/dist/features/upload/server/index.js +18 -14
  114. package/dist/features/upload/server/index.js.map +1 -1
  115. package/dist/features/upload/server/schema.d.ts +2 -2
  116. package/dist/features/upload/server/schema.d.ts.map +1 -1
  117. package/dist/features/upload/server/schema.js +4 -8
  118. package/dist/features/upload/server/schema.js.map +1 -1
  119. package/dist/features/upload/server/validate.d.ts +2 -2
  120. package/dist/features/upload/server/validate.d.ts.map +1 -1
  121. package/dist/features/upload/server/validate.js +3 -0
  122. package/dist/features/upload/server/validate.js.map +1 -1
  123. package/dist/field/Diff/converters/listitem/index.d.ts.map +1 -1
  124. package/dist/field/Diff/converters/listitem/index.js +2 -1
  125. package/dist/field/Diff/converters/listitem/index.js.map +1 -1
  126. package/dist/field/Diff/index.css +19 -22
  127. package/dist/field/Diff/index.d.ts.map +1 -1
  128. package/dist/field/Diff/index.js +1 -0
  129. package/dist/field/Diff/index.js.map +1 -1
  130. package/dist/field/RenderLexical/index.d.ts +3 -1
  131. package/dist/field/RenderLexical/index.d.ts.map +1 -1
  132. package/dist/field/RenderLexical/index.js +23 -23
  133. package/dist/field/RenderLexical/index.js.map +1 -1
  134. package/dist/field/bundled.css +1 -1
  135. package/dist/field/index.css +14 -10
  136. package/dist/i18n.d.ts.map +1 -1
  137. package/dist/i18n.js +68 -0
  138. package/dist/i18n.js.map +1 -1
  139. package/dist/index.d.ts +1 -1
  140. package/dist/index.js +1 -1
  141. package/dist/index.js.map +1 -1
  142. package/dist/lexical/LexicalEditor.css +2 -2
  143. package/dist/lexical/LexicalEditor.js.map +1 -1
  144. package/dist/lexical/plugins/InsertParagraphAtEnd/index.css +16 -23
  145. package/dist/lexical/plugins/InsertParagraphAtEnd/index.d.ts.map +1 -1
  146. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +27 -14
  147. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  148. package/dist/lexical/theme/EditorTheme.css +25 -37
  149. package/dist/lexical/ui/ContentEditable.css +1 -0
  150. package/dist/lexical/ui/icons/H3/index.d.ts.map +1 -1
  151. package/dist/lexical/ui/icons/H3/index.js +13 -6
  152. package/dist/lexical/ui/icons/H3/index.js.map +1 -1
  153. package/dist/lexical/ui/icons/H4/index.d.ts.map +1 -1
  154. package/dist/lexical/ui/icons/H4/index.js +13 -6
  155. package/dist/lexical/ui/icons/H4/index.js.map +1 -1
  156. package/dist/lexical/ui/icons/H5/index.d.ts.map +1 -1
  157. package/dist/lexical/ui/icons/H5/index.js +13 -6
  158. package/dist/lexical/ui/icons/H5/index.js.map +1 -1
  159. package/dist/lexical/ui/icons/H6/index.d.ts.map +1 -1
  160. package/dist/lexical/ui/icons/H6/index.js +13 -6
  161. package/dist/lexical/ui/icons/H6/index.js.map +1 -1
  162. package/package.json +22 -22
  163. package/dist/dependencyChecker.spec.js +0 -16
  164. package/dist/dependencyChecker.spec.js.map +0 -1
  165. package/dist/exports/client/Field-IZKDIUJY.js +0 -2
  166. package/dist/exports/client/Field-IZKDIUJY.js.map +0 -7
  167. package/dist/exports/client/chunk-SSMQFWCQ.js +0 -2
  168. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js +0 -180
  169. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js.map +0 -1
  170. package/dist/features/link/markdownTransformer.spec.js +0 -195
  171. package/dist/features/link/markdownTransformer.spec.js.map +0 -1
  172. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js +0 -88
  173. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js.map +0 -1
  174. package/dist/lexical/utils/url.spec.js +0 -114
  175. package/dist/lexical/utils/url.spec.js.map +0 -1
  176. package/dist/utilities/jsx/jsx.spec.js +0 -178
  177. package/dist/utilities/jsx/jsx.spec.js.map +0 -1
@@ -11,10 +11,12 @@ import React, { useCallback, useEffect, useRef } from 'react';
11
11
  * @todo - replace this with a general utility that works for all fields. Maybe merge with packages/ui/src/forms/RenderFields/RenderField.tsx
12
12
  */
13
13
  export const RenderLexical = args => {
14
- const $ = _c(9);
14
+ const $ = _c(10);
15
15
  const {
16
+ name,
16
17
  field,
17
18
  initialValue,
19
+ label,
18
20
  Loading,
19
21
  path,
20
22
  schemaPath,
@@ -27,23 +29,20 @@ export const RenderLexical = args => {
27
29
  _internal_renderField
28
30
  } = serverFunctionContext;
29
31
  const [entityType, entitySlug] = schemaPath.split(".", 2);
30
- const fieldPath = path ?? (field && "name" in field ? field?.name : "") ?? "";
32
+ const fieldName = name !== undefined ? name : field?.name;
33
+ const fieldLabel = label !== undefined ? label : field?.label;
34
+ const fieldPath = path ?? fieldName ?? "";
31
35
  let t0;
32
- if ($[0] !== _internal_renderField || $[1] !== field || $[2] !== initialValue || $[3] !== path || $[4] !== schemaPath) {
36
+ if ($[0] !== _internal_renderField || $[1] !== fieldLabel || $[2] !== fieldName || $[3] !== initialValue || $[4] !== path || $[5] !== schemaPath) {
33
37
  t0 = () => {
34
38
  const render = async function render() {
35
39
  const {
36
40
  Field
37
41
  } = await _internal_renderField({
38
- field: {
39
- ...(field || {}),
40
- type: "richText",
41
- admin: {
42
- ...(field?.admin || {}),
43
- hidden: false
44
- }
45
- },
42
+ name: fieldName,
43
+ hidden: false,
46
44
  initialValue: initialValue ?? undefined,
45
+ label: typeof fieldLabel === "function" ? undefined : fieldLabel,
47
46
  path,
48
47
  schemaPath
49
48
  });
@@ -52,19 +51,20 @@ export const RenderLexical = args => {
52
51
  render();
53
52
  };
54
53
  $[0] = _internal_renderField;
55
- $[1] = field;
56
- $[2] = initialValue;
57
- $[3] = path;
58
- $[4] = schemaPath;
59
- $[5] = t0;
54
+ $[1] = fieldLabel;
55
+ $[2] = fieldName;
56
+ $[3] = initialValue;
57
+ $[4] = path;
58
+ $[5] = schemaPath;
59
+ $[6] = t0;
60
60
  } else {
61
- t0 = $[5];
61
+ t0 = $[6];
62
62
  }
63
63
  const renderLexical = t0;
64
64
  const mounted = useRef(false);
65
65
  let t1;
66
66
  let t2;
67
- if ($[6] !== renderLexical) {
67
+ if ($[7] !== renderLexical) {
68
68
  t1 = () => {
69
69
  if (mounted.current) {
70
70
  return;
@@ -73,12 +73,12 @@ export const RenderLexical = args => {
73
73
  renderLexical();
74
74
  };
75
75
  t2 = [renderLexical];
76
- $[6] = renderLexical;
77
- $[7] = t1;
78
- $[8] = t2;
76
+ $[7] = renderLexical;
77
+ $[8] = t1;
78
+ $[9] = t2;
79
79
  } else {
80
- t1 = $[7];
81
- t2 = $[8];
80
+ t1 = $[8];
81
+ t2 = $[9];
82
82
  }
83
83
  useEffect(t1, t2);
84
84
  if (!Component) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","FieldContext","FieldPathContext","ServerFunctionsContext","ShimmerEffect","useServerFunctions","React","useCallback","useEffect","useRef","RenderLexical","args","$","field","initialValue","Loading","path","schemaPath","setValue","value","Component","setComponent","useState","serverFunctionContext","_internal_renderField","entityType","entitySlug","split","fieldPath","name","t0","render","Field","type","admin","hidden","undefined","renderLexical","mounted","t1","t2","current","_jsx","adjustedServerFunctionContext","getFormState","getFormStateArgs","collectionSlug","globalSlug","children","fieldValue","disabled","formInitializing","formProcessing","formSubmitted","_temp","showError"],"sources":["../../../src/field/RenderLexical/index.tsx"],"sourcesContent":["'use client'\nimport type { RichTextField } from 'payload'\n\nimport {\n FieldContext,\n FieldPathContext,\n type FieldType,\n type RenderFieldServerFnArgs,\n ServerFunctionsContext,\n type ServerFunctionsContextType,\n ShimmerEffect,\n useServerFunctions,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useRef } from 'react'\n\nimport type { LexicalRichTextField } from '../../types/index.js'\nimport type { DefaultTypedEditorState } from '../../types/nodeTypes.js'\n\n/**\n * Utility to render a lexical editor on the client.\n *\n * @experimental - may break in minor releases\n * @todo - replace this with a general utility that works for all fields. Maybe merge with packages/ui/src/forms/RenderFields/RenderField.tsx\n */\nexport const RenderLexical: React.FC<\n /**\n * If value or setValue, or both, is provided, this component will manage its own value.\n * If neither is passed, it will rely on the parent form to manage the value.\n */\n {\n /**\n * Override the loading state while the field component is being fetched and rendered.\n */\n Loading?: React.ReactElement\n\n setValue?: FieldType<DefaultTypedEditorState | undefined>['setValue']\n value?: FieldType<DefaultTypedEditorState | undefined>['value']\n } & RenderFieldServerFnArgs<LexicalRichTextField>\n> = (args) => {\n const { field, initialValue, Loading, path, schemaPath, setValue, value } = args\n const [Component, setComponent] = React.useState<null | React.ReactNode>(null)\n const serverFunctionContext = useServerFunctions()\n const { _internal_renderField } = serverFunctionContext\n\n const [entityType, entitySlug] = schemaPath.split('.', 2)\n\n const fieldPath = path ?? (field && 'name' in field ? field?.name : '') ?? ''\n\n const renderLexical = useCallback(() => {\n async function render() {\n const { Field } = await _internal_renderField({\n field: {\n ...((field as RichTextField) || {}),\n type: 'richText',\n admin: {\n ...((field as RichTextField)?.admin || {}),\n // When using \"fake\" anchor fields, hidden is often set to true. We need to override that here to ensure the field is rendered.\n hidden: false,\n },\n },\n initialValue: initialValue ?? undefined,\n path,\n schemaPath,\n })\n\n setComponent(Field)\n }\n void render()\n }, [_internal_renderField, schemaPath, path, field, initialValue])\n\n const mounted = useRef(false)\n\n useEffect(() => {\n if (mounted.current) {\n return\n }\n mounted.current = true\n void renderLexical()\n }, [renderLexical])\n\n if (!Component) {\n return typeof Loading !== 'undefined' ? Loading : <ShimmerEffect />\n }\n\n /**\n * By default, the lexical will make form state requests (e.g. to get drawer fields), passing in the arguments\n * of the current field. However, we need to override those arguments to get it to make requests based on the\n * *target* field. The server only knows the schema map of the target field.\n */\n const adjustedServerFunctionContext: ServerFunctionsContextType = {\n ...serverFunctionContext,\n getFormState: async (getFormStateArgs) => {\n return serverFunctionContext.getFormState({\n ...getFormStateArgs,\n collectionSlug: entityType === 'collection' ? entitySlug : undefined,\n globalSlug: entityType === 'global' ? entitySlug : undefined,\n })\n },\n }\n\n if (typeof value === 'undefined' && !setValue) {\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n {Component}\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n }\n\n const fieldValue: FieldType<DefaultTypedEditorState | undefined> = {\n disabled: false,\n formInitializing: false,\n formProcessing: false,\n formSubmitted: false,\n initialValue: value,\n path: fieldPath,\n setValue: setValue ?? (() => undefined),\n showError: false,\n value,\n }\n\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n <FieldContext value={fieldValue}>{Component}</FieldContext>\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SACEC,YAAY,EACZC,gBAAgB,EAGhBC,sBAAsB,EAEtBC,aAAa,EACbC,kBAAkB,QACb;AACP,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ;AAKtD;;;;;;AAMA,OAAO,MAAMC,aAAA,GAcTC,IAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EACF;IAAAa,KAAA;IAAAC,YAAA;IAAAC,OAAA;IAAAC,IAAA;IAAAC,UAAA;IAAAC,QAAA;IAAAC;EAAA,IAA4ER,IAAA;EAC5E,OAAAS,SAAA,EAAAC,YAAA,IAAkCf,KAAA,CAAAgB,QAAA,KAAuC;EACzE,MAAAC,qBAAA,GAA8BlB,kBAAA;EAC9B;IAAAmB;EAAA,IAAkCD,qBAAA;EAElC,OAAAE,UAAA,EAAAC,UAAA,IAAiCT,UAAA,CAAAU,KAAA,CAAiB,MAAK;EAEvD,MAAAC,SAAA,GAAkBZ,IAAA,KAASH,KAAA,IAAS,UAAUA,KAAA,GAAQA,KAAA,EAAAgB,IAAA,GAAc,EAAC,KAAM;EAAA,IAAAC,EAAA;EAAA,IAAAlB,CAAA,QAAAY,qBAAA,IAAAZ,CAAA,QAAAC,KAAA,IAAAD,CAAA,QAAAE,YAAA,IAAAF,CAAA,QAAAI,IAAA,IAAAJ,CAAA,QAAAK,UAAA;IAEzCa,EAAA,GAAAA,CAAA;MAChC,MAAAC,MAAA,kBAAAA,OAAA;QACE;UAAAC;QAAA,UAAwBR,qBAAA;UAAAX,KAAA;YAAA,IAEhBA,KAAC,MAA6B;YAAAoB,IAAA,EAC5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,UAAA,GAAAU;IAAa,CACrD;EAAA;EAEJ,IAEI,OAAOjB,KAAA,KAAU,gBAAgBD,QAAA;IAAA,OAEjCwB,IAAA,CAAAvC,sBAAA;MAAAgB,KAAA;QAAA,GAAoCwB;MAA6B;MAAAK,QAAA,EAC/DN,IAAA,CAAAxC,gBAAA;QAAAiB,KAAA,EAAyCS,SAAA;QAAAoB,QAAA,EACtC5B;MAAA,GADoBQ,SAAA;IAAA,C;;EAO7B,MAAAqB,UAAA;IAAAC,QAAA;IAAAC,gBAAA;IAAAC,cAAA;IAAAC,aAAA;IAAAvC,YAAA,EAKgBK,KAAA;IAAAH,IAAA,EACRY,SAAA;IAAAV,QAAA,EACIA,QAAA,IAAAoC,KAA2B;IAAAC,SAAA;IAAApC;EAAA;EAGvC,OAGEuB,IAAA,CAAAvC,sBAAA;IAAAgB,KAAA;MAAA,GAAoCwB;IAA6B;IAAAK,QAAA,EAC/DN,IAAA,CAAAxC,gBAAA;MAAAiB,KAAA,EAAyCS,SAAA;MAAAoB,QAAA,EACvCN,IAAA,CAAAzC,YAAA;QAAAkB,KAAA,EAAqB8B,UAAA;QAAAD,QAAA,EAAa5B;MAAA,C;OADbQ,SAAA;EAAA,C;CAK7B;AA3FI,SAAA0B,MAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","FieldContext","FieldPathContext","ServerFunctionsContext","ShimmerEffect","useServerFunctions","React","useCallback","useEffect","useRef","RenderLexical","args","$","name","field","initialValue","label","Loading","path","schemaPath","setValue","value","Component","setComponent","useState","serverFunctionContext","_internal_renderField","entityType","entitySlug","split","fieldName","undefined","fieldLabel","fieldPath","t0","render","Field","hidden","renderLexical","mounted","t1","t2","current","_jsx","adjustedServerFunctionContext","getFormState","getFormStateArgs","collectionSlug","globalSlug","children","fieldValue","disabled","formInitializing","formProcessing","formSubmitted","_temp","showError"],"sources":["../../../src/field/RenderLexical/index.tsx"],"sourcesContent":["'use client'\nimport {\n FieldContext,\n FieldPathContext,\n type FieldType,\n type RenderFieldServerFnArgs,\n ServerFunctionsContext,\n type ServerFunctionsContextType,\n ShimmerEffect,\n useServerFunctions,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useRef } from 'react'\n\nimport type { LexicalRichTextField } from '../../types/index.js'\nimport type { DefaultTypedEditorState } from '../../types/nodeTypes.js'\n\n/**\n * Utility to render a lexical editor on the client.\n *\n * @experimental - may break in minor releases\n * @todo - replace this with a general utility that works for all fields. Maybe merge with packages/ui/src/forms/RenderFields/RenderField.tsx\n */\nexport const RenderLexical: React.FC<\n /**\n * If value or setValue, or both, is provided, this component will manage its own value.\n * If neither is passed, it will rely on the parent form to manage the value.\n */\n {\n /** @deprecated Use `name` and `label` instead. */\n field?: Partial<LexicalRichTextField>\n /**\n * Override the loading state while the field component is being fetched and rendered.\n */\n Loading?: React.ReactElement\n\n setValue?: FieldType<DefaultTypedEditorState | undefined>['setValue']\n value?: FieldType<DefaultTypedEditorState | undefined>['value']\n } & Omit<RenderFieldServerFnArgs, 'hidden'>\n> = (args) => {\n const { name, field, initialValue, label, Loading, path, schemaPath, setValue, value } = args\n const [Component, setComponent] = React.useState<null | React.ReactNode>(null)\n const serverFunctionContext = useServerFunctions()\n const { _internal_renderField } = serverFunctionContext\n\n const [entityType, entitySlug] = schemaPath.split('.', 2)\n\n const fieldName = name !== undefined ? name : field?.name\n const fieldLabel = label !== undefined ? label : field?.label\n const fieldPath = path ?? fieldName ?? ''\n\n const renderLexical = useCallback(() => {\n async function render() {\n const { Field } = await _internal_renderField({\n name: fieldName,\n // When using \"fake\" anchor fields, hidden is often set to true.\n // We need to override that here to ensure the field is rendered.\n hidden: false,\n initialValue: initialValue ?? undefined,\n label: typeof fieldLabel === 'function' ? undefined : fieldLabel,\n path,\n schemaPath,\n })\n\n setComponent(Field)\n }\n void render()\n }, [_internal_renderField, schemaPath, path, fieldName, fieldLabel, initialValue])\n\n const mounted = useRef(false)\n\n useEffect(() => {\n if (mounted.current) {\n return\n }\n mounted.current = true\n void renderLexical()\n }, [renderLexical])\n\n if (!Component) {\n return typeof Loading !== 'undefined' ? Loading : <ShimmerEffect />\n }\n\n /**\n * By default, the lexical will make form state requests (e.g. to get drawer fields), passing in the arguments\n * of the current field. However, we need to override those arguments to get it to make requests based on the\n * *target* field. The server only knows the schema map of the target field.\n */\n const adjustedServerFunctionContext: ServerFunctionsContextType = {\n ...serverFunctionContext,\n getFormState: async (getFormStateArgs) => {\n return serverFunctionContext.getFormState({\n ...getFormStateArgs,\n collectionSlug: entityType === 'collection' ? entitySlug : undefined,\n globalSlug: entityType === 'global' ? entitySlug : undefined,\n })\n },\n }\n\n if (typeof value === 'undefined' && !setValue) {\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n {Component}\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n }\n\n const fieldValue: FieldType<DefaultTypedEditorState | undefined> = {\n disabled: false,\n formInitializing: false,\n formProcessing: false,\n formSubmitted: false,\n initialValue: value,\n path: fieldPath,\n setValue: setValue ?? (() => undefined),\n showError: false,\n value,\n }\n\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n <FieldContext value={fieldValue}>{Component}</FieldContext>\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SACEC,YAAY,EACZC,gBAAgB,EAGhBC,sBAAsB,EAEtBC,aAAa,EACbC,kBAAkB,QACb;AACP,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ;AAKtD;;;;;;AAMA,OAAO,MAAMC,aAAA,GAgBTC,IAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EACF;IAAAa,IAAA;IAAAC,KAAA;IAAAC,YAAA;IAAAC,KAAA;IAAAC,OAAA;IAAAC,IAAA;IAAAC,UAAA;IAAAC,QAA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