@payloadcms/richtext-lexical 3.0.0-beta.133 → 3.0.0-beta.134

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 (119) hide show
  1. package/dist/exports/client/Field-S5G27AVI.js +2 -0
  2. package/dist/exports/client/Field-S5G27AVI.js.map +7 -0
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/chunk-2CYU43GM.js +2 -0
  5. package/dist/exports/client/chunk-2CYU43GM.js.map +7 -0
  6. package/dist/exports/client/chunk-C7S3V4EB.js +2 -0
  7. package/dist/exports/client/chunk-C7S3V4EB.js.map +7 -0
  8. package/dist/exports/client/chunk-U7O7EYCP.js +2 -0
  9. package/dist/exports/client/chunk-U7O7EYCP.js.map +7 -0
  10. package/dist/exports/client/component-H3EYQ5KG.js +2 -0
  11. package/dist/exports/client/{component-YICNYPTU.js.map → component-H3EYQ5KG.js.map} +1 -1
  12. package/dist/exports/client/componentInline-ZGO3K4TA.js +2 -0
  13. package/dist/exports/client/componentInline-ZGO3K4TA.js.map +7 -0
  14. package/dist/exports/client/index.d.ts +7 -0
  15. package/dist/exports/client/index.d.ts.map +1 -1
  16. package/dist/exports/client/index.js +7 -7
  17. package/dist/exports/client/index.js.map +4 -4
  18. package/dist/features/blocks/client/component/BlockContent.d.ts +34 -9
  19. package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
  20. package/dist/features/blocks/client/component/BlockContent.js +63 -158
  21. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  22. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +11 -0
  23. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -0
  24. package/dist/features/blocks/client/component/components/BlockCollapsible.js +37 -0
  25. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -0
  26. package/dist/features/blocks/client/component/components/BlockEditButton.d.ts +3 -0
  27. package/dist/features/blocks/client/component/components/BlockEditButton.d.ts.map +1 -0
  28. package/dist/features/blocks/client/component/components/BlockEditButton.js +22 -0
  29. package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -0
  30. package/dist/features/blocks/client/component/components/BlockRemoveButton.d.ts +3 -0
  31. package/dist/features/blocks/client/component/components/BlockRemoveButton.d.ts.map +1 -0
  32. package/dist/features/blocks/client/component/components/BlockRemoveButton.js +22 -0
  33. package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -0
  34. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  35. package/dist/features/blocks/client/component/index.js +242 -63
  36. package/dist/features/blocks/client/component/index.js.map +1 -1
  37. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts +5 -0
  38. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts.map +1 -0
  39. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +28 -0
  40. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -0
  41. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.d.ts +3 -0
  42. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.d.ts.map +1 -0
  43. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +22 -0
  44. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -0
  45. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.d.ts +3 -0
  46. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.d.ts.map +1 -0
  47. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +22 -0
  48. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -0
  49. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.d.ts +3 -0
  50. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.d.ts.map +1 -0
  51. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +22 -0
  52. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -0
  53. package/dist/features/blocks/client/componentInline/index.d.ts +13 -1
  54. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  55. package/dist/features/blocks/client/componentInline/index.js +219 -43
  56. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  57. package/dist/features/blocks/client/index.d.ts.map +1 -1
  58. package/dist/features/blocks/client/index.js +7 -10
  59. package/dist/features/blocks/client/index.js.map +1 -1
  60. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  61. package/dist/features/blocks/client/nodes/BlocksNode.js +1 -3
  62. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  63. package/dist/features/blocks/client/plugin/commands.d.ts +0 -4
  64. package/dist/features/blocks/client/plugin/commands.d.ts.map +1 -1
  65. package/dist/features/blocks/client/plugin/commands.js +0 -1
  66. package/dist/features/blocks/client/plugin/commands.js.map +1 -1
  67. package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
  68. package/dist/features/blocks/client/plugin/index.js +28 -135
  69. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  70. package/dist/features/blocks/server/index.d.ts.map +1 -1
  71. package/dist/features/blocks/server/index.js +28 -2
  72. package/dist/features/blocks/server/index.js.map +1 -1
  73. package/dist/features/typesClient.d.ts +1 -17
  74. package/dist/features/typesClient.d.ts.map +1 -1
  75. package/dist/features/typesClient.js.map +1 -1
  76. package/dist/field/Field.d.ts.map +1 -1
  77. package/dist/field/Field.js +163 -78
  78. package/dist/field/Field.js.map +1 -1
  79. package/dist/field/bundled.css +1 -1
  80. package/dist/field/rscEntry.d.ts.map +1 -1
  81. package/dist/field/rscEntry.js +23 -1
  82. package/dist/field/rscEntry.js.map +1 -1
  83. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  84. package/dist/lexical/LexicalProvider.js +9 -18
  85. package/dist/lexical/LexicalProvider.js.map +1 -1
  86. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  87. package/dist/lexical/config/client/sanitize.js +0 -12
  88. package/dist/lexical/config/client/sanitize.js.map +1 -1
  89. package/dist/types.d.ts +2 -0
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/types.js.map +1 -1
  92. package/dist/utilities/buildInitialState.d.ts +27 -0
  93. package/dist/utilities/buildInitialState.d.ts.map +1 -0
  94. package/dist/utilities/buildInitialState.js +53 -0
  95. package/dist/utilities/buildInitialState.js.map +1 -0
  96. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  97. package/dist/utilities/fieldsDrawer/DrawerContent.js +8 -5
  98. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  99. package/dist/utilities/fieldsDrawer/useLexicalDrawer.d.ts.map +1 -1
  100. package/dist/utilities/fieldsDrawer/useLexicalDrawer.js +8 -8
  101. package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
  102. package/package.json +6 -6
  103. package/dist/exports/client/Field-GWJ72IYP.js +0 -2
  104. package/dist/exports/client/Field-GWJ72IYP.js.map +0 -7
  105. package/dist/exports/client/chunk-D7PD5DUW.js +0 -2
  106. package/dist/exports/client/chunk-D7PD5DUW.js.map +0 -7
  107. package/dist/exports/client/chunk-XDEGE6I5.js +0 -2
  108. package/dist/exports/client/chunk-XDEGE6I5.js.map +0 -7
  109. package/dist/exports/client/chunk-YGRKYSDC.js +0 -2
  110. package/dist/exports/client/chunk-YGRKYSDC.js.map +0 -7
  111. package/dist/exports/client/component-KLNTKKNE.js +0 -2
  112. package/dist/exports/client/component-KLNTKKNE.js.map +0 -7
  113. package/dist/exports/client/component-YICNYPTU.js +0 -2
  114. package/dist/exports/client/componentInline-6RPSMLNJ.js +0 -2
  115. package/dist/exports/client/componentInline-6RPSMLNJ.js.map +0 -7
  116. package/dist/features/blocks/client/component/FormSavePlugin.d.ts +0 -11
  117. package/dist/features/blocks/client/component/FormSavePlugin.d.ts.map +0 -1
  118. package/dist/features/blocks/client/component/FormSavePlugin.js +0 -53
  119. package/dist/features/blocks/client/component/FormSavePlugin.js.map +0 -1
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
 
