@payloadcms/richtext-lexical 4.0.0-internal.e7d4ebc → 4.0.0-internal.ee5d8bd

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 (611) 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-BEKGION5.js +2 -0
  5. package/dist/exports/client/chunk-BEKGION5.js.map +7 -0
  6. package/dist/exports/client/{chunk-WSAPGI3Z.js → chunk-EA5BHQ2T.js} +1 -1
  7. package/dist/exports/client/{chunk-WSAPGI3Z.js.map → chunk-EA5BHQ2T.js.map} +1 -1
  8. package/dist/exports/client/chunk-FAJJXXCW.js +2 -0
  9. package/dist/exports/client/chunk-FAJJXXCW.js.map +7 -0
  10. package/dist/exports/client/{chunk-5VIL27GI.js → chunk-IYBYNEKX.js} +1 -1
  11. package/dist/exports/client/{chunk-5VIL27GI.js.map → chunk-IYBYNEKX.js.map} +1 -1
  12. package/dist/exports/client/chunk-SE5IITBK.js +2 -0
  13. package/dist/exports/client/chunk-SE5IITBK.js.map +7 -0
  14. package/dist/exports/client/component-QENB4QTS.js +2 -0
  15. package/dist/exports/client/component-QENB4QTS.js.map +7 -0
  16. package/dist/exports/client/componentInline-AU7IBNY7.js +2 -0
  17. package/dist/exports/client/index.d.ts +1 -1
  18. package/dist/exports/client/index.d.ts.map +1 -1
  19. package/dist/exports/client/index.js +26 -26
  20. package/dist/exports/client/index.js.map +4 -4
  21. package/dist/features/align/client/index.js.map +1 -1
  22. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  23. package/dist/features/blocks/client/component/BlockReordering/index.d.ts +11 -0
  24. package/dist/features/blocks/client/component/BlockReordering/index.d.ts.map +1 -0
  25. package/dist/features/blocks/client/component/BlockReordering/index.js +18 -0
  26. package/dist/features/blocks/client/component/BlockReordering/index.js.map +1 -0
  27. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  28. package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
  29. package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
  30. package/dist/features/blocks/client/component/index.d.ts +0 -6
  31. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  32. package/dist/features/blocks/client/component/index.js +199 -109
  33. package/dist/features/blocks/client/component/index.js.map +1 -1
  34. package/dist/features/blocks/client/component/useBlockReordering.d.ts +16 -0
  35. package/dist/features/blocks/client/component/useBlockReordering.d.ts.map +1 -0
  36. package/dist/features/blocks/client/component/useBlockReordering.js +178 -0
  37. package/dist/features/blocks/client/component/useBlockReordering.js.map +1 -0
  38. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
  39. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
  40. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
  41. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
  42. package/dist/features/blocks/client/componentInline/index.css +0 -1
  43. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  44. package/dist/features/blocks/client/componentInline/index.js +32 -30
  45. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  46. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts +9 -0
  47. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts.map +1 -0
  48. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js +95 -0
  49. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -0
  50. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  51. package/dist/features/blocks/client/nodes/BlocksNode.js +0 -10
  52. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  53. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  54. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +121 -78
  55. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  56. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +142 -87
  57. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
  58. package/dist/features/blocks/server/index.js +2 -2
  59. package/dist/features/blocks/server/index.js.map +1 -1
  60. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  61. package/dist/features/blocks/server/nodes/BlocksNode.js +1 -12
  62. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  63. package/dist/features/blocks/server/nodes/InlineBlocksNode.js +2 -2
  64. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  65. package/dist/features/blocks/server/schema.d.ts +2 -0
  66. package/dist/features/blocks/server/schema.d.ts.map +1 -1
  67. package/dist/features/blocks/server/schema.js +7 -9
  68. package/dist/features/blocks/server/schema.js.map +1 -1
  69. package/dist/features/blocks/server/validate.js +1 -1
  70. package/dist/features/blocks/server/validate.js.map +1 -1
  71. package/dist/features/converters/lexicalToHtml/async/converters/heading.js +1 -1
  72. package/dist/features/converters/lexicalToHtml/async/converters/heading.js.map +1 -1
  73. package/dist/features/converters/lexicalToHtml/async/converters/list.d.ts.map +1 -1
  74. package/dist/features/converters/lexicalToHtml/async/converters/list.js +4 -3
  75. package/dist/features/converters/lexicalToHtml/async/converters/list.js.map +1 -1
  76. package/dist/features/converters/lexicalToHtml/async/converters/upload.js +3 -3
  77. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  78. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.d.ts.map +1 -1
  79. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js +3 -2
  80. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js.map +1 -1
  81. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js +1 -1
  82. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js.map +1 -1
  83. package/dist/features/converters/lexicalToHtml/sync/converters/list.d.ts.map +1 -1
  84. package/dist/features/converters/lexicalToHtml/sync/converters/list.js +4 -3
  85. package/dist/features/converters/lexicalToHtml/sync/converters/list.js.map +1 -1
  86. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +3 -3
  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/upload.d.ts.map +1 -1
  97. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +4 -5
  98. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
  99. package/dist/features/converters/utilities/payloadPopulateFn.d.ts.map +1 -1
  100. package/dist/features/converters/utilities/payloadPopulateFn.js +4 -2
  101. package/dist/features/converters/utilities/payloadPopulateFn.js.map +1 -1
  102. package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
  103. package/dist/features/debug/testRecorder/client/plugin/index.css +0 -1
  104. package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
  105. package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
  106. package/dist/features/heading/client/index.js.map +1 -1
  107. package/dist/features/heading/constants.d.ts +2 -0
  108. package/dist/features/heading/constants.d.ts.map +1 -0
  109. package/dist/features/heading/constants.js +2 -0
  110. package/dist/features/heading/constants.js.map +1 -0
  111. package/dist/features/heading/server/index.d.ts.map +1 -1
  112. package/dist/features/heading/server/index.js +5 -1
  113. package/dist/features/heading/server/index.js.map +1 -1
  114. package/dist/features/heading/server/validate.d.ts +6 -0
  115. package/dist/features/heading/server/validate.d.ts.map +1 -0
  116. package/dist/features/heading/server/validate.js +15 -0
  117. package/dist/features/heading/server/validate.js.map +1 -0
  118. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +12 -2
  119. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  120. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +18 -1
  121. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  122. package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
  123. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +1 -1
  124. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
  125. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +3 -3
  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 +18 -7
  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 -2
  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 +1 -1
  149. package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  150. package/dist/features/link/nodes/AutoLinkNode.js +2 -10
  151. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  152. package/dist/features/link/nodes/LinkNode.d.ts +1 -1
  153. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  154. package/dist/features/link/nodes/LinkNode.js +2 -15
  155. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  156. package/dist/features/link/server/baseFields.js.map +1 -1
  157. package/dist/features/link/server/index.js +2 -2
  158. package/dist/features/link/server/index.js.map +1 -1
  159. package/dist/features/link/server/validate.js +1 -1
  160. package/dist/features/link/server/validate.js.map +1 -1
  161. package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
  162. package/dist/features/lists/checklist/server/index.js +5 -2
  163. package/dist/features/lists/checklist/server/index.js.map +1 -1
  164. package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
  165. package/dist/features/lists/orderedList/server/index.js +5 -2
  166. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  167. package/dist/features/lists/shared/constants.d.ts +2 -0
  168. package/dist/features/lists/shared/constants.d.ts.map +1 -0
  169. package/dist/features/lists/shared/constants.js +2 -0
  170. package/dist/features/lists/shared/constants.js.map +1 -0
  171. package/dist/features/lists/shared/schema.d.ts.map +1 -1
  172. package/dist/features/lists/shared/schema.js.map +1 -1
  173. package/dist/features/lists/shared/validate.d.ts +5 -0
  174. package/dist/features/lists/shared/validate.d.ts.map +1 -0
  175. package/dist/features/lists/shared/validate.js +15 -0
  176. package/dist/features/lists/shared/validate.js.map +1 -0
  177. package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
  178. package/dist/features/lists/unorderedList/server/index.js +5 -2
  179. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  180. package/dist/features/relationship/client/components/index.css +3 -6
  181. package/dist/features/relationship/client/drawer/index.js.map +1 -1
  182. package/dist/features/relationship/client/index.d.ts +2 -2
  183. package/dist/features/relationship/client/index.d.ts.map +1 -1
  184. package/dist/features/relationship/client/index.js.map +1 -1
  185. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  186. package/dist/features/relationship/client/nodes/RelationshipNode.js +0 -3
  187. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  188. package/dist/features/relationship/client/plugins/index.d.ts +2 -2
  189. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  190. package/dist/features/relationship/client/plugins/index.js +27 -31
  191. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  192. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts +2 -4
  193. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
  194. package/dist/features/relationship/client/utils/useEnabledRelationships.js +53 -20
  195. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  196. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +2 -2
  197. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
  198. package/dist/features/relationship/server/graphQLPopulationPromise.js +2 -2
  199. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  200. package/dist/features/relationship/server/index.d.ts +8 -1
  201. package/dist/features/relationship/server/index.d.ts.map +1 -1
  202. package/dist/features/relationship/server/index.js +28 -11
  203. package/dist/features/relationship/server/index.js.map +1 -1
  204. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  205. package/dist/features/relationship/server/nodes/RelationshipNode.js +1 -5
  206. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  207. package/dist/features/relationship/server/schema.d.ts +3 -2
  208. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  209. package/dist/features/relationship/server/schema.js +9 -12
  210. package/dist/features/relationship/server/schema.js.map +1 -1
  211. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +1 -6
  212. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -1
  213. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +1 -5
  214. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -1
  215. package/dist/features/table/client/index.d.ts.map +1 -0
  216. package/dist/features/table/client/index.js.map +1 -0
  217. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts +8 -0
  218. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts.map +1 -0
  219. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js +19 -0
  220. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js.map +1 -0
  221. package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.css +1 -2
  222. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -0
  223. package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.js +17 -44
  224. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -0
  225. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -0
  226. package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.js +47 -24
  227. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js.map +1 -0
  228. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -0
  229. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -0
  230. package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.css +0 -3
  231. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.d.ts.map +1 -0
  232. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.js.map +1 -0
  233. package/dist/features/table/client/plugins/TablePlugin/index.d.ts.map +1 -0
  234. package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.js +54 -18
  235. package/dist/features/table/client/plugins/TablePlugin/index.js.map +1 -0
  236. package/dist/features/table/client/utils/debounce.d.ts.map +1 -0
  237. package/dist/features/table/client/utils/debounce.js.map +1 -0
  238. package/dist/features/table/client/utils/useDebounce.d.ts.map +1 -0
  239. package/dist/features/table/client/utils/useDebounce.js.map +1 -0
  240. package/dist/features/table/markdownTransformer.d.ts.map +1 -0
  241. package/dist/features/table/markdownTransformer.js.map +1 -0
  242. package/dist/features/table/server/index.d.ts +3 -0
  243. package/dist/features/table/server/index.d.ts.map +1 -0
  244. package/dist/features/{experimental_table → table}/server/index.js +4 -4
  245. package/dist/features/table/server/index.js.map +1 -0
  246. package/dist/features/table/server/schema.d.ts.map +1 -0
  247. package/dist/features/table/server/schema.js.map +1 -0
  248. package/dist/features/textState/defaultColors.js +1 -1
  249. package/dist/features/textState/defaultColors.js.map +1 -1
  250. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts +8 -0
  251. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts.map +1 -0
  252. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js +80 -0
  253. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js.map +1 -0
  254. package/dist/features/toolbars/fixed/client/Toolbar/index.css +77 -3
  255. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  256. package/dist/features/toolbars/fixed/client/Toolbar/index.js +145 -71
  257. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  258. package/dist/features/toolbars/inline/client/Toolbar/index.css +0 -1
  259. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  260. package/dist/features/toolbars/inline/client/Toolbar/index.js +84 -37
  261. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  262. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  263. package/dist/features/toolbars/shared/ToolbarButton/index.js +27 -2
  264. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  265. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  266. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +199 -81
  267. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  268. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +16 -14
  269. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  270. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +22 -6
  271. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  272. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts +5 -0
  273. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts.map +1 -0
  274. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js +109 -0
  275. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js.map +1 -0
  276. package/dist/features/typesServer.d.ts +17 -12
  277. package/dist/features/typesServer.d.ts.map +1 -1
  278. package/dist/features/typesServer.js.map +1 -1
  279. package/dist/features/upload/client/component/index.css +0 -2
  280. package/dist/features/upload/client/component/index.js +2 -1
  281. package/dist/features/upload/client/component/index.js.map +1 -1
  282. package/dist/features/upload/client/drawer/index.js.map +1 -1
  283. package/dist/features/upload/client/index.d.ts +3 -2
  284. package/dist/features/upload/client/index.d.ts.map +1 -1
  285. package/dist/features/upload/client/index.js.map +1 -1
  286. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  287. package/dist/features/upload/client/nodes/UploadNode.js +0 -7
  288. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  289. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  290. package/dist/features/upload/client/plugin/index.js +50 -53
  291. package/dist/features/upload/client/plugin/index.js.map +1 -1
  292. package/dist/features/upload/server/graphQLPopulationPromise.d.ts +2 -2
  293. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  294. package/dist/features/upload/server/graphQLPopulationPromise.js +1 -1
  295. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  296. package/dist/features/upload/server/index.d.ts +7 -3
  297. package/dist/features/upload/server/index.d.ts.map +1 -1
  298. package/dist/features/upload/server/index.js +20 -16
  299. package/dist/features/upload/server/index.js.map +1 -1
  300. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  301. package/dist/features/upload/server/nodes/UploadNode.js +1 -9
  302. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  303. package/dist/features/upload/server/schema.d.ts +4 -16
  304. package/dist/features/upload/server/schema.d.ts.map +1 -1
  305. package/dist/features/upload/server/schema.js +8 -10
  306. package/dist/features/upload/server/schema.js.map +1 -1
  307. package/dist/features/upload/server/validate.d.ts +2 -2
  308. package/dist/features/upload/server/validate.d.ts.map +1 -1
  309. package/dist/features/upload/server/validate.js +4 -1
  310. package/dist/features/upload/server/validate.js.map +1 -1
  311. package/dist/field/Diff/converters/listitem/index.d.ts.map +1 -1
  312. package/dist/field/Diff/converters/listitem/index.js +2 -1
  313. package/dist/field/Diff/converters/listitem/index.js.map +1 -1
  314. package/dist/field/Diff/converters/relationship/index.css +0 -1
  315. package/dist/field/Diff/converters/unknown/index.css +0 -1
  316. package/dist/field/Diff/converters/upload/index.css +0 -1
  317. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  318. package/dist/field/Diff/index.css +0 -2
  319. package/dist/field/Diff/index.d.ts +3 -2
  320. package/dist/field/Diff/index.d.ts.map +1 -1
  321. package/dist/field/Diff/index.js +3 -2
  322. package/dist/field/Diff/index.js.map +1 -1
  323. package/dist/field/Field.d.ts.map +1 -1
  324. package/dist/field/Field.js +8 -1
  325. package/dist/field/Field.js.map +1 -1
  326. package/dist/field/RenderLexical/index.d.ts +3 -1
  327. package/dist/field/RenderLexical/index.d.ts.map +1 -1
  328. package/dist/field/RenderLexical/index.js +23 -23
  329. package/dist/field/RenderLexical/index.js.map +1 -1
  330. package/dist/field/ViewSelector.d.ts.map +1 -1
  331. package/dist/field/ViewSelector.js +13 -4
  332. package/dist/field/ViewSelector.js.map +1 -1
  333. package/dist/field/bundled.css +1 -1
  334. package/dist/field/index.css +10 -11
  335. package/dist/field/index.js.map +1 -1
  336. package/dist/field/rscEntry.d.ts +2 -2
  337. package/dist/field/rscEntry.d.ts.map +1 -1
  338. package/dist/field/rscEntry.js.map +1 -1
  339. package/dist/i18n.d.ts.map +1 -1
  340. package/dist/i18n.js +112 -0
  341. package/dist/i18n.js.map +1 -1
  342. package/dist/index.d.ts +5 -5
  343. package/dist/index.d.ts.map +1 -1
  344. package/dist/index.js +27 -5
  345. package/dist/index.js.map +1 -1
  346. package/dist/lexical/LexicalEditor.css +21 -10
  347. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  348. package/dist/lexical/LexicalEditor.js +61 -64
  349. package/dist/lexical/LexicalEditor.js.map +1 -1
  350. package/dist/lexical/config/server/loader.d.ts +1 -1
  351. package/dist/lexical/config/server/loader.d.ts.map +1 -1
  352. package/dist/lexical/config/server/loader.js +2 -2
  353. package/dist/lexical/config/server/loader.js.map +1 -1
  354. package/dist/lexical/config/server/sanitize.d.ts +1 -1
  355. package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
  356. package/dist/lexical/config/server/sanitize.js +2 -2
  357. package/dist/lexical/config/server/sanitize.js.map +1 -1
  358. package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -1
  359. package/dist/lexical/plugins/DecoratorPlugin/index.d.ts.map +1 -1
  360. package/dist/lexical/plugins/DecoratorPlugin/index.js +24 -21
  361. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  362. package/dist/lexical/plugins/InsertParagraphAtEnd/index.css +18 -25
  363. package/dist/lexical/plugins/InsertParagraphAtEnd/index.d.ts.map +1 -1
  364. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +27 -14
  365. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  366. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  367. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -1
  368. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +0 -1
  369. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  370. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +236 -108
  371. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  372. package/dist/lexical/plugins/SlashMenu/index.css +0 -2
  373. package/dist/lexical/plugins/SlashMenu/useMenuTriggerMatch.js.map +1 -1
  374. package/dist/lexical/plugins/TextPlugin/index.js.map +1 -1
  375. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -0
  376. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +2 -2
  377. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  378. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +17 -0
  379. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  380. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +139 -37
  381. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  382. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts +7 -0
  383. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts.map +1 -0
  384. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js +15 -0
  385. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js.map +1 -0
  386. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts +7 -0
  387. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts.map +1 -0
  388. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js +62 -0
  389. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js.map +1 -0
  390. package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  391. package/dist/lexical/plugins/handles/utils/setHandlePosition.js +2 -0
  392. package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  393. package/dist/lexical/theme/EditorTheme.css +0 -2
  394. package/dist/lexical/ui/ContentEditable.css +0 -4
  395. package/dist/lexical/ui/ContentEditable.d.ts +2 -1
  396. package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
  397. package/dist/lexical/ui/ContentEditable.js +32 -11
  398. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  399. package/dist/lexical/ui/icons/H3/index.d.ts.map +1 -1
  400. package/dist/lexical/ui/icons/H3/index.js +13 -6
  401. package/dist/lexical/ui/icons/H3/index.js.map +1 -1
  402. package/dist/lexical/ui/icons/H4/index.d.ts.map +1 -1
  403. package/dist/lexical/ui/icons/H4/index.js +13 -6
  404. package/dist/lexical/ui/icons/H4/index.js.map +1 -1
  405. package/dist/lexical/ui/icons/H5/index.d.ts.map +1 -1
  406. package/dist/lexical/ui/icons/H5/index.js +13 -6
  407. package/dist/lexical/ui/icons/H5/index.js.map +1 -1
  408. package/dist/lexical/ui/icons/H6/index.d.ts.map +1 -1
  409. package/dist/lexical/ui/icons/H6/index.js +13 -6
  410. package/dist/lexical/ui/icons/H6/index.js.map +1 -1
  411. package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
  412. package/dist/lexical/utils/nodeFormat.js +0 -2
  413. package/dist/lexical/utils/nodeFormat.js.map +1 -1
  414. package/dist/lexical/utils/url.d.ts.map +1 -1
  415. package/dist/lexical/utils/url.js +1 -1
  416. package/dist/lexical/utils/url.js.map +1 -1
  417. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.d.ts +2 -0
  418. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.d.ts.map +1 -0
  419. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.js +2 -0
  420. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.js.map +1 -0
  421. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.d.ts +2 -0
  422. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.d.ts.map +1 -0
  423. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.js +2 -0
  424. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.js.map +1 -0
  425. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.d.ts +2 -0
  426. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.d.ts.map +1 -0
  427. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.js +2 -0
  428. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.js.map +1 -0
  429. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.d.ts +2 -0
  430. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.d.ts.map +1 -0
  431. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.js +2 -0
  432. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.js.map +1 -0
  433. package/dist/lexical-proxy/@lexical-react/ReactExtension.d.ts +2 -0
  434. package/dist/lexical-proxy/@lexical-react/ReactExtension.d.ts.map +1 -0
  435. package/dist/lexical-proxy/@lexical-react/ReactExtension.js +2 -0
  436. package/dist/lexical-proxy/@lexical-react/ReactExtension.js.map +1 -0
  437. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.d.ts +2 -0
  438. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.d.ts.map +1 -0
  439. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.js +2 -0
  440. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.js.map +1 -0
  441. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.d.ts +2 -0
  442. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.d.ts.map +1 -0
  443. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.js +2 -0
  444. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.js.map +1 -0
  445. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.d.ts +2 -0
  446. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.d.ts.map +1 -0
  447. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.js +2 -0
  448. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.js.map +1 -0
  449. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.d.ts +2 -0
  450. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.d.ts.map +1 -0
  451. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.js +2 -0
  452. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.js.map +1 -0
  453. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.d.ts +2 -0
  454. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.d.ts.map +1 -0
  455. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.js +2 -0
  456. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.js.map +1 -0
  457. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.d.ts +2 -0
  458. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.d.ts.map +1 -0
  459. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.js +2 -0
  460. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.js.map +1 -0
  461. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.d.ts +2 -0
  462. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.d.ts.map +1 -0
  463. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.js +2 -0
  464. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.js.map +1 -0
  465. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.d.ts +2 -0
  466. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.d.ts.map +1 -0
  467. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.js +2 -0
  468. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.js.map +1 -0
  469. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.d.ts +2 -0
  470. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.d.ts.map +1 -0
  471. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.js +2 -0
  472. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.js.map +1 -0
  473. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.d.ts +2 -0
  474. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.d.ts.map +1 -0
  475. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.js +2 -0
  476. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.js.map +1 -0
  477. package/dist/populateGraphQL/populate.js.map +1 -1
  478. package/dist/presets/llmInstructions.d.ts +2 -0
  479. package/dist/presets/llmInstructions.d.ts.map +1 -0
  480. package/dist/presets/llmInstructions.js +13 -0
  481. package/dist/presets/llmInstructions.js.map +1 -0
  482. package/dist/types/builtInNodes.d.ts +1 -1
  483. package/dist/types/builtInNodes.d.ts.map +1 -1
  484. package/dist/types/builtInNodes.js +8 -3
  485. package/dist/types/builtInNodes.js.map +1 -1
  486. package/dist/types/index.d.ts +4 -7
  487. package/dist/types/index.d.ts.map +1 -1
  488. package/dist/types/index.js.map +1 -1
  489. package/dist/types/jsonSchemaHelpers.d.ts +5 -1
  490. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -1
  491. package/dist/types/jsonSchemaHelpers.js +7 -2
  492. package/dist/types/jsonSchemaHelpers.js.map +1 -1
  493. package/dist/types/nodeTypes.d.ts +6 -1
  494. package/dist/types/nodeTypes.d.ts.map +1 -1
  495. package/dist/types/nodeTypes.js.map +1 -1
  496. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  497. package/dist/utilities/buildEditorState.js.map +1 -1
  498. package/dist/utilities/buildInitialState.d.ts +3 -2
  499. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  500. package/dist/utilities/buildInitialState.js +1 -0
  501. package/dist/utilities/buildInitialState.js.map +1 -1
  502. package/dist/utilities/createServerFeature.d.ts +1 -1
  503. package/dist/utilities/createServerFeature.d.ts.map +1 -1
  504. package/dist/utilities/createServerFeature.js +2 -2
  505. package/dist/utilities/createServerFeature.js.map +1 -1
  506. package/dist/utilities/editorConfigFactory.d.ts +6 -6
  507. package/dist/utilities/editorConfigFactory.d.ts.map +1 -1
  508. package/dist/utilities/editorConfigFactory.js +9 -9
  509. package/dist/utilities/editorConfigFactory.js.map +1 -1
  510. package/dist/utilities/fieldsDrawer/Drawer.js +36 -36
  511. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  512. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  513. package/dist/utilities/fieldsDrawer/DrawerContent.js +6 -9
  514. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  515. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -1
  516. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
  517. package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
  518. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
  519. package/dist/utilities/generateImportMap.d.ts +2 -2
  520. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  521. package/dist/utilities/generateImportMap.js.map +1 -1
  522. package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts +2 -2
  523. package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts.map +1 -1
  524. package/dist/utilities/getDefaultSanitizedEditorConfig.js +6 -17
  525. package/dist/utilities/getDefaultSanitizedEditorConfig.js.map +1 -1
  526. package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
  527. package/dist/utilities/initLexicalFeatures.js +38 -4
  528. package/dist/utilities/initLexicalFeatures.js.map +1 -1
  529. package/dist/utilities/upgradeLexicalData/index.js +6 -3
  530. package/dist/utilities/upgradeLexicalData/index.js.map +1 -1
  531. package/dist/utilities/useLexicalFeature.js +15 -6
  532. package/dist/utilities/useLexicalFeature.js.map +1 -1
  533. package/dist/utilities/useRunDeprioritized.js.map +1 -1
  534. package/dist/validate/hasText.d.ts +2 -2
  535. package/dist/validate/hasText.d.ts.map +1 -1
  536. package/dist/validate/hasText.js.map +1 -1
  537. package/dist/validate/index.d.ts +1 -1
  538. package/dist/validate/index.d.ts.map +1 -1
  539. package/package.json +125 -54
  540. package/dist/dependencyChecker.spec.js +0 -16
  541. package/dist/dependencyChecker.spec.js.map +0 -1
  542. package/dist/exports/client/Field-QGSHF22S.js +0 -2
  543. package/dist/exports/client/Field-QGSHF22S.js.map +0 -7
  544. package/dist/exports/client/bundled.css +0 -1
  545. package/dist/exports/client/chunk-ESITTE3C.js +0 -2
  546. package/dist/exports/client/chunk-ESITTE3C.js.map +0 -7
  547. package/dist/exports/client/chunk-UD4DQ4AK.js +0 -2
  548. package/dist/exports/client/chunk-UD4DQ4AK.js.map +0 -7
  549. package/dist/exports/client/chunk-X3D4LZS7.js +0 -2
  550. package/dist/exports/client/chunk-X3D4LZS7.js.map +0 -7
  551. package/dist/exports/client/component-PHZQBOJE.js +0 -2
  552. package/dist/exports/client/component-PHZQBOJE.js.map +0 -7
  553. package/dist/exports/client/componentInline-H24N7GUG.js +0 -2
  554. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts +0 -11
  555. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts.map +0 -1
  556. package/dist/features/blocks/client/component/removeEmptyArrayValues.js +0 -20
  557. package/dist/features/blocks/client/component/removeEmptyArrayValues.js.map +0 -1
  558. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js +0 -180
  559. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js.map +0 -1
  560. package/dist/features/experimental_table/client/index.d.ts.map +0 -1
  561. package/dist/features/experimental_table/client/index.js.map +0 -1
  562. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +0 -1
  563. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +0 -1
  564. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +0 -1
  565. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +0 -1
  566. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +0 -1
  567. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +0 -1
  568. package/dist/features/experimental_table/client/plugins/TablePlugin/TableGridPopup/index.d.ts.map +0 -1
  569. package/dist/features/experimental_table/client/plugins/TablePlugin/TableGridPopup/index.js.map +0 -1
  570. package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts.map +0 -1
  571. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +0 -1
  572. package/dist/features/experimental_table/client/utils/debounce.d.ts.map +0 -1
  573. package/dist/features/experimental_table/client/utils/debounce.js.map +0 -1
  574. package/dist/features/experimental_table/client/utils/useDebounce.d.ts.map +0 -1
  575. package/dist/features/experimental_table/client/utils/useDebounce.js.map +0 -1
  576. package/dist/features/experimental_table/markdownTransformer.d.ts.map +0 -1
  577. package/dist/features/experimental_table/markdownTransformer.js.map +0 -1
  578. package/dist/features/experimental_table/server/index.d.ts +0 -3
  579. package/dist/features/experimental_table/server/index.d.ts.map +0 -1
  580. package/dist/features/experimental_table/server/index.js.map +0 -1
  581. package/dist/features/experimental_table/server/schema.d.ts.map +0 -1
  582. package/dist/features/experimental_table/server/schema.js.map +0 -1
  583. package/dist/features/link/markdownTransformer.spec.js +0 -195
  584. package/dist/features/link/markdownTransformer.spec.js.map +0 -1
  585. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js +0 -88
  586. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js.map +0 -1
  587. package/dist/lexical/utils/url.spec.js +0 -114
  588. package/dist/lexical/utils/url.spec.js.map +0 -1
  589. package/dist/utilities/jsx/jsx.spec.js +0 -178
  590. package/dist/utilities/jsx/jsx.spec.js.map +0 -1
  591. /package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js.map → RelationshipComponent-TVK6I4W4.js.map} +0 -0
  592. /package/dist/exports/client/{componentInline-H24N7GUG.js.map → componentInline-AU7IBNY7.js.map} +0 -0
  593. /package/dist/features/{experimental_table → table}/client/index.d.ts +0 -0
  594. /package/dist/features/{experimental_table → table}/client/index.js +0 -0
  595. /package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.d.ts +0 -0
  596. /package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.css +0 -0
  597. /package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.d.ts +0 -0
  598. /package/dist/features/{experimental_table → table}/client/plugins/TableHoverActionsPlugin/index.d.ts +0 -0
  599. /package/dist/features/{experimental_table → table}/client/plugins/TableHoverActionsPlugin/index.js +0 -0
  600. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.d.ts +0 -0
  601. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.js +0 -0
  602. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.css +0 -0
  603. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.d.ts +0 -0
  604. /package/dist/features/{experimental_table → table}/client/utils/debounce.d.ts +0 -0
  605. /package/dist/features/{experimental_table → table}/client/utils/debounce.js +0 -0
  606. /package/dist/features/{experimental_table → table}/client/utils/useDebounce.d.ts +0 -0
  607. /package/dist/features/{experimental_table → table}/client/utils/useDebounce.js +0 -0
  608. /package/dist/features/{experimental_table → table}/markdownTransformer.d.ts +0 -0
  609. /package/dist/features/{experimental_table → table}/markdownTransformer.js +0 -0
  610. /package/dist/features/{experimental_table → table}/server/schema.d.ts +0 -0
  611. /package/dist/features/{experimental_table → table}/server/schema.js +0 -0
