@payloadcms/richtext-lexical 4.0.0-internal.9496957 → 4.0.0-internal.94ef095

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 (470) hide show
  1. package/dist/exports/client/Field-334JNLRF.js +2 -0
  2. package/dist/exports/client/Field-334JNLRF.js.map +7 -0
  3. package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js → RelationshipComponent-TVK6I4W4.js} +2 -2
  4. package/dist/exports/client/chunk-3V7KW5XF.js +2 -0
  5. package/dist/exports/client/chunk-3V7KW5XF.js.map +7 -0
  6. package/dist/exports/client/chunk-A7DZCL6D.js +2 -0
  7. package/dist/exports/client/chunk-A7DZCL6D.js.map +7 -0
  8. package/dist/exports/client/{chunk-WSAPGI3Z.js → chunk-EA5BHQ2T.js} +1 -1
  9. package/dist/exports/client/{chunk-WSAPGI3Z.js.map → chunk-EA5BHQ2T.js.map} +1 -1
  10. package/dist/exports/client/chunk-FAJJXXCW.js +2 -0
  11. package/dist/exports/client/chunk-FAJJXXCW.js.map +7 -0
  12. package/dist/exports/client/{chunk-5VIL27GI.js → chunk-IYBYNEKX.js} +1 -1
  13. package/dist/exports/client/{chunk-5VIL27GI.js.map → chunk-IYBYNEKX.js.map} +1 -1
  14. package/dist/exports/client/{component-D5QLYS7W.js → component-FCCSBBZG.js} +2 -2
  15. package/dist/exports/client/componentInline-7FQV2X7Z.js +2 -0
  16. package/dist/exports/client/index.js +28 -28
  17. package/dist/exports/client/index.js.map +4 -4
  18. package/dist/features/align/client/index.js.map +1 -1
  19. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  20. package/dist/features/blocks/client/component/BlockReordering/index.d.ts +11 -0
  21. package/dist/features/blocks/client/component/BlockReordering/index.d.ts.map +1 -0
  22. package/dist/features/blocks/client/component/BlockReordering/index.js +18 -0
  23. package/dist/features/blocks/client/component/BlockReordering/index.js.map +1 -0
  24. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  25. package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
  26. package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
  27. package/dist/features/blocks/client/component/index.d.ts +0 -6
  28. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  29. package/dist/features/blocks/client/component/index.js +209 -164
  30. package/dist/features/blocks/client/component/index.js.map +1 -1
  31. package/dist/features/blocks/client/component/useBlockReordering.d.ts +16 -0
  32. package/dist/features/blocks/client/component/useBlockReordering.d.ts.map +1 -0
  33. package/dist/features/blocks/client/component/useBlockReordering.js +178 -0
  34. package/dist/features/blocks/client/component/useBlockReordering.js.map +1 -0
  35. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
  36. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
  37. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
  38. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
  39. package/dist/features/blocks/client/componentInline/index.css +0 -1
  40. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  41. package/dist/features/blocks/client/componentInline/index.js +37 -76
  42. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  43. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts +8 -0
  44. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts.map +1 -0
  45. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js +72 -0
  46. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -0
  47. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  48. package/dist/features/blocks/client/nodes/BlocksNode.js +0 -10
  49. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  50. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  51. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +121 -78
  52. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  53. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +142 -87
  54. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
  55. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  56. package/dist/features/blocks/server/nodes/BlocksNode.js +1 -12
  57. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  58. package/dist/features/blocks/server/nodes/InlineBlocksNode.js +2 -2
  59. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  60. package/dist/features/blocks/server/schema.d.ts +2 -0
  61. package/dist/features/blocks/server/schema.d.ts.map +1 -1
  62. package/dist/features/blocks/server/schema.js +7 -9
  63. package/dist/features/blocks/server/schema.js.map +1 -1
  64. package/dist/features/blocks/server/validate.js +1 -1
  65. package/dist/features/blocks/server/validate.js.map +1 -1
  66. package/dist/features/converters/lexicalToHtml/async/converters/heading.js +1 -1
  67. package/dist/features/converters/lexicalToHtml/async/converters/heading.js.map +1 -1
  68. package/dist/features/converters/lexicalToHtml/async/converters/list.d.ts.map +1 -1
  69. package/dist/features/converters/lexicalToHtml/async/converters/list.js +4 -3
  70. package/dist/features/converters/lexicalToHtml/async/converters/list.js.map +1 -1
  71. package/dist/features/converters/lexicalToHtml/async/converters/table.d.ts.map +1 -1
  72. package/dist/features/converters/lexicalToHtml/async/converters/table.js +6 -4
  73. package/dist/features/converters/lexicalToHtml/async/converters/table.js.map +1 -1
  74. package/dist/features/converters/lexicalToHtml/async/converters/upload.d.ts.map +1 -1
  75. package/dist/features/converters/lexicalToHtml/async/converters/upload.js +5 -4
  76. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  77. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js +1 -1
  78. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js.map +1 -1
  79. package/dist/features/converters/lexicalToHtml/sync/converters/list.d.ts.map +1 -1
  80. package/dist/features/converters/lexicalToHtml/sync/converters/list.js +4 -3
  81. package/dist/features/converters/lexicalToHtml/sync/converters/list.js.map +1 -1
  82. package/dist/features/converters/lexicalToHtml/sync/converters/table.d.ts.map +1 -1
  83. package/dist/features/converters/lexicalToHtml/sync/converters/table.js +6 -4
  84. package/dist/features/converters/lexicalToHtml/sync/converters/table.js.map +1 -1
  85. package/dist/features/converters/lexicalToHtml/sync/converters/upload.d.ts.map +1 -1
  86. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +5 -4
  87. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
  88. package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
  89. package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
  90. package/dist/features/converters/lexicalToJSX/converter/converters/heading.d.ts.map +1 -1
  91. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +2 -1
  92. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
  93. package/dist/features/converters/lexicalToJSX/converter/converters/list.d.ts.map +1 -1
  94. package/dist/features/converters/lexicalToJSX/converter/converters/list.js +2 -1
  95. package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
  96. package/dist/features/converters/lexicalToJSX/converter/converters/table.d.ts.map +1 -1
  97. package/dist/features/converters/lexicalToJSX/converter/converters/table.js +3 -2
  98. package/dist/features/converters/lexicalToJSX/converter/converters/table.js.map +1 -1
  99. package/dist/features/converters/lexicalToJSX/converter/converters/upload.d.ts.map +1 -1
  100. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +4 -5
  101. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
  102. package/dist/features/converters/utilities/payloadPopulateFn.d.ts.map +1 -1
  103. package/dist/features/converters/utilities/payloadPopulateFn.js +4 -2
  104. package/dist/features/converters/utilities/payloadPopulateFn.js.map +1 -1
  105. package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
  106. package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
  107. package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
  108. package/dist/features/heading/client/index.js.map +1 -1
  109. package/dist/features/heading/constants.d.ts +2 -0
  110. package/dist/features/heading/constants.d.ts.map +1 -0
  111. package/dist/features/heading/constants.js +2 -0
  112. package/dist/features/heading/constants.js.map +1 -0
  113. package/dist/features/heading/server/index.d.ts.map +1 -1
  114. package/dist/features/heading/server/index.js +5 -1
  115. package/dist/features/heading/server/index.js.map +1 -1
  116. package/dist/features/heading/server/validate.d.ts +6 -0
  117. package/dist/features/heading/server/validate.d.ts.map +1 -0
  118. package/dist/features/heading/server/validate.js +15 -0
  119. package/dist/features/heading/server/validate.js.map +1 -0
  120. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +11 -1
  121. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  122. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +17 -0
  123. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  124. package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
  125. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +2 -2
  126. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  127. package/dist/features/horizontalRule/server/schema.d.ts +1 -0
  128. package/dist/features/horizontalRule/server/schema.d.ts.map +1 -1
  129. package/dist/features/horizontalRule/server/schema.js +6 -5
  130. package/dist/features/horizontalRule/server/schema.js.map +1 -1
  131. package/dist/features/indent/client/IndentPlugin.d.ts.map +1 -1
  132. package/dist/features/indent/client/IndentPlugin.js +122 -1
  133. package/dist/features/indent/client/IndentPlugin.js.map +1 -1
  134. package/dist/features/indent/client/index.d.ts.map +1 -1
  135. package/dist/features/indent/client/index.js +0 -2
  136. package/dist/features/indent/client/index.js.map +1 -1
  137. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  138. package/dist/features/indent/server/i18n.js +74 -37
  139. package/dist/features/indent/server/i18n.js.map +1 -1
  140. package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
  141. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  142. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +20 -9
  143. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  144. package/dist/features/link/client/plugins/floatingLinkEditor/index.css +0 -1
  145. package/dist/features/link/client/plugins/link/index.js.map +1 -1
  146. package/dist/features/link/markdownTransformer.js +2 -2
  147. package/dist/features/link/markdownTransformer.js.map +1 -1
  148. package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  149. package/dist/features/link/nodes/AutoLinkNode.js +2 -10
  150. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  151. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  152. package/dist/features/link/nodes/LinkNode.js +2 -15
  153. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  154. package/dist/features/link/server/baseFields.js.map +1 -1
  155. package/dist/features/link/server/validate.js +1 -1
  156. package/dist/features/link/server/validate.js.map +1 -1
  157. package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
  158. package/dist/features/lists/checklist/server/index.js +5 -2
  159. package/dist/features/lists/checklist/server/index.js.map +1 -1
  160. package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
  161. package/dist/features/lists/orderedList/server/index.js +5 -2
  162. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  163. package/dist/features/lists/shared/constants.d.ts +2 -0
  164. package/dist/features/lists/shared/constants.d.ts.map +1 -0
  165. package/dist/features/lists/shared/constants.js +2 -0
  166. package/dist/features/lists/shared/constants.js.map +1 -0
  167. package/dist/features/lists/shared/schema.d.ts.map +1 -1
  168. package/dist/features/lists/shared/schema.js.map +1 -1
  169. package/dist/features/lists/shared/validate.d.ts +5 -0
  170. package/dist/features/lists/shared/validate.d.ts.map +1 -0
  171. package/dist/features/lists/shared/validate.js +15 -0
  172. package/dist/features/lists/shared/validate.js.map +1 -0
  173. package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
  174. package/dist/features/lists/unorderedList/server/index.js +5 -2
  175. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  176. package/dist/features/relationship/client/components/index.css +3 -6
  177. package/dist/features/relationship/client/drawer/index.js.map +1 -1
  178. package/dist/features/relationship/client/index.d.ts +2 -2
  179. package/dist/features/relationship/client/index.d.ts.map +1 -1
  180. package/dist/features/relationship/client/index.js.map +1 -1
  181. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  182. package/dist/features/relationship/client/nodes/RelationshipNode.js +0 -3
  183. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  184. package/dist/features/relationship/client/plugins/index.d.ts +2 -2
  185. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  186. package/dist/features/relationship/client/plugins/index.js +27 -31
  187. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  188. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts +2 -4
  189. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
  190. package/dist/features/relationship/client/utils/useEnabledRelationships.js +53 -20
  191. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  192. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +2 -2
  193. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
  194. package/dist/features/relationship/server/graphQLPopulationPromise.js +2 -2
  195. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  196. package/dist/features/relationship/server/index.d.ts +8 -1
  197. package/dist/features/relationship/server/index.d.ts.map +1 -1
  198. package/dist/features/relationship/server/index.js +28 -11
  199. package/dist/features/relationship/server/index.js.map +1 -1
  200. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  201. package/dist/features/relationship/server/nodes/RelationshipNode.js +1 -5
  202. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  203. package/dist/features/relationship/server/schema.d.ts +3 -2
  204. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  205. package/dist/features/relationship/server/schema.js +9 -12
  206. package/dist/features/relationship/server/schema.js.map +1 -1
  207. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +1 -6
  208. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -1
  209. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +1 -5
  210. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -1
  211. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts +8 -0
  212. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts.map +1 -0
  213. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js +19 -0
  214. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js.map +1 -0
  215. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.css +1 -2
  216. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
  217. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js +17 -44
  218. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  219. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -1
  220. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js +48 -25
  221. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  222. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  223. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.css +0 -3
  224. package/dist/features/table/client/plugins/TablePlugin/index.js +54 -18
  225. package/dist/features/table/client/plugins/TablePlugin/index.js.map +1 -1
  226. package/dist/features/table/client/utils/useDebounce.js.map +1 -1
  227. package/dist/features/table/server/index.d.ts.map +1 -1
  228. package/dist/features/table/server/index.js +3 -1
  229. package/dist/features/table/server/index.js.map +1 -1
  230. package/dist/features/table/server/validate.d.ts +4 -0
  231. package/dist/features/table/server/validate.d.ts.map +1 -0
  232. package/dist/features/table/server/validate.js +15 -0
  233. package/dist/features/table/server/validate.js.map +1 -0
  234. package/dist/features/textState/defaultColors.js +1 -1
  235. package/dist/features/textState/defaultColors.js.map +1 -1
  236. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js.map +1 -1
  237. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  238. package/dist/features/toolbars/fixed/client/Toolbar/index.js +141 -70
  239. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  240. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  241. package/dist/features/toolbars/inline/client/Toolbar/index.js +84 -37
  242. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  243. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  244. package/dist/features/toolbars/shared/ToolbarButton/index.js +27 -2
  245. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  246. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  247. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +199 -81
  248. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  249. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +16 -12
  250. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  251. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +22 -6
  252. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  253. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts +5 -0
  254. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts.map +1 -0
  255. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js +109 -0
  256. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js.map +1 -0
  257. package/dist/features/typesServer.d.ts +16 -11
  258. package/dist/features/typesServer.d.ts.map +1 -1
  259. package/dist/features/typesServer.js.map +1 -1
  260. package/dist/features/upload/client/component/index.css +0 -2
  261. package/dist/features/upload/client/drawer/index.js.map +1 -1
  262. package/dist/features/upload/client/index.d.ts +3 -2
  263. package/dist/features/upload/client/index.d.ts.map +1 -1
  264. package/dist/features/upload/client/index.js.map +1 -1
  265. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  266. package/dist/features/upload/client/nodes/UploadNode.js +0 -7
  267. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  268. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  269. package/dist/features/upload/client/plugin/index.js +50 -53
  270. package/dist/features/upload/client/plugin/index.js.map +1 -1
  271. package/dist/features/upload/server/graphQLPopulationPromise.d.ts +2 -2
  272. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  273. package/dist/features/upload/server/graphQLPopulationPromise.js +1 -1
  274. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  275. package/dist/features/upload/server/index.d.ts +7 -3
  276. package/dist/features/upload/server/index.d.ts.map +1 -1
  277. package/dist/features/upload/server/index.js +18 -14
  278. package/dist/features/upload/server/index.js.map +1 -1
  279. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  280. package/dist/features/upload/server/nodes/UploadNode.js +1 -9
  281. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  282. package/dist/features/upload/server/schema.d.ts +4 -16
  283. package/dist/features/upload/server/schema.d.ts.map +1 -1
  284. package/dist/features/upload/server/schema.js +8 -10
  285. package/dist/features/upload/server/schema.js.map +1 -1
  286. package/dist/features/upload/server/validate.d.ts +2 -2
  287. package/dist/features/upload/server/validate.d.ts.map +1 -1
  288. package/dist/features/upload/server/validate.js +4 -1
  289. package/dist/features/upload/server/validate.js.map +1 -1
  290. package/dist/field/Diff/converters/listitem/index.d.ts.map +1 -1
  291. package/dist/field/Diff/converters/listitem/index.js +2 -1
  292. package/dist/field/Diff/converters/listitem/index.js.map +1 -1
  293. package/dist/field/Diff/converters/relationship/index.css +0 -1
  294. package/dist/field/Diff/converters/unknown/index.css +0 -1
  295. package/dist/field/Diff/converters/upload/index.css +0 -1
  296. package/dist/field/Diff/converters/upload/index.d.ts.map +1 -1
  297. package/dist/field/Diff/converters/upload/index.js +8 -7
  298. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  299. package/dist/field/Diff/index.css +0 -2
  300. package/dist/field/Diff/index.d.ts +3 -2
  301. package/dist/field/Diff/index.d.ts.map +1 -1
  302. package/dist/field/Diff/index.js +4 -2
  303. package/dist/field/Diff/index.js.map +1 -1
  304. package/dist/field/Field.d.ts.map +1 -1
  305. package/dist/field/Field.js +8 -1
  306. package/dist/field/Field.js.map +1 -1
  307. package/dist/field/RenderLexical/index.d.ts +3 -1
  308. package/dist/field/RenderLexical/index.d.ts.map +1 -1
  309. package/dist/field/RenderLexical/index.js +23 -23
  310. package/dist/field/RenderLexical/index.js.map +1 -1
  311. package/dist/field/ViewSelector.d.ts.map +1 -1
  312. package/dist/field/ViewSelector.js +13 -4
  313. package/dist/field/ViewSelector.js.map +1 -1
  314. package/dist/field/bundled.css +1 -1
  315. package/dist/field/index.css +0 -1
  316. package/dist/field/index.js.map +1 -1
  317. package/dist/field/rscEntry.d.ts +2 -2
  318. package/dist/field/rscEntry.d.ts.map +1 -1
  319. package/dist/field/rscEntry.js.map +1 -1
  320. package/dist/i18n.d.ts.map +1 -1
  321. package/dist/i18n.js +44 -0
  322. package/dist/i18n.js.map +1 -1
  323. package/dist/index.d.ts +4 -4
  324. package/dist/index.d.ts.map +1 -1
  325. package/dist/index.js +23 -1
  326. package/dist/index.js.map +1 -1
  327. package/dist/lexical/LexicalEditor.css +21 -10
  328. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  329. package/dist/lexical/LexicalEditor.js +61 -64
  330. package/dist/lexical/LexicalEditor.js.map +1 -1
  331. package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -1
  332. package/dist/lexical/plugins/DecoratorPlugin/index.d.ts.map +1 -1
  333. package/dist/lexical/plugins/DecoratorPlugin/index.js +24 -21
  334. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  335. package/dist/lexical/plugins/InsertParagraphAtEnd/index.css +2 -1
  336. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  337. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  338. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -1
  339. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +235 -88
  340. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  341. package/dist/lexical/plugins/SlashMenu/index.css +0 -1
  342. package/dist/lexical/plugins/SlashMenu/useMenuTriggerMatch.js.map +1 -1
  343. package/dist/lexical/plugins/TextPlugin/index.js.map +1 -1
  344. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -0
  345. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +2 -2
  346. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  347. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +17 -0
  348. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  349. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +139 -37
  350. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  351. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts +7 -0
  352. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts.map +1 -0
  353. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js +15 -0
  354. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js.map +1 -0
  355. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts +7 -0
  356. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts.map +1 -0
  357. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js +62 -0
  358. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js.map +1 -0
  359. package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  360. package/dist/lexical/plugins/handles/utils/setHandlePosition.js +2 -0
  361. package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  362. package/dist/lexical/theme/EditorTheme.css +0 -2
  363. package/dist/lexical/ui/ContentEditable.d.ts +2 -1
  364. package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
  365. package/dist/lexical/ui/ContentEditable.js +32 -11
  366. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  367. package/dist/lexical/ui/icons/H3/index.d.ts.map +1 -1
  368. package/dist/lexical/ui/icons/H3/index.js +13 -6
  369. package/dist/lexical/ui/icons/H3/index.js.map +1 -1
  370. package/dist/lexical/ui/icons/H4/index.d.ts.map +1 -1
  371. package/dist/lexical/ui/icons/H4/index.js +13 -6
  372. package/dist/lexical/ui/icons/H4/index.js.map +1 -1
  373. package/dist/lexical/ui/icons/H5/index.d.ts.map +1 -1
  374. package/dist/lexical/ui/icons/H5/index.js +13 -6
  375. package/dist/lexical/ui/icons/H5/index.js.map +1 -1
  376. package/dist/lexical/ui/icons/H6/index.d.ts.map +1 -1
  377. package/dist/lexical/ui/icons/H6/index.js +13 -6
  378. package/dist/lexical/ui/icons/H6/index.js.map +1 -1
  379. package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
  380. package/dist/lexical/utils/nodeFormat.js +0 -2
  381. package/dist/lexical/utils/nodeFormat.js.map +1 -1
  382. package/dist/lexical/utils/url.d.ts.map +1 -1
  383. package/dist/lexical/utils/url.js +1 -1
  384. package/dist/lexical/utils/url.js.map +1 -1
  385. package/dist/populateGraphQL/populate.d.ts.map +1 -1
  386. package/dist/populateGraphQL/populate.js +4 -1
  387. package/dist/populateGraphQL/populate.js.map +1 -1
  388. package/dist/presets/llmInstructions.d.ts +2 -0
  389. package/dist/presets/llmInstructions.d.ts.map +1 -0
  390. package/dist/presets/llmInstructions.js +13 -0
  391. package/dist/presets/llmInstructions.js.map +1 -0
  392. package/dist/types/builtInNodes.d.ts +1 -1
  393. package/dist/types/builtInNodes.d.ts.map +1 -1
  394. package/dist/types/builtInNodes.js +8 -3
  395. package/dist/types/builtInNodes.js.map +1 -1
  396. package/dist/types/index.d.ts +3 -6
  397. package/dist/types/index.d.ts.map +1 -1
  398. package/dist/types/index.js.map +1 -1
  399. package/dist/types/jsonSchemaHelpers.d.ts +5 -1
  400. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -1
  401. package/dist/types/jsonSchemaHelpers.js +7 -2
  402. package/dist/types/jsonSchemaHelpers.js.map +1 -1
  403. package/dist/types/nodeTypes.d.ts +5 -0
  404. package/dist/types/nodeTypes.d.ts.map +1 -1
  405. package/dist/types/nodeTypes.js.map +1 -1
  406. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  407. package/dist/utilities/buildEditorState.js.map +1 -1
  408. package/dist/utilities/buildInitialState.d.ts +3 -2
  409. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  410. package/dist/utilities/buildInitialState.js +1 -0
  411. package/dist/utilities/buildInitialState.js.map +1 -1
  412. package/dist/utilities/fieldsDrawer/Drawer.js +36 -36
  413. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  414. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  415. package/dist/utilities/fieldsDrawer/DrawerContent.js +127 -107
  416. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  417. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -1
  418. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
  419. package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
  420. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
  421. package/dist/utilities/generateImportMap.d.ts +2 -2
  422. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  423. package/dist/utilities/generateImportMap.js.map +1 -1
  424. package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
  425. package/dist/utilities/initLexicalFeatures.js +38 -4
  426. package/dist/utilities/initLexicalFeatures.js.map +1 -1
  427. package/dist/utilities/upgradeLexicalData/index.js +6 -3
  428. package/dist/utilities/upgradeLexicalData/index.js.map +1 -1
  429. package/dist/utilities/useLexicalFeature.js +15 -6
  430. package/dist/utilities/useLexicalFeature.js.map +1 -1
  431. package/dist/utilities/useRunDeprioritized.js.map +1 -1
  432. package/dist/validate/hasText.d.ts +2 -2
  433. package/dist/validate/hasText.d.ts.map +1 -1
  434. package/dist/validate/hasText.js.map +1 -1
  435. package/dist/validate/index.d.ts +1 -1
  436. package/dist/validate/index.d.ts.map +1 -1
  437. package/package.json +51 -54
  438. package/dist/dependencyChecker.spec.js +0 -16
  439. package/dist/dependencyChecker.spec.js.map +0 -1
  440. package/dist/exports/client/Field-F22V5L4V.js +0 -2
  441. package/dist/exports/client/Field-F22V5L4V.js.map +0 -7
  442. package/dist/exports/client/bundled.css +0 -1
  443. package/dist/exports/client/chunk-43E5QYAA.js +0 -2
  444. package/dist/exports/client/chunk-43E5QYAA.js.map +0 -7
  445. package/dist/exports/client/chunk-ESITTE3C.js +0 -2
  446. package/dist/exports/client/chunk-ESITTE3C.js.map +0 -7
  447. package/dist/exports/client/chunk-LN6VX25I.js +0 -2
  448. package/dist/exports/client/chunk-LN6VX25I.js.map +0 -7
  449. package/dist/exports/client/componentInline-H24N7GUG.js +0 -2
  450. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts +0 -11
  451. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts.map +0 -1
  452. package/dist/features/blocks/client/component/removeEmptyArrayValues.js +0 -20
  453. package/dist/features/blocks/client/component/removeEmptyArrayValues.js.map +0 -1
  454. package/dist/features/converters/lexicalToHtml/sync/alignment.spec.js +0 -92
  455. package/dist/features/converters/lexicalToHtml/sync/alignment.spec.js.map +0 -1
  456. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js +0 -180
  457. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js.map +0 -1
  458. package/dist/features/link/markdownTransformer.spec.js +0 -195
  459. package/dist/features/link/markdownTransformer.spec.js.map +0 -1
  460. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.spec.js +0 -65
  461. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.spec.js.map +0 -1
  462. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js +0 -88
  463. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js.map +0 -1
  464. package/dist/lexical/utils/url.spec.js +0 -114
  465. package/dist/lexical/utils/url.spec.js.map +0 -1
  466. package/dist/utilities/jsx/jsx.spec.js +0 -178
  467. package/dist/utilities/jsx/jsx.spec.js.map +0 -1
  468. /package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js.map → RelationshipComponent-TVK6I4W4.js.map} +0 -0
  469. /package/dist/exports/client/{component-D5QLYS7W.js.map → component-FCCSBBZG.js.map} +0 -0
  470. /package/dist/exports/client/{componentInline-H24N7GUG.js.map → componentInline-7FQV2X7Z.js.map} +0 -0
