@payloadcms/richtext-lexical 3.59.0-internal.cb85185 → 3.59.0-internal.cf50e73

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 (205) hide show
  1. package/dist/exports/client/Field-EHRBYNHO.js +2 -0
  2. package/dist/exports/client/Field-EHRBYNHO.js.map +7 -0
  3. package/dist/exports/client/RelationshipComponent-APF3CN47.js +2 -0
  4. package/dist/exports/client/RelationshipComponent-APF3CN47.js.map +7 -0
  5. package/dist/exports/client/bundled.css +1 -1
  6. package/dist/exports/client/{chunk-TLQLXR6Q.js → chunk-2Y72RT72.js} +2 -2
  7. package/dist/exports/client/chunk-3BY5IZJD.js +2 -0
  8. package/dist/exports/client/chunk-3BY5IZJD.js.map +7 -0
  9. package/dist/exports/client/chunk-CYLMY5ZJ.js +2 -0
  10. package/dist/exports/client/chunk-CYLMY5ZJ.js.map +7 -0
  11. package/dist/exports/client/component-VDJI45F2.js +2 -0
  12. package/dist/exports/client/component-VDJI45F2.js.map +7 -0
  13. package/dist/exports/client/componentInline-7TPI7ZBC.js +2 -0
  14. package/dist/exports/client/index.d.ts +0 -3
  15. package/dist/exports/client/index.d.ts.map +1 -1
  16. package/dist/exports/client/index.js +10 -35
  17. package/dist/exports/client/index.js.map +4 -4
  18. package/dist/features/align/server/i18n.d.ts.map +1 -1
  19. package/dist/features/align/server/i18n.js +6 -0
  20. package/dist/features/align/server/i18n.js.map +1 -1
  21. package/dist/features/blockquote/server/i18n.d.ts.map +1 -1
  22. package/dist/features/blockquote/server/i18n.js +3 -0
  23. package/dist/features/blockquote/server/i18n.js.map +1 -1
  24. package/dist/features/blocks/client/component/BlockContent.d.ts +27 -52
  25. package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
  26. package/dist/features/blocks/client/component/BlockContent.js +51 -48
  27. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  28. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +9 -2
  29. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -1
  30. package/dist/features/blocks/client/component/components/BlockCollapsible.js +25 -7
  31. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  32. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  33. package/dist/features/blocks/client/component/index.js +56 -71
  34. package/dist/features/blocks/client/component/index.js.map +1 -1
  35. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  36. package/dist/features/blocks/client/componentInline/index.js +11 -13
  37. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  38. package/dist/features/blocks/client/index.d.ts.map +1 -1
  39. package/dist/features/blocks/client/index.js +0 -5
  40. package/dist/features/blocks/client/index.js.map +1 -1
  41. package/dist/features/blocks/client/markdownTransformer.d.ts +17 -0
  42. package/dist/features/blocks/client/markdownTransformer.d.ts.map +1 -0
  43. package/dist/features/blocks/client/markdownTransformer.js +144 -0
  44. package/dist/features/blocks/client/markdownTransformer.js.map +1 -0
  45. package/dist/features/blocks/server/i18n.d.ts.map +1 -1
  46. package/dist/features/blocks/server/i18n.js +47 -38
  47. package/dist/features/blocks/server/i18n.js.map +1 -1
  48. package/dist/features/blocks/server/index.js +1 -1
  49. package/dist/features/blocks/server/index.js.map +1 -1
  50. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
  51. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +1 -0
  52. package/dist/features/blocks/server/markdownTransformer.d.ts +22 -0
  53. package/dist/features/blocks/server/markdownTransformer.d.ts.map +1 -0
  54. package/dist/features/blocks/server/{markdown/markdownTransformer.js → markdownTransformer.js} +48 -6
  55. package/dist/features/blocks/server/markdownTransformer.js.map +1 -0
  56. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
  57. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +3 -5
  58. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  59. package/dist/features/heading/server/i18n.d.ts.map +1 -1
  60. package/dist/features/heading/server/i18n.js +3 -0
  61. package/dist/features/heading/server/i18n.js.map +1 -1
  62. package/dist/features/horizontalRule/server/i18n.d.ts.map +1 -1
  63. package/dist/features/horizontalRule/server/i18n.js +3 -0
  64. package/dist/features/horizontalRule/server/i18n.js.map +1 -1
  65. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  66. package/dist/features/indent/server/i18n.js +4 -0
  67. package/dist/features/indent/server/i18n.js.map +1 -1
  68. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  69. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +1 -3
  70. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  71. package/dist/features/link/server/i18n.d.ts.map +1 -1
  72. package/dist/features/link/server/i18n.js +4 -0
  73. package/dist/features/link/server/i18n.js.map +1 -1
  74. package/dist/features/lists/checklist/server/i18n.d.ts.map +1 -1
  75. package/dist/features/lists/checklist/server/i18n.js +3 -0
  76. package/dist/features/lists/checklist/server/i18n.js.map +1 -1
  77. package/dist/features/lists/orderedList/server/i18n.d.ts.map +1 -1
  78. package/dist/features/lists/orderedList/server/i18n.js +3 -0
  79. package/dist/features/lists/orderedList/server/i18n.js.map +1 -1
  80. package/dist/features/lists/unorderedList/server/i18n.d.ts.map +1 -1
  81. package/dist/features/lists/unorderedList/server/i18n.js +3 -0
  82. package/dist/features/lists/unorderedList/server/i18n.js.map +1 -1
  83. package/dist/features/paragraph/server/i18n.d.ts.map +1 -1
  84. package/dist/features/paragraph/server/i18n.js +4 -0
  85. package/dist/features/paragraph/server/i18n.js.map +1 -1
  86. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  87. package/dist/features/relationship/client/components/RelationshipComponent.js +9 -5
  88. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  89. package/dist/features/relationship/server/i18n.d.ts.map +1 -1
  90. package/dist/features/relationship/server/i18n.js +3 -0
  91. package/dist/features/relationship/server/i18n.js.map +1 -1
  92. package/dist/features/textState/i18n.d.ts.map +1 -1
  93. package/dist/features/textState/i18n.js +3 -0
  94. package/dist/features/textState/i18n.js.map +1 -1
  95. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  96. package/dist/features/toolbars/fixed/client/Toolbar/index.js +1 -7
  97. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  98. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  99. package/dist/features/toolbars/inline/client/Toolbar/index.js +1 -3
  100. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  101. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  102. package/dist/features/upload/client/component/index.js +5 -6
  103. package/dist/features/upload/client/component/index.js.map +1 -1
  104. package/dist/features/upload/server/i18n.d.ts.map +1 -1
  105. package/dist/features/upload/server/i18n.js +3 -0
  106. package/dist/features/upload/server/i18n.js.map +1 -1
  107. package/dist/field/bundled.css +1 -1
  108. package/dist/field/rscEntry.d.ts.map +1 -1
  109. package/dist/field/rscEntry.js +0 -2
  110. package/dist/field/rscEntry.js.map +1 -1
  111. package/dist/i18n.d.ts.map +1 -1
  112. package/dist/i18n.js +6 -0
  113. package/dist/i18n.js.map +1 -1
  114. package/dist/index.d.ts +0 -1
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +0 -1
  117. package/dist/index.js.map +1 -1
  118. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  119. package/dist/lexical/LexicalEditor.js +8 -10
  120. package/dist/lexical/LexicalEditor.js.map +1 -1
  121. package/dist/lexical/ui/icons/CodeBlock/index.d.ts.map +1 -1
  122. package/dist/lexical/ui/icons/CodeBlock/index.js +15 -10
  123. package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
  124. package/dist/utilities/buildInitialState.d.ts +0 -1
  125. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  126. package/dist/utilities/buildInitialState.js +0 -1
  127. package/dist/utilities/buildInitialState.js.map +1 -1
  128. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  129. package/dist/utilities/fieldsDrawer/DrawerContent.js +3 -7
  130. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  131. package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -2
  132. package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
  133. package/package.json +7 -7
  134. package/dist/exports/client/Field-RQHCQRLV.js +0 -2
  135. package/dist/exports/client/Field-RQHCQRLV.js.map +0 -7
  136. package/dist/exports/client/RelationshipComponent-TSIENULZ.js +0 -2
  137. package/dist/exports/client/RelationshipComponent-TSIENULZ.js.map +0 -7
  138. package/dist/exports/client/chunk-BQCXN3B4.js +0 -2
  139. package/dist/exports/client/chunk-BQCXN3B4.js.map +0 -7
  140. package/dist/exports/client/chunk-XNERFY6G.js +0 -2
  141. package/dist/exports/client/chunk-XNERFY6G.js.map +0 -7
  142. package/dist/exports/client/component-CYFKY3IL.js +0 -2
  143. package/dist/exports/client/component-CYFKY3IL.js.map +0 -7
  144. package/dist/exports/client/componentInline-NGTRUSGB.js +0 -2
  145. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +0 -6
  146. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +0 -1
  147. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +0 -24
  148. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +0 -1
  149. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +0 -6
  150. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +0 -1
  151. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +0 -20
  152. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +0 -1
  153. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +0 -12
  154. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +0 -1
  155. package/dist/features/blocks/client/markdown/markdownTransformer.js +0 -348
  156. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +0 -1
  157. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts +0 -5
  158. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +0 -1
  159. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +0 -156
  160. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +0 -1
  161. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts +0 -61
  162. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts.map +0 -1
  163. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +0 -99
  164. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +0 -1
  165. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts +0 -4
  166. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts.map +0 -1
  167. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +0 -17
  168. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +0 -1
  169. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts +0 -4
  170. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts.map +0 -1
  171. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +0 -26
  172. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +0 -1
  173. package/dist/features/blocks/premade/CodeBlock/converter.d.ts +0 -7
  174. package/dist/features/blocks/premade/CodeBlock/converter.d.ts.map +0 -1
  175. package/dist/features/blocks/premade/CodeBlock/converter.js +0 -46
  176. package/dist/features/blocks/premade/CodeBlock/converter.js.map +0 -1
  177. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts +0 -2
  178. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts.map +0 -1
  179. package/dist/features/blocks/premade/CodeBlock/converterClient.js +0 -4
  180. package/dist/features/blocks/premade/CodeBlock/converterClient.js.map +0 -1
  181. package/dist/features/blocks/premade/CodeBlock/index.d.ts +0 -7
  182. package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +0 -1
  183. package/dist/features/blocks/premade/CodeBlock/index.js +0 -52
  184. package/dist/features/blocks/premade/CodeBlock/index.js.map +0 -1
  185. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts +0 -6
  186. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts.map +0 -1
  187. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js +0 -27
  188. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js.map +0 -1
  189. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts +0 -7
  190. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts.map +0 -1
  191. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js +0 -22
  192. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js.map +0 -1
  193. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.d.ts.map +0 -1
  194. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +0 -1
  195. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +0 -15
  196. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +0 -1
  197. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +0 -1
  198. package/dist/lexical/ui/icons/Collapse/index.d.ts +0 -3
  199. package/dist/lexical/ui/icons/Collapse/index.d.ts.map +0 -1
  200. package/dist/lexical/ui/icons/Collapse/index.js +0 -18
  201. package/dist/lexical/ui/icons/Collapse/index.js.map +0 -1
  202. /package/dist/exports/client/{chunk-TLQLXR6Q.js.map → chunk-2Y72RT72.js.map} +0 -0
  203. /package/dist/exports/client/{componentInline-NGTRUSGB.js.map → componentInline-7TPI7ZBC.js.map} +0 -0
  204. /package/dist/features/blocks/server/{markdown/linesFromMatchToContentAndPropsString.d.ts → linesFromMatchToContentAndPropsString.d.ts} +0 -0
  205. /package/dist/features/blocks/server/{markdown/linesFromMatchToContentAndPropsString.js → linesFromMatchToContentAndPropsString.js} +0 -0
