@payloadcms/richtext-lexical 3.59.0-internal.929dda3 → 3.59.0-internal.b804ca6

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-CJFETHA3.js +2 -0
  2. package/dist/exports/client/Field-CJFETHA3.js.map +7 -0
  3. package/dist/exports/client/RelationshipComponent-TSIENULZ.js +2 -0
  4. package/dist/exports/client/RelationshipComponent-TSIENULZ.js.map +7 -0
  5. package/dist/exports/client/bundled.css +1 -1
  6. package/dist/exports/client/chunk-BQCXN3B4.js +2 -0
  7. package/dist/exports/client/chunk-BQCXN3B4.js.map +7 -0
  8. package/dist/exports/client/{chunk-2Y72RT72.js → chunk-TLQLXR6Q.js} +2 -2
  9. package/dist/exports/client/chunk-XNERFY6G.js +2 -0
  10. package/dist/exports/client/chunk-XNERFY6G.js.map +7 -0
  11. package/dist/exports/client/component-CYFKY3IL.js +2 -0
  12. package/dist/exports/client/component-CYFKY3IL.js.map +7 -0
  13. package/dist/exports/client/componentInline-NGTRUSGB.js +2 -0
  14. package/dist/exports/client/index.d.ts +3 -0
  15. package/dist/exports/client/index.d.ts.map +1 -1
  16. package/dist/exports/client/index.js +35 -10
  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 +52 -27
  25. package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
  26. package/dist/features/blocks/client/component/BlockContent.js +48 -51
  27. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  28. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +2 -9
  29. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -1
  30. package/dist/features/blocks/client/component/components/BlockCollapsible.js +7 -25
  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 +71 -56
  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 +13 -11
  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 +5 -0
  40. package/dist/features/blocks/client/index.js.map +1 -1
  41. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +6 -0
  42. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -0
  43. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +24 -0
  44. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -0
  45. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +6 -0
  46. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -0
  47. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +20 -0
  48. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -0
  49. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +12 -0
  50. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -0
  51. package/dist/features/blocks/client/markdown/markdownTransformer.js +348 -0
  52. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -0
  53. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts +5 -0
  54. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -0
  55. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +156 -0
  56. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -0
  57. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts +61 -0
  58. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts.map +1 -0
  59. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +99 -0
  60. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -0
  61. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts +4 -0
  62. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts.map +1 -0
  63. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +17 -0
  64. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -0
  65. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts +4 -0
  66. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts.map +1 -0
  67. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +26 -0
  68. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -0
  69. package/dist/features/blocks/premade/CodeBlock/converter.d.ts +7 -0
  70. package/dist/features/blocks/premade/CodeBlock/converter.d.ts.map +1 -0
  71. package/dist/features/blocks/premade/CodeBlock/converter.js +46 -0
  72. package/dist/features/blocks/premade/CodeBlock/converter.js.map +1 -0
  73. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts +2 -0
  74. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts.map +1 -0
  75. package/dist/features/blocks/premade/CodeBlock/converterClient.js +4 -0
  76. package/dist/features/blocks/premade/CodeBlock/converterClient.js.map +1 -0
  77. package/dist/features/blocks/premade/CodeBlock/index.d.ts +7 -0
  78. package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +1 -0
  79. package/dist/features/blocks/premade/CodeBlock/index.js +52 -0
  80. package/dist/features/blocks/premade/CodeBlock/index.js.map +1 -0
  81. package/dist/features/blocks/server/i18n.d.ts.map +1 -1
  82. package/dist/features/blocks/server/i18n.js +9 -0
  83. package/dist/features/blocks/server/i18n.js.map +1 -1
  84. package/dist/features/blocks/server/index.js +1 -1
  85. package/dist/features/blocks/server/index.js.map +1 -1
  86. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts +6 -0
  87. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts.map +1 -0
  88. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js +27 -0
  89. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js.map +1 -0
  90. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts +7 -0
  91. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts.map +1 -0
  92. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js +22 -0
  93. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js.map +1 -0
  94. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
  95. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +1 -0
  96. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +15 -0
  97. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -0
  98. package/dist/features/blocks/server/{markdownTransformer.js → markdown/markdownTransformer.js} +6 -48
  99. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -0
  100. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
  101. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +5 -3
  102. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  103. package/dist/features/heading/server/i18n.d.ts.map +1 -1
  104. package/dist/features/heading/server/i18n.js +3 -0
  105. package/dist/features/heading/server/i18n.js.map +1 -1
  106. package/dist/features/horizontalRule/server/i18n.d.ts.map +1 -1
  107. package/dist/features/horizontalRule/server/i18n.js +3 -0
  108. package/dist/features/horizontalRule/server/i18n.js.map +1 -1
  109. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  110. package/dist/features/indent/server/i18n.js +4 -0
  111. package/dist/features/indent/server/i18n.js.map +1 -1
  112. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  113. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +3 -1
  114. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  115. package/dist/features/link/server/i18n.d.ts.map +1 -1
  116. package/dist/features/link/server/i18n.js +4 -0
  117. package/dist/features/link/server/i18n.js.map +1 -1
  118. package/dist/features/lists/checklist/server/i18n.d.ts.map +1 -1
  119. package/dist/features/lists/checklist/server/i18n.js +3 -0
  120. package/dist/features/lists/checklist/server/i18n.js.map +1 -1
  121. package/dist/features/lists/orderedList/server/i18n.d.ts.map +1 -1
  122. package/dist/features/lists/orderedList/server/i18n.js +3 -0
  123. package/dist/features/lists/orderedList/server/i18n.js.map +1 -1
  124. package/dist/features/lists/unorderedList/server/i18n.d.ts.map +1 -1
  125. package/dist/features/lists/unorderedList/server/i18n.js +3 -0
  126. package/dist/features/lists/unorderedList/server/i18n.js.map +1 -1
  127. package/dist/features/paragraph/server/i18n.d.ts.map +1 -1
  128. package/dist/features/paragraph/server/i18n.js +4 -0
  129. package/dist/features/paragraph/server/i18n.js.map +1 -1
  130. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  131. package/dist/features/relationship/client/components/RelationshipComponent.js +5 -9
  132. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  133. package/dist/features/relationship/server/i18n.d.ts.map +1 -1
  134. package/dist/features/relationship/server/i18n.js +3 -0
  135. package/dist/features/relationship/server/i18n.js.map +1 -1
  136. package/dist/features/textState/i18n.d.ts.map +1 -1
  137. package/dist/features/textState/i18n.js +3 -0
  138. package/dist/features/textState/i18n.js.map +1 -1
  139. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  140. package/dist/features/toolbars/fixed/client/Toolbar/index.js +7 -1
  141. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  142. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  143. package/dist/features/toolbars/inline/client/Toolbar/index.js +3 -1
  144. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  145. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  146. package/dist/features/upload/client/component/index.js +6 -5
  147. package/dist/features/upload/client/component/index.js.map +1 -1
  148. package/dist/features/upload/server/i18n.d.ts.map +1 -1
  149. package/dist/features/upload/server/i18n.js +3 -0
  150. package/dist/features/upload/server/i18n.js.map +1 -1
  151. package/dist/field/bundled.css +1 -1
  152. package/dist/field/rscEntry.d.ts.map +1 -1
  153. package/dist/field/rscEntry.js +2 -0
  154. package/dist/field/rscEntry.js.map +1 -1
  155. package/dist/i18n.d.ts.map +1 -1
  156. package/dist/i18n.js +6 -0
  157. package/dist/i18n.js.map +1 -1
  158. package/dist/index.d.ts +1 -0
  159. package/dist/index.d.ts.map +1 -1
  160. package/dist/index.js +1 -0
  161. package/dist/index.js.map +1 -1
  162. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  163. package/dist/lexical/LexicalEditor.js +20 -26
  164. package/dist/lexical/LexicalEditor.js.map +1 -1
  165. package/dist/lexical/ui/icons/CodeBlock/index.d.ts.map +1 -1
  166. package/dist/lexical/ui/icons/CodeBlock/index.js +10 -15
  167. package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
  168. package/dist/lexical/ui/icons/Collapse/index.d.ts +3 -0
  169. package/dist/lexical/ui/icons/Collapse/index.d.ts.map +1 -0
  170. package/dist/lexical/ui/icons/Collapse/index.js +18 -0
  171. package/dist/lexical/ui/icons/Collapse/index.js.map +1 -0
  172. package/dist/utilities/buildInitialState.d.ts +1 -0
  173. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  174. package/dist/utilities/buildInitialState.js +1 -0
  175. package/dist/utilities/buildInitialState.js.map +1 -1
  176. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  177. package/dist/utilities/fieldsDrawer/DrawerContent.js +7 -3
  178. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  179. package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -2
  180. package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
  181. package/package.json +6 -6
  182. package/dist/exports/client/Field-EHRBYNHO.js +0 -2
  183. package/dist/exports/client/Field-EHRBYNHO.js.map +0 -7
  184. package/dist/exports/client/RelationshipComponent-APF3CN47.js +0 -2
  185. package/dist/exports/client/RelationshipComponent-APF3CN47.js.map +0 -7
  186. package/dist/exports/client/chunk-3BY5IZJD.js +0 -2
  187. package/dist/exports/client/chunk-3BY5IZJD.js.map +0 -7
  188. package/dist/exports/client/chunk-CYLMY5ZJ.js +0 -2
  189. package/dist/exports/client/chunk-CYLMY5ZJ.js.map +0 -7
  190. package/dist/exports/client/component-VDJI45F2.js +0 -2
  191. package/dist/exports/client/component-VDJI45F2.js.map +0 -7
  192. package/dist/exports/client/componentInline-7TPI7ZBC.js +0 -2
  193. package/dist/features/blocks/client/markdownTransformer.d.ts +0 -17
  194. package/dist/features/blocks/client/markdownTransformer.d.ts.map +0 -1
  195. package/dist/features/blocks/client/markdownTransformer.js +0 -144
  196. package/dist/features/blocks/client/markdownTransformer.js.map +0 -1
  197. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +0 -1
  198. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +0 -1
  199. package/dist/features/blocks/server/markdownTransformer.d.ts +0 -22
  200. package/dist/features/blocks/server/markdownTransformer.d.ts.map +0 -1
  201. package/dist/features/blocks/server/markdownTransformer.js.map +0 -1
  202. /package/dist/exports/client/{chunk-2Y72RT72.js.map → chunk-TLQLXR6Q.js.map} +0 -0
  203. /package/dist/exports/client/{componentInline-7TPI7ZBC.js.map → componentInline-NGTRUSGB.js.map} +0 -0
  204. /package/dist/features/blocks/server/{linesFromMatchToContentAndPropsString.d.ts → markdown/linesFromMatchToContentAndPropsString.d.ts} +0 -0
  205. /package/dist/features/blocks/server/{linesFromMatchToContentAndPropsString.js → markdown/linesFromMatchToContentAndPropsString.js} +0 -0