@@ -4,17 +4,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
5
5
  import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
6
6
  import { getTranslation } from '@payloadcms/translations';
7
- import { Button, Drawer, EditDepthProvider, Form, formatDrawerSlug, RenderFields, ShimmerEffect, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useServerFunctions, useTranslation } from '@payloadcms/ui';
7
+ import { Button, Drawer, EditDepthProvider, Form, formatDrawerSlug, RenderFields, ShimmerEffect, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useOperation, useServerFunctions, useTranslation } from '@payloadcms/ui';
8
8
  import { abortAndIgnore } from '@payloadcms/ui/shared';
9
9
  import { $getNodeByKey, SKIP_DOM_SELECTION_TAG } from 'lexical';
10
10
  import './index.css';
11
11
  import '../../../../utilities/fieldsDrawer/index.css';
12
- import { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared';
12
+ import { deepCopyObjectSimpleWithoutReactComponents, getDataFromFormState } from 'payload/shared';
13
13
  import React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react';
14
14
  import { v4 as uuid } from 'uuid';
15
15
  import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
16
16
  import { RegisterFormSubmit, useDrawerSubmit } from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js';
17
17
  import { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js';
18
+ import { getCachedFormStateIfDataMatches } from '../getCachedFormStateIfDataMatches.js';
18
19
  import { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js';
19
20
  const InlineBlockComponentContext = /*#__PURE__*/createContext({
20
21
  initialState: false
@@ -31,6 +32,7 @@ export const InlineBlockComponent = props => {
31
32
  } = props;
32
33
  const [editor] = useLexicalComposerContext();
33
34
  const isEditable = useLexicalEditable();
35
+ const operation = useOperation();
34
36
  const {
35
37
  i18n,
36
38
  t
@@ -53,19 +55,21 @@ export const InlineBlockComponent = props => {
53
55
  } = useServerFunctions();
54
56
  const editDepth = useEditDepth();
55
57
  const firstTimeDrawer = useRef(false);
58
+ const blockType = formData.blockType;
59
+ const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockType}.fields`;
56
60
  const [initialState, setInitialState] = React.useState(() => {
57
61
  // Initial form state that was calculated server-side. May have stale values
58
- const cachedFormState = initialLexicalFormState?.[formData.id]?.formState;
62
+ const cachedState = initialLexicalFormState?.[formData.id];
63
+ const cachedFormState = cachedState?.formState;
59
64
  if (!cachedFormState) {
60
65
  return false;
61
66
  }
62
- // Merge current formData values into the cached form state
63
- // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits
64
- return Object.fromEntries(Object.entries(cachedFormState).map(([fieldName, fieldState]) => [fieldName, fieldName in formData ? {
65
- ...fieldState,
66
- initialValue: formData[fieldName],
67
- value: formData[fieldName]
68
- } : fieldState]));
67
+ return getCachedFormStateIfDataMatches({
68
+ cachedFormState,
69
+ cachedSchemaPath: cachedState.schemaPath,
70
+ currentSchemaPath: schemaFieldsPath,
71
+ formData
72
+ });
69
73
  });
70
74
  const hasMounted = useRef(false);
71
75
  const prevCacheBuster = useRef(cacheBuster);
@@ -104,7 +108,7 @@ export const InlineBlockComponent = props => {
104
108
  isEditor: true,
105
109
  isJSXConverter: false,
106
110
  nodeKey: nodeKey,
107
- // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call
111
+ // eslint-disable-next-line react-hooks/hooks -- intentionally passed as a prop for custom block components to call
108
112
  useInlineBlockComponentContext: useInlineBlockComponentContext
109
113
  });
110
114
  }
@@ -118,7 +122,7 @@ export const InlineBlockComponent = props => {
118
122
  isEditor: true,
119
123
  isJSXConverter: false,
120
124
  nodeKey: nodeKey,
121
- // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call
125
+ // eslint-disable-next-line react-hooks/hooks -- intentionally passed as a prop for custom block components to call
122
126
  useInlineBlockComponentContext: useInlineBlockComponentContext
123
127
  });
124
128
  }
@@ -141,7 +145,7 @@ export const InlineBlockComponent = props => {
141
145
  const {
142
146
  config
143
147
  } = useConfig();
144
- const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`;
148
+ const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockType}`;
145
149
  const clientSchemaMap = featureClientSchemaMap['blocks'];
146
150
  const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
147
151
  const blockOrSlug = blocksField?.blocks?.[0];
@@ -164,8 +168,6 @@ export const InlineBlockComponent = props => {
164
168
  });
165
169
  }, [editor, nodeKey]);
166
170
  const blockDisplayName = clientBlock?.labels?.singular ? getTranslation(clientBlock?.labels.singular, i18n) : clientBlock?.slug;
167
- const onChangeAbortControllerRef = useRef(new AbortController());
168
- const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`;
169
171
  // Initial state for newly created blocks
170
172
  useEffect(() => {
171
173
  const abortController = new AbortController();
@@ -185,20 +187,17 @@ export const InlineBlockComponent = props => {
185
187
  fields: true
186
188
  },
187
189
  docPreferences: await getDocPreferences(),
188
- documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {
189
- excludeFiles: true
190
- }),
190
+ documentFormState: parentDocumentFields,
191
191
  globalSlug,
192
192
  initialBlockData: formData,
193
- initialBlockFormState: formData,
194
- operation: 'update',
193
+ operation,
195
194
  readOnly: !isEditable,
196
195
  renderAllFields: true,
197
196
  schemaPath: schemaFieldsPath,
198
197
  signal: abortController.signal
199
198
  });
200
199
  if (state) {
201
- const newFormStateData = reduceFieldsToValues(deepCopyObjectSimpleWithoutReactComponents(state, {
200
+ const newFormStateData = getDataFromFormState(deepCopyObjectSimpleWithoutReactComponents(state, {
202
201
  excludeFiles: true
203
202
  }), true);
204
203
  // Things like default values may come back from the server => update the node with the new data
@@ -224,57 +223,26 @@ export const InlineBlockComponent = props => {
224
223
  }
225
224
  }
226
225
  };
227
- if (formData && !initialState) {
226
+ if (clientBlock && formData && !initialState) {
228
227
  void awaitInitialState();
229
228
  }
230
229
  return () => {
231
230
  abortAndIgnore(abortController);
232
231
  };
233
- }, [getFormState, editor, nodeKey, isEditable, CustomLabelFromProps, CustomBlockFromProps, schemaFieldsPath, id, formData, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
234
- /**
235
- * HANDLE ONCHANGE
236
- */
237
- const onChange = useCallback(async ({
238
- formState: prevFormState,
239
- submit
232
+ }, [getFormState, editor, nodeKey, isEditable, CustomLabelFromProps, CustomBlockFromProps, schemaFieldsPath, id, formData, initialState, collectionSlug, globalSlug, getDocPreferences, operation, parentDocumentFields, clientBlock]);
233
+ const onChange = useCallback(({
234
+ formState,
235
+ submitted
240
236
  }) => {
241
- abortAndIgnore(onChangeAbortControllerRef.current);
242
- const controller = new AbortController();
243
- onChangeAbortControllerRef.current = controller;
244
- const {
245
- state: state_0
246
- } = await getFormState({
247
- id,
248
- collectionSlug,
249
- docPermissions: {
250
- fields: true
251
- },
252
- docPreferences: await getDocPreferences(),
253
- documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {
254
- excludeFiles: true
255
- }),
256
- formState: prevFormState,
257
- globalSlug,
258
- initialBlockFormState: prevFormState,
259
- operation: 'update',
260
- readOnly: !isEditable,
261
- renderAllFields: submit ? true : false,
262
- schemaPath: schemaFieldsPath,
263
- signal: controller.signal
264
- });
265
- if (!state_0) {
266
- return prevFormState;
267
- }
268
- if (submit) {
237
+ if (submitted) {
269
238
  if (!CustomLabelFromProps) {
270
- setCustomLabel(state_0['_components']?.customComponents?.BlockLabel);
239
+ setCustomLabel(formState._components?.customComponents?.BlockLabel);
271
240
  }
272
241
  if (!CustomBlockFromProps) {
273
- setCustomBlock(state_0['_components']?.customComponents?.Block);
242
+ setCustomBlock(formState._components?.customComponents?.Block);
274
243
  }
275
244
  }
276
- return state_0;
277
- }, [getFormState, id, collectionSlug, getDocPreferences, parentDocumentFields, globalSlug, isEditable, schemaFieldsPath, CustomBlockFromProps, CustomLabelFromProps]);
245
+ }, [CustomLabelFromProps, CustomBlockFromProps]);
278
246
  // cleanup effect
279
247
  useEffect(() => {
280
248
  const isStateOutOfSync = (formData_0, initialState_0) => {
@@ -287,14 +255,14 @@ export const InlineBlockComponent = props => {
287
255
  if (initialState && isStateOutOfSync(formData, initialState)) {
288
256
  setInitialState(false);
289
257
  }
290
- abortAndIgnore(onChangeAbortControllerRef.current);
291
258
  };
292
259
  }, [formData, initialState]);
293
260
  /**
294
261
  * HANDLE FORM SUBMIT
295
262
  */
296
- const onFormSubmit = useCallback((formState, newData_0) => {
297
- newData_0.blockType = formData.blockType;
263
+ const onFormSubmit = useCallback(formState_0 => {
264
+ const newData_0 = getDataFromFormState(formState_0, true);
265
+ newData_0.blockType = blockType;
298
266
  editor.update(() => {
299
267
  const node_0 = $getNodeByKey(nodeKey);
300
268
  if (node_0 && $isInlineBlockNode(node_0)) {
@@ -306,7 +274,7 @@ export const InlineBlockComponent = props => {
306
274
  {
307
275
  tag: SKIP_DOM_SELECTION_TAG
308
276
  });
309
- }, [editor, nodeKey, formData]);
277
+ }, [blockType, editor, nodeKey]);
310
278
  const {
311
279
  headerActions,
312
280
  submitRef
@@ -382,24 +350,17 @@ export const InlineBlockComponent = props => {
382
350
  });
383
351
  }
384
352
  return /*#__PURE__*/_jsxs(Form, {
385
- beforeSubmit: [async ({
386
- formState: formState_0
387
- }) => {
388
- // This is only called when form is submitted from drawer
389
- return await onChange({
390
- formState: formState_0,
391
- submit: true
392
- });
393
- }],
394
353
  disableValidationOnSubmit: true,
395
354
  el: "div",
396
355
  fields: clientBlock?.fields,
397
356
  initialState: initialState || {},
398
357
  onChange: [onChange],
399
- onSubmit: (formState_1, data) => {
400
- onFormSubmit(formState_1, data);
358
+ onSubmit: formState_1 => {
359
+ onFormSubmit(formState_1);
401
360
  toggleDrawer();
402
361
  },
362
+ readOnly: !isEditable,
363
+ schemaPath: schemaFieldsPath,
403
364
  uuid: formUuid,
404
365
  children: [/*#__PURE__*/_jsx(EditDepthProvider, {
405
366
  children: /*#__PURE__*/_jsx(Drawer, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","RenderFields","ShimmerEffect","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","SKIP_DOM_SELECTION_TAG","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","createContext","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","RegisterFormSubmit","useDrawerSubmit","useLexicalDrawer","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","use","InlineBlockComponent","props","cacheBuster","className","baseClass","CustomBlock","CustomBlockFromProps","CustomLabel","CustomLabelFromProps","formData","nodeKey","editor","isEditable","i18n","t","createdInlineBlock","fieldProps","featureClientSchemaMap","initialLexicalFormState","schemaPath","setCreatedInlineBlock","uuidFromContext","fields","parentDocumentFields","getFormState","editDepth","firstTimeDrawer","setInitialState","useState","cachedFormState","id","formState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","hasMounted","prevCacheBuster","current","formUuid","setCustomLabel","undefined","customComponents","BlockLabel","setCustomBlock","Block","resolvedCustomBlock","_jsx","isEditor","isJSXConverter","resolvedCustomLabel","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","collectionSlug","getDocPreferences","globalSlug","config","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","blockOrSlug","blocks","clientBlock","blocksMap","clientBlockFields","getKey","length","removeInlineBlock","update","remove","blockDisplayName","labels","singular","onChangeAbortControllerRef","AbortController","schemaFieldsPath","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","excludeFiles","initialBlockData","initialBlockFormState","operation","readOnly","renderAllFields","signal","newFormStateData","node","newData","setFields","tag","onChange","prevFormState","submit","controller","isStateOutOfSync","keys","some","key","onFormSubmit","headerActions","submitRef","RemoveButton","buttonStyle","disabled","icon","onClick","e","preventDefault","stopPropagation","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","filter","Boolean","join","onKeyDown","role","tabIndex","ref","Label","_jsxs","beforeSubmit","disableValidationOnSubmit","onSubmit","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","height","width"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey, SKIP_DOM_SELECTION_TAG } from 'lexical'\n\nimport './index.css'\nimport '../../../../utilities/fieldsDrawer/index.css'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ViewMapInlineBlockComponentProps } from '../../../../types/index.js'\nimport type { InlineBlockFields } from '../../server/schema.js'\nimport type { BlockComponentProps } from '../component/index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport {\n RegisterFormSubmit,\n useDrawerSubmit,\n} from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\nexport type InlineBlockComponentProps<\n TFormData extends Record<string, unknown> = InlineBlockFields,\n> = {\n readonly CustomBlock?: React.FC<ViewMapInlineBlockComponentProps>\n readonly CustomLabel?: React.FC<ViewMapInlineBlockComponentProps>\n} & Pick<BlockComponentProps<TFormData>, 'cacheBuster' | 'className' | 'formData' | 'nodeKey'>\n\nexport type InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.use(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<InlineBlockComponentProps<InlineBlockFields>> = (\n props,\n) => {\n const {\n cacheBuster,\n className: baseClass,\n CustomBlock: CustomBlockFromProps,\n CustomLabel: CustomLabelFromProps,\n formData,\n nodeKey,\n } = props\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, schemaPath },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n return Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\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 [formUuid] = React.useState(() => uuid())\n\n // Server-rendered custom components (from admin.components, NOT viewMap).\n // When viewMap components exist, we render them directly with formData instead.\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomLabelFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.BlockLabel ?? undefined\n })\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomBlockFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.Block ?? undefined\n })\n\n const resolvedCustomBlock = useMemo(() => {\n if (CustomBlockFromProps) {\n return (\n <CustomBlockFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n return CustomBlock\n }, [CustomBlockFromProps, baseClass, formData, nodeKey, CustomBlock])\n\n const resolvedCustomLabel = useMemo(() => {\n if (CustomLabelFromProps) {\n return (\n <CustomLabelFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n return CustomLabel\n }, [CustomLabelFromProps, baseClass, formData, nodeKey, CustomLabel])\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient | undefined\n\n const blockOrSlug = blocksField?.blocks?.[0]\n const clientBlock: ClientBlock | undefined =\n typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = 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 onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\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 excludeFiles: true,\n }),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state, { excludeFiles: true }),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n\n setInitialState(state)\n if (!CustomLabelFromProps) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n isEditable,\n CustomLabelFromProps,\n CustomBlockFromProps,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n /**\n * HANDLE ONCHANGE\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 } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\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 (!state) {\n return prevFormState\n }\n\n if (submit) {\n if (!CustomLabelFromProps) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n isEditable,\n schemaFieldsPath,\n CustomBlockFromProps,\n CustomLabelFromProps,\n ],\n )\n // cleanup effect\n useEffect(() => {\n const isStateOutOfSync = (formData: InlineBlockFields, initialState: FormState) => {\n return Object.keys(initialState).some(\n (key) => initialState[key] && formData[key] !== initialState[key].value,\n )\n }\n\n return () => {\n // If the component is unmounted (either via removeInlineBlock or via lexical itself) and the form state got changed before,\n // we need to reset the initial state to force a re-fetch of the initial state when it gets mounted again (e.g. via lexical history undo).\n // Otherwise it would use an outdated initial state.\n if (initialState && isStateOutOfSync(formData, initialState)) {\n setInitialState(false)\n }\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [formData, initialState])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState, newData: Data) => {\n newData.blockType = formData.blockType\n\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n },\n [editor, nodeKey, formData],\n )\n\n const { headerActions, submitRef } = useDrawerSubmit()\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n removeInlineBlock()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[`${baseClass}__container`, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n {...(isEditable\n ? {\n onClick: () => toggleDrawer(),\n onKeyDown: (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n toggleDrawer()\n }\n },\n role: 'button',\n tabIndex: 0,\n }\n : {})}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [baseClass, formData.blockType, isEditable, toggleDrawer],\n )\n\n const Label = useMemo(() => {\n if (resolvedCustomLabel) {\n return () => resolvedCustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [resolvedCustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n el=\"div\"\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={formUuid}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n headerActions={headerActions}\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 <div className=\"fields-drawer\">\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 <RegisterFormSubmit submitRef={submitRef} />\n </div>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {resolvedCustomBlock ? (\n <InlineBlockComponentContext\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {resolvedCustomBlock}\n </InlineBlockComponentContext>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,MAAM,EACNC,iBAAiB,EACjBC,IAAI,EACJC,gBAAgB,EAChBC,YAAY,EACZC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,EAAEC,sBAAsB,QAAQ;AAEtD,OAAO;AACP,OAAO;AAEP,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,aAAa,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC9E,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAM3B,SAASC,sBAAsB,QAAQ;AACvC,SACEC,kBAAkB,EAClBC,eAAe,QAC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icalComposerContext","useLexicalEditable","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","RenderFields","ShimmerEffect","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useOperation","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","SKIP_DOM_SELECTION_TAG","deepCopyObjectSimpleWithoutReactComponents","getDataFromFormState","React","createContext","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","RegisterFormSubmit","useDrawerSubmit","useLexicalDrawer","getCachedFormStateIfDataMatches","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","use","InlineBlockComponent","props","cacheBuster","className","baseClass","CustomBlock","CustomBlockFromProps","CustomLabel","CustomLabelFromProps","formData","nodeKey","editor","isEditable","operation","i18n","t","createdInlineBlock","fieldProps","featureClientSchemaMap","initialLexicalFormState","schemaPath","setCreatedInlineBlock","uuidFromContext","fields","parentDocumentFields","getFormState","editDepth","firstTimeDrawer","blockType","schemaFieldsPath","setInitialState","useState","cachedState","id","cachedFormState","formState","cachedSchemaPath","currentSchemaPath","hasMounted","prevCacheBuster","current","formUuid","setCustomLabel","undefined","customComponents","BlockLabel","setCustomBlock","Block","resolvedCustomBlock","_jsx","isEditor","isJSXConverter","resolvedCustomLabel","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","collectionSlug","getDocPreferences","globalSlug","config","componentMapRenderedBlockPath","clientSchemaMap","blocksField","blockOrSlug","blocks","clientBlock","blocksMap","clientBlockFields","getKey","length","removeInlineBlock","update","remove","blockDisplayName","labels","singular","abortController","AbortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","readOnly","renderAllFields","signal","newFormStateData","excludeFiles","node","newData","setFields","tag","onChange","submitted","_components","isStateOutOfSync","Object","keys","some","key","value","onFormSubmit","headerActions","submitRef","RemoveButton","buttonStyle","disabled","icon","onClick","e","preventDefault","stopPropagation","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","filter","Boolean","join","onKeyDown","role","tabIndex","ref","Label","_jsxs","disableValidationOnSubmit","onSubmit","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","height","width"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormProps } from '@payloadcms/ui'\nimport type { BlocksFieldClient, ClientBlock, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useOperation,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey, SKIP_DOM_SELECTION_TAG } from 'lexical'\n\nimport './index.css'\nimport '../../../../utilities/fieldsDrawer/index.css'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, getDataFromFormState } from 'payload/shared'\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ViewMapInlineBlockComponentProps } from '../../../../types/index.js'\nimport type { InlineBlockFields } from '../../server/schema.js'\nimport type { BlockComponentProps } from '../component/index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport {\n RegisterFormSubmit,\n useDrawerSubmit,\n} from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { getCachedFormStateIfDataMatches } from '../getCachedFormStateIfDataMatches.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\nexport type InlineBlockComponentProps<\n TFormData extends Record<string, unknown> = InlineBlockFields,\n> = {\n readonly CustomBlock?: React.FC<ViewMapInlineBlockComponentProps>\n readonly CustomLabel?: React.FC<ViewMapInlineBlockComponentProps>\n} & Pick<BlockComponentProps<TFormData>, 'cacheBuster' | 'className' | 'formData' | 'nodeKey'>\n\nexport type InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.use(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<InlineBlockComponentProps<InlineBlockFields>> = (\n props,\n) => {\n const {\n cacheBuster,\n className: baseClass,\n CustomBlock: CustomBlockFromProps,\n CustomLabel: CustomLabelFromProps,\n formData,\n nodeKey,\n } = props\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const operation = useOperation()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, schemaPath },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n const blockType = formData.blockType\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedState = initialLexicalFormState?.[formData.id]\n const cachedFormState = cachedState?.formState\n if (!cachedFormState) {\n return false\n }\n\n return getCachedFormStateIfDataMatches({\n cachedFormState,\n cachedSchemaPath: cachedState.schemaPath,\n currentSchemaPath: schemaFieldsPath,\n formData,\n })\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 [formUuid] = React.useState(() => uuid())\n\n // Server-rendered custom components (from admin.components, NOT viewMap).\n // When viewMap components exist, we render them directly with formData instead.\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomLabelFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.BlockLabel ?? undefined\n })\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomBlockFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.Block ?? undefined\n })\n\n const resolvedCustomBlock = useMemo(() => {\n if (CustomBlockFromProps) {\n return (\n <CustomBlockFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-hooks/hooks -- intentionally passed as a prop for custom block components to call\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n return CustomBlock\n }, [CustomBlockFromProps, baseClass, formData, nodeKey, CustomBlock])\n\n const resolvedCustomLabel = useMemo(() => {\n if (CustomLabelFromProps) {\n return (\n <CustomLabelFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-hooks/hooks -- intentionally passed as a prop for custom block components to call\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n return CustomLabel\n }, [CustomLabelFromProps, baseClass, formData, nodeKey, CustomLabel])\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient | undefined\n\n const blockOrSlug = blocksField?.blocks?.[0]\n const clientBlock: ClientBlock | undefined =\n typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = 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 // 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: parentDocumentFields,\n globalSlug,\n initialBlockData: formData,\n operation,\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData = getDataFromFormState(\n deepCopyObjectSimpleWithoutReactComponents(state, { excludeFiles: true }),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n\n setInitialState(state)\n if (!CustomLabelFromProps) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n }\n\n if (clientBlock && formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n isEditable,\n CustomLabelFromProps,\n CustomBlockFromProps,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n operation,\n parentDocumentFields,\n clientBlock,\n ])\n\n const onChange = useCallback<NonNullable<FormProps['onChange']>[number]>(\n ({ formState, submitted }) => {\n if (submitted) {\n if (!CustomLabelFromProps) {\n setCustomLabel(formState._components?.customComponents?.BlockLabel)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(formState._components?.customComponents?.Block)\n }\n }\n },\n [CustomLabelFromProps, CustomBlockFromProps],\n )\n\n // cleanup effect\n useEffect(() => {\n const isStateOutOfSync = (formData: InlineBlockFields, initialState: FormState) => {\n return Object.keys(initialState).some(\n (key) => initialState[key] && formData[key] !== initialState[key].value,\n )\n }\n\n return () => {\n // If the component is unmounted (either via removeInlineBlock or via lexical itself) and the form state got changed before,\n // we need to reset the initial state to force a re-fetch of the initial state when it gets mounted again (e.g. via lexical history undo).\n // Otherwise it would use an outdated initial state.\n if (initialState && isStateOutOfSync(formData, initialState)) {\n setInitialState(false)\n }\n }\n }, [formData, initialState])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState) => {\n const newData = getDataFromFormState(formState, true)\n newData.blockType = blockType\n\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n },\n [blockType, editor, nodeKey],\n )\n\n const { headerActions, submitRef } = useDrawerSubmit()\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n removeInlineBlock()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[`${baseClass}__container`, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n {...(isEditable\n ? {\n onClick: () => toggleDrawer(),\n onKeyDown: (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n toggleDrawer()\n }\n },\n role: 'button',\n tabIndex: 0,\n }\n : {})}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [baseClass, formData.blockType, isEditable, toggleDrawer],\n )\n\n const Label = useMemo(() => {\n if (resolvedCustomLabel) {\n return () => resolvedCustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [resolvedCustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n disableValidationOnSubmit\n el=\"div\"\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState) => {\n onFormSubmit(formState)\n toggleDrawer()\n }}\n readOnly={!isEditable}\n schemaPath={schemaFieldsPath}\n uuid={formUuid}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n headerActions={headerActions}\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 <div className=\"fields-drawer\">\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 <RegisterFormSubmit submitRef={submitRef} />\n </div>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {resolvedCustomBlock ? (\n <InlineBlockComponentContext\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {resolvedCustomBlock}\n </InlineBlockComponentContext>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAKA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,MAAM,EACNC,iBAAiB,EACjBC,IAAI,EACJC,gBAAgB,EAChBC,YAAY,EACZC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,EAAEC,sBAAsB,QAAQ;AAEtD,OAAO;AACP,OAAO;AAEP,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,aAAa,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC9E,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAM3B,SAASC,sBAAsB,QAAQ;AACvC,SACEC,kBAAkB,EAClBC,eAAe,QACV;AACP,SAASC,gBAAgB,QAAQ;AACjC,SAASC,+BAA+B,QAAQ;AAChD,SAASC,kBAAkB,QAAQ;AAkBnC,MAAMC,2BAAA,gBAA8Bb,aAAA,CAA+C;EACjFc,YAAA,EAAc;AAChB;AAEA,OAAO,MAAMC,8BAAA,GAAiCA,CAAA,KAAMhB,KAAA,CAAMiB,GAAG,CAACH,2BAAA;AAE9D,OAAO,MAAMI,oBAAA,GACXC,KAAA;EAEA,MAAM;IACJC,WAAW;IACXC,SAAA,EAAWC,SAAS;IACpBC,WAAA,EAAaC,oBAAoB;IACjCC,WAAA,EAAaC,oBAAoB;IACjCC,QAAQ;IACRC;EAAO,CACR,GAAGT,KAAA;EAEJ,MAAM,CAACU,MAAA,CAAO,GAAGnD,yBAAA;EACjB,MAAMoD,UAAA,GAAanD,kBAAA;EACnB,MAAMoD,SA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CAAA,CAAE;QAC/B;kBAEClB,YAAA,gBACCuI,KAAA,CAAC;UAAIjI,SAAA,EAAU;kCACb8C,IAAA,CAACjF,YAAA;YACCuD,MAAA,EAAQ4C,WAAA,EAAa5C,MAAA;YACrBiH,WAAW;YACXC,eAAA,EAAgB;YAChBC,UAAA,EAAW;YACXC,gBAAA,EAAkB9G,gBAAA;YAClB+G,WAAA,EAAa;YACbrD,QAAA,EAAU,CAAC3E;2BAEbqC,IAAA,CAAC1D,kBAAA;YAAmBoH,SAAA,EAAWA;;aAE/B;;QAGP3D,mBAAA,gBACCC,IAAA,CAACrD,2BAAA;MACC4G,KAAA,EAAO;QACLgB,UAAA;QACA3H,YAAA;QACA6H,oBAAA;QACAS,KAAA;QACAzH,OAAA;QACAkG;MACF;gBAEC5D;sBAGHoF,KAAA,CAACV,oBAAA;iBACE7H,YAAA,gBAAeoD,IAAA,CAACkF,KAAA,qBAAWlF,IAAA,CAAChF,aAAA;QAAc4K,MAAA,EAAO;QAAOC,KAAA,EAAM;UAC9DlI,UAAA,gBACCqC,IAAA,CAAC;QAAI9C,SAAA,EAAW,GAAGC,SAAA,WAAoB;kBACrC,aAAA6C,IAAA,CAAC2D,YAAA;WAED;;;AAKd","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import type { Data, FormState } from 'payload';
2
+ export declare const getCachedFormStateIfDataMatches: ({ cachedFormState, cachedSchemaPath, currentSchemaPath, formData, }: {
3
+ cachedFormState: FormState;
4
+ cachedSchemaPath?: string;
5
+ currentSchemaPath?: string;
6
+ formData: Data;
7
+ }) => false | FormState;
8
+ //# sourceMappingURL=getCachedFormStateIfDataMatches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCachedFormStateIfDataMatches.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/client/getCachedFormStateIfDataMatches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAK9C,eAAO,MAAM,+BAA+B,wEAKzC;IACD,eAAe,EAAE,SAAS,CAAA;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,EAAE,IAAI,CAAA;CACf,KAAG,KAAK,GAAG,SAkBX,CAAA"}
@@ -0,0 +1,72 @@
1
+ import { dequal } from 'dequal/lite';
2
+ import { getDataFromFormState } from 'payload/shared';
3
+ export const getCachedFormStateIfDataMatches = ({
4
+ cachedFormState,
5
+ cachedSchemaPath,
6
+ currentSchemaPath,
7
+ formData
8
+ }) => {
9
+ if (cachedSchemaPath !== currentSchemaPath) {
10
+ return false;
11
+ }
12
+ const rowFieldPaths = getRowFieldPaths(cachedFormState);
13
+ const cachedData = normalizeData({
14
+ data: getDataFromFormState(cachedFormState, true),
15
+ rowFieldPaths
16
+ });
17
+ const currentData = normalizeData({
18
+ data: formData,
19
+ rowFieldPaths
20
+ });
21
+ return dequal(withoutSystemBlockFields(cachedData), withoutSystemBlockFields(currentData)) ? cachedFormState : false;
22
+ };
23
+ const getRowFieldPaths = formState => new Set(Object.entries(formState).filter(([, fieldState]) => Array.isArray(fieldState?.rows) && fieldState.value !== null && fieldState.value !== undefined).map(([path]) => path));
24
+ const normalizeData = ({
25
+ data,
26
+ parentPath = '',
27
+ rowFieldPaths
28
+ }) => {
29
+ const normalizedData = {};
30
+ for (const [key, value] of Object.entries(data)) {
31
+ const path = parentPath ? `${parentPath}.${key}` : key;
32
+ const normalizedValue = normalizeValue({
33
+ parentPath: path,
34
+ rowFieldPaths,
35
+ value
36
+ });
37
+ if (normalizedValue !== undefined) {
38
+ normalizedData[key] = normalizedValue;
39
+ }
40
+ }
41
+ return normalizedData;
42
+ };
43
+ const normalizeValue = ({
44
+ parentPath,
45
+ rowFieldPaths,
46
+ value
47
+ }) => {
48
+ if (value === undefined || Array.isArray(value) && value.length === 0 && rowFieldPaths.has(parentPath)) {
49
+ return undefined;
50
+ }
51
+ if (Array.isArray(value)) {
52
+ return value.map((item, index) => item && typeof item === 'object' && !Array.isArray(item) ? normalizeData({
53
+ data: item,
54
+ parentPath: `${parentPath}.${index}`,
55
+ rowFieldPaths
56
+ }) : item);
57
+ }
58
+ if (value && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) {
59
+ return normalizeData({
60
+ data: value,
61
+ parentPath,
62
+ rowFieldPaths
63
+ });
64
+ }
65
+ return value;
66
+ };
67
+ const withoutSystemBlockFields = ({
68
+ blockName: _blockName,
69
+ blockType: _blockType,
70
+ ...data
71
+ }) => data;
72
+ //# sourceMappingURL=getCachedFormStateIfDataMatches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCachedFormStateIfDataMatches.js","names":["dequal","getDataFromFormState","getCachedFormStateIfDataMatches","cachedFormState","cachedSchemaPath","currentSchemaPath","formData","rowFieldPaths","getRowFieldPaths","cachedData","normalizeData","data","currentData","withoutSystemBlockFields","formState","Set","Object","entries","filter","fieldState","Array","isArray","rows","value","undefined","map","path","parentPath","normalizedData","key","normalizedValue","normalizeValue","length","has","item","index","getPrototypeOf","prototype","blockName","_blockName","blockType","_blockType"],"sources":["../../../../src/features/blocks/client/getCachedFormStateIfDataMatches.ts"],"sourcesContent":["import type { Data, FormState } from 'payload'\n\nimport { dequal } from 'dequal/lite'\nimport { getDataFromFormState } from 'payload/shared'\n\nexport const getCachedFormStateIfDataMatches = ({\n cachedFormState,\n cachedSchemaPath,\n currentSchemaPath,\n formData,\n}: {\n cachedFormState: FormState\n cachedSchemaPath?: string\n currentSchemaPath?: string\n formData: Data\n}): false | FormState => {\n if (cachedSchemaPath !== currentSchemaPath) {\n return false\n }\n\n const rowFieldPaths = getRowFieldPaths(cachedFormState)\n const cachedData = normalizeData({\n data: getDataFromFormState(cachedFormState, true),\n rowFieldPaths,\n })\n const currentData = normalizeData({\n data: formData,\n rowFieldPaths,\n })\n\n return dequal(withoutSystemBlockFields(cachedData), withoutSystemBlockFields(currentData))\n ? cachedFormState\n : false\n}\n\nconst getRowFieldPaths = (formState: FormState): Set<string> =>\n new Set(\n Object.entries(formState)\n .filter(\n ([, fieldState]) =>\n Array.isArray(fieldState?.rows) &&\n fieldState.value !== null &&\n fieldState.value !== undefined,\n )\n .map(([path]) => path),\n )\n\nconst normalizeData = ({\n data,\n parentPath = '',\n rowFieldPaths,\n}: {\n data: Data\n parentPath?: string\n rowFieldPaths: Set<string>\n}): Data => {\n const normalizedData: Data = {}\n\n for (const [key, value] of Object.entries(data)) {\n const path = parentPath ? `${parentPath}.${key}` : key\n const normalizedValue = normalizeValue({ parentPath: path, rowFieldPaths, value })\n\n if (normalizedValue !== undefined) {\n normalizedData[key] = normalizedValue\n }\n }\n\n return normalizedData\n}\n\nconst normalizeValue = ({\n parentPath,\n rowFieldPaths,\n value,\n}: {\n parentPath: string\n rowFieldPaths: Set<string>\n value: unknown\n}): unknown => {\n if (\n value === undefined ||\n (Array.isArray(value) && value.length === 0 && rowFieldPaths.has(parentPath))\n ) {\n return undefined\n }\n\n if (Array.isArray(value)) {\n return value.map((item, index) =>\n item && typeof item === 'object' && !Array.isArray(item)\n ? normalizeData({\n data: item as Data,\n parentPath: `${parentPath}.${index}`,\n rowFieldPaths,\n })\n : item,\n )\n }\n\n if (value && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) {\n return normalizeData({ data: value, parentPath, rowFieldPaths })\n }\n\n return value\n}\n\nconst withoutSystemBlockFields = ({\n blockName: _blockName,\n blockType: _blockType,\n ...data\n}: Data): Data => data\n"],"mappings":"AAEA,SAASA,MAAM,QAAQ;AACvB,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,+BAAA,GAAkCA,CAAC;EAC9CC,eAAe;EACfC,gBAAgB;EAChBC,iBAAiB;EACjBC;AAAQ,CAMT;EACC,IAAIF,gBAAA,KAAqBC,iBAAA,EAAmB;IAC1C,OAAO;EACT;EAEA,MAAME,aAAA,GAAgBC,gBAAA,CAAiBL,eAAA;EACvC,MAAMM,UAAA,GAA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,KAAA,KAAUA,KAAA,CAAMS,MAAM,KAAK,KAAKzB,aAAA,CAAc0B,GAAG,CAACN,UAAA,GACjE;IACA,OAAOH,SAAA;EACT;EAEA,IAAIJ,KAAA,CAAMC,OAAO,CAACE,KAAA,GAAQ;IACxB,OAAOA,KAAA,CAAME,GAAG,CAAC,CAACS,IAAA,EAAMC,KAAA,KACtBD,IAAA,IAAQ,OAAOA,IAAA,KAAS,YAAY,CAACd,KAAA,CAAMC,OAAO,CAACa,IAAA,IAC/CxB,aAAA,CAAc;MACZC,IAAA,EAAMuB,IAAA;MACNP,UAAA,EAAY,GAAGA,UAAA,IAAcQ,KAAA,EAAO;MACpC5B;IACF,KACA2B,IAAA;EAER;EAEA,IAAIX,KAAA,IAAS,OAAOA,KAAA,KAAU,YAAYP,MAAA,CAAOoB,cAAc,CAACb,KAAA,MAAWP,MAAA,CAAOqB,SAAS,EAAE;IAC3F,OAAO3B,aAAA,CAAc;MAAEC,IAAA,EAAMY,KAAA;MAAOI,UAAA;MAAYpB;IAAc;EAChE;EAEA,OAAOgB,KAAA;AACT;AAEA,MAAMV,wBAAA,GAA2BA,CAAC;EAChCyB,SAAA,EAAWC,UAAU;EACrBC,SAAA,EAAWC,UAAU;EACrB,GAAG9B;AAAA,CACE,KAAWA,IAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/nodes/BlocksNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AAC5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAExF,OAAO,EAAE,eA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AAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAGlE,MAAM,MAAM,qBAAqB,GAAG,CAClC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,YAAY,EACpB,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,EAClD,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,KAC/C,GAAG,CAAC,OAAO,CAAA;AAEhB,qBAAa,SAAU,SAAQ,eAAe;IAC5C,OAAgB,KAAK,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe,CAE5D;IAED,OAAgB,OAAO,IAAI,MAAM,CAEhC;IAED,OAAgB,UAAU,CAAC,cAAc,EAAE,mBAAmB,GAAG,SAAS,CAIzE;IAEQ,QAAQ,CACf,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,UAAU,CAAC,qBAAqB,CAAC,GAChF,UAAU,CAAC,qBAAqB,CAAC,CAWnC;IAEQ,UAAU,IAAI,mBAAmB,CAEzC;CACF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,qBAAqB,GAAG,SAAS,CASzE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,SAAS,CAEhG"}
@@ -14,16 +14,6 @@ export class BlockNode extends ServerBlockNode {
14
14
  return super.getType();
15
15
  }
16
16
  static importJSON(serializedNode) {
17
- if (serializedNode.version === 1) {
18
- // Convert (version 1 had the fields wrapped in another, unnecessary data property)
19
- serializedNode = {
20
- ...serializedNode,
21
- fields: {
22
- ...serializedNode.fields.data
23
- },
24
- version: 2
25
- };
26
- }
27
17
  const node = $createBlockNode(serializedNode.fields);
28
18
  node.setFormat(serializedNode.format);
29
19
  return node;
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksNode.js","names":["ObjectID","$applyNodeReplacement","React","ServerBlockNode","BlockComponent","BlockNode","clone","node","getType","importJSON","serializedNode","version","fields","data","$createBlockNode","setFormat","format","decorate","_editor","config","CustomBlock","CustomLabel","_jsx","cacheBuster","getCacheBuster","className","theme","block","formData","getFields","nodeKey","getKey","exportJSON","id","default","toHexString","$isBlockNode"],"sources":["../../../../../src/features/blocks/client/nodes/BlocksNode.tsx"],"sourcesContent":["'use client'\nimport ObjectID from 'bson-objectid'\nimport {\n $applyNodeReplacement,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport React, { type JSX } from 'react'\n\nimport type { ViewMapBlockComponentProps } from '../../../../types/index.js'\nimport type { BlockFieldsOptionalID, SerializedBlockNode } from '../../server/schema.js'\n\nimport { ServerBlockNode } from '../../server/nodes/BlocksNode.js'\nimport { BlockComponent } from '../component/index.js'\n\nexport type BlockDecorateFunction = (\n editor: LexicalEditor,\n config: EditorConfig,\n CustomBlock?: React.FC<ViewMapBlockComponentProps>,\n CustomLabel?: React.FC<ViewMapBlockComponentProps>,\n) => JSX.Element\n\nexport class BlockNode extends ServerBlockNode {\n static override clone(node: ServerBlockNode): ServerBlockNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importJSON(serializedNode: SerializedBlockNode): BlockNode {\n if (serializedNode.version === 1) {\n // Convert (version 1 had the fields wrapped in another, unnecessary data property)\n serializedNode = {\n ...serializedNode,\n fields: {\n ...(serializedNode as any).fields.data,\n },\n version: 2,\n }\n }\n const node = $createBlockNode(serializedNode.fields)\n node.setFormat(serializedNode.format)\n return node\n }\n\n override decorate(\n ...[_editor, config, CustomBlock, CustomLabel]: Parameters<BlockDecorateFunction>\n ): ReturnType<BlockDecorateFunction> {\n return (\n <BlockComponent\n cacheBuster={this.getCacheBuster()}\n className={config.theme.block ?? 'LexicalEditorTheme__block'}\n CustomBlock={CustomBlock}\n CustomLabel={CustomLabel}\n formData={this.getFields()}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createBlockNode(fields: BlockFieldsOptionalID): BlockNode {\n return $applyNodeReplacement(\n new BlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isBlockNode(node: BlockNode | LexicalNode | null | undefined): node is BlockNode {\n return node instanceof BlockNode\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,QAAA,MAAc;AACrB,SACEC,qBAAqB,QAIhB;AACP,OAAOC,KAAA,MAAyB;AAKhC,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAS/B,OAAO,MAAMC,SAAA,SAAkBF,eAAA;EAC7B,OAAgBG,MAAMC,IAAqB,EAAmB;IAC5D,OAAO,KAAK,CAACD,KAAA,CAAMC,IAAA;EACrB;EAEA,OAAgBC,QAAA,EAAkB;IAChC,OAAO,KAAK,CAACA,OAAA;EACf;EAEA,OAAgBC,WAAWC,cAAmC,EAAa;IACzE,IAAIA,cAAA,CAAeC,OAAO,KAAK,GAAG;MAChC;MACAD,cAAA,GAAiB;QACf,GAAGA,cAAc;QACjBE,MAAA,EAAQ;UACN,GAAGF,cAAC,CAAuBE,MAAM,CAACC;QACpC;QACAF,OAAA,EAAS;MACX;IACF;IACA,MAAMJ,IAAA,GAAOO,gBAAA,CAAiBJ,cAAA,CAAeE,MAAM;IACnDL,IAAA,CAAKQ,SAAS,CAACL,cAAA,CAAeM,MAAM;IACpC,OAAOT,IAAA;EACT;EAESU,SACP,GAAG,CAACC,OAAA,EAASC,MAAA,EAAQC,WAAA,EAAaC,WAAA,CAAY,EACX;IACnC,oBACEC,IAAA,CAAClB,cAAA;MACCmB,WAAA,EAAa,IAAI,CAACC,cAAc;MAChCC,SAAA,EAAWN,MAAA,CAAOO,KAAK,CAACC,KAAK,IAAI;MACjCP,WAAA,EAAaA,WAAA;MACbC,WAAA,EAAaA,WAAA;MACbO,QAAA,EAAU,IAAI,CAACC,SAAS;MACxBC,OAAA,EAAS,IAAI,CAACC,MAAM;;EAG1B;EAESC,WAAA,EAAkC;IACzC,OAAO,KAAK,CAACA,UAAA;EACf;AACF;AAEA,OAAO,SAASlB,iBAAiBF,MAA6B;EAC5D,OAAOX,qBAAA,CACL,IAAII,SAAA,CAAU;IACZO,MAAA,EAAQ;MACN,GAAGA,MAAM;MACTqB,EAAA,EAAIrB,MAAA,EAAQqB,EAAA,IAAM,IAAIjC,QAAA,CAASkC,OAAO,GAAGC,WAAW;IACtD;EACF;AAEJ;AAEA,OAAO,SAASC,aAAa7B,IAAgD;EAC3E,OAAOA,IAAA,YAAgBF,SAAA;AACzB","ignoreList":[]}
1
+ {"version":3,"file":"BlocksNode.js","names":["ObjectID","$applyNodeReplacement","React","ServerBlockNode","BlockComponent","BlockNode","clone","node","getType","importJSON","serializedNode","$createBlockNode","fields","setFormat","format","decorate","_editor","config","CustomBlock","CustomLabel","_jsx","cacheBuster","getCacheBuster","className","theme","block","formData","getFields","nodeKey","getKey","exportJSON","id","default","toHexString","$isBlockNode"],"sources":["../../../../../src/features/blocks/client/nodes/BlocksNode.tsx"],"sourcesContent":["'use client'\nimport ObjectID from 'bson-objectid'\nimport {\n $applyNodeReplacement,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport React, { type JSX } from 'react'\n\nimport type { ViewMapBlockComponentProps } from '../../../../types/index.js'\nimport type { BlockFieldsOptionalID, SerializedBlockNode } from '../../server/schema.js'\n\nimport { ServerBlockNode } from '../../server/nodes/BlocksNode.js'\nimport { BlockComponent } from '../component/index.js'\n\nexport type BlockDecorateFunction = (\n editor: LexicalEditor,\n config: EditorConfig,\n CustomBlock?: React.FC<ViewMapBlockComponentProps>,\n CustomLabel?: React.FC<ViewMapBlockComponentProps>,\n) => JSX.Element\n\nexport class BlockNode extends ServerBlockNode {\n static override clone(node: ServerBlockNode): ServerBlockNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importJSON(serializedNode: SerializedBlockNode): BlockNode {\n const node = $createBlockNode(serializedNode.fields)\n node.setFormat(serializedNode.format)\n return node\n }\n\n override decorate(\n ...[_editor, config, CustomBlock, CustomLabel]: Parameters<BlockDecorateFunction>\n ): ReturnType<BlockDecorateFunction> {\n return (\n <BlockComponent\n cacheBuster={this.getCacheBuster()}\n className={config.theme.block ?? 'LexicalEditorTheme__block'}\n CustomBlock={CustomBlock}\n CustomLabel={CustomLabel}\n formData={this.getFields()}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createBlockNode(fields: BlockFieldsOptionalID): BlockNode {\n return $applyNodeReplacement(\n new BlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isBlockNode(node: BlockNode | LexicalNode | null | undefined): node is BlockNode {\n return node instanceof BlockNode\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,QAAA,MAAc;AACrB,SACEC,qBAAqB,QAIhB;AACP,OAAOC,KAAA,MAAyB;AAKhC,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAS/B,OAAO,MAAMC,SAAA,SAAkBF,eAAA;EAC7B,OAAgBG,MAAMC,IAAqB,EAAmB;IAC5D,OAAO,KAAK,CAACD,KAAA,CAAMC,IAAA;EACrB;EAEA,OAAgBC,QAAA,EAAkB;IAChC,OAAO,KAAK,CAACA,OAAA;EACf;EAEA,OAAgBC,WAAWC,cAAmC,EAAa;IACzE,MAAMH,IAAA,GAAOI,gBAAA,CAAiBD,cAAA,CAAeE,MAAM;IACnDL,IAAA,CAAKM,SAAS,CAACH,cAAA,CAAeI,MAAM;IACpC,OAAOP,IAAA;EACT;EAESQ,SACP,GAAG,CAACC,OAAA,EAASC,MAAA,EAAQC,WAAA,EAAaC,WAAA,CAAY,EACX;IACnC,oBACEC,IAAA,CAAChB,cAAA;MACCiB,WAAA,EAAa,IAAI,CAACC,cAAc;MAChCC,SAAA,EAAWN,MAAA,CAAOO,KAAK,CAACC,KAAK,IAAI;MACjCP,WAAA,EAAaA,WAAA;MACbC,WAAA,EAAaA,WAAA;MACbO,QAAA,EAAU,IAAI,CAACC,SAAS;MACxBC,OAAA,EAAS,IAAI,CAACC,MAAM;;EAG1B;EAESC,WAAA,EAAkC;IACzC,OAAO,KAAK,CAACA,UAAA;EACf;AACF;AAEA,OAAO,SAASnB,iBAAiBC,MAA6B;EAC5D,OAAOX,qBAAA,CACL,IAAII,SAAA,CAAU;IACZO,MAAA,EAAQ;MACN,GAAGA,MAAM;MACTmB,EAAA,EAAInB,MAAA,EAAQmB,EAAA,IAAM,IAAI/B,QAAA,CAASgC,OAAO,GAAGC,WAAW;IACtD;EACF;AAEJ;AAEA,OAAO,SAASC,aAAa3B,IAAgD;EAC3E,OAAOA,IAAA,YAAgBF,SAAA;AACzB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","$wrapNodeInElement","mergeRegister","formatDrawerSlug","useEditDepth","$createParagraphNode","$getNodeByKey","$getPreviousSelection","$getSelection","$insertNodes","$isParagraphNode","$isRangeSelection","$isRootOrShadowRoot","COMMAND_PRIORITY_EDITOR","useEffect","useState","useEditorConfigContext","useLexicalDrawer","$createBlockNode","BlockNode","$createInlineBlockNode","$isInlineBlockNode","INSERT_BLOCK_COMMAND","INSERT_INLINE_BLOCK_COMMAND","BlocksPlugin","$","editor","targetNodeKey","setTargetNodeKey","setCreatedInlineBlock","uuid","editDepth","t0","t1","slug","depth","drawerSlug","toggleDrawer","t2","hasNodes","Error","registerCommand","payload","update","selection","blockNode","focus","focusNode","getNode","__first","remove","fields","node","setFields","inlineBlockNode","getParentOrThrow","selectEnd","t3"],"sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth } from '@payloadcms/ui'\nimport {\n $createParagraphNode,\n $getNodeByKey,\n $getPreviousSelection,\n $getSelection,\n $insertNodes,\n $isParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n COMMAND_PRIORITY_EDITOR,\n} from 'lexical'\nimport { useEffect, useState } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { BlockFields, BlockFieldsOptionalID } from '../../server/schema.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { $createInlineBlockNode, $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport { INSERT_BLOCK_COMMAND, INSERT_INLINE_BLOCK_COMMAND } from './commands.js'\n\nexport type InsertBlockPayload = BlockFieldsOptionalID\n\nexport const BlocksPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n\n const [targetNodeKey, setTargetNodeKey] = useState<null | string>(null)\n\n const { setCreatedInlineBlock, uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-` + uuid,\n depth: editDepth,\n })\n\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const blockNode = $createBlockNode(payload)\n\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert blocks node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(blockNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n INSERT_INLINE_BLOCK_COMMAND,\n (fields) => {\n if (targetNodeKey) {\n const node = $getNodeByKey(targetNodeKey)\n\n if (!node || !$isInlineBlockNode(node)) {\n return false\n }\n\n node.setFields(fields as BlockFields)\n\n setTargetNodeKey(null)\n return true\n }\n\n const inlineBlockNode = $createInlineBlockNode(fields as BlockFields)\n setCreatedInlineBlock?.(inlineBlockNode)\n $insertNodes([inlineBlockNode])\n if ($isRootOrShadowRoot(inlineBlockNode.getParentOrThrow())) {\n $wrapNodeInElement(inlineBlockNode, $createParagraphNode).selectEnd()\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor, setCreatedInlineBlock, targetNodeKey, toggleDrawer])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,EAAEC,kBAAkB,EAAEC,aAAa,QAAQ;AAC5E,SAASC,gBAAgB,EAAEC,YAAY,QAAQ;AAC/C,SACEC,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,uBAAuB,QAClB;AACP,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAKpC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,EAAEC,SAAS,QAAQ;AAC5C,SAASC,sBAAsB,EAAEC,kBAAkB,QAAQ;AAC3D,SAASC,oBAAoB,EAAEC,2BAA2B,QAAQ;AAIlE,OAAO,MAAMC,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,GAAAhC,CAAA;EAAA;EA5D/DX,SAAA,CAAUwB,EA4DV,EAAGmB,EAA4D;EAAA;AAAA,CAGjE","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","$wrapNodeInElement","mergeRegister","formatDrawerSlug","useEditDepth","$createParagraphNode","$getNodeByKey","$getPreviousSelection","$getSelection","$insertNodes","$isParagraphNode","$isRangeSelection","$isRootOrShadowRoot","COMMAND_PRIORITY_EDITOR","useEffect","useState","useEditorConfigContext","useLexicalDrawer","$createBlockNode","BlockNode","$createInlineBlockNode","$isInlineBlockNode","INSERT_BLOCK_COMMAND","INSERT_INLINE_BLOCK_COMMAND","BlocksPlugin","$","editor","targetNodeKey","setTargetNodeKey","setCreatedInlineBlock","uuid","editDepth","t0","t1","slug","depth","drawerSlug","toggleDrawer","t2","hasNodes","Error","registerCommand","payload","update","selection","blockNode","focus","focusNode","getNode","__first","remove","fields","node","setFields","inlineBlockNode","getParentOrThrow","selectEnd","t3"],"sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth } from '@payloadcms/ui'\nimport {\n $createParagraphNode,\n $getNodeByKey,\n $getPreviousSelection,\n $getSelection,\n $insertNodes,\n $isParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n COMMAND_PRIORITY_EDITOR,\n} from 'lexical'\nimport { useEffect, useState } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { BlockFields, BlockFieldsOptionalID } from '../../server/schema.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { $createInlineBlockNode, $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport { INSERT_BLOCK_COMMAND, INSERT_INLINE_BLOCK_COMMAND } from './commands.js'\n\nexport type InsertBlockPayload = BlockFieldsOptionalID\n\nexport const BlocksPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n\n const [targetNodeKey, setTargetNodeKey] = useState<null | string>(null)\n\n const { setCreatedInlineBlock, uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-` + uuid,\n depth: editDepth,\n })\n\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const blockNode = $createBlockNode(payload)\n\n // we need to get the focus node before inserting the block node, as $insertNodeToNearestRoot can change the focus node\n const { focus } = selection\n const focusNode = focus.getNode()\n // Insert blocks node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(blockNode)\n\n // Delete the node it it's an empty paragraph\n if ($isParagraphNode(focusNode) && !focusNode.__first) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n INSERT_INLINE_BLOCK_COMMAND,\n (fields) => {\n if (targetNodeKey) {\n const node = $getNodeByKey(targetNodeKey)\n\n if (!node || !$isInlineBlockNode(node)) {\n return false\n }\n\n node.setFields(fields as BlockFields)\n\n setTargetNodeKey(null)\n return true\n }\n\n const inlineBlockNode = $createInlineBlockNode(fields as BlockFields)\n setCreatedInlineBlock?.(inlineBlockNode)\n $insertNodes([inlineBlockNode])\n if ($isRootOrShadowRoot(inlineBlockNode.getParentOrThrow())) {\n $wrapNodeInElement(inlineBlockNode, $createParagraphNode).selectEnd()\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor, setCreatedInlineBlock, targetNodeKey, toggleDrawer])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,EAAEC,kBAAkB,EAAEC,aAAa,QAAQ;AAC5E,SAASC,gBAAgB,EAAEC,YAAY,QAAQ;AAC/C,SACEC,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,uBAAuB,QAClB;AACP,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAKpC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,EAAEC,SAAS,QAAQ;AAC5C,SAASC,sBAAsB,EAAEC,kBAAkB,QAAQ;AAC3D,SAASC,oBAAoB,EAAEC,2BAA2B,QAAQ;AAIlE,OAAO,MAAMC,YAAA,GAAgCA,CAAA;EAAA,MAAAC,CAAA,GAAA3B,EAAA;EAC3C,OAAA4B,MAAA,IAAiB3B,yBAAA;EAEjB,OAAA4B,aAAA,EAAAC,gBAAA,IAA0Cb,QAAA,CAAwB;EAElE;IAAAc,qBAAA;IAAAC;EAAA,IAAwCd,sBAAA;EACxC,MAAAe,SAAA,GAAkB3B,YAAA;EAGV,MAAA4B,EAAA,iCAA8B,GAAGF,IAAA;EAAA,IAAAG,EAAA;EAAA,IAAAR,CAAA,QAAAM,SAAA,IAAAN,CAAA,QAAAO,EAAA;IADtBC,EAAA,GAAA9B,gBAAA,CAAiB;MAAA+B,IAAA,EAC5BF,EAAiC;MAAAG,KAAA,EAChCJ;IACT;IAAAN,CAAA,MAAAM,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