@@ -7,7 +7,6 @@ import { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from
7
7
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
8
8
  const baseClass = 'lexical-block';
9
9
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
10
- import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
11
10
  import { getTranslation } from '@payloadcms/translations';
12
11
  import { $getNodeByKey } from 'lexical';
13
12
  import { v4 as uuid } from 'uuid';
@@ -33,6 +32,8 @@ export const BlockComponent = props => {
33
32
  featureClientSchemaMap,
34
33
  field: parentLexicalRichTextField,
35
34
  initialLexicalFormState,
35
+ permissions,
36
+ readOnly,
36
37
  schemaPath
37
38
  },
38
39
  uuid: uuidFromContext
@@ -61,12 +62,10 @@ export const BlockComponent = props => {
61
62
  setDocFieldPreferences
62
63
  } = useDocumentInfo();
63
64
  const [editor] = useLexicalComposerContext();
64
- const isEditable = useLexicalEditable();
65
- const blockType = formData.blockType;
66
65
  const {
67
66
  getFormState
68
67
  } = useServerFunctions();
69
- const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`;
68
+ const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}.fields`;
70
69
  const [initialState, setInitialState] = React.useState(() => {
71
70
  return initialLexicalFormState?.[formData.id]?.formState ? {
72
71
  ...initialLexicalFormState?.[formData.id]?.formState,
@@ -92,10 +91,10 @@ export const BlockComponent = props => {
92
91
  }, [cacheBuster]);
93
92
  const [CustomLabel, setCustomLabel] = React.useState(
94
93
  // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
95
- initialState?.['_components']?.customComponents?.BlockLabel ?? undefined);
94
+ initialState?.['_components']?.customComponents?.BlockLabel);
96
95
  const [CustomBlock, setCustomBlock] = React.useState(
97
96
  // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
98
- initialState?.['_components']?.customComponents?.Block ?? undefined);
97
+ initialState?.['_components']?.customComponents?.Block);
99
98
  // Initial state for newly created blocks
100
99
  useEffect(() => {
101
100
  const abortController = new AbortController();
@@ -119,7 +118,6 @@ export const BlockComponent = props => {
119
118
  globalSlug,
120
119
  initialBlockData: formData,
121
120
  operation: 'update',
122
- readOnly: !isEditable,
123
121
  renderAllFields: true,
124
122
  schemaPath: schemaFieldsPath,
125
123
  signal: abortController.signal
@@ -137,13 +135,13 @@ export const BlockComponent = props => {
137
135
  const node = $getNodeByKey(nodeKey);
138
136
  if (node && $isBlockNode(node)) {
139
137
  const newData = newFormStateData;
140
- newData.blockType = blockType;
138
+ newData.blockType = formData.blockType;
141
139
  node.setFields(newData, true);
142
140
  }
143
141
  });
144
142
  setInitialState(state);
145
- setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined);
146
- setCustomBlock(state._components?.customComponents?.Block ?? undefined);
143
+ setCustomLabel(state._components?.customComponents?.BlockLabel);
144
+ setCustomBlock(state._components?.customComponents?.Block);
147
145
  }
148
146
  };
