@payloadcms/richtext-lexical 3.0.0-beta.84 → 3.0.0-beta.86

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 (757) hide show
  1. package/dist/cell/index.js +117 -127
  2. package/dist/cell/index.js.map +1 -1
  3. package/dist/exports/client/Component-DOSSWC76.js +2 -0
  4. package/dist/exports/client/Component-DOSSWC76.js.map +7 -0
  5. package/dist/exports/client/Component-MBLHTKDK.js +2 -0
  6. package/dist/exports/client/Component-MBLHTKDK.js.map +7 -0
  7. package/dist/exports/client/Field-KUSPHC7Q.js +2 -0
  8. package/dist/exports/client/Field-KUSPHC7Q.js.map +7 -0
  9. package/dist/exports/client/RelationshipComponent-3QWBV4GT.js +2 -0
  10. package/dist/exports/client/RelationshipComponent-3QWBV4GT.js.map +7 -0
  11. package/dist/exports/client/bundled.css +1 -1
  12. package/dist/exports/client/chunk-G5DTIOPI.js +2 -0
  13. package/dist/exports/client/chunk-G5DTIOPI.js.map +7 -0
  14. package/dist/exports/client/chunk-LGUXX2QH.js +2 -0
  15. package/dist/exports/client/chunk-LGUXX2QH.js.map +7 -0
  16. package/dist/exports/client/chunk-NI6Z4GBD.js +2 -0
  17. package/dist/exports/client/{chunk-SQHN3N6E.js.map → chunk-NI6Z4GBD.js.map} +2 -2
  18. package/dist/exports/client/chunk-OKMIHD2R.js +2 -0
  19. package/dist/exports/client/chunk-OKMIHD2R.js.map +7 -0
  20. package/dist/exports/client/chunk-TO2W7Q2G.js +2 -0
  21. package/dist/exports/client/chunk-TO2W7Q2G.js.map +7 -0
  22. package/dist/exports/client/chunk-V2LKLT2F.js +3 -0
  23. package/dist/exports/client/chunk-V2LKLT2F.js.map +7 -0
  24. package/dist/exports/client/component-3OFD6Q4Z.js +2 -0
  25. package/dist/exports/client/component-3OFD6Q4Z.js.map +7 -0
  26. package/dist/exports/client/component-LCAAX56T.js +2 -0
  27. package/dist/exports/client/component-LCAAX56T.js.map +7 -0
  28. package/dist/exports/client/component-LLWMZU6K.js +2 -0
  29. package/dist/exports/client/component-LLWMZU6K.js.map +7 -0
  30. package/dist/exports/client/componentInline-72VZAAHP.js +2 -0
  31. package/dist/exports/client/componentInline-72VZAAHP.js.map +7 -0
  32. package/dist/exports/client/index.js +9 -9
  33. package/dist/exports/client/index.js.map +3 -3
  34. package/dist/exports/server/migrate.js +0 -1
  35. package/dist/exports/server/migrate.js.map +1 -1
  36. package/dist/features/align/client/index.js +151 -134
  37. package/dist/features/align/client/index.js.map +1 -1
  38. package/dist/features/align/client/toolbarAlignGroup.d.ts.map +1 -1
  39. package/dist/features/align/client/toolbarAlignGroup.js +10 -9
  40. package/dist/features/align/client/toolbarAlignGroup.js.map +1 -1
  41. package/dist/features/align/server/i18n.js +192 -193
  42. package/dist/features/align/server/i18n.js.map +1 -1
  43. package/dist/features/align/server/index.js +5 -6
  44. package/dist/features/align/server/index.js.map +1 -1
  45. package/dist/features/blockquote/client/index.js +60 -65
  46. package/dist/features/blockquote/client/index.js.map +1 -1
  47. package/dist/features/blockquote/markdownTransformer.js +28 -34
  48. package/dist/features/blockquote/markdownTransformer.js.map +1 -1
  49. package/dist/features/blockquote/server/i18n.js +96 -97
  50. package/dist/features/blockquote/server/i18n.js.map +1 -1
  51. package/dist/features/blockquote/server/index.js +38 -37
  52. package/dist/features/blockquote/server/index.js.map +1 -1
  53. package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
  54. package/dist/features/blocks/client/component/BlockContent.js +166 -172
  55. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  56. package/dist/features/blocks/client/component/FormSavePlugin.d.ts.map +1 -1
  57. package/dist/features/blocks/client/component/FormSavePlugin.js +46 -22
  58. package/dist/features/blocks/client/component/FormSavePlugin.js.map +1 -1
  59. package/dist/features/blocks/client/component/index.js +130 -142
  60. package/dist/features/blocks/client/component/index.js.map +1 -1
  61. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts.map +1 -1
  62. package/dist/features/blocks/client/component/removeEmptyArrayValues.js +12 -8
  63. package/dist/features/blocks/client/component/removeEmptyArrayValues.js.map +1 -1
  64. package/dist/features/blocks/client/componentInline/index.js +106 -122
  65. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  66. package/dist/features/blocks/client/index.js +149 -142
  67. package/dist/features/blocks/client/index.js.map +1 -1
  68. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  69. package/dist/features/blocks/client/nodes/BlocksNode.js +41 -40
  70. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  71. package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
  72. package/dist/features/blocks/client/nodes/InlineBlocksNode.js +31 -30
  73. package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
  74. package/dist/features/blocks/client/plugin/commands.d.ts.map +1 -1
  75. package/dist/features/blocks/client/plugin/commands.js +2 -1
  76. package/dist/features/blocks/client/plugin/commands.js.map +1 -1
  77. package/dist/features/blocks/client/plugin/index.js +179 -106
  78. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  79. package/dist/features/blocks/server/graphQLPopulationPromise.js +41 -28
  80. package/dist/features/blocks/server/graphQLPopulationPromise.js.map +1 -1
  81. package/dist/features/blocks/server/i18n.js +288 -289
  82. package/dist/features/blocks/server/i18n.js.map +1 -1
  83. package/dist/features/blocks/server/index.js +149 -151
  84. package/dist/features/blocks/server/index.js.map +1 -1
  85. package/dist/features/blocks/server/nodes/BlocksNode.js +76 -73
  86. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  87. package/dist/features/blocks/server/nodes/InlineBlocksNode.js +78 -76
  88. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  89. package/dist/features/blocks/server/validate.js +45 -34
  90. package/dist/features/blocks/server/validate.js.map +1 -1
  91. package/dist/features/converters/html/converter/converters/linebreak.js +4 -7
  92. package/dist/features/converters/html/converter/converters/linebreak.js.map +1 -1
  93. package/dist/features/converters/html/converter/converters/paragraph.js +24 -19
  94. package/dist/features/converters/html/converter/converters/paragraph.js.map +1 -1
  95. package/dist/features/converters/html/converter/converters/text.js +28 -29
  96. package/dist/features/converters/html/converter/converters/text.js.map +1 -1
  97. package/dist/features/converters/html/converter/defaultConverters.js +1 -6
  98. package/dist/features/converters/html/converter/defaultConverters.js.map +1 -1
  99. package/dist/features/converters/html/converter/index.js +66 -51
  100. package/dist/features/converters/html/converter/index.js.map +1 -1
  101. package/dist/features/converters/html/converter/types.js +1 -2
  102. package/dist/features/converters/html/converter/types.js.map +1 -1
  103. package/dist/features/converters/html/field/index.js +134 -139
  104. package/dist/features/converters/html/field/index.js.map +1 -1
  105. package/dist/features/converters/html/index.js +2 -3
  106. package/dist/features/converters/html/index.js.map +1 -1
  107. package/dist/features/createClientComponent.js +7 -6
  108. package/dist/features/createClientComponent.js.map +1 -1
  109. package/dist/features/createFeaturePropComponent.js +14 -13
  110. package/dist/features/createFeaturePropComponent.js.map +1 -1
  111. package/dist/features/debug/testRecorder/client/index.js +5 -7
  112. package/dist/features/debug/testRecorder/client/index.js.map +1 -1
  113. package/dist/features/debug/testRecorder/client/plugin/index.js +518 -402
  114. package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
  115. package/dist/features/debug/testRecorder/server/index.js +4 -5
  116. package/dist/features/debug/testRecorder/server/index.js.map +1 -1
  117. package/dist/features/debug/treeView/client/index.js +5 -7
  118. package/dist/features/debug/treeView/client/index.js.map +1 -1
  119. package/dist/features/debug/treeView/client/plugin/index.js +21 -11
  120. package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
  121. package/dist/features/debug/treeView/server/index.js +4 -5
  122. package/dist/features/debug/treeView/server/index.js.map +1 -1
  123. package/dist/features/experimental_table/client/index.js +41 -58
  124. package/dist/features/experimental_table/client/index.js.map +1 -1
  125. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +714 -560
  126. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  127. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +295 -301
  128. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  129. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts +0 -7
  130. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
  131. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +228 -159
  132. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  133. package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts +1 -1
  134. package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts.map +1 -1
  135. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +129 -82
  136. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
  137. package/dist/features/experimental_table/client/utils/debounce.d.ts.map +1 -1
  138. package/dist/features/experimental_table/client/utils/debounce.js +108 -89
  139. package/dist/features/experimental_table/client/utils/debounce.js.map +1 -1
  140. package/dist/features/experimental_table/client/utils/useDebounce.d.ts.map +1 -1
  141. package/dist/features/experimental_table/client/utils/useDebounce.js +11 -13
  142. package/dist/features/experimental_table/client/utils/useDebounce.js.map +1 -1
  143. package/dist/features/experimental_table/server/index.js +127 -114
  144. package/dist/features/experimental_table/server/index.js.map +1 -1
  145. package/dist/features/format/bold/feature.client.js +34 -35
  146. package/dist/features/format/bold/feature.client.js.map +1 -1
  147. package/dist/features/format/bold/feature.server.js +14 -18
  148. package/dist/features/format/bold/feature.server.js.map +1 -1
  149. package/dist/features/format/bold/markdownTransformers.js +14 -25
  150. package/dist/features/format/bold/markdownTransformers.js.map +1 -1
  151. package/dist/features/format/inlineCode/feature.client.js +26 -28
  152. package/dist/features/format/inlineCode/feature.client.js.map +1 -1
  153. package/dist/features/format/inlineCode/feature.server.js +5 -8
  154. package/dist/features/format/inlineCode/feature.server.js.map +1 -1
  155. package/dist/features/format/inlineCode/markdownTransformers.js +3 -6
  156. package/dist/features/format/inlineCode/markdownTransformers.js.map +1 -1
  157. package/dist/features/format/italic/feature.client.js +26 -29
  158. package/dist/features/format/italic/feature.client.js.map +1 -1
  159. package/dist/features/format/italic/feature.server.js +5 -9
  160. package/dist/features/format/italic/feature.server.js.map +1 -1
  161. package/dist/features/format/italic/markdownTransformers.js +7 -12
  162. package/dist/features/format/italic/markdownTransformers.js.map +1 -1
  163. package/dist/features/format/shared/toolbarFormatGroup.d.ts.map +1 -1
  164. package/dist/features/format/shared/toolbarFormatGroup.js +9 -8
  165. package/dist/features/format/shared/toolbarFormatGroup.js.map +1 -1
  166. package/dist/features/format/strikethrough/feature.client.js +26 -28
  167. package/dist/features/format/strikethrough/feature.client.js.map +1 -1
  168. package/dist/features/format/strikethrough/feature.server.js +5 -8
  169. package/dist/features/format/strikethrough/feature.server.js.map +1 -1
  170. package/dist/features/format/strikethrough/markdownTransformers.js +3 -6
  171. package/dist/features/format/strikethrough/markdownTransformers.js.map +1 -1
  172. package/dist/features/format/subscript/feature.client.js +25 -25
  173. package/dist/features/format/subscript/feature.client.js.map +1 -1
  174. package/dist/features/format/subscript/feature.server.js +4 -5
  175. package/dist/features/format/subscript/feature.server.js.map +1 -1
  176. package/dist/features/format/superscript/feature.client.js +25 -25
  177. package/dist/features/format/superscript/feature.client.js.map +1 -1
  178. package/dist/features/format/superscript/feature.server.js +4 -5
  179. package/dist/features/format/superscript/feature.server.js.map +1 -1
  180. package/dist/features/format/underline/feature.client.js +25 -25
  181. package/dist/features/format/underline/feature.client.js.map +1 -1
  182. package/dist/features/format/underline/feature.server.js +4 -5
  183. package/dist/features/format/underline/feature.server.js.map +1 -1
  184. package/dist/features/heading/client/index.js +86 -90
  185. package/dist/features/heading/client/index.js.map +1 -1
  186. package/dist/features/heading/markdownTransformer.js +22 -25
  187. package/dist/features/heading/markdownTransformer.js.map +1 -1
  188. package/dist/features/heading/server/i18n.js +96 -97
  189. package/dist/features/heading/server/i18n.js.map +1 -1
  190. package/dist/features/heading/server/index.js +49 -51
  191. package/dist/features/heading/server/index.js.map +1 -1
  192. package/dist/features/horizontalRule/client/component/index.js +81 -51
  193. package/dist/features/horizontalRule/client/component/index.js.map +1 -1
  194. package/dist/features/horizontalRule/client/index.js +48 -57
  195. package/dist/features/horizontalRule/client/index.js.map +1 -1
  196. package/dist/features/horizontalRule/client/markdownTransformer.js +15 -18
  197. package/dist/features/horizontalRule/client/markdownTransformer.js.map +1 -1
  198. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  199. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +33 -30
  200. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  201. package/dist/features/horizontalRule/client/plugin/index.js +31 -20
  202. package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
  203. package/dist/features/horizontalRule/server/i18n.js +96 -97
  204. package/dist/features/horizontalRule/server/i18n.js.map +1 -1
  205. package/dist/features/horizontalRule/server/index.js +17 -24
  206. package/dist/features/horizontalRule/server/index.js.map +1 -1
  207. package/dist/features/horizontalRule/server/markdownTransformer.js +15 -18
  208. package/dist/features/horizontalRule/server/markdownTransformer.js.map +1 -1
  209. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +71 -66
  210. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  211. package/dist/features/indent/client/index.js +52 -47
  212. package/dist/features/indent/client/index.js.map +1 -1
  213. package/dist/features/indent/client/toolbarIndentGroup.d.ts.map +1 -1
  214. package/dist/features/indent/client/toolbarIndentGroup.js +9 -8
  215. package/dist/features/indent/client/toolbarIndentGroup.js.map +1 -1
  216. package/dist/features/indent/server/i18n.js +128 -129
  217. package/dist/features/indent/server/i18n.js.map +1 -1
  218. package/dist/features/indent/server/index.js +5 -6
  219. package/dist/features/indent/server/index.js.map +1 -1
  220. package/dist/features/link/client/index.js +78 -83
  221. package/dist/features/link/client/index.js.map +1 -1
  222. package/dist/features/link/client/plugins/autoLink/index.js +267 -271
  223. package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
  224. package/dist/features/link/client/plugins/clickableLink/index.js +3 -3
  225. package/dist/features/link/client/plugins/clickableLink/index.js.map +1 -1
  226. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/commands.d.ts.map +1 -1
  227. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/commands.js +2 -1
  228. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/commands.js.map +1 -1
  229. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +254 -276
  230. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  231. package/dist/features/link/client/plugins/floatingLinkEditor/index.js +8 -6
  232. package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
  233. package/dist/features/link/client/plugins/floatingLinkEditor/types.js +1 -2
  234. package/dist/features/link/client/plugins/floatingLinkEditor/types.js.map +1 -1
  235. package/dist/features/link/client/plugins/link/index.js +50 -41
  236. package/dist/features/link/client/plugins/link/index.js.map +1 -1
  237. package/dist/features/link/markdownTransformer.js +38 -39
  238. package/dist/features/link/markdownTransformer.js.map +1 -1
  239. package/dist/features/link/nodes/AutoLinkNode.js +57 -56
  240. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  241. package/dist/features/link/nodes/LinkNode.js +277 -276
  242. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  243. package/dist/features/link/nodes/types.js +1 -2
  244. package/dist/features/link/nodes/types.js.map +1 -1
  245. package/dist/features/link/server/baseFields.js +118 -88
  246. package/dist/features/link/server/baseFields.js.map +1 -1
  247. package/dist/features/link/server/graphQLPopulationPromise.js +42 -28
  248. package/dist/features/link/server/graphQLPopulationPromise.js.map +1 -1
  249. package/dist/features/link/server/i18n.js +96 -97
  250. package/dist/features/link/server/i18n.js.map +1 -1
  251. package/dist/features/link/server/index.js +120 -114
  252. package/dist/features/link/server/index.js.map +1 -1
  253. package/dist/features/link/server/transformExtraFields.js +15 -15
  254. package/dist/features/link/server/transformExtraFields.js.map +1 -1
  255. package/dist/features/link/server/validate.js +37 -26
  256. package/dist/features/link/server/validate.js.map +1 -1
  257. package/dist/features/lists/checklist/client/index.js +77 -85
  258. package/dist/features/lists/checklist/client/index.js.map +1 -1
  259. package/dist/features/lists/checklist/client/plugin/index.js +3 -3
  260. package/dist/features/lists/checklist/client/plugin/index.js.map +1 -1
  261. package/dist/features/lists/checklist/markdownTransformers.js +7 -11
  262. package/dist/features/lists/checklist/markdownTransformers.js.map +1 -1
  263. package/dist/features/lists/checklist/server/i18n.js +96 -97
  264. package/dist/features/lists/checklist/server/i18n.js.map +1 -1
  265. package/dist/features/lists/checklist/server/index.js +21 -25
  266. package/dist/features/lists/checklist/server/index.js.map +1 -1
  267. package/dist/features/lists/htmlConverter.js +54 -43
  268. package/dist/features/lists/htmlConverter.js.map +1 -1
  269. package/dist/features/lists/orderedList/client/index.js +71 -77
  270. package/dist/features/lists/orderedList/client/index.js.map +1 -1
  271. package/dist/features/lists/orderedList/markdownTransformer.js +7 -11
  272. package/dist/features/lists/orderedList/markdownTransformer.js.map +1 -1
  273. package/dist/features/lists/orderedList/server/i18n.js +96 -97
  274. package/dist/features/lists/orderedList/server/i18n.js.map +1 -1
  275. package/dist/features/lists/orderedList/server/index.js +21 -25
  276. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  277. package/dist/features/lists/plugin/index.js +3 -3
  278. package/dist/features/lists/plugin/index.js.map +1 -1
  279. package/dist/features/lists/shared/markdown.js +48 -49
  280. package/dist/features/lists/shared/markdown.js.map +1 -1
  281. package/dist/features/lists/shared/slashMenuListGroup.js +9 -8
  282. package/dist/features/lists/shared/slashMenuListGroup.js.map +1 -1
  283. package/dist/features/lists/unorderedList/client/index.js +68 -76
  284. package/dist/features/lists/unorderedList/client/index.js.map +1 -1
  285. package/dist/features/lists/unorderedList/markdownTransformer.js +7 -11
  286. package/dist/features/lists/unorderedList/markdownTransformer.js.map +1 -1
  287. package/dist/features/lists/unorderedList/server/i18n.js +96 -97
  288. package/dist/features/lists/unorderedList/server/i18n.js.map +1 -1
  289. package/dist/features/lists/unorderedList/server/index.js +17 -23
  290. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  291. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/heading/converter.js +18 -17
  292. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/heading/converter.js.map +1 -1
  293. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/link/converter.js +30 -29
  294. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/link/converter.js.map +1 -1
  295. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/list/converter.js +21 -20
  296. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/list/converter.js.map +1 -1
  297. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/listItem/converter.js +21 -19
  298. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/listItem/converter.js.map +1 -1
  299. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/quote/converter.js +18 -17
  300. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/quote/converter.js.map +1 -1
  301. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/unknown/converter.js +24 -23
  302. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/unknown/converter.js.map +1 -1
  303. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.js +20 -21
  304. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.js.map +1 -1
  305. package/dist/features/migrations/lexicalPluginToLexical/converter/defaultConverters.js +1 -10
  306. package/dist/features/migrations/lexicalPluginToLexical/converter/defaultConverters.js.map +1 -1
  307. package/dist/features/migrations/lexicalPluginToLexical/converter/index.js +69 -61
  308. package/dist/features/migrations/lexicalPluginToLexical/converter/index.js.map +1 -1
  309. package/dist/features/migrations/lexicalPluginToLexical/converter/types.js +1 -2
  310. package/dist/features/migrations/lexicalPluginToLexical/converter/types.js.map +1 -1
  311. package/dist/features/migrations/lexicalPluginToLexical/feature.client.js +5 -7
  312. package/dist/features/migrations/lexicalPluginToLexical/feature.client.js.map +1 -1
  313. package/dist/features/migrations/lexicalPluginToLexical/feature.server.js +42 -43
  314. package/dist/features/migrations/lexicalPluginToLexical/feature.server.js.map +1 -1
  315. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.d.ts.map +1 -1
  316. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +11 -11
  317. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
  318. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +64 -59
  319. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  320. package/dist/features/migrations/slateToLexical/converter/converters/blockquote/converter.js +19 -19
  321. package/dist/features/migrations/slateToLexical/converter/converters/blockquote/converter.js.map +1 -1
  322. package/dist/features/migrations/slateToLexical/converter/converters/heading/converter.js +20 -25
  323. package/dist/features/migrations/slateToLexical/converter/converters/heading/converter.js.map +1 -1
  324. package/dist/features/migrations/slateToLexical/converter/converters/indent/converter.js +28 -30
  325. package/dist/features/migrations/slateToLexical/converter/converters/indent/converter.js.map +1 -1
  326. package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js +26 -26
  327. package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js.map +1 -1
  328. package/dist/features/migrations/slateToLexical/converter/converters/listItem/converter.js +22 -21
  329. package/dist/features/migrations/slateToLexical/converter/converters/listItem/converter.js.map +1 -1
  330. package/dist/features/migrations/slateToLexical/converter/converters/orderedList/converter.js +22 -22
  331. package/dist/features/migrations/slateToLexical/converter/converters/orderedList/converter.js.map +1 -1
  332. package/dist/features/migrations/slateToLexical/converter/converters/relationship/converter.js +12 -13
  333. package/dist/features/migrations/slateToLexical/converter/converters/relationship/converter.js.map +1 -1
  334. package/dist/features/migrations/slateToLexical/converter/converters/unknown/converter.js +23 -23
  335. package/dist/features/migrations/slateToLexical/converter/converters/unknown/converter.js.map +1 -1
  336. package/dist/features/migrations/slateToLexical/converter/converters/unorderedList/converter.js +22 -22
  337. package/dist/features/migrations/slateToLexical/converter/converters/unorderedList/converter.js.map +1 -1
  338. package/dist/features/migrations/slateToLexical/converter/converters/upload/converter.js +15 -16
  339. package/dist/features/migrations/slateToLexical/converter/converters/upload/converter.js.map +1 -1
  340. package/dist/features/migrations/slateToLexical/converter/defaultConverters.js +1 -13
  341. package/dist/features/migrations/slateToLexical/converter/defaultConverters.js.map +1 -1
  342. package/dist/features/migrations/slateToLexical/converter/index.js +105 -98
  343. package/dist/features/migrations/slateToLexical/converter/index.js.map +1 -1
  344. package/dist/features/migrations/slateToLexical/converter/types.js +1 -2
  345. package/dist/features/migrations/slateToLexical/converter/types.js.map +1 -1
  346. package/dist/features/migrations/slateToLexical/feature.client.js +7 -7
  347. package/dist/features/migrations/slateToLexical/feature.client.js.map +1 -1
  348. package/dist/features/migrations/slateToLexical/feature.server.js +43 -44
  349. package/dist/features/migrations/slateToLexical/feature.server.js.map +1 -1
  350. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.d.ts.map +1 -1
  351. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +11 -11
  352. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
  353. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +64 -59
  354. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  355. package/dist/features/paragraph/client/index.js +58 -61
  356. package/dist/features/paragraph/client/index.js.map +1 -1
  357. package/dist/features/paragraph/server/i18n.js +128 -129
  358. package/dist/features/paragraph/server/i18n.js.map +1 -1
  359. package/dist/features/paragraph/server/index.js +6 -7
  360. package/dist/features/paragraph/server/index.js.map +1 -1
  361. package/dist/features/relationship/client/components/RelationshipComponent.js +141 -149
  362. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  363. package/dist/features/relationship/client/drawer/commands.js +0 -1
  364. package/dist/features/relationship/client/drawer/commands.js.map +1 -1
  365. package/dist/features/relationship/client/drawer/index.js +138 -67
  366. package/dist/features/relationship/client/drawer/index.js.map +1 -1
  367. package/dist/features/relationship/client/index.js +53 -59
  368. package/dist/features/relationship/client/index.js.map +1 -1
  369. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  370. package/dist/features/relationship/client/nodes/RelationshipNode.js +60 -59
  371. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  372. package/dist/features/relationship/client/plugins/index.js +90 -35
  373. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  374. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.d.ts.map +1 -1
  375. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +97 -26
  376. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +1 -1
  377. package/dist/features/relationship/server/graphQLPopulationPromise.js +34 -26
  378. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  379. package/dist/features/relationship/server/i18n.js +96 -97
  380. package/dist/features/relationship/server/i18n.js.map +1 -1
  381. package/dist/features/relationship/server/index.js +48 -44
  382. package/dist/features/relationship/server/index.js.map +1 -1
  383. package/dist/features/relationship/server/nodes/RelationshipNode.js +90 -87
  384. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  385. package/dist/features/shared/slashMenu/basicGroup.js +9 -8
  386. package/dist/features/shared/slashMenu/basicGroup.js.map +1 -1
  387. package/dist/features/shared/toolbar/addDropdownGroup.js +8 -9
  388. package/dist/features/shared/toolbar/addDropdownGroup.js.map +1 -1
  389. package/dist/features/shared/toolbar/featureButtonsGroup.js +7 -8
  390. package/dist/features/shared/toolbar/featureButtonsGroup.js.map +1 -1
  391. package/dist/features/shared/toolbar/textDropdownGroup.js +8 -9
  392. package/dist/features/shared/toolbar/textDropdownGroup.js.map +1 -1
  393. package/dist/features/toolbars/fixed/client/Toolbar/index.js +264 -187
  394. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  395. package/dist/features/toolbars/fixed/client/index.js +5 -7
  396. package/dist/features/toolbars/fixed/client/index.js.map +1 -1
  397. package/dist/features/toolbars/fixed/server/index.js +14 -13
  398. package/dist/features/toolbars/fixed/server/index.js.map +1 -1
  399. package/dist/features/toolbars/inline/client/Toolbar/index.js +374 -286
  400. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  401. package/dist/features/toolbars/inline/client/index.js +5 -7
  402. package/dist/features/toolbars/inline/client/index.js.map +1 -1
  403. package/dist/features/toolbars/inline/server/index.js +4 -5
  404. package/dist/features/toolbars/inline/server/index.js.map +1 -1
  405. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts +1 -1
  406. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  407. package/dist/features/toolbars/shared/ToolbarButton/index.js +75 -97
  408. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  409. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +190 -211
  410. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  411. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts +1 -1
  412. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  413. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +289 -124
  414. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  415. package/dist/features/toolbars/types.js +1 -2
  416. package/dist/features/toolbars/types.js.map +1 -1
  417. package/dist/features/typeUtilities.js +2 -3
  418. package/dist/features/typeUtilities.js.map +1 -1
  419. package/dist/features/typesClient.js +1 -2
  420. package/dist/features/typesClient.js.map +1 -1
  421. package/dist/features/typesServer.js +1 -2
  422. package/dist/features/typesServer.js.map +1 -1
  423. package/dist/features/upload/client/component/index.js +208 -224
  424. package/dist/features/upload/client/component/index.js.map +1 -1
  425. package/dist/features/upload/client/drawer/commands.js +1 -1
  426. package/dist/features/upload/client/drawer/commands.js.map +1 -1
  427. package/dist/features/upload/client/drawer/index.js +107 -58
  428. package/dist/features/upload/client/drawer/index.js.map +1 -1
  429. package/dist/features/upload/client/feature.client.js +51 -61
  430. package/dist/features/upload/client/feature.client.js.map +1 -1
  431. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  432. package/dist/features/upload/client/nodes/UploadNode.js +76 -73
  433. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  434. package/dist/features/upload/client/plugin/index.js +67 -39
  435. package/dist/features/upload/client/plugin/index.js.map +1 -1
  436. package/dist/features/upload/server/feature.server.js +190 -171
  437. package/dist/features/upload/server/feature.server.js.map +1 -1
  438. package/dist/features/upload/server/graphQLPopulationPromise.js +60 -47
  439. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  440. package/dist/features/upload/server/i18n.js +96 -97
  441. package/dist/features/upload/server/i18n.js.map +1 -1
  442. package/dist/features/upload/server/nodes/UploadNode.js +113 -108
  443. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  444. package/dist/features/upload/server/validate.js +53 -40
  445. package/dist/features/upload/server/validate.js.map +1 -1
  446. package/dist/field/Field.js +124 -105
  447. package/dist/field/Field.js.map +1 -1
  448. package/dist/field/bundled.css +1 -0
  449. package/dist/field/index.js +92 -36
  450. package/dist/field/index.js.map +1 -1
  451. package/dist/i18n.js +160 -161
  452. package/dist/i18n.js.map +1 -1
  453. package/dist/index.d.ts.map +1 -1
  454. package/dist/index.js +670 -623
  455. package/dist/index.js.map +1 -1
  456. package/dist/lexical/EditorPlugin.d.ts.map +1 -1
  457. package/dist/lexical/EditorPlugin.js +15 -10
  458. package/dist/lexical/EditorPlugin.js.map +1 -1
  459. package/dist/lexical/LexicalEditor.js +206 -161
  460. package/dist/lexical/LexicalEditor.js.map +1 -1
  461. package/dist/lexical/LexicalProvider.js +83 -82
  462. package/dist/lexical/LexicalProvider.js.map +1 -1
  463. package/dist/lexical/config/client/EditorConfigProvider.js +76 -79
  464. package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
  465. package/dist/lexical/config/client/default.js +3 -3
  466. package/dist/lexical/config/client/default.js.map +1 -1
  467. package/dist/lexical/config/client/loader.js +42 -39
  468. package/dist/lexical/config/client/loader.js.map +1 -1
  469. package/dist/lexical/config/client/sanitize.js +165 -165
  470. package/dist/lexical/config/client/sanitize.js.map +1 -1
  471. package/dist/lexical/config/server/default.js +5 -27
  472. package/dist/lexical/config/server/default.js.map +1 -1
  473. package/dist/lexical/config/server/loader.js +103 -103
  474. package/dist/lexical/config/server/loader.js.map +1 -1
  475. package/dist/lexical/config/server/sanitize.js +98 -99
  476. package/dist/lexical/config/server/sanitize.js.map +1 -1
  477. package/dist/lexical/config/types.js +1 -2
  478. package/dist/lexical/config/types.js.map +1 -1
  479. package/dist/lexical/nodes/index.js +9 -8
  480. package/dist/lexical/nodes/index.js.map +1 -1
  481. package/dist/lexical/plugins/MarkdownShortcut/index.js +17 -5
  482. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  483. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +384 -361
  484. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  485. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +223 -160
  486. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  487. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js +1 -2
  488. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js.map +1 -1
  489. package/dist/lexical/plugins/SlashMenu/index.js +191 -179
  490. package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
  491. package/dist/lexical/plugins/SlashMenu/useMenuTriggerMatch.d.ts.map +1 -1
  492. package/dist/lexical/plugins/SlashMenu/useMenuTriggerMatch.js +41 -26
  493. package/dist/lexical/plugins/SlashMenu/useMenuTriggerMatch.js.map +1 -1
  494. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +164 -129
  495. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  496. package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts.map +1 -1
  497. package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js +11 -10
  498. package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.js.map +1 -1
  499. package/dist/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.d.ts.map +1 -1
  500. package/dist/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.js +11 -10
  501. package/dist/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.js.map +1 -1
  502. package/dist/lexical/plugins/handles/DraggableBlockPlugin/highlightElemOriginalPosition.d.ts.map +1 -1
  503. package/dist/lexical/plugins/handles/DraggableBlockPlugin/highlightElemOriginalPosition.js +27 -23
  504. package/dist/lexical/plugins/handles/DraggableBlockPlugin/highlightElemOriginalPosition.js.map +1 -1
  505. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +331 -300
  506. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  507. package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +110 -97
  508. package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
  509. package/dist/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.d.ts.map +1 -1
  510. package/dist/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.js +23 -16
  511. package/dist/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.js.map +1 -1
  512. package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.d.ts.map +1 -1
  513. package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.js +18 -27
  514. package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.js.map +1 -1
  515. package/dist/lexical/plugins/handles/utils/getCollapsedMargins.d.ts.map +1 -1
  516. package/dist/lexical/plugins/handles/utils/getCollapsedMargins.js +15 -11
  517. package/dist/lexical/plugins/handles/utils/getCollapsedMargins.js.map +1 -1
  518. package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.d.ts.map +1 -1
  519. package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.js +133 -118
  520. package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.js.map +1 -1
  521. package/dist/lexical/plugins/handles/utils/getTopLevelNodeKeys.d.ts.map +1 -1
  522. package/dist/lexical/plugins/handles/utils/getTopLevelNodeKeys.js +3 -2
  523. package/dist/lexical/plugins/handles/utils/getTopLevelNodeKeys.js.map +1 -1
  524. package/dist/lexical/plugins/handles/utils/isOnHandleElement.d.ts.map +1 -1
  525. package/dist/lexical/plugins/handles/utils/isOnHandleElement.js +3 -2
  526. package/dist/lexical/plugins/handles/utils/isOnHandleElement.js.map +1 -1
  527. package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  528. package/dist/lexical/plugins/handles/utils/setHandlePosition.js +26 -25
  529. package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  530. package/dist/lexical/theme/EditorTheme.d.ts.map +1 -1
  531. package/dist/lexical/theme/EditorTheme.js +97 -102
  532. package/dist/lexical/theme/EditorTheme.js.map +1 -1
  533. package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
  534. package/dist/lexical/ui/ContentEditable.js +27 -10
  535. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  536. package/dist/lexical/ui/icons/AI/index.d.ts.map +1 -1
  537. package/dist/lexical/ui/icons/AI/index.js +31 -33
  538. package/dist/lexical/ui/icons/AI/index.js.map +1 -1
  539. package/dist/lexical/ui/icons/Add/index.d.ts.map +1 -1
  540. package/dist/lexical/ui/icons/Add/index.js +16 -18
  541. package/dist/lexical/ui/icons/Add/index.js.map +1 -1
  542. package/dist/lexical/ui/icons/AlignCenter/index.d.ts.map +1 -1
  543. package/dist/lexical/ui/icons/AlignCenter/index.js +25 -28
  544. package/dist/lexical/ui/icons/AlignCenter/index.js.map +1 -1
  545. package/dist/lexical/ui/icons/AlignJustify/index.d.ts.map +1 -1
  546. package/dist/lexical/ui/icons/AlignJustify/index.js +25 -28
  547. package/dist/lexical/ui/icons/AlignJustify/index.js.map +1 -1
  548. package/dist/lexical/ui/icons/AlignLeft/index.d.ts.map +1 -1
  549. package/dist/lexical/ui/icons/AlignLeft/index.js +25 -28
  550. package/dist/lexical/ui/icons/AlignLeft/index.js.map +1 -1
  551. package/dist/lexical/ui/icons/AlignRight/index.d.ts.map +1 -1
  552. package/dist/lexical/ui/icons/AlignRight/index.js +25 -28
  553. package/dist/lexical/ui/icons/AlignRight/index.js.map +1 -1
  554. package/dist/lexical/ui/icons/Block/index.d.ts.map +1 -1
  555. package/dist/lexical/ui/icons/Block/index.js +34 -37
  556. package/dist/lexical/ui/icons/Block/index.js.map +1 -1
  557. package/dist/lexical/ui/icons/Blockquote/index.d.ts.map +1 -1
  558. package/dist/lexical/ui/icons/Blockquote/index.js +16 -15
  559. package/dist/lexical/ui/icons/Blockquote/index.js.map +1 -1
  560. package/dist/lexical/ui/icons/Bold/index.d.ts.map +1 -1
  561. package/dist/lexical/ui/icons/Bold/index.js +16 -15
  562. package/dist/lexical/ui/icons/Bold/index.js.map +1 -1
  563. package/dist/lexical/ui/icons/Checklist/index.d.ts.map +1 -1
  564. package/dist/lexical/ui/icons/Checklist/index.js +24 -26
  565. package/dist/lexical/ui/icons/Checklist/index.js.map +1 -1
  566. package/dist/lexical/ui/icons/Code/index.d.ts.map +1 -1
  567. package/dist/lexical/ui/icons/Code/index.js +19 -21
  568. package/dist/lexical/ui/icons/Code/index.js.map +1 -1
  569. package/dist/lexical/ui/icons/CodeBlock/index.d.ts.map +1 -1
  570. package/dist/lexical/ui/icons/CodeBlock/index.js +19 -21
  571. package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
  572. package/dist/lexical/ui/icons/H1/index.d.ts.map +1 -1
  573. package/dist/lexical/ui/icons/H1/index.js +16 -15
  574. package/dist/lexical/ui/icons/H1/index.js.map +1 -1
  575. package/dist/lexical/ui/icons/H2/index.d.ts.map +1 -1
  576. package/dist/lexical/ui/icons/H2/index.js +16 -15
  577. package/dist/lexical/ui/icons/H2/index.js.map +1 -1
  578. package/dist/lexical/ui/icons/H3/index.d.ts.map +1 -1
  579. package/dist/lexical/ui/icons/H3/index.js +16 -15
  580. package/dist/lexical/ui/icons/H3/index.js.map +1 -1
  581. package/dist/lexical/ui/icons/H4/index.d.ts.map +1 -1
  582. package/dist/lexical/ui/icons/H4/index.js +16 -15
  583. package/dist/lexical/ui/icons/H4/index.js.map +1 -1
  584. package/dist/lexical/ui/icons/H5/index.d.ts.map +1 -1
  585. package/dist/lexical/ui/icons/H5/index.js +16 -15
  586. package/dist/lexical/ui/icons/H5/index.js.map +1 -1
  587. package/dist/lexical/ui/icons/H6/index.d.ts.map +1 -1
  588. package/dist/lexical/ui/icons/H6/index.js +16 -15
  589. package/dist/lexical/ui/icons/H6/index.js.map +1 -1
  590. package/dist/lexical/ui/icons/HorizontalRule/index.d.ts.map +1 -1
  591. package/dist/lexical/ui/icons/HorizontalRule/index.js +19 -18
  592. package/dist/lexical/ui/icons/HorizontalRule/index.js.map +1 -1
  593. package/dist/lexical/ui/icons/IndentDecrease/index.d.ts.map +1 -1
  594. package/dist/lexical/ui/icons/IndentDecrease/index.js +28 -32
  595. package/dist/lexical/ui/icons/IndentDecrease/index.js.map +1 -1
  596. package/dist/lexical/ui/icons/IndentIncrease/index.d.ts.map +1 -1
  597. package/dist/lexical/ui/icons/IndentIncrease/index.js +28 -32
  598. package/dist/lexical/ui/icons/IndentIncrease/index.js.map +1 -1
  599. package/dist/lexical/ui/icons/InlineBlocks/index.d.ts.map +1 -1
  600. package/dist/lexical/ui/icons/InlineBlocks/index.js +18 -17
  601. package/dist/lexical/ui/icons/InlineBlocks/index.js.map +1 -1
  602. package/dist/lexical/ui/icons/Italic/index.d.ts.map +1 -1
  603. package/dist/lexical/ui/icons/Italic/index.js +16 -15
  604. package/dist/lexical/ui/icons/Italic/index.js.map +1 -1
  605. package/dist/lexical/ui/icons/Link/index.d.ts.map +1 -1
  606. package/dist/lexical/ui/icons/Link/index.js +17 -16
  607. package/dist/lexical/ui/icons/Link/index.js.map +1 -1
  608. package/dist/lexical/ui/icons/Meatballs/index.d.ts.map +1 -1
  609. package/dist/lexical/ui/icons/Meatballs/index.js +19 -22
  610. package/dist/lexical/ui/icons/Meatballs/index.js.map +1 -1
  611. package/dist/lexical/ui/icons/OrderedList/index.d.ts.map +1 -1
  612. package/dist/lexical/ui/icons/OrderedList/index.js +31 -36
  613. package/dist/lexical/ui/icons/OrderedList/index.js.map +1 -1
  614. package/dist/lexical/ui/icons/Relationship/index.d.ts.map +1 -1
  615. package/dist/lexical/ui/icons/Relationship/index.js +31 -33
  616. package/dist/lexical/ui/icons/Relationship/index.js.map +1 -1
  617. package/dist/lexical/ui/icons/Strikethrough/index.d.ts.map +1 -1
  618. package/dist/lexical/ui/icons/Strikethrough/index.js +19 -21
  619. package/dist/lexical/ui/icons/Strikethrough/index.js.map +1 -1
  620. package/dist/lexical/ui/icons/Subscript/index.d.ts.map +1 -1
  621. package/dist/lexical/ui/icons/Subscript/index.js +16 -15
  622. package/dist/lexical/ui/icons/Subscript/index.js.map +1 -1
  623. package/dist/lexical/ui/icons/Superscript/index.d.ts.map +1 -1
  624. package/dist/lexical/ui/icons/Superscript/index.js +16 -15
  625. package/dist/lexical/ui/icons/Superscript/index.js.map +1 -1
  626. package/dist/lexical/ui/icons/Table/index.d.ts.map +1 -1
  627. package/dist/lexical/ui/icons/Table/index.js +17 -16
  628. package/dist/lexical/ui/icons/Table/index.js.map +1 -1
  629. package/dist/lexical/ui/icons/Text/index.d.ts.map +1 -1
  630. package/dist/lexical/ui/icons/Text/index.js +16 -15
  631. package/dist/lexical/ui/icons/Text/index.js.map +1 -1
  632. package/dist/lexical/ui/icons/Underline/index.d.ts.map +1 -1
  633. package/dist/lexical/ui/icons/Underline/index.js +19 -21
  634. package/dist/lexical/ui/icons/Underline/index.js.map +1 -1
  635. package/dist/lexical/ui/icons/UnorderedList/index.d.ts.map +1 -1
  636. package/dist/lexical/ui/icons/UnorderedList/index.js +46 -52
  637. package/dist/lexical/ui/icons/UnorderedList/index.js.map +1 -1
  638. package/dist/lexical/ui/icons/Upload/index.d.ts.map +1 -1
  639. package/dist/lexical/ui/icons/Upload/index.js +28 -31
  640. package/dist/lexical/ui/icons/Upload/index.js.map +1 -1
  641. package/dist/lexical/utils/canUseDOM.d.ts.map +1 -1
  642. package/dist/lexical/utils/canUseDOM.js +2 -1
  643. package/dist/lexical/utils/canUseDOM.js.map +1 -1
  644. package/dist/lexical/utils/environment.d.ts.map +1 -1
  645. package/dist/lexical/utils/environment.js +2 -1
  646. package/dist/lexical/utils/environment.js.map +1 -1
  647. package/dist/lexical/utils/getDOMRangeRect.d.ts.map +1 -1
  648. package/dist/lexical/utils/getDOMRangeRect.js +13 -12
  649. package/dist/lexical/utils/getDOMRangeRect.js.map +1 -1
  650. package/dist/lexical/utils/getSelectedNode.d.ts.map +1 -1
  651. package/dist/lexical/utils/getSelectedNode.js +18 -13
  652. package/dist/lexical/utils/getSelectedNode.js.map +1 -1
  653. package/dist/lexical/utils/guard.d.ts.map +1 -1
  654. package/dist/lexical/utils/guard.js +3 -2
  655. package/dist/lexical/utils/guard.js.map +1 -1
  656. package/dist/lexical/utils/joinClasses.d.ts.map +1 -1
  657. package/dist/lexical/utils/joinClasses.js +3 -2
  658. package/dist/lexical/utils/joinClasses.js.map +1 -1
  659. package/dist/lexical/utils/markdown/createBlockNode.js +9 -10
  660. package/dist/lexical/utils/markdown/createBlockNode.js.map +1 -1
  661. package/dist/lexical/utils/nodeFormat.js +58 -59
  662. package/dist/lexical/utils/nodeFormat.js.map +1 -1
  663. package/dist/lexical/utils/point.d.ts.map +1 -1
  664. package/dist/lexical/utils/point.js +40 -32
  665. package/dist/lexical/utils/point.js.map +1 -1
  666. package/dist/lexical/utils/rect.d.ts.map +1 -1
  667. package/dist/lexical/utils/rect.js +167 -134
  668. package/dist/lexical/utils/rect.js.map +1 -1
  669. package/dist/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
  670. package/dist/lexical/utils/setFloatingElemPosition.js +56 -45
  671. package/dist/lexical/utils/setFloatingElemPosition.js.map +1 -1
  672. package/dist/lexical/utils/setFloatingElemPositionForLinkEditor.d.ts.map +1 -1
  673. package/dist/lexical/utils/setFloatingElemPositionForLinkEditor.js +23 -22
  674. package/dist/lexical/utils/setFloatingElemPositionForLinkEditor.js.map +1 -1
  675. package/dist/lexical/utils/swipe.d.ts.map +1 -1
  676. package/dist/lexical/utils/swipe.js +82 -83
  677. package/dist/lexical/utils/swipe.js.map +1 -1
  678. package/dist/lexical/utils/url.js +23 -22
  679. package/dist/lexical/utils/url.js.map +1 -1
  680. package/dist/nodeTypes.js +1 -2
  681. package/dist/nodeTypes.js.map +1 -1
  682. package/dist/populateGraphQL/defaultValue.js +24 -29
  683. package/dist/populateGraphQL/defaultValue.js.map +1 -1
  684. package/dist/populateGraphQL/populate.js +35 -25
  685. package/dist/populateGraphQL/populate.js.map +1 -1
  686. package/dist/populateGraphQL/populateLexicalPopulationPromises.js +47 -32
  687. package/dist/populateGraphQL/populateLexicalPopulationPromises.js.map +1 -1
  688. package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.js +39 -25
  689. package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.js.map +1 -1
  690. package/dist/types.js +1 -2
  691. package/dist/types.js.map +1 -1
  692. package/dist/utilities/createClientFeature.d.ts.map +1 -1
  693. package/dist/utilities/createClientFeature.js +40 -26
  694. package/dist/utilities/createClientFeature.js.map +1 -1
  695. package/dist/utilities/createServerFeature.d.ts.map +1 -1
  696. package/dist/utilities/createServerFeature.js +46 -31
  697. package/dist/utilities/createServerFeature.js.map +1 -1
  698. package/dist/utilities/fieldsDrawer/Drawer.js +28 -17
  699. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  700. package/dist/utilities/fieldsDrawer/DrawerContent.js +149 -78
  701. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  702. package/dist/utilities/forEachNodeRecursively.js +24 -19
  703. package/dist/utilities/forEachNodeRecursively.js.map +1 -1
  704. package/dist/utilities/generateComponentMap.js +90 -82
  705. package/dist/utilities/generateComponentMap.js.map +1 -1
  706. package/dist/utilities/generateImportMap.js +53 -47
  707. package/dist/utilities/generateImportMap.js.map +1 -1
  708. package/dist/utilities/generateSchemaMap.js +35 -30
  709. package/dist/utilities/generateSchemaMap.js.map +1 -1
  710. package/dist/utilities/migrateSlateToLexical/index.js +99 -86
  711. package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
  712. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +73 -66
  713. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
  714. package/dist/utilities/recurseNodeTree.js +25 -22
  715. package/dist/utilities/recurseNodeTree.js.map +1 -1
  716. package/dist/utilities/upgradeLexicalData/index.js +99 -86
  717. package/dist/utilities/upgradeLexicalData/index.js.map +1 -1
  718. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +71 -66
  719. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
  720. package/dist/utilities/useLexicalFeature.js +9 -8
  721. package/dist/utilities/useLexicalFeature.js.map +1 -1
  722. package/dist/validate/index.js +32 -26
  723. package/dist/validate/index.js.map +1 -1
  724. package/dist/validate/validateNodes.js +31 -28
  725. package/dist/validate/validateNodes.js.map +1 -1
  726. package/package.json +22 -11
  727. package/dist/exports/client/Component-7HS6FEJS.js +0 -2
  728. package/dist/exports/client/Component-7HS6FEJS.js.map +0 -7
  729. package/dist/exports/client/Component-LAKSCIDX.js +0 -2
  730. package/dist/exports/client/Component-LAKSCIDX.js.map +0 -7
  731. package/dist/exports/client/Field-BYB3WX7J.js +0 -2
  732. package/dist/exports/client/Field-BYB3WX7J.js.map +0 -7
  733. package/dist/exports/client/RelationshipComponent-GYUTPDNG.js +0 -2
  734. package/dist/exports/client/RelationshipComponent-GYUTPDNG.js.map +0 -7
  735. package/dist/exports/client/chunk-4EX7W4UX.js +0 -2
  736. package/dist/exports/client/chunk-4EX7W4UX.js.map +0 -7
  737. package/dist/exports/client/chunk-E4HH5PS6.js +0 -2
  738. package/dist/exports/client/chunk-E4HH5PS6.js.map +0 -7
  739. package/dist/exports/client/chunk-EBB2CEB6.js +0 -2
  740. package/dist/exports/client/chunk-EBB2CEB6.js.map +0 -7
  741. package/dist/exports/client/chunk-LTR7V74A.js +0 -2
  742. package/dist/exports/client/chunk-LTR7V74A.js.map +0 -7
  743. package/dist/exports/client/chunk-SQHN3N6E.js +0 -2
  744. package/dist/exports/client/chunk-VMCQSR3T.js +0 -3
  745. package/dist/exports/client/chunk-VMCQSR3T.js.map +0 -7
  746. package/dist/exports/client/component-6C5JERGA.js +0 -2
  747. package/dist/exports/client/component-6C5JERGA.js.map +0 -7
  748. package/dist/exports/client/component-GUWIGB77.js +0 -2
  749. package/dist/exports/client/component-GUWIGB77.js.map +0 -7
  750. package/dist/exports/client/component-UQ2BKD5X.js +0 -2
  751. package/dist/exports/client/component-UQ2BKD5X.js.map +0 -7
  752. package/dist/exports/client/componentInline-C2XIK5VZ.js +0 -2
  753. package/dist/exports/client/componentInline-C2XIK5VZ.js.map +0 -7
  754. package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.d.ts +0 -12
  755. package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.d.ts.map +0 -1
  756. package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.js +0 -181
  757. package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.js.map +0 -1
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
5
  import { getTranslation } from '@payloadcms/translations';
