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

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 (267) hide show
  1. package/dist/exports/client/Field-ZK6DB4T2.js +2 -0
  2. package/dist/exports/client/Field-ZK6DB4T2.js.map +7 -0
  3. package/dist/exports/client/chunk-3LRZDIIG.js +2 -0
  4. package/dist/exports/client/{chunk-LN6VX25I.js.map → chunk-3LRZDIIG.js.map} +2 -2
  5. package/dist/exports/client/chunk-4JYWPIBB.js +2 -0
  6. package/dist/exports/client/chunk-4JYWPIBB.js.map +7 -0
  7. package/dist/exports/client/chunk-UH7ALTP6.js +2 -0
  8. package/dist/exports/client/chunk-UH7ALTP6.js.map +7 -0
  9. package/dist/exports/client/{component-D5QLYS7W.js → component-ELXHSW52.js} +2 -2
  10. package/dist/exports/client/componentInline-HCGJ5ZFN.js +2 -0
  11. package/dist/exports/client/index.js +28 -28
  12. package/dist/exports/client/index.js.map +4 -4
  13. package/dist/features/blocks/client/component/BlockReordering/index.d.ts +11 -0
  14. package/dist/features/blocks/client/component/BlockReordering/index.d.ts.map +1 -0
  15. package/dist/features/blocks/client/component/BlockReordering/index.js +18 -0
  16. package/dist/features/blocks/client/component/BlockReordering/index.js.map +1 -0
  17. package/dist/features/blocks/client/component/index.d.ts +0 -6
  18. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  19. package/dist/features/blocks/client/component/index.js +196 -107
  20. package/dist/features/blocks/client/component/index.js.map +1 -1
  21. package/dist/features/blocks/client/component/useBlockReordering.d.ts +16 -0
  22. package/dist/features/blocks/client/component/useBlockReordering.d.ts.map +1 -0
  23. package/dist/features/blocks/client/component/useBlockReordering.js +178 -0
  24. package/dist/features/blocks/client/component/useBlockReordering.js.map +1 -0
  25. package/dist/features/blocks/client/componentInline/index.css +0 -1
  26. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  27. package/dist/features/blocks/client/componentInline/index.js +30 -28
  28. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  29. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts +9 -0
  30. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts.map +1 -0
  31. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js +95 -0
  32. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -0
  33. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  34. package/dist/features/blocks/client/nodes/BlocksNode.js +0 -10
  35. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  36. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  37. package/dist/features/blocks/server/nodes/BlocksNode.js +1 -12
  38. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  39. package/dist/features/blocks/server/nodes/InlineBlocksNode.js +2 -2
  40. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  41. package/dist/features/blocks/server/schema.d.ts +2 -0
  42. package/dist/features/blocks/server/schema.d.ts.map +1 -1
  43. package/dist/features/blocks/server/schema.js +7 -9
  44. package/dist/features/blocks/server/schema.js.map +1 -1
  45. package/dist/features/blocks/server/validate.js +1 -1
  46. package/dist/features/blocks/server/validate.js.map +1 -1
  47. package/dist/features/converters/lexicalToHtml/async/converters/upload.js +3 -3
  48. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  49. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +3 -3
  50. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
  51. package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
  52. package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
  53. package/dist/features/converters/lexicalToJSX/converter/converters/upload.d.ts.map +1 -1
  54. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +4 -5
  55. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
  56. package/dist/features/converters/utilities/payloadPopulateFn.d.ts.map +1 -1
  57. package/dist/features/converters/utilities/payloadPopulateFn.js +4 -2
  58. package/dist/features/converters/utilities/payloadPopulateFn.js.map +1 -1
  59. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +11 -1
  60. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  61. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +17 -0
  62. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  63. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +2 -2
  64. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  65. package/dist/features/horizontalRule/server/schema.d.ts +1 -0
  66. package/dist/features/horizontalRule/server/schema.d.ts.map +1 -1
  67. package/dist/features/horizontalRule/server/schema.js +6 -5
  68. package/dist/features/horizontalRule/server/schema.js.map +1 -1
  69. package/dist/features/indent/client/IndentPlugin.d.ts.map +1 -1
  70. package/dist/features/indent/client/IndentPlugin.js +122 -1
  71. package/dist/features/indent/client/IndentPlugin.js.map +1 -1
  72. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  73. package/dist/features/indent/server/i18n.js +74 -37
  74. package/dist/features/indent/server/i18n.js.map +1 -1
  75. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  76. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +8 -5
  77. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  78. package/dist/features/link/client/plugins/floatingLinkEditor/index.css +0 -1
  79. package/dist/features/link/client/plugins/link/index.js.map +1 -1
  80. package/dist/features/link/markdownTransformer.js +2 -2
  81. package/dist/features/link/markdownTransformer.js.map +1 -1
  82. package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  83. package/dist/features/link/nodes/AutoLinkNode.js +2 -10
  84. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  85. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  86. package/dist/features/link/nodes/LinkNode.js +2 -15
  87. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  88. package/dist/features/link/server/baseFields.js.map +1 -1
  89. package/dist/features/link/server/validate.js +1 -1
  90. package/dist/features/link/server/validate.js.map +1 -1
  91. package/dist/features/lists/shared/schema.d.ts.map +1 -1
  92. package/dist/features/lists/shared/schema.js.map +1 -1
  93. package/dist/features/relationship/client/components/index.css +3 -6
  94. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  95. package/dist/features/relationship/client/nodes/RelationshipNode.js +0 -3
  96. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  97. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  98. package/dist/features/relationship/server/nodes/RelationshipNode.js +1 -5
  99. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  100. package/dist/features/relationship/server/schema.d.ts +1 -0
  101. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  102. package/dist/features/relationship/server/schema.js +4 -2
  103. package/dist/features/relationship/server/schema.js.map +1 -1
  104. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.css +0 -1
  105. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js +1 -1
  106. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  107. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -1
  108. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js +41 -18
  109. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  110. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.css +0 -3
  111. package/dist/features/textState/defaultColors.js +1 -1
  112. package/dist/features/textState/defaultColors.js.map +1 -1
  113. package/dist/features/toolbars/fixed/client/Toolbar/index.css +2 -2
  114. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  115. package/dist/features/toolbars/fixed/client/Toolbar/index.js +15 -0
  116. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  117. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  118. package/dist/features/toolbars/inline/client/Toolbar/index.js +17 -2
  119. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  120. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  121. package/dist/features/toolbars/shared/ToolbarButton/index.js +1 -0
  122. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  123. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  124. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +85 -32
  125. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  126. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +4 -1
  127. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts +5 -0
  128. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts.map +1 -0
  129. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js +79 -0
  130. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js.map +1 -0
  131. package/dist/features/typesServer.d.ts +16 -11
  132. package/dist/features/typesServer.d.ts.map +1 -1
  133. package/dist/features/typesServer.js.map +1 -1
  134. package/dist/features/upload/client/component/index.css +0 -2
  135. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  136. package/dist/features/upload/client/nodes/UploadNode.js +0 -7
  137. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  138. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  139. package/dist/features/upload/client/plugin/index.js +3 -1
  140. package/dist/features/upload/client/plugin/index.js.map +1 -1
  141. package/dist/features/upload/server/index.d.ts +1 -1
  142. package/dist/features/upload/server/index.d.ts.map +1 -1
  143. package/dist/features/upload/server/index.js.map +1 -1
  144. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  145. package/dist/features/upload/server/nodes/UploadNode.js +1 -9
  146. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  147. package/dist/features/upload/server/schema.d.ts +2 -14
  148. package/dist/features/upload/server/schema.d.ts.map +1 -1
  149. package/dist/features/upload/server/schema.js +4 -2
  150. package/dist/features/upload/server/schema.js.map +1 -1
  151. package/dist/features/upload/server/validate.js +1 -1
  152. package/dist/features/upload/server/validate.js.map +1 -1
  153. package/dist/field/Diff/converters/relationship/index.css +0 -1
  154. package/dist/field/Diff/converters/unknown/index.css +0 -1
  155. package/dist/field/Diff/converters/upload/index.css +0 -1
  156. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  157. package/dist/field/Diff/index.css +20 -19
  158. package/dist/field/Diff/index.d.ts +3 -2
  159. package/dist/field/Diff/index.d.ts.map +1 -1
  160. package/dist/field/Diff/index.js +2 -2
  161. package/dist/field/Diff/index.js.map +1 -1
  162. package/dist/field/Field.d.ts.map +1 -1
  163. package/dist/field/Field.js +8 -1
  164. package/dist/field/Field.js.map +1 -1
  165. package/dist/field/ViewSelector.d.ts.map +1 -1
  166. package/dist/field/ViewSelector.js +1 -0
  167. package/dist/field/ViewSelector.js.map +1 -1
  168. package/dist/field/bundled.css +1 -1
  169. package/dist/field/index.css +0 -5
  170. package/dist/field/rscEntry.d.ts +2 -2
  171. package/dist/field/rscEntry.d.ts.map +1 -1
  172. package/dist/field/rscEntry.js.map +1 -1
  173. package/dist/index.d.ts +4 -4
  174. package/dist/index.d.ts.map +1 -1
  175. package/dist/index.js +23 -1
  176. package/dist/index.js.map +1 -1
  177. package/dist/lexical/LexicalEditor.css +23 -12
  178. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  179. package/dist/lexical/LexicalEditor.js +61 -64
  180. package/dist/lexical/LexicalEditor.js.map +1 -1
  181. package/dist/lexical/plugins/DecoratorPlugin/index.d.ts.map +1 -1
  182. package/dist/lexical/plugins/DecoratorPlugin/index.js +24 -21
  183. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  184. package/dist/lexical/plugins/InsertParagraphAtEnd/index.css +2 -1
  185. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +1 -1
  186. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  187. package/dist/lexical/plugins/SlashMenu/index.css +0 -1
  188. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -0
  189. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +2 -2
  190. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  191. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +1 -0
  192. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  193. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +16 -2
  194. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  195. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts +7 -0
  196. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts.map +1 -0
  197. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js +65 -0
  198. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js.map +1 -0
  199. package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  200. package/dist/lexical/plugins/handles/utils/setHandlePosition.js +2 -0
  201. package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  202. package/dist/lexical/theme/EditorTheme.css +35 -25
  203. package/dist/lexical/ui/ContentEditable.css +0 -1
  204. package/dist/lexical/ui/ContentEditable.d.ts +2 -1
  205. package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
  206. package/dist/lexical/ui/ContentEditable.js +32 -11
  207. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  208. package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
  209. package/dist/lexical/utils/nodeFormat.js +0 -2
  210. package/dist/lexical/utils/nodeFormat.js.map +1 -1
  211. package/dist/lexical/utils/url.d.ts.map +1 -1
  212. package/dist/lexical/utils/url.js +1 -1
  213. package/dist/lexical/utils/url.js.map +1 -1
  214. package/dist/populateGraphQL/populate.js.map +1 -1
  215. package/dist/presets/llmInstructions.d.ts +2 -0
  216. package/dist/presets/llmInstructions.d.ts.map +1 -0
  217. package/dist/presets/llmInstructions.js +13 -0
  218. package/dist/presets/llmInstructions.js.map +1 -0
  219. package/dist/types/builtInNodes.d.ts +1 -1
  220. package/dist/types/builtInNodes.d.ts.map +1 -1
  221. package/dist/types/builtInNodes.js +8 -3
  222. package/dist/types/builtInNodes.js.map +1 -1
  223. package/dist/types/index.d.ts +3 -6
  224. package/dist/types/index.d.ts.map +1 -1
  225. package/dist/types/index.js.map +1 -1
  226. package/dist/types/jsonSchemaHelpers.d.ts +5 -1
  227. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -1
  228. package/dist/types/jsonSchemaHelpers.js +7 -2
  229. package/dist/types/jsonSchemaHelpers.js.map +1 -1
  230. package/dist/types/nodeTypes.d.ts +5 -0
  231. package/dist/types/nodeTypes.d.ts.map +1 -1
  232. package/dist/types/nodeTypes.js.map +1 -1
  233. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  234. package/dist/utilities/buildEditorState.js.map +1 -1
  235. package/dist/utilities/buildInitialState.d.ts +3 -2
  236. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  237. package/dist/utilities/buildInitialState.js +1 -0
  238. package/dist/utilities/buildInitialState.js.map +1 -1
  239. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  240. package/dist/utilities/fieldsDrawer/DrawerContent.js +2 -7
  241. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  242. package/dist/utilities/generateImportMap.d.ts +2 -2
  243. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  244. package/dist/utilities/generateImportMap.js.map +1 -1
  245. package/dist/utilities/upgradeLexicalData/index.js +6 -3
  246. package/dist/utilities/upgradeLexicalData/index.js.map +1 -1
  247. package/dist/validate/hasText.d.ts +2 -2
  248. package/dist/validate/hasText.d.ts.map +1 -1
  249. package/dist/validate/hasText.js.map +1 -1
  250. package/dist/validate/index.d.ts +1 -1
  251. package/dist/validate/index.d.ts.map +1 -1
  252. package/package.json +44 -47
  253. package/dist/exports/client/Field-QKAL7KMC.js +0 -2
  254. package/dist/exports/client/Field-QKAL7KMC.js.map +0 -7
  255. package/dist/exports/client/bundled.css +0 -1
  256. package/dist/exports/client/chunk-43E5QYAA.js +0 -2
  257. package/dist/exports/client/chunk-43E5QYAA.js.map +0 -7
  258. package/dist/exports/client/chunk-ESITTE3C.js +0 -2
  259. package/dist/exports/client/chunk-ESITTE3C.js.map +0 -7
  260. package/dist/exports/client/chunk-LN6VX25I.js +0 -2
  261. package/dist/exports/client/componentInline-H24N7GUG.js +0 -2
  262. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts +0 -11
  263. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts.map +0 -1
  264. package/dist/features/blocks/client/component/removeEmptyArrayValues.js +0 -20
  265. package/dist/features/blocks/client/component/removeEmptyArrayValues.js.map +0 -1
  266. /package/dist/exports/client/{component-D5QLYS7W.js.map → component-ELXHSW52.js.map} +0 -0
  267. /package/dist/exports/client/{componentInline-H24N7GUG.js.map → componentInline-HCGJ5ZFN.js.map} +0 -0