149
147
  if (formData && !initialState) {
@@ -152,9 +150,9 @@ export const BlockComponent = props => {
152
150
  return () => {
153
151
  abortAndIgnore(abortController);
154
152
  };
155
- }, [getFormState, schemaFieldsPath, isEditable, id, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields, blockType]);
153
+ }, [getFormState, schemaFieldsPath, id, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
156
154
  const [isCollapsed, setIsCollapsed] = React.useState(initialLexicalFormState?.[formData.id]?.collapsed ?? false);
157
- const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`;
155
+ const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}`;
158
156
  const clientSchemaMap = featureClientSchemaMap['blocks'];
159
157
  const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
160
158
  const clientBlock = blocksField.blockReferences ? typeof blocksField?.blockReferences?.[0] === 'string' ? config.blocksMap[blocksField?.blockReferences?.[0]] : blocksField?.blockReferences?.[0] : blocksField?.blocks?.[0];
@@ -183,7 +181,6 @@ export const BlockComponent = props => {
183
181
  globalSlug,
184
182
  initialBlockFormState: prevFormState,
185
183
  operation: 'update',
186
- readOnly: !isEditable,
187
184
  renderAllFields: submit ? true : false,
188
185
  schemaPath: schemaFieldsPath,
189
186
  signal: controller.signal
@@ -202,14 +199,14 @@ export const BlockComponent = props => {
202
199
  const node_0 = $getNodeByKey(nodeKey);
203
200
  if (node_0 && $isBlockNode(node_0)) {
204
201
  const newData_0 = newFormStateData_0;
205
- newData_0.blockType = blockType;
202
+ newData_0.blockType = formData.blockType;
206
203
  node_0.setFields(newData_0, true);
207
204
  }
208
205
  });
209
206
  }, 0);
210
207
  if (submit) {
211
- setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined);
212
- setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined);
208
+ setCustomLabel(newFormState._components?.customComponents?.BlockLabel);
209
+ setCustomBlock(newFormState._components?.customComponents?.Block);
213
210
  let rowErrorCount = 0;