@@ -7,6 +7,7 @@ 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';
10
11
  import { getTranslation } from '@payloadcms/translations';
11
12
  import { $getNodeByKey } from 'lexical';
12
13
  import { v4 as uuid } from 'uuid';
@@ -32,8 +33,6 @@ export const BlockComponent = props => {
32
33
  featureClientSchemaMap,
33
34
  field: parentLexicalRichTextField,
34
35
  initialLexicalFormState,
35
- permissions,
36
- readOnly,
37
36
  schemaPath
38
37
  },
39
38
  uuid: uuidFromContext
@@ -62,10 +61,12 @@ export const BlockComponent = props => {
62
61
  setDocFieldPreferences
63
62
  } = useDocumentInfo();
64
63
  const [editor] = useLexicalComposerContext();
64
+ const isEditable = useLexicalEditable();
65
+ const blockType = formData.blockType;
65
66
  const {
66
67
  getFormState
67
68
  } = useServerFunctions();
68
- const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}.fields`;
69
+ const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`;
69
70
  const [initialState, setInitialState] = React.useState(() => {
70
71
  return initialLexicalFormState?.[formData.id]?.formState ? {
71
72
  ...initialLexicalFormState?.[formData.id]?.formState,
@@ -91,10 +92,10 @@ export const BlockComponent = props => {
91
92
  }, [cacheBuster]);
92
93
  const [CustomLabel, setCustomLabel] = React.useState(
93
94
  // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
94
- initialState?.['_components']?.customComponents?.BlockLabel);
95
+ initialState?.['_components']?.customComponents?.BlockLabel ?? undefined);
95
96
  const [CustomBlock, setCustomBlock] = React.useState(
96
97
  // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
97
- initialState?.['_components']?.customComponents?.Block);
98
+ initialState?.['_components']?.customComponents?.Block ?? undefined);
98
99
  // Initial state for newly created blocks