@@ -0,0 +1,11 @@
1
+ import type { LexicalEditor } from 'lexical';
2
+ import type { ReactNode } from 'react';
3
+ import { useBlockReordering } from '../useBlockReordering.js';
4
+ export declare function BlockReordering({ children, editor, nodeKey, }: {
5
+ children: (props: {
6
+ reorderInstructionsID: string;
7
+ } & ReturnType<typeof useBlockReordering>) => ReactNode;
8
+ editor: LexicalEditor;
9
+ nodeKey: string;
10
+ }): ReactNode;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/blocks/client/component/BlockReordering/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAE7D,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,MAAM,EACN,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,CACR,KAAK,EAAE;QAAE,qBAAqB,EAAE,MAAM,CAAA;KAAE,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,KAC7E,SAAS,CAAA;IACd,MAAM,EAAE,aAAa,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;CAChB,aAKA"}
@@ -0,0 +1,18 @@
1
+ import { useId } from 'react';
2
+ import { useBlockReordering } from '../useBlockReordering.js';
3
+ export function BlockReordering({
4
+ children,
5
+ editor,
6
+ nodeKey
7
+ }) {
8
+ const reorder = useBlockReordering({
9
+ editor,
10
+ nodeKey
11
+ });
12
+ const reorderInstructionsID = useId();
13
+ return children({
14
+ ...reorder,
15
+ reorderInstructionsID
16
+ });
17
+ }
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["useId","useBlockReordering","BlockReordering","children","editor","nodeKey","reorder","reorderInstructionsID"],"sources":["../../../../../../src/features/blocks/client/component/BlockReordering/index.tsx"],"sourcesContent":["import type { LexicalEditor } from 'lexical'\nimport type { ReactNode } from 'react'\n\nimport { useId } from 'react'\n\nimport { useBlockReordering } from '../useBlockReordering.js'\n\nexport function BlockReordering({\n children,\n editor,\n nodeKey,\n}: {\n children: (\n props: { reorderInstructionsID: string } & ReturnType<typeof useBlockReordering>,\n ) => ReactNode\n editor: LexicalEditor\n nodeKey: string\n}) {\n const reorder = useBlockReordering({ editor, nodeKey })\n const reorderInstructionsID = useId()\n\n return children({ ...reorder, reorderInstructionsID })\n}\n"],"mappings":"AAGA,SAASA,KAAK,QAAQ;AAEtB,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,SAASC,gBAAgB;EAC9BC,QAAQ;EACRC,MAAM;EACNC;AAAO,CAOR;EACC,MAAMC,OAAA,GAAUL,kBAAA,CAAmB;IAAEG,MAAA;IAAQC;EAAQ;EACrD,MAAME,qBAAA,GAAwBP,KAAA;EAE9B,OAAOG,QAAA,CAAS;IAAE,GAAGG,OAAO;IAAEC;EAAsB;AACtD","ignoreList":[]}
@@ -21,13 +21,7 @@ export type BlockComponentProps<TFormData extends Record<string, unknown> = Bloc
21
21
  * Will be rendered with useBlockComponentContext hook.