214
211
  for (const formField of Object.values(newFormState)) {
215
212
  if (formField?.valid === false) {
@@ -219,7 +216,7 @@ export const BlockComponent = props => {
219
216
  setErrorCount(rowErrorCount);
220
217
  }
221
218
  return newFormState;
222
- }, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, blockType, parentDocumentFields, isEditable, editor, nodeKey]);
219
+ }, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, formData.blockType, parentDocumentFields, editor, nodeKey]);
223
220
  useEffect(() => {
224
221
  return () => {
225
222
  abortAndIgnore(onChangeAbortControllerRef.current);
@@ -254,7 +251,7 @@ export const BlockComponent = props => {
254
251
  const EditButton = useMemo(() => () => /*#__PURE__*/_jsx(Button, {
255
252
  buttonStyle: "icon-label",
256
253
  className: `${baseClass}__editButton`,
257
- disabled: !isEditable,
254
+ disabled: readOnly,
258
255
  el: "button",
259
256
  icon: "edit",
260
257
  onClick: e => {
@@ -273,11 +270,11 @@ export const BlockComponent = props => {
273
270
  tooltip: t('lexical:blocks:inlineBlocks:edit', {
274
271
  label: blockDisplayName
275
272
  })
276
- }), [blockDisplayName, t, isEditable, toggleDrawer]);
273
+ }), [blockDisplayName, readOnly, t, toggleDrawer]);
277
274
  const RemoveButton = useMemo(() => () => /*#__PURE__*/_jsx(Button, {
278
275
  buttonStyle: "icon-label",
279
276
  className: `${baseClass}__removeButton`,
280
- disabled: !isEditable,
277
+ disabled: parentLexicalRichTextField?.admin?.readOnly || false,
281
278
  icon: "x",
282
279
  onClick: e_1 => {
283
280
  e_1.preventDefault();
@@ -285,65 +282,53 @@ export const BlockComponent = props => {
285
282
  },
286
283
  round: true,
287
284
  tooltip: "Remove Block"
288
- }), [isEditable, removeBlock]);
285
+ }), [parentLexicalRichTextField?.admin?.readOnly, removeBlock]);
289
286
  const BlockCollapsible = useMemo(() => ({
290
- Actions,
291
287
  children,
292
- className,
293
- collapsibleProps,
294
288
  disableBlockName,
295
289
  editButton,
296
290
  errorCount: errorCount_0,
297
291
  fieldHasErrors,
298
292
  Label,
299
- Pill: CustomPill,
300
293
  removeButton
301
- }) => {
302
- return /*#__PURE__*/_jsx("div", {
303
- className: baseClass + ' ' + baseClass + '-' + blockType,
304
- children: /*#__PURE__*/_jsx(Collapsible, {
305
- className: [`${baseClass}__row`, fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`, className].filter(Boolean).join(' '),
306
- collapsibleStyle: fieldHasErrors ? 'error' : 'default',
307
- header: /*#__PURE__*/_jsxs("div", {
308
- className: `${baseClass}__block-header`,
309
- children: [typeof Label !== 'undefined' ? Label : typeof CustomLabel !== 'undefined' ? CustomLabel : /*#__PURE__*/_jsxs("div", {
310
- className: `${baseClass}__block-label`,
311
- children: [typeof CustomPill !== 'undefined' ? CustomPill : /*#__PURE__*/_jsx(Pill, {
312
- className: `${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`,
313
- pillStyle: "white",
314
- size: "small",
315
- children: blockDisplayName ?? blockType
316
- }), !disableBlockName && !clientBlock?.admin?.disableBlockName && /*#__PURE__*/_jsx(SectionTitle, {
317
- path: "blockName",
318
- readOnly: !isEditable
319
- }), fieldHasErrors && /*#__PURE__*/_jsx(ErrorPill, {
320
- count: errorCount_0 ?? 0,
321
- i18n: i18n,
322
- withMessage: true
323
- })]
324
- }), /*#__PURE__*/_jsx("div", {
325
- className: `${baseClass}__block-actions`,
326
- children: typeof Actions !== 'undefined' ? Actions : /*#__PURE__*/_jsxs(_Fragment, {
327
- children: [CustomBlock && editButton !== false || !CustomBlock && editButton ? /*#__PURE__*/_jsx(EditButton, {}) : null, removeButton !== false && isEditable ? /*#__PURE__*/_jsx(RemoveButton, {}) : null]
328
- })
294
+ }) => /*#__PURE__*/_jsx("div", {
295
+ className: baseClass + ' ' + baseClass + '-' + formData.blockType,
296
+ children: /*#__PURE__*/_jsx(Collapsible, {
297
+ className: [`${baseClass}__row`, fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`].join(' '),
298
+ collapsibleStyle: fieldHasErrors ? 'error' : 'default',
299
+ header: /*#__PURE__*/_jsxs("div", {
300
+ className: `${baseClass}__block-header`,
301
+ children: [Label ?? CustomLabel ? Label ?? CustomLabel : /*#__PURE__*/_jsxs("div", {
302
+ children: [/*#__PURE__*/_jsx(Pill, {
303
+ className: `${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`,
304
+ pillStyle: "white",
305
+ size: "small",
306
+ children: blockDisplayName ?? formData?.blockType
307
+ }), !disableBlockName && !clientBlock?.admin?.disableBlockName && /*#__PURE__*/_jsx(SectionTitle, {
308
+ path: "blockName",
309
+ readOnly: parentLexicalRichTextField?.admin?.readOnly || false
310
+ }), fieldHasErrors && /*#__PURE__*/_jsx(ErrorPill, {
311
+ count: errorCount_0 ?? 0,
312
+ i18n: i18n,
313
+ withMessage: true
329
314
  })]
330
- }),
331
- isCollapsed: isCollapsed,
332
- onToggle: incomingCollapsedState => {
333
- onCollapsedChange(incomingCollapsedState);
334
- setIsCollapsed(incomingCollapsedState);
335
- },
336
- ...(collapsibleProps || {}),
337
- children: children
338
- }, 0)
339
- });
340
- }, [CustomBlock, CustomLabel, EditButton, RemoveButton, blockDisplayName, clientBlock?.admin?.disableBlockName, blockType, i18n, isCollapsed, onCollapsedChange, isEditable]);
341
- const blockID = formData?.id;
315
+ }), /*#__PURE__*/_jsxs("div", {
316
+ children: [CustomBlock && editButton !== false || !CustomBlock && editButton ? /*#__PURE__*/_jsx(EditButton, {}) : null, removeButton !== false && editor.isEditable() ? /*#__PURE__*/_jsx(RemoveButton, {}) : null]
317
+ })]
318
+ }),
319
+ isCollapsed: isCollapsed,
320
+ onToggle: incomingCollapsedState => {
321
+ onCollapsedChange(incomingCollapsedState);
322
+ setIsCollapsed(incomingCollapsedState);
323
+ },
324
+ children: children
325
+ }, 0)
326
+ }), [CustomBlock, CustomLabel, EditButton, RemoveButton, blockDisplayName, clientBlock?.admin?.disableBlockName, editor, formData.blockType, i18n, isCollapsed, onCollapsedChange, parentLexicalRichTextField?.admin?.readOnly]);
342
327
  const BlockDrawer = useMemo(() => () => /*#__PURE__*/_jsx(EditDepthProvider, {
343
328
  children: /*#__PURE__*/_jsx(Drawer, {
344
329
  className: '',
345
330
  slug: drawerSlug,
346
- title: t(`lexical:blocks:inlineBlocks:${blockID ? 'edit' : 'create'}`, {
331
+ title: t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {
347
332
  label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label')
348
333
  }),
349
334
  children: initialState ? /*#__PURE__*/_jsxs(_Fragment, {
@@ -356,14 +341,14 @@ export const BlockComponent = props => {
356
341
 
357
342
  parentSchemaPath: schemaFieldsPath,
358
343
  permissions: true,
359
- readOnly: !isEditable
344
+ readOnly: false
360
345
  }), /*#__PURE__*/_jsx(FormSubmit, {
361
346
  programmaticSubmit: true,
362
347
  children: t('fields:saveChanges')
363
348
  })]
364
349
  }) : null
365
350
  })
366
- }), [initialState, drawerSlug, blockID, blockDisplayName, t, isEditable, clientBlock?.fields, schemaFieldsPath]);
351
+ }), [initialState, drawerSlug, blockDisplayName, t, clientBlock?.fields, schemaFieldsPath, permissions]);
367
352
  // Memoized Form JSX