99
100
  useEffect(() => {
100
101
  const abortController = new AbortController();
@@ -118,6 +119,7 @@ export const BlockComponent = props => {
118
119
  globalSlug,
119
120
  initialBlockData: formData,
120
121
  operation: 'update',
122
+ readOnly: !isEditable,
121
123
  renderAllFields: true,
122
124
  schemaPath: schemaFieldsPath,
123
125
  signal: abortController.signal
@@ -135,13 +137,13 @@ export const BlockComponent = props => {
135
137
  const node = $getNodeByKey(nodeKey);
136
138
  if (node && $isBlockNode(node)) {
137
139
  const newData = newFormStateData;
138
- newData.blockType = formData.blockType;
140
+ newData.blockType = blockType;
139
141
  node.setFields(newData, true);
140
142
  }
141
143
  });
142
144
  setInitialState(state);
143
- setCustomLabel(state._components?.customComponents?.BlockLabel);
144
- setCustomBlock(state._components?.customComponents?.Block);
145
+ setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined);
146
+ setCustomBlock(state._components?.customComponents?.Block ?? undefined);
145
147
  }
146
148
  };
147
149
  if (formData && !initialState) {
@@ -150,9 +152,9 @@ export const BlockComponent = props => {
150
152
  return () => {
151
153
  abortAndIgnore(abortController);
152
154
  };
153
- }, [getFormState, schemaFieldsPath, id, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
155
+ }, [getFormState, schemaFieldsPath, isEditable, id, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields, blockType]);
154
156
  const [isCollapsed, setIsCollapsed] = React.useState(initialLexicalFormState?.[formData.id]?.collapsed ?? false);