@@ -9,12 +9,13 @@ 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 } 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, reduceFormStateToBlockData } from '../getCachedFormStateIfDataMatches.js';
18
19
  import { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js';
19
20
  const InlineBlockComponentContext = /*#__PURE__*/createContext({
20
21
  initialState: false
@@ -53,19 +54,23 @@ export const InlineBlockComponent = props => {
53
54
  } = useServerFunctions();
54
55
  const editDepth = useEditDepth();
55
56
  const firstTimeDrawer = useRef(false);
57
+ const blockType = formData.blockType;
58
+ const formDataRef = useRef(formData);
59
+ formDataRef.current = formData;
60
+ const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockType}.fields`;
56
61
  const [initialState, setInitialState] = React.useState(() => {
57
62
  // Initial form state that was calculated server-side. May have stale values
58
- const cachedFormState = initialLexicalFormState?.[formData.id]?.formState;
63
+ const cachedState = initialLexicalFormState?.[formData.id];
64
+ const cachedFormState = cachedState?.formState;
59
65
  if (!cachedFormState) {
60
66
  return false;
61
67
  }
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]));
68
+ return getCachedFormStateIfDataMatches({
69
+ cachedFormState,
70
+ cachedSchemaPath: cachedState.schemaPath,
71
+ currentSchemaPath: schemaFieldsPath,
72
+ formData
73
+ });
69
74
  });
70
75
  const hasMounted = useRef(false);
71
76
  const prevCacheBuster = useRef(cacheBuster);
@@ -104,7 +109,7 @@ export const InlineBlockComponent = props => {
104
109
  isEditor: true,
105
110
  isJSXConverter: false,
106
111
  nodeKey: nodeKey,
107
- // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call
112
+ // eslint-disable-next-line react-hooks/hooks -- intentionally passed as a prop for custom block components to call
108
113
  useInlineBlockComponentContext: useInlineBlockComponentContext
109
114
  });
110
115
  }
@@ -118,7 +123,7 @@ export const InlineBlockComponent = props => {
118
123
  isEditor: true,
119
124
  isJSXConverter: false,
120
125
  nodeKey: nodeKey,
121
- // eslint-disable-next-line react-compiler/react-compiler -- intentionally passed as a prop for custom block components to call
126
+ // eslint-disable-next-line react-hooks/hooks -- intentionally passed as a prop for custom block components to call
122
127
  useInlineBlockComponentContext: useInlineBlockComponentContext
123
128
  });
124
129
  }
@@ -141,7 +146,7 @@ export const InlineBlockComponent = props => {
141
146
  const {
142
147
  config
143
148
  } = useConfig();
144
- const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`;
149
+ const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockType}`;
145
150
  const clientSchemaMap = featureClientSchemaMap['blocks'];
146
151
  const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
147
152
  const blockOrSlug = blocksField?.blocks?.[0];
@@ -165,7 +170,6 @@ export const InlineBlockComponent = props => {
165
170
  }, [editor, nodeKey]);
166
171
  const blockDisplayName = clientBlock?.labels?.singular ? getTranslation(clientBlock?.labels.singular, i18n) : clientBlock?.slug;
167
172
  const onChangeAbortControllerRef = useRef(new AbortController());
168
- const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`;
169
173
  // Initial state for newly created blocks
170
174
  useEffect(() => {
171
175
  const abortController = new AbortController();
@@ -185,12 +189,9 @@ export const InlineBlockComponent = props => {
185
189
  fields: true
186
190
  },
187
191
  docPreferences: await getDocPreferences(),
188
- documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {
189
- excludeFiles: true
190
- }),
192
+ documentFormState: parentDocumentFields,
191
193
  globalSlug,
192
194
  initialBlockData: formData,
193
- initialBlockFormState: formData,
194
195
  operation: 'update',
195
196
  readOnly: !isEditable,
196
197
  renderAllFields: true,
@@ -198,9 +199,9 @@ export const InlineBlockComponent = props => {
198
199
  signal: abortController.signal
199
200
  });
200
201
  if (state) {
201
- const newFormStateData = reduceFieldsToValues(deepCopyObjectSimpleWithoutReactComponents(state, {
202
+ const newFormStateData = reduceFormStateToBlockData(deepCopyObjectSimpleWithoutReactComponents(state, {
202
203
  excludeFiles: true
203
- }), true);
204
+ }));
204
205
  // Things like default values may come back from the server => update the node with the new data
205
206
  editor.update(() => {
206
207
  const node = $getNodeByKey(nodeKey);
@@ -224,13 +225,13 @@ export const InlineBlockComponent = props => {
224
225
  }
225
226
  }
226
227
  };
227
- if (formData && !initialState) {
228
+ if (clientBlock && formData && !initialState) {
228
229
  void awaitInitialState();
229
230
  }
230
231
  return () => {
231
232
  abortAndIgnore(abortController);
232
233
  };
233
- }, [getFormState, editor, nodeKey, isEditable, CustomLabelFromProps, CustomBlockFromProps, schemaFieldsPath, id, formData, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
234
+ }, [getFormState, editor, nodeKey, isEditable, CustomLabelFromProps, CustomBlockFromProps, schemaFieldsPath, id, formData, initialState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields, clientBlock]);
234
235
  /**
235
236
  * HANDLE ONCHANGE
236
237
  */
@@ -241,21 +242,21 @@ export const InlineBlockComponent = props => {
241
242
  abortAndIgnore(onChangeAbortControllerRef.current);
242
243
  const controller = new AbortController();
243
244
  onChangeAbortControllerRef.current = controller;
245
+ const blockData = reduceFormStateToBlockData(prevFormState, formDataRef.current);
244
246
  const {
245
247
  state: state_0
246
248
  } = await getFormState({
247
249
  id,
248
250
  collectionSlug,
251
+ data: blockData,
249
252
  docPermissions: {
250
253
  fields: true
251
254
  },
252
255
  docPreferences: await getDocPreferences(),
253
- documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {
254
- excludeFiles: true
255
- }),
256
+ documentFormState: parentDocumentFields,
256
257
  formState: prevFormState,
257
258
  globalSlug,
258
- initialBlockFormState: prevFormState,
259
+ initialBlockData: blockData,
259
260
  operation: 'update',
260
261
  readOnly: !isEditable,
261
262
  renderAllFields: submit ? true : false,
@@ -293,8 +294,9 @@ export const InlineBlockComponent = props => {
293
294
  /**
294
295
  * HANDLE FORM SUBMIT
295
296
  */
296
- const onFormSubmit = useCallback((formState, newData_0) => {
297
- newData_0.blockType = formData.blockType;
297
+ const onFormSubmit = useCallback(formState => {
298
+ const newData_0 = reduceFormStateToBlockData(formState, formDataRef.current);
299
+ newData_0.blockType = blockType;
298
300
  editor.update(() => {
299
301
  const node_0 = $getNodeByKey(nodeKey);
300
302
  if (node_0 && $isInlineBlockNode(node_0)) {
@@ -306,7 +308,7 @@ export const InlineBlockComponent = props => {
306
308
  {
307
309
  tag: SKIP_DOM_SELECTION_TAG
308
310
  });
309
- }, [editor, nodeKey, formData]);
311
+ }, [blockType, editor, nodeKey]);
310
312
  const {
311
313
  headerActions,
312
314
  submitRef
@@ -396,8 +398,8 @@ export const InlineBlockComponent = props => {
396
398
  fields: clientBlock?.fields,
397
399
  initialState: initialState || {},
398
400
  onChange: [onChange],
399
- onSubmit: (formState_1, data) => {
400
- onFormSubmit(formState_1, data);
401
+ onSubmit: formState_1 => {
402
+ onFormSubmit(formState_1);
401
403
  toggleDrawer();
402
404
  },
403
405
  uuid: formUuid,
@@ -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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,EAAa;YACbpD,QAAA,EAAU,CAACnF;2BAEbuC,IAAA,CAAC3D,kBAAA;YAAmByH,SAAA,EAAWA;;aAE/B;;QAGP/D,mBAAA,gBACCC,IAAA,CAACvD,2BAAA;MACC2C,KAAA,EAAO;QACLuF,UAAA;QACAjI,YAAA;QACAmI,oBAAA;QACAS,KAAA;QACA/H,OAAA;QACAwG;MACF;gBAEChE;sBAGHwF,KAAA,CAACV,oBAAA;iBACEnI,YAAA,gBAAesD,IAAA,CAACsF,KAAA,qBAAWtF,IAAA,CAAChF,aAAA;QAAciL,MAAA,EAAO;QAAOC,KAAA,EAAM;UAC9DzI,UAAA,gBACCuC,IAAA,CAAC;QAAIhD,SAAA,EAAW,GAAGC,SAAA,WAAoB;kBACrC,aAAA+C,IAAA,CAAC+D,YAAA;WAED;;;AAKd","ignoreList":[]}
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","React","createContext","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","RegisterFormSubmit","useDrawerSubmit","useLexicalDrawer","getCachedFormStateIfDataMatches","reduceFormStateToBlockData","$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","blockType","formDataRef","current","schemaFieldsPath","setInitialState","useState","cachedState","id","cachedFormState","formState","cachedSchemaPath","currentSchemaPath","hasMounted","prevCacheBuster","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","onChangeAbortControllerRef","AbortController","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","newFormStateData","excludeFiles","node","newData","setFields","tag","onChange","prevFormState","submit","controller","blockData","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","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, 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 } 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 {\n getCachedFormStateIfDataMatches,\n reduceFormStateToBlockData,\n} 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 { 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 formDataRef = useRef(formData)\n formDataRef.current = formData\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 const onChangeAbortControllerRef = useRef(new AbortController())\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: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData = reduceFormStateToBlockData(\n deepCopyObjectSimpleWithoutReactComponents(state, { excludeFiles: 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 parentDocumentFields,\n clientBlock,\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 const blockData = reduceFormStateToBlockData(prevFormState, formDataRef.current)\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: blockData,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: parentDocumentFields,\n formState: prevFormState,\n globalSlug,\n initialBlockData: blockData,\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) => {\n const newData = reduceFormStateToBlockData(formState, formDataRef.current)\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 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) => {\n onFormSubmit(formState)\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 <Remove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A,EAAa7C,MAAA;YACrBuH,WAAW;YACXC,eAAA,EAAgB;YAChBC,UAAA,EAAW;YACXC,gBAAA,EAAkBlH,gBAAA;YAClBmH,WAAA,EAAa;YACbxD,QAAA,EAAU,CAAC7E;2BAEbqC,IAAA,CAAC3D,kBAAA;YAAmByH,SAAA,EAAWA;;aAE/B;;QAGP/D,mBAAA,gBACCC,IAAA,CAACrD,2BAAA;MACCgH,KAAA,EAAO;QACLgB,UAAA;QACA/H,YAAA;QACAiI,oBAAA;QACAS,KAAA;QACA7H,OAAA;QACAsG;MACF;gBAEChE;sBAGHwF,KAAA,CAACV,oBAAA;iBACEjI,YAAA,gBAAeoD,IAAA,CAACsF,KAAA,qBAAWtF,IAAA,CAAC/E,aAAA;QAAcgL,MAAA,EAAO;QAAOC,KAAA,EAAM;UAC9DvI,UAAA,gBACCqC,IAAA,CAAC;QAAI9C,SAAA,EAAW,GAAGC,SAAA,WAAoB;kBACrC,aAAA6C,IAAA,CAAC+D,YAAA;WAED;;;AAKd","ignoreList":[]}
@@ -0,0 +1,9 @@
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
+ export declare const reduceFormStateToBlockData: (formState: FormState, currentData?: Data) => Data;
9
+ //# 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,SAcX,CAAA;AAED,eAAO,MAAM,0BAA0B,cAAe,SAAS,gBAAgB,IAAI,KAAG,IA4BrF,CAAA"}
@@ -0,0 +1,95 @@
1
+ import { dequal } from 'dequal/lite';
2
+ import { reduceFieldsToValues } 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 cachedData = reduceFormStateToBlockData(cachedFormState);
13
+ const currentData = normalizeData({
14
+ data: formData,
15
+ rowFieldPaths: getRowFieldPaths(cachedFormState)
16
+ });
17
+ return dequal(withoutSystemBlockFields(cachedData), withoutSystemBlockFields(currentData)) ? cachedFormState : false;
18
+ };
19
+ export const reduceFormStateToBlockData = (formState, currentData) => {
20
+ const formStateWithoutRowCounts = Object.fromEntries(Object.entries(formState).map(([path, fieldState]) => {
21
+ if (!fieldState || !Array.isArray(fieldState.rows)) {
22
+ return [path, fieldState];
23
+ }
24
+ if (fieldState.value === undefined || fieldState.disableFormData !== false && fieldState.isModified !== true && fieldState.rows.length === 0 && getValueAtPath(currentData, path) === null) {
25
+ return [path, {
26
+ ...fieldState,
27
+ value: null
28
+ }];
29
+ }
30
+ return [path, fieldState.value === null ? fieldState : {
31
+ ...fieldState,
32
+ disableFormData: true
33
+ }];
34
+ }));
35
+ return normalizeData({
36
+ data: reduceFieldsToValues(formStateWithoutRowCounts, true),
37
+ rowFieldPaths: new Set()
38
+ });
39
+ };
40
+ const getValueAtPath = (data, path) => path.split('.').reduce((value, pathSegment) => {
41
+ if (!value || typeof value !== 'object') {
42
+ return undefined;
43
+ }
44
+ return value[pathSegment];
45
+ }, data);
46
+ const getRowFieldPaths = formState => new Set(Object.entries(formState).filter(([, fieldState]) => Array.isArray(fieldState?.rows) && fieldState.value !== null && fieldState.value !== undefined).map(([path]) => path));
47
+ const normalizeData = ({
48
+ data,
49
+ parentPath = '',
50
+ rowFieldPaths
51
+ }) => {
52
+ const normalizedData = {};
53
+ for (const [key, value] of Object.entries(data)) {
54
+ const path = parentPath ? `${parentPath}.${key}` : key;
55
+ const normalizedValue = normalizeValue({
56
+ parentPath: path,
57
+ rowFieldPaths,
58
+ value
59
+ });
60
+ if (normalizedValue !== undefined) {
61
+ normalizedData[key] = normalizedValue;
62
+ }
63
+ }
64
+ return normalizedData;
65
+ };
66
+ const normalizeValue = ({
67
+ parentPath,
68
+ rowFieldPaths,
69
+ value
70
+ }) => {
71
+ if (value === undefined || Array.isArray(value) && value.length === 0 && rowFieldPaths.has(parentPath)) {
72
+ return undefined;
73
+ }
74
+ if (Array.isArray(value)) {
75
+ return value.map((item, index) => item && typeof item === 'object' && !Array.isArray(item) ? normalizeData({
76
+ data: item,
77
+ parentPath: `${parentPath}.${index}`,
78
+ rowFieldPaths
79
+ }) : item);
80
+ }
81
+ if (value && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) {
82
+ return normalizeData({
83
+ data: value,
84
+ parentPath,
85
+ rowFieldPaths
86
+ });
87
+ }
88
+ return value;
89
+ };
90
+ const withoutSystemBlockFields = ({
91
+ blockName: _blockName,
92
+ blockType: _blockType,
93
+ ...data
94
+ }) => data;
95
+ //# sourceMappingURL=getCachedFormStateIfDataMatches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCachedFormStateIfDataMatches.js","names":["dequal","reduceFieldsToValues","getCachedFormStateIfDataMatches","cachedFormState","cachedSchemaPath","currentSchemaPath","formData","cachedData","reduceFormStateToBlockData","currentData","normalizeData","data","rowFieldPaths","getRowFieldPaths","withoutSystemBlockFields","formState","formStateWithoutRowCounts","Object","fromEntries","entries","map","path","fieldState","Array","isArray","rows","value","undefined","disableFormData","isModified","length","getValueAtPath","Set","split","reduce","pathSegment","filter","parentPath","normalizedData","key","normalizedValue","normalizeValue","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 { reduceFieldsToValues } 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 cachedData = reduceFormStateToBlockData(cachedFormState)\n const currentData = normalizeData({\n data: formData,\n rowFieldPaths: getRowFieldPaths(cachedFormState),\n })\n\n return dequal(withoutSystemBlockFields(cachedData), withoutSystemBlockFields(currentData))\n ? cachedFormState\n : false\n}\n\nexport const reduceFormStateToBlockData = (formState: FormState, currentData?: Data): Data => {\n const formStateWithoutRowCounts = Object.fromEntries(\n Object.entries(formState).map(([path, fieldState]) => {\n if (!fieldState || !Array.isArray(fieldState.rows)) {\n return [path, fieldState]\n }\n\n if (\n fieldState.value === undefined ||\n (fieldState.disableFormData !== false &&\n fieldState.isModified !== true &&\n fieldState.rows.length === 0 &&\n getValueAtPath(currentData, path) === null)\n ) {\n return [path, { ...fieldState, value: null }]\n }\n\n return [\n path,\n fieldState.value === null ? fieldState : { ...fieldState, disableFormData: true },\n ]\n }),\n )\n\n return normalizeData({\n data: reduceFieldsToValues(formStateWithoutRowCounts, true),\n rowFieldPaths: new Set(),\n })\n}\n\nconst getValueAtPath = (data: Data | undefined, path: string): unknown =>\n path.split('.').reduce<unknown>((value, pathSegment) => {\n if (!value || typeof value !== 'object') {\n return undefined\n }\n\n return (value as Record<string, unknown>)[pathSegment]\n }, data)\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,UAAA,GAAaC,0BAAA,CAA2BL,eAAA;EAC9C,MAAMM,WAAA,GAAcC,aAAA,CAAc;IAChCC,IAAA,EAAML,QAAA;IACNM,aAAA,EAAeC,gBAAA,CAAiBV,eAAA;EACl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A,EAAMC,KAAA,KACtBD,IAAA,IAAQ,OAAOA,IAAA,KAAS,YAAY,CAACpB,KAAA,CAAMC,OAAO,CAACmB,IAAA,IAC/CjC,aAAA,CAAc;MACZC,IAAA,EAAMgC,IAAA;MACNN,UAAA,EAAY,GAAGA,UAAA,IAAcO,KAAA,EAAO;MACpChC;IACF,KACA+B,IAAA;EAER;EAEA,IAAIjB,KAAA,IAAS,OAAOA,KAAA,KAAU,YAAYT,MAAA,CAAO4B,cAAc,CAACnB,KAAA,MAAWT,MAAA,CAAO6B,SAAS,EAAE;IAC3F,OAAOpC,aAAA,CAAc;MAAEC,IAAA,EAAMe,KAAA;MAAOW,UAAA;MAAYzB;IAAc;EAChE;EAEA,OAAOc,KAAA;AACT;AAEA,MAAMZ,wBAAA,GAA2BA,CAAC;EAChCiC,SAAA,EAAWC,UAAU;EACrBC,SAAA,EAAWC,UAAU;EACrB,GAAGvC;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,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,CA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AAE,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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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,YAAA,GAAgCA,CAAA;EAAA,MAAAC,CAAA,GAAA3B,EAAA;EAC3C,OAAA4B,MAAA,IAAiB3B,yBAAA;EAEjB,OAAA4B,aAAA,EAAAC,gBAAA,IAA0Cb,QAAA,KAAwB;EAElE;IAAAc,qBAAA;IAAAC;EAAA,IAAwCd,sBAAA;EACxC,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4B,MAAA;QAAA,IAGQxB,aAAA;UACF,MAAAyB,IAAA,GAAa9C,aAAA,CAAcqB,aAAA;UAAA,IAEvB,CAACyB,IAAA,KAAS/B,kBAAA,CAAmB+B,IAAA;YAAA;UAAA;UAIjCA,IAAA,CAAAC,SAAA,CAAeF,MAAA;UAEfvB,gBAAA,KAAiB;UAAA;QAAA;QAInB,MAAA0B,eAAA,GAAwBlC,sBAAA,CAAuB+B,MAAA;QAC/CtB,qBAAA,GAAwByB,eAAA;QACxB7C,YAAA,EAAc6C,eAAA,CAAgB;QAAA,IAC1B1C,mBAAA,CAAoB0C,eAAA,CAAAC,gBAAA,CAAgC;UACtDtD,kBAAA,CAAmBqD,eAAA,EAAAjD,oBAAiB,EAAAmD,SAAA,CAA+B;QAAA;QAAA;MAAA,GAAA3C,uBAKvE;IAAA;IAGNY,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAI,qBAAA;IAAAJ,CAAA,MAAAE,aAAA;IAAAF,CAAA,MAAAa,EAAA;EAAA;IAAAA,EAAA,GAAAb,CAAA;EAAA;EAAA,IAAAgC,EAAA;EAAA,IAAAhC,CAAA,QAAAC,MAAA,IAAAD,CAAA,QAAAI,qBAAA,IAAAJ,CAAA,QAAAE,aAAA,IAAAF,CAAA,SAAAY,YAAA;IAAGoB,EAAA,IAAC/B,MAAA,EAAQG,qBAAA,EAAuBF,aAAA,EAAeU,YAAA;IAAaZ,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAI,qBAAA;IAAAJ,CAAA,MAAAE,aAAA;IAAAF,CAAA,OAAAY,YAAA;IAAAZ,CAAA,OAAAgC,EAAA;EAAA;IAAAA,EAAA,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":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