368
353
  const Block = useMemo(() => {
369
354
  if (!initialState) {
@@ -385,7 +370,7 @@ export const BlockComponent = props => {
385
370
  onChange: [onChange],
386
371
  onSubmit: (formState_0, newData_1) => {
387
372
  // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component
388
- newData_1.blockType = blockType;
373
+ newData_1.blockType = formData.blockType;
389
374
  editor.update(() => {
390
375
  const node_1 = $getNodeByKey(nodeKey);
391
376
  if (node_1 && $isBlockNode(node_1)) {
@@ -409,7 +394,7 @@ export const BlockComponent = props => {
409
394
  RemoveButton: RemoveButton
410
395
  })
411
396
  });
412
- }, [BlockCollapsible, BlockDrawer, CustomBlock, blockType, RemoveButton, EditButton, editor, errorCount, toggleDrawer, clientBlock?.fields,
397
+ }, [BlockCollapsible, BlockDrawer, CustomBlock, clientBlock?.fields, RemoveButton, EditButton, editor, errorCount, toggleDrawer, clientBlock?.fields,
413
398
  // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.
414
399
  initialState, nodeKey, onChange, submitted]);
415
400
  if (!clientBlock) {
@@ -418,7 +403,7 @@ export const BlockComponent = props => {
418
403
  fieldHasErrors: true,
419
404
  children: /*#__PURE__*/_jsxs("div", {
420
405
  className: "lexical-block-not-found",
421
- children: ["Error: Block '", blockType, "' not found in the config but exists in the lexical data"]
406
+ children: ["Error: Block '", formData.blockType, "' not found in the config but exists in the lexical data"]
422
407
  })
423
408
  });
424
409
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","FormSubmit","Pill","RenderFields","SectionTitle","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","useCallback","useEffect","useMemo","useRef","baseClass","useLexicalComposerContext","useLexicalEditable","getTranslation","$getNodeByKey","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isBlockNode","BlockContent","removeEmptyArrayValues","BlockComponent","props","cacheBuster","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","config","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","isEditable","blockType","getFormState","schemaFieldsPath","initialState","setInitialState","formState","blockName","initialValue","passesCondition","valid","value","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","undefined","CustomBlock","setCustomBlock","Block","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","newFormStateData","update","node","newData","setFields","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","i18n","t","onChange","prevFormState","submit","controller","newFormState","initialBlockFormState","setTimeout","rowErrorCount","formField","Object","values","removeBlock","remove","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","_jsx","buttonStyle","className","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","BlockCollapsible","Actions","children","collapsibleProps","disableBlockName","editButton","fieldHasErrors","Label","CustomPill","removeButton","filter","Boolean","join","collapsibleStyle","header","_jsxs","pillStyle","admin","path","count","withMessage","_Fragment","onToggle","incomingCollapsedState","blockID","BlockDrawer","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","programmaticSubmit","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n FormSubmit,\n Pill,\n RenderFields,\n SectionTitle,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\n\nconst baseClass = 'lexical-block'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { $getNodeByKey } from 'lexical'\nimport {\n type BlocksFieldClient,\n type ClientBlock,\n type CollapsedPreferences,\n type FormState,\n} from 'payload'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport './index.scss'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { type BlockCollapsibleWithErrorProps, BlockContent } from './BlockContent.js'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, formData, nodeKey } = props\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const { config } = useConfig()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const blockType = formData.blockType\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n return initialLexicalFormState?.[formData.id]?.formState\n ? {\n ...initialLexicalFormState?.[formData.id]?.formState,\n blockName: {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n },\n }\n : false\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel ?? undefined,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block ?? undefined,\n )\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as BlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined)\n setCustomBlock(state._components?.customComponents?.Block ?? undefined)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n isEditable,\n id,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n blockType,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const { i18n, t } = useTranslation<object, string>()\n\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state: newFormState } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n removeEmptyArrayValues({\n fields: deepCopyObjectSimpleWithoutReactComponents(newFormState),\n }),\n true,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n node.setFields(newData, true)\n }\n })\n }, 0)\n\n if (submit) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined)\n setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined)\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n blockType,\n parentDocumentFields,\n isEditable,\n editor,\n nodeKey,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, t, isEditable, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [isEditable, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n ({\n Actions,\n children,\n className,\n collapsibleProps,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n Pill: CustomPill,\n removeButton,\n }: BlockCollapsibleWithErrorProps) => {\n return (\n <div className={baseClass + ' ' + baseClass + '-' + blockType}>\n <Collapsible\n className={[\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__block-header`}>\n {typeof Label !== 'undefined' ? (\n Label\n ) : typeof CustomLabel !== 'undefined' ? (\n CustomLabel\n ) : (\n <div className={`${baseClass}__block-label`}>\n {typeof CustomPill !== 'undefined' ? (\n CustomPill\n ) : (\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`}\n pillStyle=\"white\"\n size=\"small\"\n >\n {blockDisplayName ?? blockType}\n </Pill>\n )}\n {!disableBlockName && !clientBlock?.admin?.disableBlockName && (\n <SectionTitle path=\"blockName\" readOnly={!isEditable} />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n\n <div className={`${baseClass}__block-actions`}>\n {typeof Actions !== 'undefined' ? (\n Actions\n ) : (\n <>\n {(CustomBlock && editButton !== false) || (!CustomBlock && editButton) ? (\n <EditButton />\n ) : null}\n {removeButton !== false && isEditable ? <RemoveButton /> : null}\n </>\n )}\n </div>\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n {...(collapsibleProps || {})}\n >\n {children}\n </Collapsible>\n </div>\n )\n },\n [\n CustomBlock,\n CustomLabel,\n EditButton,\n RemoveButton,\n blockDisplayName,\n clientBlock?.admin?.disableBlockName,\n blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n isEditable,\n ],\n )\n\n const blockID = formData?.id\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${blockID ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields ?? []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockID,\n blockDisplayName,\n t,\n isEditable,\n clientBlock?.fields,\n schemaFieldsPath,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n el=\"div\"\n fields={clientBlock?.fields ?? []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState, newData) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n newData.blockType = blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData as BlockFields, true)\n }\n })\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={CustomBlock}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlock?.fields ?? []}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n CustomBlock,\n blockType,\n RemoveButton,\n EditButton,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className=\"lexical-block-not-found\">\n Error: Block '{blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\n }\n\n return Block\n}\n"],"mappings":"AAAA;;;AAEA,SACEA,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,IAAI,EACJC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAE/D,MAAMC,SAAA,GAAY;AAElB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC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AAA,EAAMA,IAAA;gBAEN,aAAA0H,IAAA,CAACtH,YAAA;QACCV,SAAA,EAAWA,SAAA;QACXyK,WAAA,EAAaA,WAAA;QACblM,WAAA,EAAayK,gBAAA;QACbhF,WAAA,EAAaA,WAAA;QACb+D,UAAA,EAAYA,UAAA;QACZ9F,UAAA,EAAYA,UAAA;QACZkJ,UAAA,EAAYxF,WAAA,EAAa/D,MAAA,IAAU,EAAE;QACrCoB,YAAA,EAAcA,YAAA;QACdhC,OAAA,EAASA,OAAA;QACT+H,YAAA,EAAcA;;;EAItB,GAAG,CACDC,gBAAA,EACAyB,WAAA,EACAzG,WAAA,EACAnB,SAAA,EACAkG,YAAA,EACAhB,UAAA,EACApF,MAAA,EACAV,UAAA,EACAO,YAAA,EACAmD,WAAA,EAAa/D,MAAA;EACb;EACAoB,YAAA,EACAhC,OAAA,EACAiF,QAAA,EACAhF,SAAA,CACD;EAED,IAAI,CAAC0E,WAAA,EAAa;IAChB,oBACEqC,IAAA,CAACgB,gBAAA;MAAiBI,gBAAA,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAS,KAAA,CAAC;QAAI7B,SAAA,EAAU;mBAA0B,kBACxBrF,SAAA,EAAU;;;EAIjC;EAEA,OAAOqB,KAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","FormSubmit","Pill","RenderFields","SectionTitle","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","useCallback","useEffect","useMemo","useRef","baseClass","useLexicalComposerContext","getTranslation","$getNodeByKey","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isBlockNode","BlockContent","removeEmptyArrayValues","BlockComponent","props","cacheBuster","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","permissions","readOnly","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","config","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","getFormState","schemaFieldsPath","blockType","initialState","setInitialState","formState","blockName","initialValue","passesCondition","valid","value","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","operation","renderAllFields","signal","newFormStateData","update","node","newData","setFields","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","i18n","t","onChange","prevFormState","submit","controller","newFormState","initialBlockFormState","setTimeout","rowErrorCount","formField","Object","values","removeBlock","remove","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","_jsx","buttonStyle","className","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","admin","BlockCollapsible","children","disableBlockName","editButton","fieldHasErrors","Label","removeButton","join","collapsibleStyle","header","_jsxs","pillStyle","path","count","withMessage","isEditable","onToggle","incomingCollapsedState","BlockDrawer","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","programmaticSubmit","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n FormSubmit,\n Pill,\n RenderFields,\n SectionTitle,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\n\nconst baseClass = 'lexical-block'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { getTranslation } from '@payloadcms/translations'\nimport { $getNodeByKey } from 'lexical'\nimport {\n type BlocksFieldClient,\n type ClientBlock,\n type CollapsedPreferences,\n type FormState,\n} from 'payload'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport './index.scss'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { BlockContent } from './BlockContent.js'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, formData, nodeKey } = props\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const { config } = useConfig()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n const [editor] = useLexicalComposerContext()\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n return initialLexicalFormState?.[formData.id]?.formState\n ? {\n ...initialLexicalFormState?.[formData.id]?.formState,\n blockName: {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n },\n }\n : false\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as BlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state._components?.customComponents?.BlockLabel)\n setCustomBlock(state._components?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n id,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const { i18n, t } = useTranslation<object, string>()\n\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state: newFormState } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n removeEmptyArrayValues({\n fields: deepCopyObjectSimpleWithoutReactComponents(newFormState),\n }),\n true,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n node.setFields(newData, true)\n }\n })\n }, 0)\n\n if (submit) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel)\n setCustomBlock(newFormState._components?.customComponents?.Block)\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n formData.blockType,\n parentDocumentFields,\n editor,\n nodeKey,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={parentLexicalRichTextField?.admin?.readOnly || false}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [parentLexicalRichTextField?.admin?.readOnly, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n ({\n children,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n removeButton,\n }: {\n children?: React.ReactNode\n disableBlockName?: boolean\n editButton?: boolean\n errorCount?: number\n fieldHasErrors?: boolean\n /**\n * Override the default label with a custom label\n */\n Label?: React.ReactNode\n removeButton?: boolean\n }) => (\n <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>\n <Collapsible\n className={[\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ].join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__block-header`}>\n {(Label ?? CustomLabel) ? (\n (Label ?? CustomLabel)\n ) : (\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n size=\"small\"\n >\n {blockDisplayName ?? formData?.blockType}\n </Pill>\n {!disableBlockName && !clientBlock?.admin?.disableBlockName && (\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly || false}\n />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n\n <div>\n {(CustomBlock && editButton !== false) || (!CustomBlock && editButton) ? (\n <EditButton />\n ) : null}\n {removeButton !== false && editor.isEditable() ? <RemoveButton /> : null}\n </div>\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n {children}\n </Collapsible>\n </div>\n ),\n [\n CustomBlock,\n CustomLabel,\n EditButton,\n RemoveButton,\n blockDisplayName,\n clientBlock?.admin?.disableBlockName,\n editor,\n formData.blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n parentLexicalRichTextField?.admin?.readOnly,\n ],\n )\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields ?? []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={false}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockDisplayName,\n t,\n clientBlock?.fields,\n schemaFieldsPath,\n permissions,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n el=\"div\"\n fields={clientBlock?.fields ?? []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState, newData) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData as BlockFields, true)\n }\n })\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={CustomBlock}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlock?.fields ?? []}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n CustomBlock,\n clientBlock?.fields,\n RemoveButton,\n EditButton,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className=\"lexical-block-not-found\">\n Error: Block '{formData.blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\n }\n\n return Block\n}\n"],"mappings":"AAAA;;;AAEA,SACEA,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,IAAI,EACJC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAE/D,MAAMC,SAAA,GAAY;AAElB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAO9B,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,YAAY,QAAQ;AAC7B,SAASC,YAAY,QAAQ;AAC7B,SAASC,sBAAsB,QAAQ;AAavC,OAAO,MAAMC,cAAA,GAAmCC,KAAA;EAC9C,MAAM;IAAEC,WAAW;IAAEC,QAAQ;IAAEC;EAAO,CAAE,GAAGH,KAAA;EAC3C,MAAMI,SAAA,GAAY3B,gBAAA;EAClB,MAAM;IAAE4B,EAAE;IAAEC,cAAc;IAAEC;EAAU,CAAE,GAAGhC,eAAA;EAC3C,MAAM;IACJiC,UAAA,EAAY;MACVC,sBAAsB;MACtBC,KAAA,EAAOC,0BAA0B;MACjCC,uBAAuB;MACvBC,WAAW;MACXC,QAAQ;MACRC;IAAU,CACX;IACDtB,IAAA,EAAMuB;EAAe,CACtB,GAAGtB,sBAAA;EAEJ,MAAM;IAAEuB,MAAA,EAAQC;EAAoB,CAAE,GAAG5C,eAAA;EACzC,MAA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AAO;YAC9BA,MAAA,CAAKE,SAAS,CAACD,SAAA,EAAwB;UACzC;QACF;QACAvC,YAAA;MACF;MACAzB,SAAA,EAAWA,SAAA;MACXX,IAAA,EAAMA,IAAA;gBAEN,aAAAyH,IAAA,CAACrH,YAAA;QACCT,SAAA,EAAWA,SAAA;QACXiK,WAAA,EAAaA,WAAA;QACb1L,WAAA,EAAawK,gBAAA;QACbhF,WAAA,EAAaA,WAAA;QACb8D,UAAA,EAAYA,UAAA;QACZ3F,UAAA,EAAYA,UAAA;QACZyI,UAAA,EAAYlF,WAAA,EAAa5D,MAAA,IAAU,EAAE;QACrCmB,YAAA,EAAcA,YAAA;QACdjC,OAAA,EAASA,OAAA;QACT8H,YAAA,EAAcA;;;EAItB,GAAG,CACDE,gBAAA,EACAkB,WAAA,EACAlG,WAAA,EACA0B,WAAA,EAAa5D,MAAA,EACbgH,YAAA,EACAhB,UAAA,EACAjF,MAAA,EACAV,UAAA,EACAO,YAAA,EACAgD,WAAA,EAAa5D,MAAA;EACb;EACAmB,YAAA,EACAjC,OAAA,EACAgF,QAAA,EACA/E,SAAA,CACD;EAED,IAAI,CAACyE,WAAA,EAAa;IAChB,oBACEqC,IAAA,CAACiB,gBAAA;MAAiBE,gBAAA,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAM,KAAA,CAAC;QAAIzB,SAAA,EAAU;mBAA0B,kBACxBlH,QAAA,CAASiC,SAAS,EAAC;;;EAI1C;EAEA,OAAOkB,KAAA;AACT","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiE,MAAM,OAAO,CAAA;AAGrF,OAAO,KAAK,EAAwC,SAAS,EAAE,MAAM,SAAS,CAAA;AAuB9E,OAAO,cAAc,CAAA;AAMrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAM/E,KAAK,KAA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SAAS,GAAG,SAAS,CAAA;IAC3C,oBAAoB,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAA;IAC9D,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;CACxB,CAAA;AAMD,eAAO,MAAM,8BAA8B,uCAA+C,CAAA;AAE1F,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAgZhD,CAAA"}
@@ -4,7 +4,6 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
4
4
  import React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react';
5
5
  const baseClass = 'inline-block';
6
6
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
7
- import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
8
7
  import { getTranslation } from '@payloadcms/translations';
9
8
  import { Button, Drawer, EditDepthProvider, Form, formatDrawerSlug, FormSubmit, RenderFields, ShimmerEffect, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useServerFunctions, useTranslation } from '@payloadcms/ui';
10
9
  import { abortAndIgnore } from '@payloadcms/ui/shared';
@@ -25,7 +24,6 @@ export const InlineBlockComponent = props => {
25
24
  nodeKey
26
25
  } = props;
27
26
  const [editor] = useLexicalComposerContext();
28
- const isEditable = useLexicalEditable();
29
27
  const {
30
28
  i18n,
31
29
  t
@@ -35,6 +33,8 @@ export const InlineBlockComponent = props => {
35
33
  fieldProps: {
36
34
  featureClientSchemaMap,
37
35
  initialLexicalFormState,
36
+ permissions,
37
+ readOnly,
38
38
  schemaPath
39
39
  },
40
40
  setCreatedInlineBlock,
@@ -132,7 +132,6 @@ export const InlineBlockComponent = props => {
132
132
  initialBlockData: formData,
133
133
  initialBlockFormState: formData,
134
134
  operation: 'update',
135
- readOnly: !isEditable,
136
135
  renderAllFields: true,
137
136
  schemaPath: schemaFieldsPath,
138
137
  signal: abortController.signal
@@ -159,7 +158,7 @@ export const InlineBlockComponent = props => {
159
158
  return () => {
160
159
  abortAndIgnore(abortController);
161
160
  };
162
- }, [getFormState, editor, nodeKey, isEditable, schemaFieldsPath, id, formData, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
161
+ }, [getFormState, editor, nodeKey, schemaFieldsPath, id, formData, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
163
162
  /**
164
163
  * HANDLE ONCHANGE
165
164
  */
@@ -184,7 +183,6 @@ export const InlineBlockComponent = props => {
184
183
  globalSlug,
185
184
  initialBlockFormState: prevFormState,
186
185
  operation: 'update',
187
- readOnly: !isEditable,
188
186
  renderAllFields: submit ? true : false,
189
187
  schemaPath: schemaFieldsPath,
190
188
  signal: controller.signal
@@ -197,7 +195,7 @@ export const InlineBlockComponent = props => {
197
195
  setCustomBlock(state_0['_components']?.customComponents?.Block);
198
196
  }
199
197
  return state_0;
200
- }, [getFormState, id, collectionSlug, getDocPreferences, parentDocumentFields, globalSlug, isEditable, schemaFieldsPath]);
198
+ }, [getFormState, id, collectionSlug, getDocPreferences, parentDocumentFields, globalSlug, schemaFieldsPath]);
201
199
  // cleanup effect
202
200
  useEffect(() => {
203
201
  const isStateOutOfSync = (formData_0, initialState_0) => {
@@ -228,7 +226,7 @@ export const InlineBlockComponent = props => {
228
226
  const RemoveButton = useMemo(() => () => /*#__PURE__*/_jsx(Button, {
229
227
  buttonStyle: "icon-label",
230
228
  className: `${baseClass}__removeButton`,
231
- disabled: !isEditable,
229
+ disabled: readOnly,
232
230
  icon: "x",
233
231
  onClick: e => {
234
232
  e.preventDefault();
@@ -239,11 +237,11 @@ export const InlineBlockComponent = props => {
239
237
  tooltip: t('lexical:blocks:inlineBlocks:remove', {
240
238
  label: blockDisplayName
241
239
  })
242
- }), [blockDisplayName, isEditable, removeInlineBlock, t]);
240
+ }), [blockDisplayName, readOnly, removeInlineBlock, t]);
243
241
  const EditButton = useMemo(() => () => /*#__PURE__*/_jsx(Button, {
244
242
  buttonStyle: "icon-label",
245
243
  className: `${baseClass}__editButton`,
246
- disabled: !isEditable,
244
+ disabled: readOnly,
247
245
  el: "button",
248
246
  icon: "edit",
249
247
  onClick: () => {
@@ -254,7 +252,7 @@ export const InlineBlockComponent = props => {
254
252
  tooltip: t('lexical:blocks:inlineBlocks:edit', {
255
253
  label: blockDisplayName
256
254
  })
257
- }), [blockDisplayName, isEditable, t, toggleDrawer]);
255
+ }), [blockDisplayName, readOnly, t, toggleDrawer]);
258
256
  const InlineBlockContainer = useMemo(() => ({
259
257
  children,
260
258
  className
@@ -277,7 +275,7 @@ export const InlineBlockComponent = props => {
277
275
  className: `${baseClass}-not-found`,
278
276
  children: [/*#__PURE__*/_jsxs("span", {
279
277
  children: ["Error: Block '", formData.blockType, "' not found"]
280
- }), isEditable ? /*#__PURE__*/_jsx("div", {
278
+ }), editor.isEditable() ? /*#__PURE__*/_jsx("div", {
281
279
  className: `${baseClass}__actions`,
282
280
  children: /*#__PURE__*/_jsx(RemoveButton, {})
283
281
  }) : null]
@@ -320,7 +318,7 @@ export const InlineBlockComponent = props => {
320
318
 
321
319
  parentSchemaPath: schemaFieldsPath,
322
320
  permissions: true,
323
- readOnly: !isEditable
321
+ readOnly: false
324
322
  }), /*#__PURE__*/_jsx(FormSubmit, {
325
323
  programmaticSubmit: true,
326
324
  children: t('fields:saveChanges')
@@ -341,7 +339,7 @@ export const InlineBlockComponent = props => {
341
339
  children: [initialState ? /*#__PURE__*/_jsx(Label, {}) : /*#__PURE__*/_jsx(ShimmerEffect, {
342
340
  height: "15px",
343
341
  width: "40px"
344
- }), isEditable ? /*#__PURE__*/_jsxs("div", {
342
+ }), editor.isEditable() ? /*#__PURE__*/_jsxs("div", {
345
343
  className: `${baseClass}__actions`,
346
344
  children: [/*#__PURE__*/_jsx(EditButton, {}), /*#__PURE__*/_jsx(RemoveButton, {})]
347
345
  }) : null]