155
- const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}`;
157
+ const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`;
156
158
  const clientSchemaMap = featureClientSchemaMap['blocks'];
157
159
  const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
158
160
  const clientBlock = blocksField.blockReferences ? typeof blocksField?.blockReferences?.[0] === 'string' ? config.blocksMap[blocksField?.blockReferences?.[0]] : blocksField?.blockReferences?.[0] : blocksField?.blocks?.[0];
@@ -181,6 +183,7 @@ export const BlockComponent = props => {
181
183
  globalSlug,
182
184
  initialBlockFormState: prevFormState,
183
185
  operation: 'update',
186
+ readOnly: !isEditable,
184
187
  renderAllFields: submit ? true : false,
185
188
  schemaPath: schemaFieldsPath,
186
189
  signal: controller.signal
@@ -199,14 +202,14 @@ export const BlockComponent = props => {
199
202
  const node_0 = $getNodeByKey(nodeKey);
200
203
  if (node_0 && $isBlockNode(node_0)) {
201
204
  const newData_0 = newFormStateData_0;
202
- newData_0.blockType = formData.blockType;
205
+ newData_0.blockType = blockType;
203
206
  node_0.setFields(newData_0, true);
204
207
  }
205
208
  });
206
209
  }, 0);
207
210
  if (submit) {
208
- setCustomLabel(newFormState._components?.customComponents?.BlockLabel);
209
- setCustomBlock(newFormState._components?.customComponents?.Block);
211
+ setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined);
212
+ setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined);
210
213
  let rowErrorCount = 0;