3
+ import { c as _c } from "react/compiler-runtime";
3
4
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
5
  import { FieldLabel, useEditDepth, useField, withCondition } from '@payloadcms/ui';
5
6
  import React, { useCallback } from 'react';
@@ -8,102 +9,185 @@ import { LexicalProvider } from '../lexical/LexicalProvider.js';
8
9
  import './bundled.css';
9
10
  const baseClass = 'rich-text-lexical';
10
11
  const RichTextComponent = props => {
12
+ const $ = _c(42);
11
13
  const {
12
14
  editorConfig,
13
- field: {
14
- name,
15
- admin: {
16
- className,
17
- readOnly: readOnlyFromAdmin,
18
- style,
19
- width
20
- } = {},
21
- label,
22
- localized,
23
- required
24
- },
15
+ field: t0,
25
16
  path: pathFromProps,
26
17
  readOnly: readOnlyFromTopLevelProps,
27
18
  validate
28
19
  } = props;
20
+ const {
21
+ name,
22
+ admin: t1,
23
+ label,
24
+ localized,
25
+ required
26
+ } = t0;
27
+ let t2;
28
+ if ($[0] !== t1) {
29
+ t2 = t1 === undefined ? {} : t1;
30
+ $[0] = t1;
31
+ $[1] = t2;
32
+ } else {
33
+ t2 = $[1];
34
+ }
35
+ const {
36
+ className,
37
+ readOnly: readOnlyFromAdmin,
38
+ style,
39
+ width
40
+ } = t2;
29
41
  const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin;
30
42
  const path = pathFromProps ?? name;
31
43
  const editDepth = useEditDepth();
32
- const memoizedValidate = useCallback((value, validationOptions) => {
33
- if (typeof validate === 'function') {
34
- return validate(value, {
35
- ...validationOptions,
36
- props,
37
- required
38
- });
39
- }
40
- },
41
- // Important: do not add props to the dependencies array.
42
- // This would cause an infinite loop and endless re-rendering.
43
- // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709
44
- [validate, required]);
44
+ let t3;
45
+ if ($[2] !== validate || $[3] !== required) {
46
+ t3 = (value, validationOptions) => {
47
+ if (typeof validate === "function") {
48
+ return validate(value, {
49
+ ...validationOptions,
50
+ required
51
+ });
52
+ }
53
+ };
54
+ $[2] = validate;
55
+ $[3] = required;
56
+ $[4] = t3;
57
+ } else {
58
+ t3 = $[4];
59
+ }
60
+ const memoizedValidate = t3;
61
+ let t4;
62
+ if ($[5] !== path || $[6] !== memoizedValidate) {
63
+ t4 = {
64
+ path,
65
+ validate: memoizedValidate
66
+ };
67
+ $[5] = path;
68
+ $[6] = memoizedValidate;
69
+ $[7] = t4;
70
+ } else {
71
+ t4 = $[7];
72
+ }
45
73
  const {
46
- customComponents: {
47
- AfterInput,
48
- BeforeInput,
49
- Description,
50
- Error,
51
- Label
52
- } = {},
74
+ customComponents: t5,
53
75
  formInitializing,
54
76
  formProcessing,
55
77
  initialValue,
56
78
  setValue,
57
79
  showError,
58
80
  value: value_0
59
- } = useField({
60
- path,
61
- // @ts-expect-error: TODO: Fix this
62
- validate: memoizedValidate
63
- });
81
+ } = useField(t4);
82
+ let t6;
83
+ if ($[8] !== t5) {
84
+ t6 = t5 === undefined ? {} : t5;
85
+ $[8] = t5;
86
+ $[9] = t6;
87
+ } else {
88
+ t6 = $[9];
89
+ }
90
+ const {
91
+ AfterInput,
92
+ BeforeInput,
93
+ Description,
94
+ Error,
95
+ Label
96
+ } = t6;
64
97
  const disabled = readOnlyFromProps || formProcessing || formInitializing;