22
22
  */
23
23
  readonly CustomLabel?: React.FC<ViewMapBlockComponentProps>;
24
- /**
25
- * The block's form data (field values).
26
- */
27
24
  readonly formData: TFormData;
28
- /**
29
- * The unique key identifying this block node in the current editor instance.
30
- */
31
25
  readonly nodeKey: string;
32
26
  };
33
27
  export declare const BlockComponent: React.FC<BlockComponentProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAGtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,aAAa,CAAA;AACpB,OAAO,8CAA8C,CAAA;AAerD,MAAM,MAAM,mBAAmB,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,IAAI;IACzF;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAA;IAC3D;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAA;IAC3D;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA0uBxD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAGtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,aAAa,CAAA;AACpB,OAAO,8CAA8C,CAAA;AAmBrD,MAAM,MAAM,mBAAmB,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,IAAI;IACzF;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAA;IAC3D;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAA;IAC3D,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAyyBxD,CAAA"}
@@ -1,13 +1,14 @@
1
1
  'use client';
2
2
 
3
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
4
5
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
5
6
  import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
6
7
  import { getTranslation } from '@payloadcms/translations';
7
8
  import { Button, Collapsible, Drawer, EditDepthProvider, ErrorPill, Form, formatDrawerSlug, MoreIcon, Pill, Popup, PopupList, RenderFields, SectionTitle, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useFormSubmitted, useServerFunctions, useTranslation, XIcon } from '@payloadcms/ui';