211
214
  for (const formField of Object.values(newFormState)) {
212
215
  if (formField?.valid === false) {
@@ -216,7 +219,7 @@ export const BlockComponent = props => {
216
219
  setErrorCount(rowErrorCount);
217
220
  }
218
221
  return newFormState;
219
- }, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, formData.blockType, parentDocumentFields, editor, nodeKey]);
222
+ }, [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath, blockType, parentDocumentFields, isEditable, editor, nodeKey]);
220
223
  useEffect(() => {
221
224
  return () => {
222
225
  abortAndIgnore(onChangeAbortControllerRef.current);
@@ -251,7 +254,7 @@ export const BlockComponent = props => {
251
254
  const EditButton = useMemo(() => () => /*#__PURE__*/_jsx(Button, {
252
255
  buttonStyle: "icon-label",
253
256
  className: `${baseClass}__editButton`,
254
- disabled: readOnly,
257
+ disabled: !isEditable,
255
258
  el: "button",
256
259
  icon: "edit",
257
260
  onClick: e => {
@@ -270,11 +273,11 @@ export const BlockComponent = props => {
270
273
  tooltip: t('lexical:blocks:inlineBlocks:edit', {
271
274
  label: blockDisplayName
272
275
  })
273
- }), [blockDisplayName, readOnly, t, toggleDrawer]);
276
+ }), [blockDisplayName, t, isEditable, toggleDrawer]);
274
277
  const RemoveButton = useMemo(() => () => /*#__PURE__*/_jsx(Button, {
275
278
  buttonStyle: "icon-label",
276
279
  className: `${baseClass}__removeButton`,
277
- disabled: parentLexicalRichTextField?.admin?.readOnly || false,
280
+ disabled: !isEditable,
278
281
  icon: "x",
279
282
  onClick: e_1 => {
280
283
  e_1.preventDefault();
@@ -282,53 +285,65 @@ export const BlockComponent = props => {
282
285
  },
283
286
  round: true,
284
287
  tooltip: "Remove Block"
285
- }), [parentLexicalRichTextField?.admin?.readOnly, removeBlock]);
288
+ }), [isEditable, removeBlock]);
286
289
  const BlockCollapsible = useMemo(() => ({
290
+ Actions,
287
291
  children,
292
+ className,
293
+ collapsibleProps,
288
294
  disableBlockName,
289
295
  editButton,
290
296
  errorCount: errorCount_0,
291
297
  fieldHasErrors,
292
298
  Label,
299
+ Pill: CustomPill,
293
300
  removeButton
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
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
+ })
314
329
  })]
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]);
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;
327
342
  const BlockDrawer = useMemo(() => () => /*#__PURE__*/_jsx(EditDepthProvider, {
328
343
  children: /*#__PURE__*/_jsx(Drawer, {
329
344
  className: '',
330
345
  slug: drawerSlug,
331
- title: t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {
346
+ title: t(`lexical:blocks:inlineBlocks:${blockID ? 'edit' : 'create'}`, {
332
347
  label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label')
333
348
  }),
334
349
  children: initialState ? /*#__PURE__*/_jsxs(_Fragment, {
@@ -341,14 +356,14 @@ export const BlockComponent = props => {
341
356
 
342
357
  parentSchemaPath: schemaFieldsPath,
343
358
  permissions: true,
344
- readOnly: false
359
+ readOnly: !isEditable
345
360
  }), /*#__PURE__*/_jsx(FormSubmit, {
346
361
  programmaticSubmit: true,
347
362
  children: t('fields:saveChanges')
348
363
  })]
349
364
  }) : null
350
365
  })
351
- }), [initialState, drawerSlug, blockDisplayName, t, clientBlock?.fields, schemaFieldsPath, permissions]);
366
+ }), [initialState, drawerSlug, blockID, blockDisplayName, t, isEditable, clientBlock?.fields, schemaFieldsPath]);
352
367
  // Memoized Form JSX