@@ -12,187 +14,179 @@ import { FormSavePlugin } from './FormSavePlugin.js';
12
14
  // Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.
13
15
  // Inside of fields.data however, that sub-blocks blockName property does not exist at all.
14
16
  function removeUndefinedAndNullAndEmptyArraysRecursively(obj) {
15
- for(const key in obj){
16
- const value = obj[key];
17
- if (Array.isArray(value) && !value?.length) {
18
- delete obj[key];
19
- } else if (value && typeof value === 'object') {
20
- removeUndefinedAndNullAndEmptyArraysRecursively(value);
21
- } else if (value === undefined || value === null) {
22
- delete obj[key];
23
- }
17
+ for (const key in obj) {
18
+ const value = obj[key];
19
+ if (Array.isArray(value) && !value?.length) {
20
+ delete obj[key];
21
+ } else if (value && typeof value === 'object') {
22
+ removeUndefinedAndNullAndEmptyArraysRecursively(value);
23
+ } else if (value === undefined || value === null) {
24
+ delete obj[key];
24
25
  }
26
+ }
25
27
  }
26
28
  /**
27
29
  * The actual content of the Block. This should be INSIDE a Form component,
28
30
  * scoped to the block. All format operations in here are thus scoped to the block's form, and
29
31
  * not the whole document.
30
- */ export const BlockContent = (props)=>{
31
- const { baseClass, clientBlock, field, formSchema, nodeKey, schemaPath } = props;
32
- let { formData } = props;
33
- const { i18n } = useTranslation();
34
- const [editor] = useLexicalComposerContext();
35
- // Used for saving collapsed to preferences (and gettin' it from there again)
36
- // Remember, these preferences are scoped to the whole document, not just this form. This
37
- // is important to consider for the data path used in setDocFieldPreferences
38
- const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo();
39
- const [isCollapsed, setIsCollapsed] = React.useState(()=>{
40
- let initialState = false;
41
- void getDocPreferences().then((currentDocPreferences)=>{
42
- const currentFieldPreferences = currentDocPreferences?.fields[field.name];
43
- const collapsedArray = currentFieldPreferences?.collapsed;
44
- if (collapsedArray && collapsedArray.includes(formData.id)) {
45
- initialState = true;
46
- setIsCollapsed(true);
47
- }
48
- });
49
- return initialState;
32
+ */
33
+ export const BlockContent = props => {
34
+ const {
35
+ baseClass,
36
+ clientBlock,
37
+ field,
38
+ formSchema,
39
+ nodeKey,
40
+ schemaPath
41
+ } = props;
42
+ let {
43
+ formData
44
+ } = props;
45
+ const {
46
+ i18n
47
+ } = useTranslation();
48
+ const [editor] = useLexicalComposerContext();
49
+ // Used for saving collapsed to preferences (and gettin' it from there again)
50
+ // Remember, these preferences are scoped to the whole document, not just this form. This
51
+ // is important to consider for the data path used in setDocFieldPreferences
52
+ const {
53
+ getDocPreferences,
54
+ setDocFieldPreferences
55
+ } = useDocumentInfo();
56
+ const [isCollapsed, setIsCollapsed] = React.useState(() => {
57
+ let initialState = false;
58
+ void getDocPreferences().then(currentDocPreferences => {
59
+ const currentFieldPreferences = currentDocPreferences?.fields[field.name];
60
+ const collapsedArray = currentFieldPreferences?.collapsed;
61
+ if (collapsedArray && collapsedArray.includes(formData.id)) {
62
+ initialState = true;
63
+ setIsCollapsed(true);
64
+ }
50
65
  });
51
- const hasSubmitted = useFormSubmitted();
52
- const [errorCount, setErrorCount] = React.useState(0);
53
- const fieldHasErrors = hasSubmitted && errorCount > 0;
54
- const classNames = [
55
- `${baseClass}__row`,
56
- fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`
57
- ].filter(Boolean).join(' ');
58
- const onFormChange = useCallback(({ fullFieldsWithValues, newFormData })=>{
59
- newFormData.id = formData.id;
60
- newFormData.blockType = formData.blockType;
61
- removeUndefinedAndNullAndEmptyArraysRecursively(newFormData);
62
- removeUndefinedAndNullAndEmptyArraysRecursively(formData);
63
- // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,
64
- // which would trigger the "Leave without saving" dialog unnecessarily
65
- if (!dequal(formData, newFormData)) {
66
- // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108
67
- // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.
68
- // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we
69
- // ensure that the nested editor has finished its update cycle before we update the block node.
70
- setTimeout(()=>{
71
- editor.update(()=>{
72
- const node = $getNodeByKey(nodeKey);
73
- if (node) {
74
- formData = newFormData;
75
- node.setFields(newFormData);
76
- }
77
- });
78
- }, 0);
66
+ return initialState;
67
+ });
68
+ const hasSubmitted = useFormSubmitted();
69
+ const [errorCount, setErrorCount] = React.useState(0);
70
+ const fieldHasErrors = hasSubmitted && errorCount > 0;
71
+ const classNames = [`${baseClass}__row`, fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`].filter(Boolean).join(' ');
72
+ const onFormChange = useCallback(({
73
+ fullFieldsWithValues,
74
+ newFormData
75
+ }) => {
76
+ newFormData.id = formData.id;
77
+ newFormData.blockType = formData.blockType;
78
+ removeUndefinedAndNullAndEmptyArraysRecursively(newFormData);
79
+ removeUndefinedAndNullAndEmptyArraysRecursively(formData);
80
+ // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,
81
+ // which would trigger the "Leave without saving" dialog unnecessarily
82
+ if (!dequal(formData, newFormData)) {
83
+ // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108
84
+ // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.
85
+ // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we
86
+ // ensure that the nested editor has finished its update cycle before we update the block node.
87
+ setTimeout(() => {
88
+ editor.update(() => {
89
+ const node = $getNodeByKey(nodeKey);
90
+ if (node) {
91
+ formData = newFormData;
92
+ node.setFields(newFormData);
93
+ }
94
+ });
95
+ }, 0);
96
+ }
97
+ // update error count
98
+ if (hasSubmitted) {
99
+ let rowErrorCount = 0;
100
+ for (const formField of Object.values(fullFieldsWithValues)) {
101
+ if (formField?.valid === false) {
102
+ rowErrorCount++;
103
+ }
104
+ }
105
+ setErrorCount(rowErrorCount);
106
+ }
107
+ }, [editor, nodeKey, hasSubmitted, formData]);
108
+ const onCollapsedChange = useCallback(changedCollapsed => {
109
+ void getDocPreferences().then(currentDocPreferences_0 => {
110
+ const currentFieldPreferences_0 = currentDocPreferences_0?.fields[field.name];
111
+ const collapsedArray_0 = currentFieldPreferences_0?.collapsed;
112
+ const newCollapsed = collapsedArray_0 && collapsedArray_0?.length ? collapsedArray_0 : [];
113
+ if (changedCollapsed) {
114
+ if (!newCollapsed.includes(formData.id)) {
115
+ newCollapsed.push(formData.id);
79
116
  }
80
- // update error count
81
- if (hasSubmitted) {
82
- let rowErrorCount = 0;
83
- for (const formField of Object.values(fullFieldsWithValues)){
84
- if (formField?.valid === false) {
85
- rowErrorCount++;
86
- }
87
- }
88
- setErrorCount(rowErrorCount);
117
+ } else {
118
+ if (newCollapsed.includes(formData.id)) {
119
+ newCollapsed.splice(newCollapsed.indexOf(formData.id), 1);
89
120
  }
90
- }, [
91
- editor,
92
- nodeKey,
93
- hasSubmitted,
94
- formData
95
- ]);
96
- const onCollapsedChange = useCallback((changedCollapsed)=>{
97
- void getDocPreferences().then((currentDocPreferences)=>{
98
- const currentFieldPreferences = currentDocPreferences?.fields[field.name];
99
- const collapsedArray = currentFieldPreferences?.collapsed;
100
- const newCollapsed = collapsedArray && collapsedArray?.length ? collapsedArray : [];
101
- if (changedCollapsed) {
102
- if (!newCollapsed.includes(formData.id)) {
103
- newCollapsed.push(formData.id);
104
- }
105
- } else {
106
- if (newCollapsed.includes(formData.id)) {
107
- newCollapsed.splice(newCollapsed.indexOf(formData.id), 1);
108
- }
109
- }
110
- setDocFieldPreferences(field.name, {
111
- collapsed: newCollapsed,
112
- hello: 'hi'
113
- });
114
- });
115
- }, [
116
- getDocPreferences,
117
- field.name,
118
- setDocFieldPreferences,
119
- formData.id
120
- ]);
121
- const removeBlock = useCallback(()=>{
122
- editor.update(()=>{
123
- $getNodeByKey(nodeKey).remove();
124
- });
125
- }, [
126
- editor,
127
- nodeKey
128
- ]);
129
- return /*#__PURE__*/ _jsxs(React.Fragment, {
130
- children: [
131
- /*#__PURE__*/ _jsx(Collapsible, {
132
- className: classNames,
133
- collapsibleStyle: fieldHasErrors ? 'error' : 'default',
134
- header: clientBlock?.admin?.components?.Label ? /*#__PURE__*/ _jsx(RenderComponent, {
135
- clientProps: {
136
- blockKind: 'lexicalBlock',
137
- formData
138
- },
139
- mappedComponent: clientBlock.admin.components.Label
140
- }) : /*#__PURE__*/ _jsxs("div", {
141
- className: `${baseClass}__block-header`,
142
- children: [
143
- /*#__PURE__*/ _jsxs("div", {
144
- children: [
145
- /*#__PURE__*/ _jsx(Pill, {
146
- className: `${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`,
147
- pillStyle: "white",
148
- children: typeof clientBlock?.labels.singular === 'string' ? getTranslation(clientBlock?.labels.singular, i18n) : clientBlock.slug
149
- }),
150
- /*#__PURE__*/ _jsx(SectionTitle, {
151
- path: "blockName",
152
- readOnly: field?.admin?.readOnly
153
- }),
154
- fieldHasErrors && /*#__PURE__*/ _jsx(ErrorPill, {
155
- count: errorCount,
156
- i18n: i18n,
157
- withMessage: true
158
- })
159
- ]
160
- }),
161
- editor.isEditable() && /*#__PURE__*/ _jsx(Button, {
162
- buttonStyle: "icon-label",
163
- className: `${baseClass}__removeButton`,
164
- disabled: field?.admin?.readOnly,
165
- icon: "x",
166
- onClick: (e)=>{
167
- e.preventDefault();
168
- removeBlock();
169
- },
170
- round: true,
171
- tooltip: "Remove Block"
172
- })
173
- ]
174
- }),
175
- isCollapsed: isCollapsed,
176
- onToggle: (incomingCollapsedState)=>{
177
- onCollapsedChange(incomingCollapsedState);
178
- setIsCollapsed(incomingCollapsedState);
179
- },
180
- children: /*#__PURE__*/ _jsx(RenderFields, {
181
- className: `${baseClass}__fields`,
182
- fields: formSchema,
183
- forceRender: true,
184
- margins: "small",
185
- path: "" // Leaving path empty makes it so field values are not prefixed / scoped by the entire schemaPath. e.g. we can access "myField" instead of "someLexicalField.feature.blocks.someArrayB" // TODO: Could there be any implications leaving path different than schemaPath?
186
- ,
187
- readOnly: false,
188
- schemaPath: schemaPath
189
- })
190
- }, 0),
191
- /*#__PURE__*/ _jsx(FormSavePlugin, {
192
- onChange: onFormChange
193
- })
194
- ]
121
+ }
122
+ setDocFieldPreferences(field.name, {
123
+ collapsed: newCollapsed,
124
+ hello: 'hi'
125
+ });
195
126
  });
196
- };
127
+ }, [getDocPreferences, field.name, setDocFieldPreferences, formData.id]);
128
+ const removeBlock = useCallback(() => {
129
+ editor.update(() => {
130
+ $getNodeByKey(nodeKey).remove();
131
+ });
132
+ }, [editor, nodeKey]);
133
+ return /*#__PURE__*/_jsxs(React.Fragment, {
134
+ children: [/*#__PURE__*/_jsx(Collapsible, {
135
+ className: classNames,
136
+ collapsibleStyle: fieldHasErrors ? 'error' : 'default',
137
+ header: clientBlock?.admin?.components?.Label ? /*#__PURE__*/_jsx(RenderComponent, {
138
+ clientProps: {
139
+ blockKind: 'lexicalBlock',
140
+ formData
141
+ },
142
+ mappedComponent: clientBlock.admin.components.Label
143
+ }) : /*#__PURE__*/_jsxs("div", {
144
+ className: `${baseClass}__block-header`,
145
+ children: [/*#__PURE__*/_jsxs("div", {
146
+ children: [/*#__PURE__*/_jsx(Pill, {
147
+ className: `${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`,
148
+ pillStyle: "white",
149
+ children: typeof clientBlock?.labels.singular === 'string' ? getTranslation(clientBlock?.labels.singular, i18n) : clientBlock.slug
150
+ }), /*#__PURE__*/_jsx(SectionTitle, {
151
+ path: "blockName",
152
+ readOnly: field?.admin?.readOnly
153
+ }), fieldHasErrors && /*#__PURE__*/_jsx(ErrorPill, {
154
+ count: errorCount,
155
+ i18n: i18n,
156
+ withMessage: true
157
+ })]
158
+ }), editor.isEditable() && /*#__PURE__*/_jsx(Button, {
159
+ buttonStyle: "icon-label",
160
+ className: `${baseClass}__removeButton`,
161
+ disabled: field?.admin?.readOnly,
162
+ icon: "x",
163
+ onClick: e => {
164
+ e.preventDefault();
165
+ removeBlock();
166
+ },
167
+ round: true,
168
+ tooltip: "Remove Block"
169
+ })]
170
+ }),
171
+ isCollapsed: isCollapsed,
172
+ onToggle: incomingCollapsedState => {
173
+ onCollapsedChange(incomingCollapsedState);
174
+ setIsCollapsed(incomingCollapsedState);
175
+ },
176
+ children: /*#__PURE__*/_jsx(RenderFields, {
177
+ className: `${baseClass}__fields`,
178
+ fields: formSchema,
179
+ forceRender: true,
180
+ margins: "small",
181
+ path: "" // Leaving path empty makes it so field values are not prefixed / scoped by the entire schemaPath. e.g. we can access "myField" instead of "someLexicalField.feature.blocks.someArrayB" // TODO: Could there be any implications leaving path different than schemaPath?
182
+ ,
197
183
 
184
+ readOnly: false,
185
+ schemaPath: schemaPath
186
+ })
187
+ }, 0), /*#__PURE__*/_jsx(FormSavePlugin, {
188
+ onChange: onFormChange
189
+ })]
190
+ });
191
+ };
198
192
  //# sourceMappingURL=BlockContent.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/features/blocks/client/component/BlockContent.tsx"],"sourcesContent":["import type { ClientBlock, ClientField, CollapsedPreferences, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n ErrorPill,\n Pill,\n RenderComponent,\n RenderFields,\n SectionTitle,\n useDocumentInfo,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport { dequal } from 'dequal/lite'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../../types.js'\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\nimport type { BlockNode } from '../nodes/BlocksNode.js'\n\nimport { FormSavePlugin } from './FormSavePlugin.js'\n\ntype Props = {\n baseClass: string\n clientBlock: ClientBlock\n field: LexicalRichTextFieldProps['field']\n formData: BlockFields\n formSchema: ClientField[]\n nodeKey: string\n path: string\n schemaPath: string\n}\n\n// Recursively remove all undefined values from even being present in formData, as they will\n// cause isDeepEqual to return false if, for example, formData has a key that fields.data\n// does not have, even if it's undefined.\n// Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.\n// Inside of fields.data however, that sub-blocks blockName property does not exist at all.\nfunction removeUndefinedAndNullAndEmptyArraysRecursively(obj: object) {\n for (const key in obj) {\n const value = obj[key]\n if (Array.isArray(value) && !value?.length) {\n delete obj[key]\n } else if (value && typeof value === 'object') {\n removeUndefinedAndNullAndEmptyArraysRecursively(value)\n } else if (value === undefined || value === null) {\n delete obj[key]\n }\n }\n}\n\n/**\n * The actual content of the Block. This should be INSIDE a Form component,\n * scoped to the block. All format operations in here are thus scoped to the block's form, and\n * not the whole document.\n */\nexport const BlockContent: React.FC<Props> = (props) => {\n const { baseClass, clientBlock, field, formSchema, nodeKey, schemaPath } = props\n let { formData } = props\n\n const { i18n } = useTranslation()\n const [editor] = useLexicalComposerContext()\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(() => {\n let initialState = false\n\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n if (collapsedArray && collapsedArray.includes(formData.id)) {\n initialState = true\n setIsCollapsed(true)\n }\n })\n return initialState\n })\n\n const hasSubmitted = useFormSubmitted()\n\n const [errorCount, setErrorCount] = React.useState(0)\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const classNames = [\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const onFormChange = useCallback(\n ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: BlockFields\n }) => {\n newFormData.id = formData.id\n newFormData.blockType = formData.blockType\n\n removeUndefinedAndNullAndEmptyArraysRecursively(newFormData)\n removeUndefinedAndNullAndEmptyArraysRecursively(formData)\n\n // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,\n // which would trigger the \"Leave without saving\" dialog unnecessarily\n if (!dequal(formData, newFormData)) {\n // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108\n // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.\n // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we\n // ensure that the nested editor has finished its update cycle before we update the block node.\n setTimeout(() => {\n editor.update(() => {\n const node: BlockNode = $getNodeByKey(nodeKey)\n if (node) {\n formData = newFormData\n node.setFields(newFormData)\n }\n })\n }, 0)\n }\n\n // update error count\n if (hasSubmitted) {\n let rowErrorCount = 0\n for (const formField of Object.values(fullFieldsWithValues)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n },\n [editor, nodeKey, hasSubmitted, formData],\n )\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(field.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, field.name, setDocFieldPreferences, formData.id],\n )\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n return (\n <React.Fragment>\n <Collapsible\n className={classNames}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof clientBlock?.labels.singular === 'string'\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock.slug}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={field?.admin?.readOnly} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n {editor.isEditable() && (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n )}\n </div>\n )\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n <RenderFields\n className={`${baseClass}__fields`}\n fields={formSchema}\n forceRender\n margins=\"small\"\n path=\"\" // Leaving path empty makes it so field values are not prefixed / scoped by the entire schemaPath. e.g. we can access \"myField\" instead of \"someLexicalField.feature.blocks.someArrayB\" // TODO: Could there be any implications leaving path different than schemaPath?\n readOnly={false}\n schemaPath={schemaPath} // Having the correct schemaPath here allows sub-fields (like array > addRow) to run correct form-state calls and retrieve their needed form state from the server\n />\n </Collapsible>\n\n <FormSavePlugin onChange={onFormChange} />\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","getTranslation","Button","Collapsible","ErrorPill","Pill","RenderComponent","RenderFields","SectionTitle","useDocumentInfo","useFormSubmitted","useTranslation","dequal","$getNodeByKey","React","useCallback","FormSavePlugin","removeUndefinedAndNullAndEmptyArraysRecursively","obj","key","value","Array","isArray","length","undefined","BlockContent","props","baseClass","clientBlock","field","formSchema","nodeKey","schemaPath","formData","i18n","editor","getDocPreferences","setDocFieldPreferences","isCollapsed","setIsCollapsed","useState","initialState","then","currentDocPreferences","currentFieldPreferences","fields","name","collapsedArray","collapsed","includes","id","hasSubmitted","errorCount","setErrorCount","fieldHasErrors","classNames","filter","Boolean","join","onFormChange","fullFieldsWithValues","newFormData","blockType","setTimeout","update","node","setFields","rowErrorCount","formField","Object","values","valid","onCollapsedChange","changedCollapsed","newCollapsed","push","splice","indexOf","hello","removeBlock","remove","Fragment","className","collapsibleStyle","header","admin","components","Label","clientProps","blockKind","mappedComponent","div","pillStyle","labels","singular","slug","path","readOnly","count","withMessage","isEditable","buttonStyle","disabled","icon","onClick","e","preventDefault","round","tooltip","onToggle","incomingCollapsedState","forceRender","margins","onChange"],"mappings":";AAEA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,WAAW,EACXC,SAAS,EACTC,IAAI,EACJC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,eAAe,EACfC,gBAAgB,EAChBC,cAAc,QACT,iBAAgB;AACvB,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,aAAa,QAAQ,UAAS;AACvC,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAM1C,SAASC,cAAc,QAAQ,sBAAqB;AAapD,4FAA4F;AAC5F,yFAAyF;AACzF,yCAAyC;AACzC,+IAA+I;AAC/I,2FAA2F;AAC3F,SAASC,gDAAgDC,GAAW;IAClE,IAAK,MAAMC,OAAOD,IAAK;QACrB,MAAME,QAAQF,GAAG,CAACC,IAAI;QACtB,IAAIE,MAAMC,OAAO,CAACF,UAAU,CAACA,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BACA4B,KAAK;4BACLC,SAAQ;;;;gBAMlBtE,aAAaA;gBAEbuE,UAAU,CAACC;oBACTtC,kBAAkBsC;oBAClBvE,eAAeuE;gBACjB;0BAEA,cAAA,KAACvG;oBACC2E,WAAW,CAAC,EAAEvD,UAAU,QAAQ,CAAC;oBACjCkB,QAAQf;oBACRiF,WAAW;oBACXC,SAAQ;oBACRhB,MAAK,GAAG,wQAAwQ;;oBAChRC,UAAU;oBACVjE,YAAYA;;eAbT;0BAiBP,KAAChB;gBAAeiG,UAAUtD;;;;AAGhC,EAAC"}
1
+ {"version":3,"file":"BlockContent.js","names":["useLexicalComposerContext","getTranslation","Button","Collapsible","ErrorPill","Pill","RenderComponent","RenderFields","SectionTitle","useDocumentInfo","useFormSubmitted","useTranslation","dequal","$getNodeByKey","React","useCallback","FormSavePlugin","removeUndefinedAndNullAndEmptyArraysRecursively","obj","key","value","Array","isArray","length","undefined","BlockContent","props","baseClass","clientBlock","field","formSchema","nodeKey","schemaPath","formData","i18n","editor","getDocPreferences","setDocFieldPreferences","isCollapsed","setIsCollapsed","useState","initialState","then","currentDocPreferences","currentFieldPreferences","fields","name","collapsedArray","collapsed","includes","id","hasSubmitted","errorCount","setErrorCount","fieldHasErrors","classNames","filter","Boolean","join","onFormChange","fullFieldsWithValues","newFormData","blockType","setTimeout","update","node","setFields","rowErrorCount","formField","Object","values","valid","onCollapsedChange","changedCollapsed","newCollapsed","push","splice","indexOf","hello","removeBlock","remove","_jsxs","Fragment","_jsx","className","collapsibleStyle","header","admin","components","Label","clientProps","blockKind","mappedComponent","pillStyle","labels","singular","slug","path","readOnly","count","withMessage","isEditable","buttonStyle","disabled","icon","onClick","e","preventDefault","round","tooltip","onToggle","incomingCollapsedState","forceRender","margins","onChange"],"sources":["../../../../../src/features/blocks/client/component/BlockContent.tsx"],"sourcesContent":["'use client'\nimport type { ClientBlock, ClientField, CollapsedPreferences, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n ErrorPill,\n Pill,\n RenderComponent,\n RenderFields,\n SectionTitle,\n useDocumentInfo,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport { dequal } from 'dequal/lite'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../../types.js'\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\nimport type { BlockNode } from '../nodes/BlocksNode.js'\n\nimport { FormSavePlugin } from './FormSavePlugin.js'\n\ntype Props = {\n baseClass: string\n clientBlock: ClientBlock\n field: LexicalRichTextFieldProps['field']\n formData: BlockFields\n formSchema: ClientField[]\n nodeKey: string\n path: string\n schemaPath: string\n}\n\n// Recursively remove all undefined values from even being present in formData, as they will\n// cause isDeepEqual to return false if, for example, formData has a key that fields.data\n// does not have, even if it's undefined.\n// Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.\n// Inside of fields.data however, that sub-blocks blockName property does not exist at all.\nfunction removeUndefinedAndNullAndEmptyArraysRecursively(obj: object) {\n for (const key in obj) {\n const value = obj[key]\n if (Array.isArray(value) && !value?.length) {\n delete obj[key]\n } else if (value && typeof value === 'object') {\n removeUndefinedAndNullAndEmptyArraysRecursively(value)\n } else if (value === undefined || value === null) {\n delete obj[key]\n }\n }\n}\n\n/**\n * The actual content of the Block. This should be INSIDE a Form component,\n * scoped to the block. All format operations in here are thus scoped to the block's form, and\n * not the whole document.\n */\nexport const BlockContent: React.FC<Props> = (props) => {\n const { baseClass, clientBlock, field, formSchema, nodeKey, schemaPath } = props\n let { formData } = props\n\n const { i18n } = useTranslation()\n const [editor] = useLexicalComposerContext()\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(() => {\n let initialState = false\n\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n if (collapsedArray && collapsedArray.includes(formData.id)) {\n initialState = true\n setIsCollapsed(true)\n }\n })\n return initialState\n })\n\n const hasSubmitted = useFormSubmitted()\n\n const [errorCount, setErrorCount] = React.useState(0)\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const classNames = [\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const onFormChange = useCallback(\n ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: BlockFields\n }) => {\n newFormData.id = formData.id\n newFormData.blockType = formData.blockType\n\n removeUndefinedAndNullAndEmptyArraysRecursively(newFormData)\n removeUndefinedAndNullAndEmptyArraysRecursively(formData)\n\n // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,\n // which would trigger the \"Leave without saving\" dialog unnecessarily\n if (!dequal(formData, newFormData)) {\n // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108\n // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.\n // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we\n // ensure that the nested editor has finished its update cycle before we update the block node.\n setTimeout(() => {\n editor.update(() => {\n const node: BlockNode = $getNodeByKey(nodeKey)\n if (node) {\n formData = newFormData\n node.setFields(newFormData)\n }\n })\n }, 0)\n }\n\n // update error count\n if (hasSubmitted) {\n let rowErrorCount = 0\n for (const formField of Object.values(fullFieldsWithValues)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n },\n [editor, nodeKey, hasSubmitted, formData],\n )\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(field.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, field.name, setDocFieldPreferences, formData.id],\n )\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n return (\n <React.Fragment>\n <Collapsible\n className={classNames}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof clientBlock?.labels.singular === 'string'\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock.slug}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={field?.admin?.readOnly} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n {editor.isEditable() && (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n )}\n </div>\n )\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n <RenderFields\n className={`${baseClass}__fields`}\n fields={formSchema}\n forceRender\n margins=\"small\"\n path=\"\" // Leaving path empty makes it so field values are not prefixed / scoped by the entire schemaPath. e.g. we can access \"myField\" instead of \"someLexicalField.feature.blocks.someArrayB\" // TODO: Could there be any implications leaving path different than schemaPath?\n readOnly={false}\n schemaPath={schemaPath} // Having the correct schemaPath here allows sub-fields (like array > addRow) to run correct form-state calls and retrieve their needed form state from the server\n />\n </Collapsible>\n\n <FormSavePlugin onChange={onFormChange} />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,WAAW,EACXC,SAAS,EACTC,IAAI,EACJC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,eAAe,EACfC,gBAAgB,EAChBC,cAAc,QACT;AACP,SAASC,MAAM,QAAQ;AACvB,SAASC,aAAa,QAAQ;AAC9B,OAAOC,KAAA,IAASC,WAAW,QAAQ;AAMnC,SAASC,cAAc,QAAQ;AAa/B;AACA;AACA;AACA;AACA;AACA,SAASC,gDAAgDC,GAAW;EAClE,KAAK,MAAMC,GAAA,IAAOD,GAAA,EAAK;IACrB,MAAME,KAAA,GAAQF,GAAG,CAACC,GAAA,CAAI;IACtB,IAAIE,KAAA,CAAMC,OAAO,CAACF,KAAA,KAAU,CAACA,KAAA,EAAOG,MAAA,EAAQ;MAC1C,OAAOL,GAAG,CAACC,GAAA,CAAI;IACjB,OAAO,IAAIC,KAAA,IAAS,OAAOA,KAAA,KAAU,UAAU;MAC7CH,+CAAA,CAAgDG,KAAA;IAClD,OAAO,IAAIA,KAAA,KAAUI,SAAA,IAAaJ,KAAA,KAAU,MAAM;MAChD,OAAOF,GAAG,CAACC,GAAA,CAAI;IACjB;EACF;AACF;AAEA;;;;;AAKA,OAAO,MAAMM,YAAA,GAAiCC,KAAA;EAC5C,MAAM;IAAEC,SAAS;I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A,CAAOC,QAAA,EAAU7D,IAAA,IAC7CN,WAAA,CAAYoE;2BAElBb,IAAA,CAAC3E,YAAA;YAAayF,IAAA,EAAK;YAAYC,QAAA,EAAUrE,KAAA,EAAO0D,KAAA,EAAOW;cACtD5C,cAAA,iBAAkB6B,IAAA,CAAC/E,SAAA;YAAU+F,KAAA,EAAO/C,UAAA;YAAYlB,IAAA,EAAMA,IAAA;YAAMkE,WAAW;;YAEzEjE,MAAA,CAAOkE,UAAU,mBAChBlB,IAAA,CAACjF,MAAA;UACCoG,WAAA,EAAY;UACZlB,SAAA,EAAW,GAAGzD,SAAA,gBAAyB;UACvC4E,QAAA,EAAU1E,KAAA,EAAO0D,KAAA,EAAOW,QAAA;UACxBM,IAAA,EAAK;UACLC,OAAA,EAAUC,CAAA;YACRA,CAAA,CAAEC,cAAc;YAChB5B,WAAA;UACF;UACA6B,KAAK;UACLC,OAAA,EAAQ;;;MAMlBvE,WAAA,EAAaA,WAAA;MAEbwE,QAAA,EAAWC,sBAAA;QACTvC,iBAAA,CAAkBuC,sBAAA;QAClBxE,cAAA,CAAewE,sBAAA;MACjB;gBAEA,aAAA5B,IAAA,CAAC5E,YAAA;QACC6E,SAAA,EAAW,GAAGzD,SAAA,UAAmB;QACjCkB,MAAA,EAAQf,UAAA;QACRkF,WAAW;QACXC,OAAA,EAAQ;QACRhB,IAAA,EAAK,GAAG;QAAA;;QACRC,QAAA,EAAU;QACVlE,UAAA,EAAYA;;OAbT,I,aAiBPmD,IAAA,CAACnE,cAAA;MAAekG,QAAA,EAAUvD;;;AAGhC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormSavePlugin.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/FormSavePlugin.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,CAAC,EACV,oBAAoB,EACpB,WAAW,GACZ,EAAE;QACD,oBAAoB,EAAE,SAAS,CAAA;QAC/B,WAAW,EAAE,IAAI,CAAA;KAClB,KAAK,IAAI,CAAA;CACX,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAkB1C,CAAA"}
1
+ {"version":3,"file":"FormSavePlugin.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/FormSavePlugin.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,CAAC,EACV,oBAAoB,EACpB,WAAW,GACZ,EAAE;QACD,oBAAoB,EAAE,SAAS,CAAA;QAC/B,WAAW,EAAE,IAAI,CAAA;KAClB,KAAK,IAAI,CAAA;CACX,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAkB1C,CAAA"}
@@ -1,29 +1,53 @@
1
+ 'use client';
2
+
3
+ import { c as _c } from "react/compiler-runtime";
1
4
  import { useAllFormFields } from '@payloadcms/ui';
2
5
  import { reduceFieldsToValues } from 'payload/shared';
3
6
  import { useEffect } from 'react';
4
7
  import { removeEmptyArrayValues } from './removeEmptyArrayValues.js';
5
- export const FormSavePlugin = (props)=>{
6
- const { onChange } = props;
7
- const [_fields] = useAllFormFields();
8
- const fields = removeEmptyArrayValues({
9
- fields: _fields
8
+ export const FormSavePlugin = props => {
9
+ const $ = _c(8);
10
+ const {
11
+ onChange
12
+ } = props;
13
+ const [_fields] = useAllFormFields();
14
+ let t0;
15
+ let fields;
16
+ if ($[0] !== _fields) {
17
+ fields = removeEmptyArrayValues({
18
+ fields: _fields
10
19
  });
11
- // Pass in fields, and indicate if you'd like to "unflatten" field data.
12
- // The result below will reflect the data stored in the form at the given time
13
- const newFormData = reduceFieldsToValues(fields, true);
14
- useEffect(()=>{
15
- if (onChange) {
16
- onChange({
17
- fullFieldsWithValues: fields,
18
- newFormData
19
- });
20
- }
21
- }, [
22
- newFormData,
23
- onChange,
24
- fields
25
- ]);
26
- return null;
20
+ t0 = reduceFieldsToValues(fields, true);
21
+ $[0] = _fields;
22
+ $[1] = t0;
23
+ $[2] = fields;
24
+ } else {
25
+ t0 = $[1];
26
+ fields = $[2];
27
+ }
28
+ const newFormData = t0;
29
+ let t1;
30
+ let t2;
31
+ if ($[3] !== onChange || $[4] !== fields || $[5] !== newFormData) {
32
+ t1 = () => {
33
+ if (onChange) {
34
+ onChange({
35
+ fullFieldsWithValues: fields,
36
+ newFormData
37
+ });
38
+ }
39
+ };
40
+ t2 = [newFormData, onChange, fields];
41
+ $[3] = onChange;
42
+ $[4] = fields;
43
+ $[5] = newFormData;
44
+ $[6] = t1;
45
+ $[7] = t2;
46
+ } else {
47
+ t1 = $[6];
48
+ t2 = $[7];
49
+ }
50
+ useEffect(t1, t2);
51
+ return null;
27
52
  };
28
-
29
53
  //# sourceMappingURL=FormSavePlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/features/blocks/client/component/FormSavePlugin.tsx"],"sourcesContent":["import type { Data, FormState } from 'payload'\nimport type React from 'react'\n\nimport { useAllFormFields } from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport { useEffect } from 'react'\n\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n onChange?: ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: Data\n }) => void\n}\n\nexport const FormSavePlugin: React.FC<Props> = (props) => {\n const { onChange } = props\n\n const [_fields] = useAllFormFields()\n\n const fields = removeEmptyArrayValues({ fields: _fields })\n\n // Pass in fields, and indicate if you'd like to \"unflatten\" field data.\n // The result below will reflect the data stored in the form at the given time\n const newFormData = reduceFieldsToValues(fields, true)\n\n useEffect(() => {\n if (onChange) {\n onChange({ fullFieldsWithValues: fields, newFormData })\n }\n }, [newFormData, onChange, fields])\n\n return null\n}\n"],"names":["useAllFormFields","reduceFieldsToValues","useEffect","removeEmptyArrayValues","FormSavePlugin","props","onChange","_fields","fields","newFormData","fullFieldsWithValues"],"mappings":"AAGA,SAASA,gBAAgB,QAAQ,iBAAgB;AACjD,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,SAAS,QAAQ,QAAO;AAEjC,SAASC,sBAAsB,QAAQ,8BAA6B;AAYpE,OAAO,MAAMC,iBAAkC,CAACC;IAC9C,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IAErB,MAAM,CAACE,QAAQ,GAAGP;IAElB,MAAMQ,SAASL,uBAAuB;QAAEK,QAAQD;IAAQ;IAExD,wEAAwE;IACxE,8EAA8E;IAC9E,MAAME,cAAcR,qBAAqBO,QAAQ;IAEjDN,UAAU;QACR,IAAII,UAAU;YACZA,SAAS;gBAAEI,sBAAsBF;gBAAQC;YAAY;QACvD;IACF,GAAG;QAACA;QAAaH;QAAUE;KAAO;IAElC,OAAO;AACT,EAAC"}
1
+ {"version":3,"file":"FormSavePlugin.js","names":["c","_c","useAllFormFields","reduceFieldsToValues","useEffect","removeEmptyArrayValues","FormSavePlugin","props","$","onChange","_fields","t0","fields","newFormData","t1","t2","fullFieldsWithValues"],"sources":["../../../../../src/features/blocks/client/component/FormSavePlugin.tsx"],"sourcesContent":["'use client'\nimport type { Data, FormState } from 'payload'\nimport type React from 'react'\n\nimport { useAllFormFields } from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport { useEffect } from 'react'\n\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n onChange?: ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: Data\n }) => void\n}\n\nexport const FormSavePlugin: React.FC<Props> = (props) => {\n const { onChange } = props\n\n const [_fields] = useAllFormFields()\n\n const fields = removeEmptyArrayValues({ fields: _fields })\n\n // Pass in fields, and indicate if you'd like to \"unflatten\" field data.\n // The result below will reflect the data stored in the form at the given time\n const newFormData = reduceFieldsToValues(fields, true)\n\n useEffect(() => {\n if (onChange) {\n onChange({ fullFieldsWithValues: fields, newFormData })\n }\n }, [newFormData, onChange, fields])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,gBAAgB,QAAQ;AACjC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,SAAS,QAAQ;AAE1B,SAASC,sBAAsB,QAAQ;AAYvC,OAAO,MAAMC,cAAA,GAAkCC,KAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAC7C;IAAAQ;EAAA,IAAqBF,KAAA;EAErB,OAAAG,OAAA,IAAkBR,gBAAA;EAAA,IAAAS,EAAA;EAAA,IAAAC,MAAA;EAAA,IAAAJ,CAAA,QAAAE,OAAA;IAElBE,MAAA,GAAeP,sBAAA;MAAAO,MAAA,EAAiCF;IAAA,CAAQ;IAIpCC,EAAA,GAAAR,oBAAA,CAAqBS,MAAA,MAAQ;IAAAJ,CAAA,MAAAE,OAAA;IAAAF,CAAA,MAAAG,EAAA;IAAAH,CAAA,MAAAI,MAAA;EAAA;IAAAD,EAAA,GAAAH,CAAA;IAAAI,MAAA,GAAAJ,CAAA;EAAA;EAAjD,MAAAK,WAAA,GAAoBF,EAA6B;EAAA,IAAAG,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAP,CAAA,QAAAC,QAAA,IAAAD,CAAA,QAAAI,MAAA,IAAAJ,CAAA,QAAAK,WAAA;IAEvCC,EAAA,GAAAA,CAAA;MAAA,IACJL,QAAA;QACFA,QAAA;UAAAO,oBAAA,EAAiCJ,MAAA;UAAAC;QAAA,CAAoB;MAAA;IAAA;IAEtDE,EAAA,IAACF,WAAA,EAAaJ,QAAA,EAAUG,MAAA;IAAOJ,CA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