8
9
  import { abortAndIgnore } from '@payloadcms/ui/shared';
9
10
  import { $getNodeByKey, $getRoot, SKIP_DOM_SELECTION_TAG } from 'lexical';
10
- import { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared';
11
+ import { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared';
11
12
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
12
13
  import { v4 as uuid } from 'uuid';
13
14
  import './index.css';
@@ -15,9 +16,10 @@ import '../../../../utilities/fieldsDrawer/index.css';
15
16
  import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
16
17
  import { RegisterFormSubmit, useDrawerSubmit } from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js';
17
18
  import { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js';
19
+ import { getCachedFormStateIfDataMatches, reduceFormStateToBlockData } from '../getCachedFormStateIfDataMatches.js';
18
20
  import { $isBlockNode } from '../nodes/BlocksNode.js';
19
21
  import { BlockContent, useBlockComponentContext } from './BlockContent.js';
20
- import { removeEmptyArrayValues } from './removeEmptyArrayValues.js';
22
+ import { BlockReordering } from './BlockReordering/index.js';
21
23
  export const BlockComponent = props => {
22
24
  const {
23
25
  cacheBuster,
@@ -68,31 +70,43 @@ export const BlockComponent = props => {
68
70
  const [editor] = useLexicalComposerContext();
69
71
  const isEditable = useLexicalEditable();
70
72
  const blockType = formData.blockType;
73
+ const formDataRef = useRef(formData);
74
+ formDataRef.current = formData;
75
+ const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`;
76
+ const clientSchemaMap = featureClientSchemaMap['blocks'];
77
+ const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
78
+ const blockOrSlug = blocksField?.blocks?.[0];
79
+ const clientBlock = typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug;
71
80
  const {
72
81
  getFormState
73
82
  } = useServerFunctions();
74
83
  const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`;
75
84
  const [initialState, setInitialState] = React.useState(() => {
76
85
  // Initial form state that was calculated server-side. May have stale values
77
- const cachedFormState = initialLexicalFormState?.[formData.id]?.formState;
86
+ const cachedState = initialLexicalFormState?.[formData.id];
87
+ const cachedFormState = cachedState?.formState;
78
88
  if (!cachedFormState) {
79
89
  return false;
80
90
  }
81
- // Merge current formData values into the cached form state
82
- // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits
83
- const mergedState = Object.fromEntries(Object.entries(cachedFormState).map(([fieldName, fieldState]) => [fieldName, fieldName in formData ? {
84
- ...fieldState,
85
- initialValue: formData[fieldName],
86
- value: formData[fieldName]
87
- } : fieldState]));
91
+ const matchingCachedState = getCachedFormStateIfDataMatches({
92
+ cachedFormState,
93
+ cachedSchemaPath: cachedState.schemaPath,
94
+ currentSchemaPath: schemaFieldsPath,
95
+ formData
96
+ });
97
+ if (!matchingCachedState) {
98
+ return false;
99
+ }
88
100
  // Manually add blockName, as it's not part of cachedFormState
89
- mergedState.blockName = {
90
- initialValue: formData.blockName,
91
- passesCondition: true,
92
- valid: true,
93
- value: formData.blockName
101
+ return {
102
+ ...matchingCachedState,
103
+ blockName: {
104
+ initialValue: formData.blockName,
105
+ passesCondition: true,
106
+ valid: true,
107
+ value: formData.blockName
108
+ }
94
109
  };
95
- return mergedState;
96
110
  });
97
111
  const hasMounted = useRef(false);
98
112
  const prevCacheBuster = useRef(cacheBuster);
@@ -173,9 +187,7 @@ export const BlockComponent = props => {
173
187
  fields: true
174
188
  },
175
189
  docPreferences: await getDocPreferences(),
176
- documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {
177
- excludeFiles: true
178
- }),
190
+ documentFormState: parentDocumentFields,
179
191
  globalSlug,
180
192
  initialBlockData: formData,
181
193
  operation: 'update',
@@ -191,9 +203,9 @@ export const BlockComponent = props => {
191
203
  valid: true,
192
204
  value: formData.blockName
193
205
  };
194
- const newFormStateData = reduceFieldsToValues(deepCopyObjectSimpleWithoutReactComponents(state, {
206
+ const newFormStateData = reduceFormStateToBlockData(deepCopyObjectSimpleWithoutReactComponents(state, {
195
207
  excludeFiles: true
196
- }), true);
208
+ }));
197
209
  // Things like default values may come back from the server => update the node with the new data
198
210
  editor.update(() => {
199
211
  const node = $getNodeByKey(nodeKey);
@@ -217,19 +229,14 @@ export const BlockComponent = props => {
217
229
  }
218
230
  }
219
231
  };
220
- if (formData && !initialState) {
232
+ if (clientBlock && formData && !initialState) {
221
233
  void awaitInitialState();
222
234
  }
223
235
  return () => {
224
236
  abortAndIgnore(abortController);
225
237
  };
226
- }, [getFormState, schemaFieldsPath, isEditable, id, CustomLabelFromProps, CustomBlockFromProps, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields, blockType]);
238
+ }, [getFormState, schemaFieldsPath, isEditable, id, CustomLabelFromProps, CustomBlockFromProps, formData, editor, nodeKey, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields, blockType, clientBlock]);
227
239
  const [isCollapsed, setIsCollapsed] = React.useState(initialLexicalFormState?.[formData.id]?.collapsed ?? false);
228
- const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`;
229
- const clientSchemaMap = featureClientSchemaMap['blocks'];
230
- const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
231
- const blockOrSlug = blocksField?.blocks?.[0];
232
- const clientBlock = typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug;
233
240
  const {
234
241
  i18n,
235
242
  t
@@ -241,21 +248,21 @@ export const BlockComponent = props => {
241
248
  abortAndIgnore(onChangeAbortControllerRef.current);
242
249
  const controller = new AbortController();
243
250
  onChangeAbortControllerRef.current = controller;
251
+ const blockData = reduceFormStateToBlockData(prevFormState, formDataRef.current);
244
252
  const {
245
253
  state: newFormState
246
254
  } = await getFormState({
247
255
  id,
248
256
  collectionSlug,
257
+ data: blockData,
249
258
  docPermissions: {
250
259
  fields: true
251
260
  },
252
261
  docPreferences: await getDocPreferences(),
253
- documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {
254
- excludeFiles: true
255
- }),
262
+ documentFormState: parentDocumentFields,
256
263
  formState: prevFormState,
257
264
  globalSlug,
258
- initialBlockFormState: prevFormState,
265
+ initialBlockData: blockData,
259
266
  operation: 'update',
260
267
  readOnly: !isEditable,
261
268
  renderAllFields: submit ? true : false,
@@ -268,11 +275,9 @@ export const BlockComponent = props => {
268
275
  if (prevFormState.blockName) {
269
276
  newFormState.blockName = prevFormState.blockName;
270
277
  }
271
- const newFormStateData_0 = reduceFieldsToValues(removeEmptyArrayValues({
272
- fields: deepCopyObjectSimpleWithoutReactComponents(newFormState, {
273
- excludeFiles: true
274
- })
275
- }), true);
278
+ const newFormStateData_0 = reduceFormStateToBlockData(deepCopyObjectSimpleWithoutReactComponents(newFormState, {
279
+ excludeFiles: true
280
+ }), blockData);
276
281
  setTimeout(() => {
277
282
  editor.update(() => {
278
283
  const node_0 = $getNodeByKey(nodeKey);
@@ -394,7 +399,7 @@ export const BlockComponent = props => {
394
399
  round: true,
395
400
  tooltip: "Remove Block"
396
401
  }), [baseClass, isEditable, removeBlock]);
397
- const BlockCollapsible = useMemo(() => ({
402
+ const BlockCollapsible = useMemo(() => function BlockCollapsible({
398
403
  Actions,
399
404
  children: children_0,
400
405
  className,
@@ -408,77 +413,132 @@ export const BlockComponent = props => {
408
413
  removeButton,
409
414
  showDragHandle = true,
410
415
  showRowNumber = true
411
- }) => {
412
- return /*#__PURE__*/_jsx("div", {
413
- className: `${baseClass}__container ${baseClass}-${blockType}`,
414
- children: /*#__PURE__*/_jsx(Collapsible, {
415
- actions: typeof Actions !== 'undefined' ? Actions : isEditable ? /*#__PURE__*/_jsx(Popup, {
416
- button: /*#__PURE__*/_jsx(MoreIcon, {}),
417
- buttonClassName: `${baseClass}__actions-button`,
418
- caret: false,
419
- horizontalAlign: "right",
420
- render: ({
421
- close
422
- }) => /*#__PURE__*/_jsxs(PopupList.ButtonGroup, {
423
- buttonSize: "medium",
424
- children: [(resolvedCustomBlock && editButton !== false || !resolvedCustomBlock && editButton) && /*#__PURE__*/_jsx(PopupList.Button, {
425
- onClick: () => {
426
- toggleDrawer();
427
- close();
428
- },
429
- children: t('general:edit')
430
- }), removeButton !== false && /*#__PURE__*/_jsxs(PopupList.Button, {
431
- onClick: () => {
432
- removeBlock();
433
- close();
434
- },
435
- children: [/*#__PURE__*/_jsx(XIcon, {}), t('general:remove')]
436
- })]
416
+ }) {
417
+ return /*#__PURE__*/_jsx(BlockReordering, {
418
+ editor: editor,
419
+ nodeKey: nodeKey,
420
+ children: ({
421
+ isReordering,
422
+ move,
423
+ onBlur,
424
+ onKeyDown,
425
+ reorderInstructionsID,
426
+ targetIndex
427
+ }) => /*#__PURE__*/_jsx("div", {
428
+ className: `${baseClass}__container ${baseClass}-${blockType}`,
429
+ onKeyDownCapture: event => {
430
+ const target = event.target;
431
+ if (event.altKey || event.ctrlKey || event.metaKey || target.closest('.collapsible')?.parentElement !== event.currentTarget) {
432
+ return;
433
+ }
434
+ // Handle controls before Lexical consumes keys using its retained text selection.
435
+ if (target.matches('.collapsible__drag') && (event.key !== 'Escape' || isReordering) && [' ', 'ArrowDown', 'ArrowUp', 'Enter', 'Escape', 'Tab'].includes(event.key)) {
436
+ onKeyDown(event);
437
+ event.stopPropagation();
438
+ } else if (event.key === 'Tab' && target.matches('.collapsible__toggle')) {
439
+ event.stopPropagation();
440
+ }
441
+ },
442
+ children: /*#__PURE__*/_jsxs(Collapsible, {
443
+ actions: typeof Actions !== 'undefined' ? Actions : isEditable ? /*#__PURE__*/_jsx(Popup, {
444
+ button: /*#__PURE__*/_jsx(MoreIcon, {}),
445
+ buttonAriaLabel: t('general:moreOptions'),
446
+ buttonClassName: `${baseClass}__actions-button`,
447
+ caret: false,
448
+ horizontalAlign: "right",
449
+ popupType: "menu",
450
+ render: ({
451
+ close
452
+ }) => /*#__PURE__*/_jsxs(PopupList.ButtonGroup, {
453
+ buttonSize: "medium",
454
+ children: [/*#__PURE__*/_jsx(PopupList.Button, {
455
+ onClick: () => {
456
+ close();
457
+ move({
458
+ direction: -1
459
+ });
460
+ },
461
+ children: t('general:moveUp')
462
+ }), /*#__PURE__*/_jsx(PopupList.Button, {
463
+ onClick: () => {
464
+ close();
465
+ move({
466
+ direction: 1
467
+ });
468
+ },
469
+ children: t('general:moveDown')
470
+ }), (resolvedCustomBlock && editButton !== false || !resolvedCustomBlock && editButton) && /*#__PURE__*/_jsx(PopupList.Button, {
471
+ onClick: () => {
472
+ toggleDrawer();
473
+ close();
474
+ },
475
+ children: t('general:edit')
476
+ }), removeButton !== false && /*#__PURE__*/_jsxs(PopupList.Button, {
477
+ onClick: () => {
478
+ removeBlock();
479
+ close();
480
+ },
481
+ children: [/*#__PURE__*/_jsx(XIcon, {}), t('general:remove')]
482
+ })]
483
+ }),
484
+ size: "large"
485
+ }) : null,
486
+ className: [`${baseClass}__row`, fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`, className].filter(Boolean).join(' '),
487
+ collapsibleStyle: fieldHasErrors ? 'error' : 'default',
488
+ dragHandleProps: showDragHandle && isEditable ? {
489
+ id: nodeKey,
490
+ attributes: {
491
+ 'aria-describedby': reorderInstructionsID,
492
+ 'aria-pressed': isReordering,
493
+ role: 'button',
494
+ tabIndex: 0
495
+ },
496
+ listeners: {
497
+ onBlur
498
+ }
499
+ } : undefined,
500
+ header: /*#__PURE__*/_jsx("div", {
501
+ className: `${baseClass}__block-header`,
502
+ children: typeof Label !== 'undefined' ? Label : typeof resolvedCustomLabel !== 'undefined' ? resolvedCustomLabel : /*#__PURE__*/_jsxs("div", {
503
+ className: `${baseClass}__block-label`,
504
+ children: [showRowNumber && /*#__PURE__*/_jsx("span", {
505
+ className: `${baseClass}__block-number`,
506
+ children: String(rowIndex + 1).padStart(2, '0')
507
+ }), typeof CustomPill !== 'undefined' ? CustomPill : /*#__PURE__*/_jsx(Pill, {
508
+ className: `${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`,
509
+ pillStyle: "white",
510
+ size: "small",
511
+ children: blockDisplayName ?? blockType
512
+ }), !disableBlockName && !clientBlock?.admin?.disableBlockName && /*#__PURE__*/_jsx(SectionTitle, {
513
+ path: "blockName",
514
+ readOnly: !isEditable
515
+ }), fieldHasErrors && /*#__PURE__*/_jsx(BlockErrorPill, {
516
+ count: errorCount_0 ?? 0
517
+ })]
518
+ })
437
519
  }),
438
- size: "large"
439
- }) : null,
440
- className: [`${baseClass}__row`, fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`, className].filter(Boolean).join(' '),
441
- collapsibleStyle: fieldHasErrors ? 'error' : 'default',
442
- dragHandleProps: showDragHandle ? {
443
- id: nodeKey,
444
- attributes: {
445
- role: 'button',
446
- tabIndex: 0
520
+ isCollapsed: isCollapsed,
521
+ onToggle: incomingCollapsedState => {
522
+ onCollapsedChange(incomingCollapsedState);
523
+ setIsCollapsed(incomingCollapsedState);
447
524
  },
448
- listeners: {}
449
- } : undefined,
450
- header: /*#__PURE__*/_jsx("div", {
451
- className: `${baseClass}__block-header`,
452
- children: typeof Label !== 'undefined' ? Label : typeof resolvedCustomLabel !== 'undefined' ? resolvedCustomLabel : /*#__PURE__*/_jsxs("div", {
453
- className: `${baseClass}__block-label`,
454
- children: [showRowNumber && /*#__PURE__*/_jsx("span", {
455
- className: `${baseClass}__block-number`,
456
- children: String(rowIndex + 1).padStart(2, '0')
457
- }), typeof CustomPill !== 'undefined' ? CustomPill : /*#__PURE__*/_jsx(Pill, {
458
- className: `${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`,
459
- pillStyle: "white",
460
- size: "small",
461
- children: blockDisplayName ?? blockType
462
- }), !disableBlockName && !clientBlock?.admin?.disableBlockName && /*#__PURE__*/_jsx(SectionTitle, {
463
- path: "blockName",
464
- readOnly: !isEditable
465
- }), fieldHasErrors && /*#__PURE__*/_jsx(ErrorPill, {
466
- count: errorCount_0 ?? 0,
467
- i18n: i18n,
468
- withMessage: true
525
+ ...(collapsibleProps || {}),
526
+ AfterCollapsible: /*#__PURE__*/_jsxs(_Fragment, {
527
+ children: [collapsibleProps?.AfterCollapsible, /*#__PURE__*/_jsx("span", {
528
+ className: "sr-only",
529
+ role: "status",
530
+ children: isReordering ? `${t('general:order')}: ${(targetIndex ?? 0) + 1}` : ''
469
531
  })]
470
- })
471
- }),
472
- isCollapsed: isCollapsed,
473
- onToggle: incomingCollapsedState => {
474
- onCollapsedChange(incomingCollapsedState);
475
- setIsCollapsed(incomingCollapsedState);
476
- },
477
- ...(collapsibleProps || {}),
478
- children: children_0
479
- }, 0)
532
+ }),
533
+ children: [/*#__PURE__*/_jsxs("span", {
534
+ className: "sr-only",
535
+ id: reorderInstructionsID,
536
+ children: ["Space / Enter · ", t('general:moveUp'), " ↑ · ", t('general:moveDown'), " ↓ ·", ' ', t('general:cancel'), " Escape"]
537
+ }), children_0]
538
+ }, 0)
539
+ })
480
540
  });
481
- }, [resolvedCustomBlock, resolvedCustomLabel, blockDisplayName, baseClass, clientBlock?.admin?.disableBlockName, blockType, i18n, isCollapsed, onCollapsedChange, isEditable, nodeKey, removeBlock, rowIndex, t, toggleDrawer]);
541
+ }, [editor, resolvedCustomBlock, resolvedCustomLabel, blockDisplayName, baseClass, clientBlock?.admin?.disableBlockName, blockType, isCollapsed, onCollapsedChange, isEditable, nodeKey, removeBlock, rowIndex, t, toggleDrawer]);
482
542
  const blockID = formData?.id;
483
543
  const {
484
544
  headerActions,
@@ -532,8 +592,9 @@ export const BlockComponent = props => {
532
592
  fields: clientBlock?.fields ?? [],
533
593
  initialState: initialState,
534
594
  onChange: [onChange],
535
- onSubmit: (formState_0, newData_1) => {
595
+ onSubmit: formState_0 => {
536
596
  // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component
597
+ const newData_1 = reduceFormStateToBlockData(formState_0, formDataRef.current);
537
598
  newData_1.blockType = blockType;
538
599
  editor.update(() => {
539
600
  const node_1 = $getNodeByKey(nodeKey);
@@ -578,4 +639,32 @@ export const BlockComponent = props => {
578
639
  }
579
640
  return Block;
580
641
  };
642
+ /**
643
+ * Reads `i18n` itself so `BlockCollapsible` does not depend on it. `BlockCollapsible` is created in
644
+ * a `useMemo`, so each new `i18n` object (e.g. once the date-fns locale is set after mount) would
645
+ * remount the whole block, closing its open menus and dropping focus.
646
+ */
647
+ const BlockErrorPill = t0 => {
648
+ const $ = _c(3);
649
+ const {
650
+ count
651
+ } = t0;
652
+ const {
653
+ i18n
654
+ } = useTranslation();
655
+ let t1;
656
+ if ($[0] !== count || $[1] !== i18n) {
657
+ t1 = _jsx(ErrorPill, {
658
+ count,
659
+ i18n,
660
+ withMessage: true
661
+ });
662
+ $[0] = count;
663
+ $[1] = i18n;
664
+ $[2] = t1;
665
+ } else {
666
+ t1 = $[2];
667
+ }
668
+ return t1;
669
+ };
581
670
  //# sourceMappingURL=index.js.map