65
- const classes = [baseClass, 'field-type', className, showError && 'error', disabled && `${baseClass}--read-only`, editorConfig?.admin?.hideGutter !== true ? `${baseClass}--show-gutter` : null].filter(Boolean).join(' ');
98
+ const t7 = showError && "error";
99
+ const t8 = disabled && `${baseClass}--read-only`;
100
+ const t9 = editorConfig?.admin?.hideGutter !== true ? `${baseClass}--show-gutter` : null;
101
+ let t10;
102
+ if ($[10] !== className || $[11] !== t7 || $[12] !== t8 || $[13] !== t9) {
103
+ t10 = [baseClass, "field-type", className, t7, t8, t9].filter(Boolean);
104
+ $[10] = className;
105
+ $[11] = t7;
106
+ $[12] = t8;
107
+ $[13] = t9;
108
+ $[14] = t10;
109
+ } else {
110
+ t10 = $[14];
111
+ }
112
+ const classes = t10.join(" ");
66
113
  const pathWithEditDepth = `${path}.${editDepth}`;
67
- return /*#__PURE__*/_jsxs("div", {
68
- className: classes,
69
- style: {
70
- ...style,
71
- width
72
- },
73
- children: [Error, Label || /*#__PURE__*/_jsx(FieldLabel, {
74
- label: label,
75
- localized: localized,
76
- required: required
77
- }), /*#__PURE__*/_jsxs("div", {
78
- className: `${baseClass}__wrap`,
79
- children: [/*#__PURE__*/_jsxs(ErrorBoundary, {
80
- fallbackRender: fallbackRender,
81
- onReset: () => {},
82
- children: [BeforeInput, /*#__PURE__*/_jsx(LexicalProvider, {
83
- composerKey: pathWithEditDepth,
84
- editorConfig: editorConfig,
85
- fieldProps: props,
86
- onChange: editorState => {
87
- let serializedEditorState = editorState.toJSON();
88
- // Transform state through save hooks
89
- if (editorConfig?.features?.hooks?.save?.length) {
90
- editorConfig.features.hooks.save.forEach(hook => {
91
- serializedEditorState = hook({
92
- incomingEditorState: serializedEditorState
93
- });
94
- });
95
- }
96
- setValue(serializedEditorState);
97
- },
98
- readOnly: disabled,
99
- value: value_0
100
- }, JSON.stringify({
101
- initialValue,
102
- path
103
- })), AfterInput]
104
- }), Description]
105
- })]
106
- }, pathWithEditDepth);
114
+ let t11;
115
+ if ($[15] !== setValue) {
116
+ t11 = editorState => {
117
+ setValue(editorState.toJSON());
118
+ };
119
+ $[15] = setValue;
120
+ $[16] = t11;
121
+ } else {
122
+ t11 = $[16];
123
+ }
124
+ const handleChange = t11;
125
+ let t12;
126
+ if ($[17] !== style || $[18] !== width || $[19] !== Label || $[20] !== label || $[21] !== localized || $[22] !== required || $[23] !== pathWithEditDepth || $[24] !== editorConfig || $[25] !== props || $[26] !== handleChange || $[27] !== disabled || $[28] !== value_0 || $[29] !== initialValue || $[30] !== path || $[31] !== BeforeInput || $[32] !== AfterInput || $[33] !== Description || $[34] !== Error || $[35] !== classes) {
127
+ let t13;
128
+ if ($[37] !== Label || $[38] !== label || $[39] !== localized || $[40] !== required) {
129
+ t13 = Label || _jsx(FieldLabel, {
130
+ label,
131
+ localized,
132
+ required
133
+ });
134
+ $[37] = Label;
135
+ $[38] = label;
136
+ $[39] = localized;
137
+ $[40] = required;
138
+ $[41] = t13;
139
+ } else {
140
+ t13 = $[41];
141
+ }
142
+ t12 = _jsxs("div", {
143
+ className: classes,
144
+ style: {
145
+ ...style,
146
+ width
147
+ },
148
+ children: [Error, t13, _jsxs("div", {
149
+ className: `${baseClass}__wrap`,
150
+ children: [_jsxs(ErrorBoundary, {
151
+ fallbackRender,
152
+ onReset: _temp,
153
+ children: [BeforeInput, _jsx(LexicalProvider, {
154
+ composerKey: pathWithEditDepth,
155
+ editorConfig,
156
+ fieldProps: props,
157
+ onChange: handleChange,
158
+ readOnly: disabled,
159
+ value: value_0
160
+ }, JSON.stringify({
161
+ initialValue,
162
+ path
163
+ })), AfterInput]
164
+ }), Description]
165
+ })]
166
+ }, pathWithEditDepth);
167
+ $[17] = style;
168
+ $[18] = width;
169
+ $[19] = Label;
170
+ $[20] = label;
171
+ $[21] = localized;
172
+ $[22] = required;
173
+ $[23] = pathWithEditDepth;
174
+ $[24] = editorConfig;
175
+ $[25] = props;
176
+ $[26] = handleChange;
177
+ $[27] = disabled;
178
+ $[28] = value_0;
179
+ $[29] = initialValue;
180
+ $[30] = path;
181
+ $[31] = BeforeInput;
182
+ $[32] = AfterInput;
183
+ $[33] = Description;
184
+ $[34] = Error;
185
+ $[35] = classes;
186
+ $[36] = t12;
187
+ } else {
188
+ t12 = $[36];
189
+ }
190
+ return t12;
107
191
  };