353
368
  const Block = useMemo(() => {
354
369
  if (!initialState) {
@@ -370,7 +385,7 @@ export const BlockComponent = props => {
370
385
  onChange: [onChange],
371
386
  onSubmit: (formState_0, newData_1) => {
372
387
  // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component
373
- newData_1.blockType = formData.blockType;
388
+ newData_1.blockType = blockType;
374
389
  editor.update(() => {
375
390
  const node_1 = $getNodeByKey(nodeKey);
376
391
  if (node_1 && $isBlockNode(node_1)) {
@@ -394,7 +409,7 @@ export const BlockComponent = props => {
394
409
  RemoveButton: RemoveButton
395
410
  })
396
411
  });
397
- }, [BlockCollapsible, BlockDrawer, CustomBlock, clientBlock?.fields, RemoveButton, EditButton, editor, errorCount, toggleDrawer, clientBlock?.fields,
412
+ }, [BlockCollapsible, BlockDrawer, CustomBlock, blockType, RemoveButton, EditButton, editor, errorCount, toggleDrawer, clientBlock?.fields,
398
413
  // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.
399
414
  initialState, nodeKey, onChange, submitted]);
400
415
  if (!clientBlock) {
@@ -403,7 +418,7 @@ export const BlockComponent = props => {
403
418
  fieldHasErrors: true,
404
419
  children: /*#__PURE__*/_jsxs("div", {
405
420
  className: "lexical-block-not-found",
406
- children: ["Error: Block '", formData.blockType, "' not found in the config but exists in the lexical data"]
421
+ children: ["Error: Block '", blockType, "' not found in the config but exists in the lexical data"]
407
422
  })
408
423
  });
409
424
  }
@@ -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","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,MAA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A,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAM,KAAA,CAAC;QAAIzB,SAAA,EAAU;mBAA0B,kBACxBlH,QAAA,CAASiC,SAAS,EAAC;;;EAI1C;EAEA,OAAOkB,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","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,oB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IAAIiE,MAAA,IAAQxE,YAAA,CAAawE,MAAA,GAAO;YAC9BA,MAAA,CAAKE,SAAS,CAACD,SAAA,EAAwB;UACzC;QACF;QACA1C,YAAA;MACF;MACAvB,SAAA,EAAWA,SAAA;MACXX,IAAA,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 +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;AAKrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;A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AE,KAAK,GAAG,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,CA+YhD,CAAA"}
@@ -4,6 +4,7 @@ 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';
7
8
  import { getTranslation } from '@payloadcms/translations';
8
9
  import { Button, Drawer, EditDepthProvider, Form, formatDrawerSlug, FormSubmit, RenderFields, ShimmerEffect, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useServerFunctions, useTranslation } from '@payloadcms/ui';
9
10
  import { abortAndIgnore } from '@payloadcms/ui/shared';
@@ -24,6 +25,7 @@ export const InlineBlockComponent = props => {
24
25
  nodeKey
25
26
  } = props;
26
27
  const [editor] = useLexicalComposerContext();
28
+ const isEditable = useLexicalEditable();
27
29
  const {
28
30
  i18n,
29
31
  t
@@ -33,8 +35,6 @@ export const InlineBlockComponent = props => {
33
35
  fieldProps: {
34
36
  featureClientSchemaMap,
35
37
  initialLexicalFormState,
36
- permissions,
37
- readOnly,
38
38
  schemaPath
39
39
  },
40
40
  setCreatedInlineBlock,
@@ -132,6 +132,7 @@ export const InlineBlockComponent = props => {
132
132
  initialBlockData: formData,
133
133
  initialBlockFormState: formData,
134
134
  operation: 'update',
135
+ readOnly: !isEditable,
135
136
  renderAllFields: true,
136
137
  schemaPath: schemaFieldsPath,
137
138
  signal: abortController.signal
@@ -158,7 +159,7 @@ export const InlineBlockComponent = props => {
158
159
  return () => {
159
160
  abortAndIgnore(abortController);
160
161
  };
161
- }, [getFormState, editor, nodeKey, schemaFieldsPath, id, formData, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
162
+ }, [getFormState, editor, nodeKey, isEditable, schemaFieldsPath, id, formData, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
162
163
  /**
163
164
  * HANDLE ONCHANGE
164
165
  */
@@ -183,6 +184,7 @@ export const InlineBlockComponent = props => {
183
184
  globalSlug,
184
185
  initialBlockFormState: prevFormState,
185
186
  operation: 'update',
187
+ readOnly: !isEditable,
186
188
  renderAllFields: submit ? true : false,
187
189
  schemaPath: schemaFieldsPath,
188
190
  signal: controller.signal
@@ -195,7 +197,7 @@ export const InlineBlockComponent = props => {
195
197
  setCustomBlock(state_0['_components']?.customComponents?.Block);
196
198
  }
197
199
  return state_0;
198
- }, [getFormState, id, collectionSlug, getDocPreferences, parentDocumentFields, globalSlug, schemaFieldsPath]);
200
+ }, [getFormState, id, collectionSlug, getDocPreferences, parentDocumentFields, globalSlug, isEditable, schemaFieldsPath]);
199
201
  // cleanup effect
200
202
  useEffect(() => {
201
203
  const isStateOutOfSync = (formData_0, initialState_0) => {
@@ -226,7 +228,7 @@ export const InlineBlockComponent = props => {
226
228
  const RemoveButton = useMemo(() => () => /*#__PURE__*/_jsx(Button, {
227
229
  buttonStyle: "icon-label",
228
230
  className: `${baseClass}__removeButton`,
229
- disabled: readOnly,
231
+ disabled: !isEditable,
230
232
  icon: "x",
231
233
  onClick: e => {
232
234
  e.preventDefault();
@@ -237,11 +239,11 @@ export const InlineBlockComponent = props => {
237
239
  tooltip: t('lexical:blocks:inlineBlocks:remove', {
238
240
  label: blockDisplayName
239
241
  })
240
- }), [blockDisplayName, readOnly, removeInlineBlock, t]);
242
+ }), [blockDisplayName, isEditable, removeInlineBlock, t]);
241
243
  const EditButton = useMemo(() => () => /*#__PURE__*/_jsx(Button, {
242
244
  buttonStyle: "icon-label",
243
245
  className: `${baseClass}__editButton`,
244
- disabled: readOnly,
246
+ disabled: !isEditable,
245
247
  el: "button",
246
248
  icon: "edit",
247
249
  onClick: () => {
@@ -252,7 +254,7 @@ export const InlineBlockComponent = props => {
252
254
  tooltip: t('lexical:blocks:inlineBlocks:edit', {
253
255
  label: blockDisplayName
254
256
  })
255
- }), [blockDisplayName, readOnly, t, toggleDrawer]);
257
+ }), [blockDisplayName, isEditable, t, toggleDrawer]);
256
258
  const InlineBlockContainer = useMemo(() => ({
257
259
  children,
258
260
  className
@@ -275,7 +277,7 @@ export const InlineBlockComponent = props => {
275
277
  className: `${baseClass}-not-found`,
276
278
  children: [/*#__PURE__*/_jsxs("span", {
277
279
  children: ["Error: Block '", formData.blockType, "' not found"]
278
- }), editor.isEditable() ? /*#__PURE__*/_jsx("div", {
280
+ }), isEditable ? /*#__PURE__*/_jsx("div", {
279
281
  className: `${baseClass}__actions`,
280
282
  children: /*#__PURE__*/_jsx(RemoveButton, {})
281
283
  }) : null]
@@ -318,7 +320,7 @@ export const InlineBlockComponent = props => {
318
320
 
319
321
  parentSchemaPath: schemaFieldsPath,
320
322
  permissions: true,
321
- readOnly: false
323
+ readOnly: !isEditable
322
324
  }), /*#__PURE__*/_jsx(FormSubmit, {
323
325
  programmaticSubmit: true,
324
326
  children: t('fields:saveChanges')
@@ -339,7 +341,7 @@ export const InlineBlockComponent = props => {
339
341
  children: [initialState ? /*#__PURE__*/_jsx(Label, {}) : /*#__PURE__*/_jsx(ShimmerEffect, {
340
342
  height: "15px",
341
343
  width: "40px"
342
- }), editor.isEditable() ? /*#__PURE__*/_jsxs("div", {
344
+ }), isEditable ? /*#__PURE__*/_jsxs("div", {
343
345
  className: `${baseClass}__actions`,
344
346
  children: [/*#__PURE__*/_jsx(EditButton, {}), /*#__PURE__*/_jsx(RemoveButton, {})]
345
347
  }) : null]