108
192
  function fallbackRender({
109
193
  error
@@ -123,4 +207,5 @@ function fallbackRender({
123
207
  });
124
208
  }
125
209
  export const RichText = withCondition(RichTextComponent);
210
+ function _temp() {}
126
211
  //# sourceMappingURL=Field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","names":["FieldLabel","useEditDepth","useField","withCondition","React","useCallback","ErrorBoundary","LexicalProvider","baseClass","RichTextComponent","props","editorConfig","field","name","admin","className","readOnly","readOnlyFromAdmin","style","width","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","formInitializing","formProcessing","initialValue","setValue","showError","disabled","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","_jsxs","_jsx","fallbackRender","onReset","composerKey","fieldProps","onChange","editorState","serializedEditorState","toJSON","features","hooks","save","length","forEach","hook","incomingEditorState","JSON","stringify","error","role","color","message","RichText"],"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { SerializedEditorState } from 'lexical'\n\nimport { FieldLabel, useEditDepth, useField, withCondition } from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\nimport './bundled.css'\nimport './index.scss'\nimport '../lexical/theme/EditorTheme.scss'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field: {\n name,\n admin: { className, readOnly: readOnlyFromAdmin, style, width } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n const path = pathFromProps ?? name\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, props, required })\n }\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n formInitializing,\n formProcessing,\n initialValue,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n path,\n // @ts-expect-error: TODO: Fix this\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || formProcessing || formInitializing\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true ? `${baseClass}--show-gutter` : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n return (\n <div\n className={classes}\n key={pathWithEditDepth}\n style={{\n ...style,\n width,\n }}\n >\n {Error}\n {Label || <FieldLabel label={label} localized={localized} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n key={JSON.stringify({ initialValue, path })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={(editorState) => {\n let serializedEditorState = editorState.toJSON()\n\n // Transform state through save hooks\n if (editorConfig?.features?.hooks?.save?.length) {\n editorConfig.features.hooks.save.forEach((hook) => {\n serializedEditorState = hook({ incomingEditorState: serializedEditorState })\n })\n }\n\n setValue(serializedEditorState)\n }}\n readOnly={disabled}\n value={value}\n />\n {AfterInput}\n </ErrorBoundary>\n {Description}\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }): React.ReactElement {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = withCondition(RichTextCom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;UACA1C,QAAA,EAAU2B,QAAA;UACVb,KAAA,EAAOA;WAdFqC,IAAA,CAAKC,SAAS,CAAC;UAAE5B,YAAA;UAAcjB;QAAK,KAgB1CU,UAAA;UAEFE,WAAA;;KAjCEc,iBAAA;AAqCX;AAEA,SAASG,eAAe;EAAEiB;AAAK,CAAE;EAC/B;EAEA,oBACEnB,KAAA,CAAC;IAAInC,SAAA,EAAU;IAAgBuD,IAAA,EAAK;4BAClCnB,IAAA,CAAC;gBAAE;qBACHA,IAAA,CAAC;MAAIjC,KAAA,EAAO;QAAEqD,KAAA,EAAO;MAAM;gBAAIF,KAAA,CAAMG;;;AAG3C;AAEA,OAAO,MAAMC,QAAA,GAAqCtE,aAAA,CAAcM,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"Field.js","names":["c","_c","FieldLabel","useEditDepth","useField","withCondition","React","useCallback","ErrorBoundary","LexicalProvider","baseClass","RichTextComponent","props","$","editorConfig","field","t0","path","pathFromProps","readOnly","readOnlyFromTopLevelProps","validate","name","admin","t1","label","localized","required","t2","undefined","className","readOnlyFromAdmin","style","width","readOnlyFromProps","editDepth","t3","value","validationOptions","memoizedValidate","t4","customComponents","t5","formInitializing","formProcessing","initialValue","setValue","showError","value_0","t6","AfterInput","BeforeInput","Description","Error","Label","disabled","t7","t8","t9","hideGutter","t10","filter","Boolean","classes","join","pathWithEditDepth","t11","editorState","toJSON","handleChange","t12","t13","_jsx","_jsxs","children","fallbackRender","onReset","_temp","composerKey","fieldProps","onChange","JSON","stringify","error","role","color","message","RichText"],"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\n\nimport { FieldLabel, useEditDepth, useField, withCondition } from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\nimport './bundled.css'\nimport './index.scss'\nimport '../lexical/theme/EditorTheme.scss'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field: {\n name,\n admin: { className, readOnly: readOnlyFromAdmin, style, width } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n const path = pathFromProps ?? name\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, required })\n }\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n formInitializing,\n formProcessing,\n initialValue,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n path,\n // @ts-expect-error: TODO: Fix this\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || formProcessing || formInitializing\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true ? `${baseClass}--show-gutter` : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n setValue(editorState.toJSON())\n },\n [setValue],\n )\n\n return (\n <div\n className={classes}\n key={pathWithEditDepth}\n style={{\n ...style,\n width,\n }}\n >\n {Error}\n {Label || <FieldLabel label={label} localized={localized} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n key={JSON.stringify({ initialValue, path })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n {AfterInput}\n </ErrorBoundary>\n {Description}\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }): React.ReactElement {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = withCondition(RichTextComponent)\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,UAAU,EAAEC,YAAY,EAAEC,QAAQ,EAAEC,aAAa,QAAQ;AAClE,OAAOC,KAAA,IAASC,WAAW,QAAQ;AACnC,SAASC,aAAa,QAAQ;AAK9B,SAASC,eAAe,QAAQ;AAChC,OAAO;AAIP,MAAMC,SAAA,GAAY;AAElB,MAAMC,iBAAA,GAIFC,KAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EACF;IAAAa,YAAA;IAAAC,KAAA,EAAAC,EAAA;IAAAC,IAAA,EAAAC,aAAA;IAAAC,QAAA,EAAAC,yBAAA;IAAAC;EAAA,IAYIT,KAAA;EAVK;IAAAU,IAAA;IAAAC,KAAA,EAAAC,EAAA;IAAAC,KAAA;IAAAC,SAAA;IAAAC;EAAA,IAAAX,EAMN;EAAA,IAAAY,EAAA;EAAA,IAAAf,CAAA,QAAAW,EAAA;IAJQI,EAAA,GAAAJ,EAA6D,KAAAK,SAAA,QAA7DL,EAA6D;IAAAX,CAAA,MAAAW,EAAA;IAAAX,CAAA,MAAAe,EAAA;EAAA;IAAAA,EAAA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