@payloadcms/richtext-lexical 4.0.0-internal.167c7cd → 4.0.0-internal.16f218d

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 (538) hide show
  1. package/dist/exports/client/Field-334JNLRF.js +2 -0
  2. package/dist/exports/client/Field-334JNLRF.js.map +7 -0
  3. package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js → RelationshipComponent-TVK6I4W4.js} +2 -2
  4. package/dist/exports/client/chunk-BEKGION5.js +2 -0
  5. package/dist/exports/client/chunk-BEKGION5.js.map +7 -0
  6. package/dist/exports/client/{chunk-WSAPGI3Z.js → chunk-EA5BHQ2T.js} +1 -1
  7. package/dist/exports/client/{chunk-WSAPGI3Z.js.map → chunk-EA5BHQ2T.js.map} +1 -1
  8. package/dist/exports/client/chunk-FAJJXXCW.js +2 -0
  9. package/dist/exports/client/chunk-FAJJXXCW.js.map +7 -0
  10. package/dist/exports/client/{chunk-5VIL27GI.js → chunk-IYBYNEKX.js} +1 -1
  11. package/dist/exports/client/{chunk-5VIL27GI.js.map → chunk-IYBYNEKX.js.map} +1 -1
  12. package/dist/exports/client/chunk-SE5IITBK.js +2 -0
  13. package/dist/exports/client/chunk-SE5IITBK.js.map +7 -0
  14. package/dist/exports/client/{component-D5QLYS7W.js → component-QENB4QTS.js} +2 -2
  15. package/dist/exports/client/componentInline-AU7IBNY7.js +2 -0
  16. package/dist/exports/client/index.d.ts +1 -1
  17. package/dist/exports/client/index.d.ts.map +1 -1
  18. package/dist/exports/client/index.js +26 -26
  19. package/dist/exports/client/index.js.map +4 -4
  20. package/dist/features/align/client/index.js.map +1 -1
  21. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  22. package/dist/features/blocks/client/component/BlockReordering/index.d.ts +11 -0
  23. package/dist/features/blocks/client/component/BlockReordering/index.d.ts.map +1 -0
  24. package/dist/features/blocks/client/component/BlockReordering/index.js +18 -0
  25. package/dist/features/blocks/client/component/BlockReordering/index.js.map +1 -0
  26. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  27. package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
  28. package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
  29. package/dist/features/blocks/client/component/index.d.ts +0 -6
  30. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  31. package/dist/features/blocks/client/component/index.js +199 -109
  32. package/dist/features/blocks/client/component/index.js.map +1 -1
  33. package/dist/features/blocks/client/component/useBlockReordering.d.ts +16 -0
  34. package/dist/features/blocks/client/component/useBlockReordering.d.ts.map +1 -0
  35. package/dist/features/blocks/client/component/useBlockReordering.js +178 -0
  36. package/dist/features/blocks/client/component/useBlockReordering.js.map +1 -0
  37. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
  38. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
  39. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
  40. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
  41. package/dist/features/blocks/client/componentInline/index.css +0 -1
  42. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  43. package/dist/features/blocks/client/componentInline/index.js +32 -30
  44. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  45. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts +9 -0
  46. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts.map +1 -0
  47. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js +95 -0
  48. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -0
  49. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  50. package/dist/features/blocks/client/nodes/BlocksNode.js +0 -10
  51. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  52. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  53. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +121 -78
  54. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  55. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +142 -87
  56. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
  57. package/dist/features/blocks/server/index.js +2 -2
  58. package/dist/features/blocks/server/index.js.map +1 -1
  59. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  60. package/dist/features/blocks/server/nodes/BlocksNode.js +1 -12
  61. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  62. package/dist/features/blocks/server/nodes/InlineBlocksNode.js +2 -2
  63. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  64. package/dist/features/blocks/server/schema.d.ts +2 -0
  65. package/dist/features/blocks/server/schema.d.ts.map +1 -1
  66. package/dist/features/blocks/server/schema.js +7 -9
  67. package/dist/features/blocks/server/schema.js.map +1 -1
  68. package/dist/features/blocks/server/validate.js +1 -1
  69. package/dist/features/blocks/server/validate.js.map +1 -1
  70. package/dist/features/converters/lexicalToHtml/async/converters/heading.js +1 -1
  71. package/dist/features/converters/lexicalToHtml/async/converters/heading.js.map +1 -1
  72. package/dist/features/converters/lexicalToHtml/async/converters/list.d.ts.map +1 -1
  73. package/dist/features/converters/lexicalToHtml/async/converters/list.js +4 -3
  74. package/dist/features/converters/lexicalToHtml/async/converters/list.js.map +1 -1
  75. package/dist/features/converters/lexicalToHtml/async/converters/upload.js +3 -3
  76. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  77. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.d.ts.map +1 -1
  78. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js +3 -2
  79. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js.map +1 -1
  80. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js +1 -1
  81. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js.map +1 -1
  82. package/dist/features/converters/lexicalToHtml/sync/converters/list.d.ts.map +1 -1
  83. package/dist/features/converters/lexicalToHtml/sync/converters/list.js +4 -3
  84. package/dist/features/converters/lexicalToHtml/sync/converters/list.js.map +1 -1
  85. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +3 -3
  86. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
  87. package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
  88. package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
  89. package/dist/features/converters/lexicalToJSX/converter/converters/heading.d.ts.map +1 -1
  90. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +2 -1
  91. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
  92. package/dist/features/converters/lexicalToJSX/converter/converters/list.d.ts.map +1 -1
  93. package/dist/features/converters/lexicalToJSX/converter/converters/list.js +2 -1
  94. package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
  95. package/dist/features/converters/lexicalToJSX/converter/converters/upload.d.ts.map +1 -1
  96. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +4 -5
  97. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
  98. package/dist/features/converters/utilities/payloadPopulateFn.d.ts.map +1 -1
  99. package/dist/features/converters/utilities/payloadPopulateFn.js +4 -2
  100. package/dist/features/converters/utilities/payloadPopulateFn.js.map +1 -1
  101. package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
  102. package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
  103. package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
  104. package/dist/features/heading/client/index.js.map +1 -1
  105. package/dist/features/heading/constants.d.ts +2 -0
  106. package/dist/features/heading/constants.d.ts.map +1 -0
  107. package/dist/features/heading/constants.js +2 -0
  108. package/dist/features/heading/constants.js.map +1 -0
  109. package/dist/features/heading/server/index.d.ts.map +1 -1
  110. package/dist/features/heading/server/index.js +5 -1
  111. package/dist/features/heading/server/index.js.map +1 -1
  112. package/dist/features/heading/server/validate.d.ts +6 -0
  113. package/dist/features/heading/server/validate.d.ts.map +1 -0
  114. package/dist/features/heading/server/validate.js +15 -0
  115. package/dist/features/heading/server/validate.js.map +1 -0
  116. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +11 -1
  117. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  118. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +17 -0
  119. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  120. package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
  121. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +2 -2
  122. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  123. package/dist/features/horizontalRule/server/schema.d.ts +1 -0
  124. package/dist/features/horizontalRule/server/schema.d.ts.map +1 -1
  125. package/dist/features/horizontalRule/server/schema.js +6 -5
  126. package/dist/features/horizontalRule/server/schema.js.map +1 -1
  127. package/dist/features/indent/client/IndentPlugin.d.ts.map +1 -1
  128. package/dist/features/indent/client/IndentPlugin.js +122 -1
  129. package/dist/features/indent/client/IndentPlugin.js.map +1 -1
  130. package/dist/features/indent/client/index.d.ts.map +1 -1
  131. package/dist/features/indent/client/index.js +0 -2
  132. package/dist/features/indent/client/index.js.map +1 -1
  133. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  134. package/dist/features/indent/server/i18n.js +74 -37
  135. package/dist/features/indent/server/i18n.js.map +1 -1
  136. package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
  137. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  138. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +18 -7
  139. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  140. package/dist/features/link/client/plugins/floatingLinkEditor/index.css +0 -1
  141. package/dist/features/link/client/plugins/link/index.js.map +1 -1
  142. package/dist/features/link/markdownTransformer.js +2 -2
  143. package/dist/features/link/markdownTransformer.js.map +1 -1
  144. package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  145. package/dist/features/link/nodes/AutoLinkNode.js +2 -10
  146. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  147. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  148. package/dist/features/link/nodes/LinkNode.js +2 -15
  149. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  150. package/dist/features/link/server/baseFields.js.map +1 -1
  151. package/dist/features/link/server/index.js +2 -2
  152. package/dist/features/link/server/index.js.map +1 -1
  153. package/dist/features/link/server/validate.js +1 -1
  154. package/dist/features/link/server/validate.js.map +1 -1
  155. package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
  156. package/dist/features/lists/checklist/server/index.js +5 -2
  157. package/dist/features/lists/checklist/server/index.js.map +1 -1
  158. package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
  159. package/dist/features/lists/orderedList/server/index.js +5 -2
  160. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  161. package/dist/features/lists/shared/constants.d.ts +2 -0
  162. package/dist/features/lists/shared/constants.d.ts.map +1 -0
  163. package/dist/features/lists/shared/constants.js +2 -0
  164. package/dist/features/lists/shared/constants.js.map +1 -0
  165. package/dist/features/lists/shared/schema.d.ts.map +1 -1
  166. package/dist/features/lists/shared/schema.js.map +1 -1
  167. package/dist/features/lists/shared/validate.d.ts +5 -0
  168. package/dist/features/lists/shared/validate.d.ts.map +1 -0
  169. package/dist/features/lists/shared/validate.js +15 -0
  170. package/dist/features/lists/shared/validate.js.map +1 -0
  171. package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
  172. package/dist/features/lists/unorderedList/server/index.js +5 -2
  173. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  174. package/dist/features/relationship/client/components/index.css +3 -6
  175. package/dist/features/relationship/client/drawer/index.js.map +1 -1
  176. package/dist/features/relationship/client/index.d.ts +2 -2
  177. package/dist/features/relationship/client/index.d.ts.map +1 -1
  178. package/dist/features/relationship/client/index.js.map +1 -1
  179. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  180. package/dist/features/relationship/client/nodes/RelationshipNode.js +0 -3
  181. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  182. package/dist/features/relationship/client/plugins/index.d.ts +2 -2
  183. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  184. package/dist/features/relationship/client/plugins/index.js +27 -31
  185. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  186. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts +2 -4
  187. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
  188. package/dist/features/relationship/client/utils/useEnabledRelationships.js +53 -20
  189. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  190. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +2 -2
  191. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
  192. package/dist/features/relationship/server/graphQLPopulationPromise.js +2 -2
  193. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  194. package/dist/features/relationship/server/index.d.ts +8 -1
  195. package/dist/features/relationship/server/index.d.ts.map +1 -1
  196. package/dist/features/relationship/server/index.js +28 -11
  197. package/dist/features/relationship/server/index.js.map +1 -1
  198. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  199. package/dist/features/relationship/server/nodes/RelationshipNode.js +1 -5
  200. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  201. package/dist/features/relationship/server/schema.d.ts +3 -2
  202. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  203. package/dist/features/relationship/server/schema.js +9 -12
  204. package/dist/features/relationship/server/schema.js.map +1 -1
  205. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +1 -6
  206. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -1
  207. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +1 -5
  208. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -1
  209. package/dist/features/table/client/index.d.ts.map +1 -0
  210. package/dist/features/table/client/index.js.map +1 -0
  211. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts +8 -0
  212. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts.map +1 -0
  213. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js +19 -0
  214. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js.map +1 -0
  215. package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.css +1 -2
  216. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -0
  217. package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.js +17 -44
  218. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -0
  219. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -0
  220. package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.js +47 -24
  221. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js.map +1 -0
  222. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -0
  223. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -0
  224. package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.css +0 -3
  225. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.d.ts.map +1 -0
  226. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.js.map +1 -0
  227. package/dist/features/table/client/plugins/TablePlugin/index.d.ts.map +1 -0
  228. package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.js +54 -18
  229. package/dist/features/table/client/plugins/TablePlugin/index.js.map +1 -0
  230. package/dist/features/table/client/utils/debounce.d.ts.map +1 -0
  231. package/dist/features/table/client/utils/debounce.js.map +1 -0
  232. package/dist/features/table/client/utils/useDebounce.d.ts.map +1 -0
  233. package/dist/features/table/client/utils/useDebounce.js.map +1 -0
  234. package/dist/features/table/markdownTransformer.d.ts.map +1 -0
  235. package/dist/features/table/markdownTransformer.js.map +1 -0
  236. package/dist/features/table/server/index.d.ts +3 -0
  237. package/dist/features/table/server/index.d.ts.map +1 -0
  238. package/dist/features/{experimental_table → table}/server/index.js +4 -4
  239. package/dist/features/table/server/index.js.map +1 -0
  240. package/dist/features/table/server/schema.d.ts.map +1 -0
  241. package/dist/features/table/server/schema.js.map +1 -0
  242. package/dist/features/textState/defaultColors.js +1 -1
  243. package/dist/features/textState/defaultColors.js.map +1 -1
  244. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts +8 -0
  245. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts.map +1 -0
  246. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js +80 -0
  247. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js.map +1 -0
  248. package/dist/features/toolbars/fixed/client/Toolbar/index.css +77 -3
  249. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  250. package/dist/features/toolbars/fixed/client/Toolbar/index.js +145 -71
  251. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  252. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  253. package/dist/features/toolbars/inline/client/Toolbar/index.js +84 -37
  254. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  255. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  256. package/dist/features/toolbars/shared/ToolbarButton/index.js +27 -2
  257. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  258. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  259. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +199 -81
  260. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  261. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +16 -12
  262. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  263. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +22 -6
  264. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  265. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts +5 -0
  266. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts.map +1 -0
  267. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js +109 -0
  268. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js.map +1 -0
  269. package/dist/features/typesServer.d.ts +17 -12
  270. package/dist/features/typesServer.d.ts.map +1 -1
  271. package/dist/features/typesServer.js.map +1 -1
  272. package/dist/features/upload/client/component/index.css +0 -2
  273. package/dist/features/upload/client/drawer/index.js.map +1 -1
  274. package/dist/features/upload/client/index.d.ts +3 -2
  275. package/dist/features/upload/client/index.d.ts.map +1 -1
  276. package/dist/features/upload/client/index.js.map +1 -1
  277. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  278. package/dist/features/upload/client/nodes/UploadNode.js +0 -7
  279. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  280. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  281. package/dist/features/upload/client/plugin/index.js +50 -53
  282. package/dist/features/upload/client/plugin/index.js.map +1 -1
  283. package/dist/features/upload/server/graphQLPopulationPromise.d.ts +2 -2
  284. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  285. package/dist/features/upload/server/graphQLPopulationPromise.js +1 -1
  286. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  287. package/dist/features/upload/server/index.d.ts +7 -3
  288. package/dist/features/upload/server/index.d.ts.map +1 -1
  289. package/dist/features/upload/server/index.js +20 -16
  290. package/dist/features/upload/server/index.js.map +1 -1
  291. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  292. package/dist/features/upload/server/nodes/UploadNode.js +1 -9
  293. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  294. package/dist/features/upload/server/schema.d.ts +4 -16
  295. package/dist/features/upload/server/schema.d.ts.map +1 -1
  296. package/dist/features/upload/server/schema.js +8 -10
  297. package/dist/features/upload/server/schema.js.map +1 -1
  298. package/dist/features/upload/server/validate.d.ts +2 -2
  299. package/dist/features/upload/server/validate.d.ts.map +1 -1
  300. package/dist/features/upload/server/validate.js +4 -1
  301. package/dist/features/upload/server/validate.js.map +1 -1
  302. package/dist/field/Diff/converters/listitem/index.d.ts.map +1 -1
  303. package/dist/field/Diff/converters/listitem/index.js +2 -1
  304. package/dist/field/Diff/converters/listitem/index.js.map +1 -1
  305. package/dist/field/Diff/converters/relationship/index.css +0 -1
  306. package/dist/field/Diff/converters/unknown/index.css +0 -1
  307. package/dist/field/Diff/converters/upload/index.css +0 -1
  308. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  309. package/dist/field/Diff/index.css +0 -2
  310. package/dist/field/Diff/index.d.ts +3 -2
  311. package/dist/field/Diff/index.d.ts.map +1 -1
  312. package/dist/field/Diff/index.js +3 -2
  313. package/dist/field/Diff/index.js.map +1 -1
  314. package/dist/field/Field.d.ts.map +1 -1
  315. package/dist/field/Field.js +8 -1
  316. package/dist/field/Field.js.map +1 -1
  317. package/dist/field/RenderLexical/index.d.ts +3 -1
  318. package/dist/field/RenderLexical/index.d.ts.map +1 -1
  319. package/dist/field/RenderLexical/index.js +23 -23
  320. package/dist/field/RenderLexical/index.js.map +1 -1
  321. package/dist/field/ViewSelector.d.ts.map +1 -1
  322. package/dist/field/ViewSelector.js +13 -4
  323. package/dist/field/ViewSelector.js.map +1 -1
  324. package/dist/field/bundled.css +1 -1
  325. package/dist/field/index.css +10 -11
  326. package/dist/field/index.js.map +1 -1
  327. package/dist/field/rscEntry.d.ts +2 -2
  328. package/dist/field/rscEntry.d.ts.map +1 -1
  329. package/dist/field/rscEntry.js.map +1 -1
  330. package/dist/i18n.d.ts.map +1 -1
  331. package/dist/i18n.js +112 -0
  332. package/dist/i18n.js.map +1 -1
  333. package/dist/index.d.ts +5 -5
  334. package/dist/index.d.ts.map +1 -1
  335. package/dist/index.js +27 -5
  336. package/dist/index.js.map +1 -1
  337. package/dist/lexical/LexicalEditor.css +21 -10
  338. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  339. package/dist/lexical/LexicalEditor.js +61 -64
  340. package/dist/lexical/LexicalEditor.js.map +1 -1
  341. package/dist/lexical/config/server/loader.d.ts +1 -1
  342. package/dist/lexical/config/server/loader.d.ts.map +1 -1
  343. package/dist/lexical/config/server/loader.js +2 -2
  344. package/dist/lexical/config/server/loader.js.map +1 -1
  345. package/dist/lexical/config/server/sanitize.d.ts +1 -1
  346. package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
  347. package/dist/lexical/config/server/sanitize.js +2 -2
  348. package/dist/lexical/config/server/sanitize.js.map +1 -1
  349. package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -1
  350. package/dist/lexical/plugins/DecoratorPlugin/index.d.ts.map +1 -1
  351. package/dist/lexical/plugins/DecoratorPlugin/index.js +24 -21
  352. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  353. package/dist/lexical/plugins/InsertParagraphAtEnd/index.css +18 -24
  354. package/dist/lexical/plugins/InsertParagraphAtEnd/index.d.ts.map +1 -1
  355. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +27 -14
  356. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  357. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  358. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -1
  359. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +235 -88
  360. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  361. package/dist/lexical/plugins/SlashMenu/index.css +0 -1
  362. package/dist/lexical/plugins/SlashMenu/useMenuTriggerMatch.js.map +1 -1
  363. package/dist/lexical/plugins/TextPlugin/index.js.map +1 -1
  364. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -0
  365. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +2 -2
  366. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  367. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +17 -0
  368. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  369. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +139 -37
  370. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  371. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts +7 -0
  372. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts.map +1 -0
  373. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js +15 -0
  374. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js.map +1 -0
  375. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts +7 -0
  376. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts.map +1 -0
  377. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js +62 -0
  378. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js.map +1 -0
  379. package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  380. package/dist/lexical/plugins/handles/utils/setHandlePosition.js +2 -0
  381. package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  382. package/dist/lexical/theme/EditorTheme.css +0 -2
  383. package/dist/lexical/ui/ContentEditable.d.ts +2 -1
  384. package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
  385. package/dist/lexical/ui/ContentEditable.js +32 -11
  386. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  387. package/dist/lexical/ui/icons/H3/index.d.ts.map +1 -1
  388. package/dist/lexical/ui/icons/H3/index.js +13 -6
  389. package/dist/lexical/ui/icons/H3/index.js.map +1 -1
  390. package/dist/lexical/ui/icons/H4/index.d.ts.map +1 -1
  391. package/dist/lexical/ui/icons/H4/index.js +13 -6
  392. package/dist/lexical/ui/icons/H4/index.js.map +1 -1
  393. package/dist/lexical/ui/icons/H5/index.d.ts.map +1 -1
  394. package/dist/lexical/ui/icons/H5/index.js +13 -6
  395. package/dist/lexical/ui/icons/H5/index.js.map +1 -1
  396. package/dist/lexical/ui/icons/H6/index.d.ts.map +1 -1
  397. package/dist/lexical/ui/icons/H6/index.js +13 -6
  398. package/dist/lexical/ui/icons/H6/index.js.map +1 -1
  399. package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
  400. package/dist/lexical/utils/nodeFormat.js +0 -2
  401. package/dist/lexical/utils/nodeFormat.js.map +1 -1
  402. package/dist/lexical/utils/url.d.ts.map +1 -1
  403. package/dist/lexical/utils/url.js +1 -1
  404. package/dist/lexical/utils/url.js.map +1 -1
  405. package/dist/populateGraphQL/populate.js.map +1 -1
  406. package/dist/presets/llmInstructions.d.ts +2 -0
  407. package/dist/presets/llmInstructions.d.ts.map +1 -0
  408. package/dist/presets/llmInstructions.js +13 -0
  409. package/dist/presets/llmInstructions.js.map +1 -0
  410. package/dist/types/builtInNodes.d.ts +1 -1
  411. package/dist/types/builtInNodes.d.ts.map +1 -1
  412. package/dist/types/builtInNodes.js +8 -3
  413. package/dist/types/builtInNodes.js.map +1 -1
  414. package/dist/types/index.d.ts +4 -7
  415. package/dist/types/index.d.ts.map +1 -1
  416. package/dist/types/index.js.map +1 -1
  417. package/dist/types/jsonSchemaHelpers.d.ts +5 -1
  418. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -1
  419. package/dist/types/jsonSchemaHelpers.js +7 -2
  420. package/dist/types/jsonSchemaHelpers.js.map +1 -1
  421. package/dist/types/nodeTypes.d.ts +6 -1
  422. package/dist/types/nodeTypes.d.ts.map +1 -1
  423. package/dist/types/nodeTypes.js.map +1 -1
  424. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  425. package/dist/utilities/buildEditorState.js.map +1 -1
  426. package/dist/utilities/buildInitialState.d.ts +3 -2
  427. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  428. package/dist/utilities/buildInitialState.js +1 -0
  429. package/dist/utilities/buildInitialState.js.map +1 -1
  430. package/dist/utilities/createServerFeature.d.ts +1 -1
  431. package/dist/utilities/createServerFeature.d.ts.map +1 -1
  432. package/dist/utilities/createServerFeature.js +2 -2
  433. package/dist/utilities/createServerFeature.js.map +1 -1
  434. package/dist/utilities/editorConfigFactory.d.ts +6 -6
  435. package/dist/utilities/editorConfigFactory.d.ts.map +1 -1
  436. package/dist/utilities/editorConfigFactory.js +9 -9
  437. package/dist/utilities/editorConfigFactory.js.map +1 -1
  438. package/dist/utilities/fieldsDrawer/Drawer.js +36 -36
  439. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  440. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  441. package/dist/utilities/fieldsDrawer/DrawerContent.js +6 -9
  442. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  443. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -1
  444. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
  445. package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
  446. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
  447. package/dist/utilities/generateImportMap.d.ts +2 -2
  448. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  449. package/dist/utilities/generateImportMap.js.map +1 -1
  450. package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts +2 -2
  451. package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts.map +1 -1
  452. package/dist/utilities/getDefaultSanitizedEditorConfig.js +6 -17
  453. package/dist/utilities/getDefaultSanitizedEditorConfig.js.map +1 -1
  454. package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
  455. package/dist/utilities/initLexicalFeatures.js +38 -4
  456. package/dist/utilities/initLexicalFeatures.js.map +1 -1
  457. package/dist/utilities/upgradeLexicalData/index.js +6 -3
  458. package/dist/utilities/upgradeLexicalData/index.js.map +1 -1
  459. package/dist/utilities/useLexicalFeature.js +15 -6
  460. package/dist/utilities/useLexicalFeature.js.map +1 -1
  461. package/dist/utilities/useRunDeprioritized.js.map +1 -1
  462. package/dist/validate/hasText.d.ts +2 -2
  463. package/dist/validate/hasText.d.ts.map +1 -1
  464. package/dist/validate/hasText.js.map +1 -1
  465. package/dist/validate/index.d.ts +1 -1
  466. package/dist/validate/index.d.ts.map +1 -1
  467. package/package.json +50 -53
  468. package/dist/dependencyChecker.spec.js +0 -16
  469. package/dist/dependencyChecker.spec.js.map +0 -1
  470. package/dist/exports/client/Field-IZKDIUJY.js +0 -2
  471. package/dist/exports/client/Field-IZKDIUJY.js.map +0 -7
  472. package/dist/exports/client/bundled.css +0 -1
  473. package/dist/exports/client/chunk-43E5QYAA.js +0 -2
  474. package/dist/exports/client/chunk-43E5QYAA.js.map +0 -7
  475. package/dist/exports/client/chunk-ESITTE3C.js +0 -2
  476. package/dist/exports/client/chunk-ESITTE3C.js.map +0 -7
  477. package/dist/exports/client/chunk-SSMQFWCQ.js +0 -2
  478. package/dist/exports/client/chunk-SSMQFWCQ.js.map +0 -7
  479. package/dist/exports/client/componentInline-H24N7GUG.js +0 -2
  480. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts +0 -11
  481. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts.map +0 -1
  482. package/dist/features/blocks/client/component/removeEmptyArrayValues.js +0 -20
  483. package/dist/features/blocks/client/component/removeEmptyArrayValues.js.map +0 -1
  484. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js +0 -180
  485. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js.map +0 -1
  486. package/dist/features/experimental_table/client/index.d.ts.map +0 -1
  487. package/dist/features/experimental_table/client/index.js.map +0 -1
  488. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +0 -1
  489. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +0 -1
  490. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +0 -1
  491. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +0 -1
  492. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +0 -1
  493. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +0 -1
  494. package/dist/features/experimental_table/client/plugins/TablePlugin/TableGridPopup/index.d.ts.map +0 -1
  495. package/dist/features/experimental_table/client/plugins/TablePlugin/TableGridPopup/index.js.map +0 -1
  496. package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts.map +0 -1
  497. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +0 -1
  498. package/dist/features/experimental_table/client/utils/debounce.d.ts.map +0 -1
  499. package/dist/features/experimental_table/client/utils/debounce.js.map +0 -1
  500. package/dist/features/experimental_table/client/utils/useDebounce.d.ts.map +0 -1
  501. package/dist/features/experimental_table/client/utils/useDebounce.js.map +0 -1
  502. package/dist/features/experimental_table/markdownTransformer.d.ts.map +0 -1
  503. package/dist/features/experimental_table/markdownTransformer.js.map +0 -1
  504. package/dist/features/experimental_table/server/index.d.ts +0 -3
  505. package/dist/features/experimental_table/server/index.d.ts.map +0 -1
  506. package/dist/features/experimental_table/server/index.js.map +0 -1
  507. package/dist/features/experimental_table/server/schema.d.ts.map +0 -1
  508. package/dist/features/experimental_table/server/schema.js.map +0 -1
  509. package/dist/features/link/markdownTransformer.spec.js +0 -195
  510. package/dist/features/link/markdownTransformer.spec.js.map +0 -1
  511. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js +0 -88
  512. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js.map +0 -1
  513. package/dist/lexical/utils/url.spec.js +0 -114
  514. package/dist/lexical/utils/url.spec.js.map +0 -1
  515. package/dist/utilities/jsx/jsx.spec.js +0 -178
  516. package/dist/utilities/jsx/jsx.spec.js.map +0 -1
  517. /package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js.map → RelationshipComponent-TVK6I4W4.js.map} +0 -0
  518. /package/dist/exports/client/{component-D5QLYS7W.js.map → component-QENB4QTS.js.map} +0 -0
  519. /package/dist/exports/client/{componentInline-H24N7GUG.js.map → componentInline-AU7IBNY7.js.map} +0 -0
  520. /package/dist/features/{experimental_table → table}/client/index.d.ts +0 -0
  521. /package/dist/features/{experimental_table → table}/client/index.js +0 -0
  522. /package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.d.ts +0 -0
  523. /package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.css +0 -0
  524. /package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.d.ts +0 -0
  525. /package/dist/features/{experimental_table → table}/client/plugins/TableHoverActionsPlugin/index.d.ts +0 -0
  526. /package/dist/features/{experimental_table → table}/client/plugins/TableHoverActionsPlugin/index.js +0 -0
  527. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.d.ts +0 -0
  528. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.js +0 -0
  529. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.css +0 -0
  530. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.d.ts +0 -0
  531. /package/dist/features/{experimental_table → table}/client/utils/debounce.d.ts +0 -0
  532. /package/dist/features/{experimental_table → table}/client/utils/debounce.js +0 -0
  533. /package/dist/features/{experimental_table → table}/client/utils/useDebounce.d.ts +0 -0
  534. /package/dist/features/{experimental_table → table}/client/utils/useDebounce.js +0 -0
  535. /package/dist/features/{experimental_table → table}/markdownTransformer.d.ts +0 -0
  536. /package/dist/features/{experimental_table → table}/markdownTransformer.js +0 -0
  537. /package/dist/features/{experimental_table → table}/server/schema.d.ts +0 -0
  538. /package/dist/features/{experimental_table → table}/server/schema.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"useLexicalDrawer.js","names":["c","_c","useLexicalComposerContext","useModal","$getPreviousSelection","$getSelection","$setSelection","useCallback","useEffect","useState","useLexicalDrawer","slug","restoreLate","$","editor","selectionState","setSelectionState","wasOpen","setWasOpen","closeModal","closeBaseModal","modalState","toggleModal","toggleBaseModal","t0","read","selection","storeSelection","t1","update","clone","discrete","skipTransforms","restoreSelection","t2","closeDrawer","isModalOpen","isOpen","t3","toggleDrawer","t4","t5","thisModalState","setTimeout","t6"],"sources":["../../../src/utilities/fieldsDrawer/useLexicalDrawer.tsx"],"sourcesContent":["'use client'\nimport type { BaseSelection } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useModal } from '@payloadcms/ui'\nimport { $getPreviousSelection, $getSelection, $setSelection } from 'lexical'\nimport { useCallback, useEffect, useState } from 'react'\n\n/**\n *\n * Wrapper around useModal that restores and saves selection state (cursor position) when opening and closing the drawer.\n * By default, the lexical cursor position may be lost when opening a drawer and clicking somewhere on that drawer.\n */\nexport const useLexicalDrawer = (slug: string, restoreLate?: boolean) => {\n const [editor] = useLexicalComposerContext()\n const [selectionState, setSelectionState] = useState<BaseSelection | null>(null)\n const [wasOpen, setWasOpen] = useState<boolean>(false)\n\n const { closeModal: closeBaseModal, modalState, toggleModal: toggleBaseModal } = useModal()\n\n const storeSelection = useCallback(() => {\n editor.read(() => {\n const selection = $getSelection() ?? $getPreviousSelection()\n setSelectionState(selection)\n })\n }, [editor])\n\n const restoreSelection = useCallback(() => {\n if (selectionState) {\n editor.update(\n () => {\n $setSelection(selectionState.clone())\n },\n { discrete: true, skipTransforms: true },\n )\n }\n }, [editor, selectionState])\n\n const closeDrawer = useCallback(() => {\n //restoreSelection() // Should already be stored by the useEffect below\n closeBaseModal(slug)\n }, [closeBaseModal, slug])\n const isModalOpen = modalState?.[slug]?.isOpen\n\n const toggleDrawer = useCallback(() => {\n if (!isModalOpen) {\n storeSelection()\n } else {\n restoreSelection()\n }\n setWasOpen(true)\n toggleBaseModal(slug)\n }, [slug, storeSelection, toggleBaseModal, restoreSelection, isModalOpen])\n\n // We need to handle drawer closing via a useEffect, as toggleDrawer / closeDrawer will not be triggered if the drawer\n // is closed by clicking outside of the drawer. This useEffect will handle everything.\n useEffect(() => {\n if (!wasOpen) {\n return\n }\n\n const thisModalState = modalState[slug]\n // Exists in modalState (thus has opened at least once before) and is closed\n if (thisModalState && !thisModalState?.isOpen) {\n setWasOpen(false)\n\n if (restoreLate) {\n // restoreLate is used for upload extra field drawers. For some reason, the selection is not restored if we call restoreSelection immediately.\n setTimeout(() => {\n restoreSelection()\n }, 0)\n } else {\n restoreSelection()\n }\n }\n }, [modalState, slug, restoreSelection, wasOpen, restoreLate])\n\n return {\n closeDrawer,\n toggleDrawer,\n }\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,QAAQ,QAAQ;AACzB,SAASC,qBAAqB,EAAEC,aAAa,EAAEC,aAAa,QAAQ;AACpE,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAEjD;;;;;AAKA,OAAO,MAAMC,gBAAA,GAAmBA,CAAAC,IAAA,EAAAC,WAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EAC9B,OAAAa,MAAA,IAAiBZ,yBAAA;EACjB,OAAAa,cAAA,EAAAC,iBAAA,IAA4CP,QAAA,KAA+B;EAC3E,OAAAQ,OAAA,EAAAC,UAAA,IAA8BT,QAAA,MAAkB;EAEhD;IAAAU,UAAA,EAAAC,cAAA;IAAAC,UA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A,GAAA5B,CAAA;EAAA;EAnB7DL,SAAA,CAAUgC,EAmBV,EAAGC,EAA0D;EAAA,IAAAG,EAAA;EAAA,IAAA/B,CAAA,SAAAsB,WAAA,IAAAtB,CAAA,SAAA0B,YAAA;IAEtDK,EAAA;MAAAT,WAAA;MAAAI;IAAA;IAGP1B,CAAA,OAAAsB,WAAA;IAAAtB,CAAA,OAAA0B,YAAA;IAAA1B,CAAA,OAAA+B,EAAA;EAAA;IAAAA,EAAA,GAAA/B,CAAA;EAAA;EAAA,OAHO+B,EAGP;AAAA,CACF","ignoreList":[]}
1
+ {"version":3,"file":"useLexicalDrawer.js","names":["c","_c","useLexicalComposerContext","useModal","$getPreviousSelection","$getSelection","$setSelection","useCallback","useEffect","useState","useLexicalDrawer","slug","restoreLate","$","editor","selectionState","setSelectionState","wasOpen","setWasOpen","closeModal","closeBaseModal","modalState","toggleModal","toggleBaseModal","t0","read","selection","storeSelection","t1","update","clone","discrete","skipTransforms","restoreSelection","t2","closeDrawer","isModalOpen","isOpen","t3","toggleDrawer","t4","t5","thisModalState","setTimeout","t6"],"sources":["../../../src/utilities/fieldsDrawer/useLexicalDrawer.tsx"],"sourcesContent":["'use client'\nimport type { BaseSelection } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useModal } from '@payloadcms/ui'\nimport { $getPreviousSelection, $getSelection, $setSelection } from 'lexical'\nimport { useCallback, useEffect, useState } from 'react'\n\n/**\n *\n * Wrapper around useModal that restores and saves selection state (cursor position) when opening and closing the drawer.\n * By default, the lexical cursor position may be lost when opening a drawer and clicking somewhere on that drawer.\n */\nexport const useLexicalDrawer = (slug: string, restoreLate?: boolean) => {\n const [editor] = useLexicalComposerContext()\n const [selectionState, setSelectionState] = useState<BaseSelection | null>(null)\n const [wasOpen, setWasOpen] = useState<boolean>(false)\n\n const { closeModal: closeBaseModal, modalState, toggleModal: toggleBaseModal } = useModal()\n\n const storeSelection = useCallback(() => {\n editor.read(() => {\n const selection = $getSelection() ?? $getPreviousSelection()\n setSelectionState(selection)\n })\n }, [editor])\n\n const restoreSelection = useCallback(() => {\n if (selectionState) {\n editor.update(\n () => {\n $setSelection(selectionState.clone())\n },\n { discrete: true, skipTransforms: true },\n )\n }\n }, [editor, selectionState])\n\n const closeDrawer = useCallback(() => {\n //restoreSelection() // Should already be stored by the useEffect below\n closeBaseModal(slug)\n }, [closeBaseModal, slug])\n const isModalOpen = modalState?.[slug]?.isOpen\n\n const toggleDrawer = useCallback(() => {\n if (!isModalOpen) {\n storeSelection()\n } else {\n restoreSelection()\n }\n setWasOpen(true)\n toggleBaseModal(slug)\n }, [slug, storeSelection, toggleBaseModal, restoreSelection, isModalOpen])\n\n // We need to handle drawer closing via a useEffect, as toggleDrawer / closeDrawer will not be triggered if the drawer\n // is closed by clicking outside of the drawer. This useEffect will handle everything.\n useEffect(() => {\n if (!wasOpen) {\n return\n }\n\n const thisModalState = modalState[slug]\n // Exists in modalState (thus has opened at least once before) and is closed\n if (thisModalState && !thisModalState?.isOpen) {\n setWasOpen(false)\n\n if (restoreLate) {\n // restoreLate is used for upload extra field drawers. For some reason, the selection is not restored if we call restoreSelection immediately.\n setTimeout(() => {\n restoreSelection()\n }, 0)\n } else {\n restoreSelection()\n }\n }\n }, [modalState, slug, restoreSelection, wasOpen, restoreLate])\n\n return {\n closeDrawer,\n toggleDrawer,\n }\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,QAAQ,QAAQ;AACzB,SAASC,qBAAqB,EAAEC,aAAa,EAAEC,aAAa,QAAQ;AACpE,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAEjD;;;;;AAKA,OAAO,MAAMC,gBAAA,GAAmBA,CAAAC,IAAA,EAAAC,WAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EAC9B,OAAAa,MAAA,IAAiBZ,yBAAA;EACjB,OAAAa,cAA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AAC,CAAA,OAAAQ,UAAA;IAAAR,CAAA,OAAAD,WAAA;IAAAC,CAAA,OAAAoB,gBAAA;IAAApB,CAAA,OAAAF,IAAA;IAAAE,CAAA,OAAAI,OAAA;IAAAJ,CAAA,OAAA2B,EAAA;IAAA3B,CAAA,OAAA4B,EAAA;EAAA;IAAAD,EAAA,GAAA3B,CAAA;IAAA4B,EAAA,GAAA5B,CAAA;EAAA;EAnB7DL,SAAA,CAAUgC,EAmBV,EAAGC,EAA0D;EAAA,IAAAG,EAAA;EAAA,IAAA/B,CAAA,SAAAsB,WAAA,IAAAtB,CAAA,SAAA0B,YAAA;IAEtDK,EAAA;MAAAT,WAAA;MAAAI;IAGP;IAAA1B,CAAA,OAAAsB,WAAA;IAAAtB,CAAA,OAAA0B,YAAA;IAAA1B,CAAA,OAAA+B,EAAA;EAAA;IAAAA,EAAA,GAAA/B,CAAA;EAAA;EAAA,OAHO+B,EAGP;AAAA,CACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useLexicalListDrawer.js","names":["c","_c","useLexicalComposerContext","useListDrawer","useModal","$getNodeByKey","$getPreviousSelection","$getRoot","$getSelection","$isRangeSelection","$setSelection","useCallback","useEffect","useState","useLexicalListDrawer","args","$","editor","selectionState","setSelectionState","wasOpen","setWasOpen","BaseListDrawer","BaseListDrawerToggler","t0","closeDrawer","baseCloseDrawer","drawerSlug","listDrawerSlug","isDrawerOpen","openDrawer","baseOpenDrawer","modalState","t1","Symbol","for","selection","$storeSelection","t2","update","anchor","focus","key","clone","selectEnd","discrete","skipTransforms","restoreSelection","t3","closeListDrawer","t4","t5","thisModalState","isOpen","setTimeout","t6","props","_jsx","onClick","t7","t8","isListDrawerOpen","ListDrawer","ListDrawerToggler"],"sources":["../../../src/utilities/fieldsDrawer/useLexicalListDrawer.tsx"],"sourcesContent":["'use client'\nimport type { UseListDrawer } from '@payloadcms/ui'\nimport type { BaseSelection } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useListDrawer, useModal } from '@payloadcms/ui'\nimport {\n $getNodeByKey,\n $getPreviousSelection,\n $getRoot,\n $getSelection,\n $isRangeSelection,\n $setSelection,\n} from 'lexical'\nimport { useCallback, useEffect, useState } from 'react'\n\n/**\n *\n * Wrapper around useListDrawer that restores and saves selection state (cursor position) when opening and closing the drawer.\n * By default, the lexical cursor position may be lost when opening a drawer and clicking somewhere on that drawer.\n */\nexport const useLexicalListDrawer = (\n args: Parameters<UseListDrawer>[0],\n): {\n closeListDrawer: () => void\n isListDrawerOpen: boolean\n ListDrawer: ReturnType<UseListDrawer>[0]\n listDrawerSlug: string\n ListDrawerToggler: ReturnType<UseListDrawer>[1]\n openListDrawer: (selection?: BaseSelection) => void\n} => {\n const [editor] = useLexicalComposerContext()\n const [selectionState, setSelectionState] = useState<BaseSelection | null>(null)\n const [wasOpen, setWasOpen] = useState<boolean>(false)\n\n const [\n BaseListDrawer,\n BaseListDrawerToggler,\n {\n closeDrawer: baseCloseDrawer,\n drawerSlug: listDrawerSlug,\n isDrawerOpen,\n openDrawer: baseOpenDrawer,\n },\n ] = useListDrawer(args)\n const { modalState } = useModal()\n\n const $storeSelection = useCallback(() => {\n // editor.read() causes an error here when creating a new upload node from the slash menu. It seems like we can omit it here though, as all\n // invocations of that functions are wrapped in editor.read() or editor.update() somewhere in the call stack.\n const selection = $getSelection() ?? $getPreviousSelection()\n setSelectionState(selection)\n }, [])\n\n const restoreSelection = useCallback(() => {\n if (selectionState) {\n editor.update(\n () => {\n if ($isRangeSelection(selectionState)) {\n const { anchor, focus } = selectionState\n if ($getNodeByKey(anchor.key) && $getNodeByKey(focus.key)) {\n $setSelection(selectionState.clone())\n }\n } else {\n // not ideal, but better than losing the selection. Try to set the selection\n // in a valid place if you remove selected nodes!\n $getRoot().selectEnd()\n }\n },\n { discrete: true, skipTransforms: true },\n )\n }\n }, [editor, selectionState])\n\n const closeListDrawer = () => {\n //restoreSelection() // Should already be stored by the useEffect below\n baseCloseDrawer()\n }\n\n // We need to handle drawer closing via a useEffect, as toggleDrawer / closeDrawer will not be triggered if the drawer\n // is closed by clicking outside of the drawer. This useEffect will handle everything.\n useEffect(() => {\n if (!wasOpen) {\n return\n }\n\n const thisModalState = modalState[listDrawerSlug]\n // Exists in modalState (thus has opened at least once before) and is closed\n if (thisModalState && !thisModalState?.isOpen) {\n setWasOpen(false)\n setTimeout(() => {\n restoreSelection()\n }, 1)\n }\n }, [modalState, listDrawerSlug, restoreSelection, wasOpen])\n\n return {\n closeListDrawer,\n isListDrawerOpen: isDrawerOpen,\n ListDrawer: BaseListDrawer,\n listDrawerSlug,\n ListDrawerToggler: (props) => (\n <BaseListDrawerToggler\n {...props}\n onClick={() => {\n $storeSelection()\n }}\n />\n ),\n openListDrawer: () => {\n $storeSelection()\n baseOpenDrawer()\n setWasOpen(true)\n },\n }\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,EAAEC,QAAQ,QAAQ;AACxC,SACEC,aAAa,EACbC,qBAAqB,EACrBC,QAAQ,EACRC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,QACR;AACP,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAEjD;;;;;AAKA,OAAO,MAAMC,oBAAA,GAAuBC,IAAA;EAAA,MAAAC,CAAA,GAAAf,EAAA;EAUlC,OAAAgB,MAAA,IAAiBf,yBAAA;EACjB,OAAAgB,cAAA,EAAAC,iBAAA,IAA4CN,QAAA,KAA+B;EAC3E,OAAAO,OAAA,EAAAC,UAAA,IAA8BR,QAAA,MAAkB;EAEhD,OAAAS,cAAA,EAAAC,qBAAA,EAAAC,EAAA,IASIrB,aAAA,CAAcY,IAAA;EANhB;IAAAU,WAAA,EAAAC,eAAA;IAAAC,UAAA,EAAAC,cAAA;IAAAC,YAAA;IAAAC,UAAA,EAAAC;EAAA,IAAAP,EAKC;EAEH;IAAAQ;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AAA,IAAAvC,CAAA,SAAA2C,EAAA;IAjBKC,EAAA;MAAAX,eAAA;MAAAY,gBAAA,EAEahC,YAAA;MAAAiC,UAAA,EACNxC,cAAA;MAAAM,cAAA;MAAAmC,iBAAA,EAEOR,E;sBAQHI;IAIhB;IACF3C,CAAA,OAAAM,cAAA;IAAAN,CAAA,OAAAiC,eAAA;IAAAjC,CAAA,OAAAa,YAAA;IAAAb,CAAA,OAAAY,cAAA;IAAAZ,CAAA,OAAAuC,EAAA;IAAAvC,CAAA,OAAA2C,EAAA;IAAA3C,CAAA,OAAA4C,EAAA;EAAA;IAAAA,EAAA,GAAA5C,CAAA;EAAA;EAAA,OAlBO4C,EAkBP;AAAA,CACF","ignoreList":[]}
1
+ {"version":3,"file":"useLexicalListDrawer.js","names":["c","_c","useLexicalComposerContext","useListDrawer","useModal","$getNodeByKey","$getPreviousSelection","$getRoot","$getSelection","$isRangeSelection","$setSelection","useCallback","useEffect","useState","useLexicalListDrawer","args","$","editor","selectionState","setSelectionState","wasOpen","setWasOpen","BaseListDrawer","BaseListDrawerToggler","t0","closeDrawer","baseCloseDrawer","drawerSlug","listDrawerSlug","isDrawerOpen","openDrawer","baseOpenDrawer","modalState","t1","Symbol","for","selection","$storeSelection","t2","update","anchor","focus","key","clone","selectEnd","discrete","skipTransforms","restoreSelection","t3","closeListDrawer","t4","t5","thisModalState","isOpen","setTimeout","t6","props","_jsx","onClick","t7","t8","isListDrawerOpen","ListDrawer","ListDrawerToggler"],"sources":["../../../src/utilities/fieldsDrawer/useLexicalListDrawer.tsx"],"sourcesContent":["'use client'\nimport type { UseListDrawer } from '@payloadcms/ui'\nimport type { BaseSelection } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useListDrawer, useModal } from '@payloadcms/ui'\nimport {\n $getNodeByKey,\n $getPreviousSelection,\n $getRoot,\n $getSelection,\n $isRangeSelection,\n $setSelection,\n} from 'lexical'\nimport { useCallback, useEffect, useState } from 'react'\n\n/**\n *\n * Wrapper around useListDrawer that restores and saves selection state (cursor position) when opening and closing the drawer.\n * By default, the lexical cursor position may be lost when opening a drawer and clicking somewhere on that drawer.\n */\nexport const useLexicalListDrawer = (\n args: Parameters<UseListDrawer>[0],\n): {\n closeListDrawer: () => void\n isListDrawerOpen: boolean\n ListDrawer: ReturnType<UseListDrawer>[0]\n listDrawerSlug: string\n ListDrawerToggler: ReturnType<UseListDrawer>[1]\n openListDrawer: (selection?: BaseSelection) => void\n} => {\n const [editor] = useLexicalComposerContext()\n const [selectionState, setSelectionState] = useState<BaseSelection | null>(null)\n const [wasOpen, setWasOpen] = useState<boolean>(false)\n\n const [\n BaseListDrawer,\n BaseListDrawerToggler,\n {\n closeDrawer: baseCloseDrawer,\n drawerSlug: listDrawerSlug,\n isDrawerOpen,\n openDrawer: baseOpenDrawer,\n },\n ] = useListDrawer(args)\n const { modalState } = useModal()\n\n const $storeSelection = useCallback(() => {\n // editor.read() causes an error here when creating a new upload node from the slash menu. It seems like we can omit it here though, as all\n // invocations of that functions are wrapped in editor.read() or editor.update() somewhere in the call stack.\n const selection = $getSelection() ?? $getPreviousSelection()\n setSelectionState(selection)\n }, [])\n\n const restoreSelection = useCallback(() => {\n if (selectionState) {\n editor.update(\n () => {\n if ($isRangeSelection(selectionState)) {\n const { anchor, focus } = selectionState\n if ($getNodeByKey(anchor.key) && $getNodeByKey(focus.key)) {\n $setSelection(selectionState.clone())\n }\n } else {\n // not ideal, but better than losing the selection. Try to set the selection\n // in a valid place if you remove selected nodes!\n $getRoot().selectEnd()\n }\n },\n { discrete: true, skipTransforms: true },\n )\n }\n }, [editor, selectionState])\n\n const closeListDrawer = () => {\n //restoreSelection() // Should already be stored by the useEffect below\n baseCloseDrawer()\n }\n\n // We need to handle drawer closing via a useEffect, as toggleDrawer / closeDrawer will not be triggered if the drawer\n // is closed by clicking outside of the drawer. This useEffect will handle everything.\n useEffect(() => {\n if (!wasOpen) {\n return\n }\n\n const thisModalState = modalState[listDrawerSlug]\n // Exists in modalState (thus has opened at least once before) and is closed\n if (thisModalState && !thisModalState?.isOpen) {\n setWasOpen(false)\n setTimeout(() => {\n restoreSelection()\n }, 1)\n }\n }, [modalState, listDrawerSlug, restoreSelection, wasOpen])\n\n return {\n closeListDrawer,\n isListDrawerOpen: isDrawerOpen,\n ListDrawer: BaseListDrawer,\n listDrawerSlug,\n ListDrawerToggler: (props) => (\n <BaseListDrawerToggler\n {...props}\n onClick={() => {\n $storeSelection()\n }}\n />\n ),\n openListDrawer: () => {\n $storeSelection()\n baseOpenDrawer()\n setWasOpen(true)\n },\n }\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,EAAEC,QAAQ,QAAQ;AACxC,SACEC,aAAa,EACbC,qBAAqB,EACrBC,QAAQ,EACRC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,QACR;AACP,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAEjD;;;;;AAKA,OAAO,MAAMC,oBAAA,GAAuBC,IAAA;EAAA,MAAAC,CAAA,GAAAf,EAAA;EAUlC,OAAAgB,MAAA,IAAiBf,yBAAA;EACjB,OAAAgB,cAAA,EAAAC,iBAAA,IAA4CN,QAAA,CAA+B;EAC3E,OAAAO,OAAA,EAAAC,UAAA,IAA8BR,QAAA,CAAkB;EAEhD,OAAAS,cAAA,EAAAC,qBAAA,EAAAC,EAAA,IASIrB,aAAA,CAAcY,IAAA;EANhB;IAAAU,WAAA,EAAAC,eAAA;IAAAC,UAAA,EAAAC,cAAA;IAAAC,YAAA;IAAAC,UAAA,EAAAC;EAAA,IAAAP,EAKC;EAEH;IAAAQ;EAAA,IAAuB5B,QAAA;EAAA,IAAA6B,EAAA;EAAA,IAAAjB,CAAA,QAAAkB,MAAA,CAAAC,GAAA;IAEaF,EAAA,GAAAA,CAAA;MAGlC,MAAAG,SAAA,GAAkB5B,aAAA,CAAmB,K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AiC,UAAA,EACNxC,cAAA;MAAAM,cAAA;MAAAmC,iBAAA,EAEOR,E;sBAQHI;IAKlB;IAAA3C,CAAA,OAAAM,cAAA;IAAAN,CAAA,OAAAiC,eAAA;IAAAjC,CAAA,OAAAa,YAAA;IAAAb,CAAA,OAAAY,cAAA;IAAAZ,CAAA,OAAAuC,EAAA;IAAAvC,CAAA,OAAA2C,EAAA;IAAA3C,CAAA,OAAA4C,EAAA;EAAA;IAAAA,EAAA,GAAA5C,CAAA;EAAA;EAAA,OAlBO4C,EAkBP;AAAA,CACF","ignoreList":[]}
@@ -1,8 +1,8 @@
1
1
  import type { RichTextAdapter } from 'payload';
2
2
  import type { ResolvedServerFeatureMap } from '../features/typesServer.js';
3
- import type { LexicalEditorProps } from '../types/index.js';
3
+ import type { LexicalEditorArgs } from '../types/index.js';
4
4
  export declare const getGenerateImportMap: (args: {
5
- lexicalEditorArgs?: LexicalEditorProps;
5
+ lexicalEditorArgs?: LexicalEditorArgs;
6
6
  resolvedFeatureMap: ResolvedServerFeatureMap;
7
7
  }) => RichTextAdapter['generateImportMap'];
8
8
  //# sourceMappingURL=generateImportMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,eAAO,MAAM,oBAAoB,SACxB;IACL,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;IACtC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,mBAAmB,CAiDtC,CAAA"}
1
+ {"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,eAAO,MAAM,oBAAoB,SACxB;IACL,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,mBAAmB,CAiDtC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"generateImportMap.js","names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","lexicalEditorArgs","views","resolvedFeature","resolvedFeatureMap","values","componentImports","Array","isArray","Object","ClientFeature","nodes","length","node","getSubFields","subFields","fields"],"sources":["../../src/utilities/generateImportMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport { genImportMapIterateFields } from 'payload'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\nimport type { LexicalEditorProps } from '../types/index.js'\n\nexport const getGenerateImportMap =\n (args: {\n lexicalEditorArgs?: LexicalEditorProps\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateImportMap'] =>\n ({ addToImportMap, baseDir, config, importMap, imports }) => {\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell')\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField')\n addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent')\n\n addToImportMap(args.lexicalEditorArgs?.views)\n\n for (const resolvedFeature of args.resolvedFeatureMap.values()) {\n if ('componentImports' in resolvedFeature) {\n if (typeof resolvedFeature.componentImports === 'function') {\n resolvedFeature.componentImports({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n } else if (Array.isArray(resolvedFeature.componentImports)) {\n addToImportMap(resolvedFeature.componentImports)\n } else if (typeof resolvedFeature.componentImports === 'object') {\n addToImportMap(Object.values(resolvedFeature.componentImports))\n }\n }\n\n addToImportMap(resolvedFeature.ClientFeature)\n\n /*\n * Now run for all possible sub-fields\n */\n if (resolvedFeature.nodes?.length) {\n for (const node of resolvedFeature.nodes) {\n if (typeof node?.getSubFields !== 'function') {\n continue\n }\n const subFields = node.getSubFields({})\n if (subFields?.length) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: subFields,\n importMap,\n imports,\n })\n }\n }\n }\n }\n }\n"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ;AAK1C,OAAO,MAAMC,oBAAA,GACVC,IAAA,IAID,CAAC;EAAEC,cAAc;EAAEC,OAAO;EAAEC,MAAM;EAAEC,SAAS;EAAEC;AAAO,CAAE;EACtDJ,cAAA,CAAe;EACfA,cAAA,CAAe;EACfA,cAAA,CAAe;EAEfA,cAAA,CAAeD,IAAA,CAAKM,iBAAiB,EAAEC,KAAA;EAEvC,KAAK,MAAMC,eAAA,IAAmBR,IAAA,CAAKS,kBAAkB,CAACC,MAAM,IAAI;IAC9D,IAAI,sBAAsBF,eAAA,EAAiB;MACzC,IAAI,OAAOA,eAAA,CAAgBG,gBAAgB,KAAK,YAAY;QAC1DH,eAAA,CAAgBG,gBAAgB,CAAC;UAC/BV,cAAA;UACAC,OAAA;UACAC,MAAA;UACAC,SAAA;UACAC;QACF;MACF,OAAO,IAAIO,KAAA,CAAMC,OAAO,CAACL,eAAA,CAAgBG,gBAAgB,GAAG;QAC1DV,cAAA,CAAeO,eAAA,CAAgBG,gBAAgB;MACjD,OAAO,IAAI,OAAOH,eAAA,CAAgBG,gBAAgB,KAAK,UAAU;QAC/DV,cAAA,CAAea,MAAA,CAAOJ,MAAM,CAACF,eAAA,CAAgBG,gBAAgB;MAC/D;IACF;IAEAV,cAAA,CAAeO,eAAA,CAAgBO,aAAa;IAE5C;;;IAGA,IAAIP,eAAA,CAAgBQ,KAAK,EAAEC,MAAA,EAAQ;MACjC,KAAK,MAAMC,IAAA,IAAQV,eAAA,CAAgBQ,KAAK,EAAE;QACxC,IAAI,OAAOE,IAAA,EAAMC,YAAA,KAAiB,YAAY;UAC5C;QACF;QACA,MAAMC,SAAA,GAAYF,IAAA,CAAKC,YAAY,CAAC,CAAC;QACrC,IAAIC,SAAA,EAAWH,MAAA,EAAQ;UACrBnB,yBAAA,CAA0B;YACxBG,cAAA;YACAC,OAAA;YACAC,MAAA;YACAkB,MAAA,EAAQD,SAAA;YACRhB,SAAA;YACAC;UACF;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"generateImportMap.js","names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","lexicalEditorArgs","views","resolvedFeature","resolvedFeatureMap","values","componentImports","Array","isArray","Object","ClientFeature","nodes","length","node","getSubFields","subFields","fields"],"sources":["../../src/utilities/generateImportMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport { genImportMapIterateFields } from 'payload'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\nimport type { LexicalEditorArgs } from '../types/index.js'\n\nexport const getGenerateImportMap =\n (args: {\n lexicalEditorArgs?: LexicalEditorArgs\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateImportMap'] =>\n ({ addToImportMap, baseDir, config, importMap, imports }) => {\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell')\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField')\n addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent')\n\n addToImportMap(args.lexicalEditorArgs?.views)\n\n for (const resolvedFeature of args.resolvedFeatureMap.values()) {\n if ('componentImports' in resolvedFeature) {\n if (typeof resolvedFeature.componentImports === 'function') {\n resolvedFeature.componentImports({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n } else if (Array.isArray(resolvedFeature.componentImports)) {\n addToImportMap(resolvedFeature.componentImports)\n } else if (typeof resolvedFeature.componentImports === 'object') {\n addToImportMap(Object.values(resolvedFeature.componentImports))\n }\n }\n\n addToImportMap(resolvedFeature.ClientFeature)\n\n /*\n * Now run for all possible sub-fields\n */\n if (resolvedFeature.nodes?.length) {\n for (const node of resolvedFeature.nodes) {\n if (typeof node?.getSubFields !== 'function') {\n continue\n }\n const subFields = node.getSubFields({})\n if (subFields?.length) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: subFields,\n importMap,\n imports,\n })\n }\n }\n }\n }\n }\n"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ;AAK1C,OAAO,MAAMC,oBAAA,GACVC,IAAA,IAID,CAAC;EAAEC,cAAc;EAAEC,OAAO;EAAEC,MAAM;EAAEC,SAAS;EAAEC;AAAO,CAAE;EACtDJ,cAAA,CAAe;EACfA,cAAA,CAAe;EACfA,cAAA,CAAe;EAEfA,cAAA,CAAeD,IAAA,CAAKM,iBAAiB,EAAEC,KAAA;EAEvC,KAAK,MAAMC,eAAA,IAAmBR,IAAA,CAAKS,kBAAkB,CAACC,MAAM,IAAI;IAC9D,IAAI,sBAAsBF,eAAA,EAAiB;MACzC,IAAI,OAAOA,eAAA,CAAgBG,gBAAgB,KAAK,YAAY;QAC1DH,eAAA,CAAgBG,gBAAgB,CAAC;UAC/BV,cAAA;UACAC,OAAA;UACAC,MAAA;UACAC,SAAA;UACAC;QACF;MACF,OAAO,IAAIO,KAAA,CAAMC,OAAO,CAACL,eAAA,CAAgBG,gBAAgB,GAAG;QAC1DV,cAAA,CAAeO,eAAA,CAAgBG,gBAAgB;MACjD,OAAO,IAAI,OAAOH,eAAA,CAAgBG,gBAAgB,KAAK,UAAU;QAC/DV,cAAA,CAAea,MAAA,CAAOJ,MAAM,CAACF,eAAA,CAAgBG,gBAAgB;MAC/D;IACF;IAEAV,cAAA,CAAeO,eAAA,CAAgBO,aAAa;IAE5C;;;IAGA,IAAIP,eAAA,CAAgBQ,KAAK,EAAEC,MAAA,EAAQ;MACjC,KAAK,MAAMC,IAAA,IAAQV,eAAA,CAAgBQ,KAAK,EAAE;QACxC,IAAI,OAAOE,IAAA,EAAMC,YAAA,KAAiB,YAAY;UAC5C;QACF;QACA,MAAMC,SAAA,GAAYF,IAAA,CAAKC,YAAY,CAAC,CAAC;QACrC,IAAIC,SAAA,EAAWH,MAAA,EAAQ;UACrBnB,yBAAA,CAA0B;YACxBG,cAAA;YACAC,OAAA;YACAC,MAAA;YACAkB,MAAA,EAAQD,SAAA;YACRhB,SAAA;YACAC;UACF;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import type { SanitizedConfig } from 'payload';
2
2
  import { type SanitizedServerEditorConfig } from '../index.js';
3
- export declare const getDefaultSanitizedEditorConfig: (args: {
3
+ export declare const getDefaultSanitizedEditorConfig: ({ config, parentIsLocalized, }: {
4
4
  config: SanitizedConfig;
5
5
  parentIsLocalized: boolean;
6
- }) => Promise<SanitizedServerEditorConfig>;
6
+ }) => SanitizedServerEditorConfig;
7
7
  //# sourceMappingURL=getDefaultSanitizedEditorConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDefaultSanitizedEditorConfig.d.ts","sourceRoot":"","sources":["../../src/utilities/getDefaultSanitizedEditorConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAgB9D,eAAO,MAAM,+BAA+B,SAAgB;IAC1D,MAAM,EAAE,eAAe,CAAA;IACvB,iBAAiB,EAAE,OAAO,CAAA;CAC3B,KAAG,OAAO,CAAC,2BAA2B,CAoBtC,CAAA"}
1
+ {"version":3,"file":"getDefaultSanitizedEditorConfig.d.ts","sourceRoot":"","sources":["../../src/utilities/getDefaultSanitizedEditorConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAQ9D,eAAO,MAAM,+BAA+B,mCAGzC;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,iBAAiB,EAAE,OAAO,CAAA;CAC3B,KAAG,2BAGH,CAAA"}
@@ -1,21 +1,10 @@
1
1
  import { defaultEditorConfig } from '../lexical/config/server/default.js';
2
2
  import { sanitizeServerEditorConfig } from '../lexical/config/server/sanitize.js';
3
- let cachedDefaultSanitizedServerEditorConfig = global._payload_lexical_defaultSanitizedServerEditorConfig;
4
- if (!cachedDefaultSanitizedServerEditorConfig) {
5
- cachedDefaultSanitizedServerEditorConfig = global._payload_lexical_defaultSanitizedServerEditorConfig = null;
6
- }
7
- export const getDefaultSanitizedEditorConfig = async args => {
8
- const {
9
- config,
10
- parentIsLocalized
11
- } = args;
12
- if (cachedDefaultSanitizedServerEditorConfig) {
13
- return await cachedDefaultSanitizedServerEditorConfig;
14
- }
15
- cachedDefaultSanitizedServerEditorConfig = sanitizeServerEditorConfig(defaultEditorConfig, config, parentIsLocalized);
16
- global.payload_lexical_defaultSanitizedServerEditorConfig = cachedDefaultSanitizedServerEditorConfig;
17
- cachedDefaultSanitizedServerEditorConfig = await cachedDefaultSanitizedServerEditorConfig;
18
- global.payload_lexical_defaultSanitizedServerEditorConfig = cachedDefaultSanitizedServerEditorConfig;
19
- return cachedDefaultSanitizedServerEditorConfig;
3
+ const lexicalGlobal = globalThis;
4
+ export const getDefaultSanitizedEditorConfig = ({
5
+ config,
6
+ parentIsLocalized
7
+ }) => {
8
+ return lexicalGlobal._payload_lexical_defaultSanitizedServerEditorConfig ??= sanitizeServerEditorConfig(defaultEditorConfig, config, parentIsLocalized);
20
9
  };
21
10
  //# sourceMappingURL=getDefaultSanitizedEditorConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDefaultSanitizedEditorConfig.js","names":["defaultEditorConfig","sanitizeServerEditorConfig","cachedDefaultSanitizedServerEditorConfig","global","_payload_lexical_defaultSanitizedServerEditorConfig","getDefaultSanitizedEditorConfig","args","config","parentIsLocalized","payload_lexical_defaultSanitizedServerEditorConfig"],"sources":["../../src/utilities/getDefaultSanitizedEditorConfig.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { type SanitizedServerEditorConfig } from '../index.js'\nimport { defaultEditorConfig } from '../lexical/config/server/default.js'\nimport { sanitizeServerEditorConfig } from '../lexical/config/server/sanitize.js'\n\nlet cachedDefaultSanitizedServerEditorConfig:\n | null\n | Promise<SanitizedServerEditorConfig>\n | SanitizedServerEditorConfig = (global as any)\n ._payload_lexical_defaultSanitizedServerEditorConfig\n\nif (!cachedDefaultSanitizedServerEditorConfig) {\n cachedDefaultSanitizedServerEditorConfig = (\n global as any\n )._payload_lexical_defaultSanitizedServerEditorConfig = null\n}\n\nexport const getDefaultSanitizedEditorConfig = async (args: {\n config: SanitizedConfig\n parentIsLocalized: boolean\n}): Promise<SanitizedServerEditorConfig> => {\n const { config, parentIsLocalized } = args\n\n if (cachedDefaultSanitizedServerEditorConfig) {\n return await cachedDefaultSanitizedServerEditorConfig\n }\n\n cachedDefaultSanitizedServerEditorConfig = sanitizeServerEditorConfig(\n defaultEditorConfig,\n config,\n parentIsLocalized,\n )\n ;(global as any).payload_lexical_defaultSanitizedServerEditorConfig =\n cachedDefaultSanitizedServerEditorConfig\n\n cachedDefaultSanitizedServerEditorConfig = await cachedDefaultSanitizedServerEditorConfig\n ;(global as any).payload_lexical_defaultSanitizedServerEditorConfig =\n cachedDefaultSanitizedServerEditorConfig\n\n return cachedDefaultSanitizedServerEditorConfig\n}\n"],"mappings":"AAGA,SAASA,mBAAmB,QAAQ;AACpC,SAASC,0BAA0B,QAAQ;AAE3C,IAAIC,wCAAA,GAG8BC,MAAC,CAChCC,mDAAmD;AAEtD,IAAI,CAACF,wCAAA,EAA0C;EAC7CA,wCAAA,GAA2CC,MACzC,CACAC,mDAAmD,GAAG;AAC1D;AAEA,OAAO,MAAMC,+BAAA,GAAkC,MAAOC,IAAA;EAIpD,MAAM;IAAEC,MAAM;IAAEC;EAAiB,CAAE,GAAGF,IAAA;EAEtC,IAAIJ,wCAAA,EAA0C;IAC5C,OAAO,MAAMA,wCAAA;EACf;EAEAA,wCAAA,GAA2CD,0BAAA,CACzCD,mBAAA,EACAO,MAAA,EACAC,iBAAA;EAEAL,MAAA,CAAeM,kDAAkD,GACjEP,wCAAA;EAEFA,wCAAA,GAA2C,MAAMA,wCAAA;EAC/CC,MAAA,CAAeM,kDAAkD,GACjEP,wCAAA;EAEF,OAAOA,wCAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"getDefaultSanitizedEditorConfig.js","names":["defaultEditorConfig","sanitizeServerEditorConfig","lexicalGlobal","globalThis","getDefaultSanitizedEditorConfig","config","parentIsLocalized","_payload_lexical_defaultSanitizedServerEditorConfig"],"sources":["../../src/utilities/getDefaultSanitizedEditorConfig.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { type SanitizedServerEditorConfig } from '../index.js'\nimport { defaultEditorConfig } from '../lexical/config/server/default.js'\nimport { sanitizeServerEditorConfig } from '../lexical/config/server/sanitize.js'\n\nconst lexicalGlobal = globalThis as {\n _payload_lexical_defaultSanitizedServerEditorConfig?: SanitizedServerEditorConfig\n} & typeof globalThis\n\nexport const getDefaultSanitizedEditorConfig = ({\n config,\n parentIsLocalized,\n}: {\n config: SanitizedConfig\n parentIsLocalized: boolean\n}): SanitizedServerEditorConfig => {\n return (lexicalGlobal._payload_lexical_defaultSanitizedServerEditorConfig ??=\n sanitizeServerEditorConfig(defaultEditorConfig, config, parentIsLocalized))\n}\n"],"mappings":"AAGA,SAASA,mBAAmB,QAAQ;AACpC,SAASC,0BAA0B,QAAQ;AAE3C,MAAMC,aAAA,GAAgBC,UAAA;AAItB,OAAO,MAAMC,+BAAA,GAAkCA,CAAC;EAC9CC,MAAM;EACNC;AAAiB,CAIlB;EACC,OAAQJ,aAAA,CAAcK,mDAAmD,KACvEN,0BAAA,CAA2BD,mBAAA,EAAqBK,MAAA,EAAQC,iBAAA;AAC5D","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"initLexicalFeatures.d.ts","sourceRoot":"","sources":["../../src/utilities/initLexicalFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAA;AAOtF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAC1F,KAAK,IAAI,GAAG;IACV,oBAAoB,EAAE,oBAAoB,CAAA;IAC1C,cAAc,EAAE,cAAc,CAAA;IAC9B,IAAI,EAAE,UAAU,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,qBAAqB,EAAE,2BAA2B,CAAA;IAClD,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG;IAC/C,cAAc,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAA;IAC3D,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3C,sBAAsB,EAAE,sBAAsB,CAAA;CAC/C,CA0FA"}
1
+ {"version":3,"file":"initLexicalFeatures.d.ts","sourceRoot":"","sources":["../../src/utilities/initLexicalFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAA;AAOtF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAC1F,KAAK,IAAI,GAAG;IACV,oBAAoB,EAAE,oBAAoB,CAAA;IAC1C,cAAc,EAAE,cAAc,CAAA;IAC9B,IAAI,EAAE,UAAU,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,qBAAqB,EAAE,2BAA2B,CAAA;IAClD,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG;IAC/C,cAAc,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAA;IAC3D,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3C,sBAAsB,EAAE,sBAAsB,CAAA;CAC/C,CA6FA"}
@@ -45,10 +45,11 @@ export function initLexicalFeatures(args) {
45
45
  const featureSchemaPath = `${args.schemaPath}.lexical_internal_feature.${featureKey}`;
46
46
  featureClientSchemaMap[featureKey] = {};
47
47
  // Like args.fieldSchemaMap, we only want to include the sub-fields of the current feature
48
- for (const [key, entry] of args.clientFieldSchemaMap.entries()) {
49
- if (key.startsWith(featureSchemaPath)) {
50
- featureClientSchemaMap[featureKey][key] = 'fields' in entry ? entry.fields : [entry];
51
- }
48
+ const featureEntries = getFeatureEntriesByPath({
49
+ clientFieldSchemaMap: args.clientFieldSchemaMap
50
+ }).get(featureSchemaPath) ?? new Map();
51
+ for (const [key, entry] of featureEntries) {
52
+ featureClientSchemaMap[featureKey][key] = 'fields' in entry ? entry.fields : [entry];
52
53
  }
53
54
  }
54
55
  if (resolvedFeature.componentImports && typeof resolvedFeature.componentImports === 'object' && !Array.isArray(resolvedFeature.componentImports)) {
@@ -69,4 +70,37 @@ export function initLexicalFeatures(args) {
69
70
  featureClientSchemaMap
70
71
  };
71
72
  }
73
+ const FEATURE_PATH_SEGMENT = '.lexical_internal_feature.';
74
+ const featureEntriesCache = new WeakMap();
75
+ /**
76
+ * Groups the client field schema map entries by the lexical feature they belong to,
77
+ * so each rich text field does not have to scan the whole client field schema map.
78
+ */
79
+ function getFeatureEntriesByPath({
80
+ clientFieldSchemaMap
81
+ }) {
82
+ const cachedEntriesByPath = featureEntriesCache.get(clientFieldSchemaMap);
83
+ if (cachedEntriesByPath) {
84
+ return cachedEntriesByPath;
85
+ }
86
+ const entriesByPath = new Map();
87
+ for (const [key, entry] of clientFieldSchemaMap) {
88
+ let segmentIndex = key.indexOf(FEATURE_PATH_SEGMENT);
89
+ // An entry of a rich text field nested in a feature also belongs to each outer feature
90
+ while (segmentIndex !== -1) {
91
+ const featureKeyStart = segmentIndex + FEATURE_PATH_SEGMENT.length;
92
+ const featureKeyEnd = key.indexOf('.', featureKeyStart);
93
+ const featurePath = featureKeyEnd === -1 ? key : key.slice(0, featureKeyEnd);
94
+ let featureEntries = entriesByPath.get(featurePath);
95
+ if (!featureEntries) {
96
+ featureEntries = new Map();
97
+ entriesByPath.set(featurePath, featureEntries);
98
+ }
99
+ featureEntries.set(key, entry);
100
+ segmentIndex = key.indexOf(FEATURE_PATH_SEGMENT, featureKeyStart);
101
+ }
102
+ }
103
+ featureEntriesCache.set(clientFieldSchemaMap, entriesByPath);
104
+ return entriesByPath;
105
+ }
72
106
  //# sourceMappingURL=initLexicalFeatures.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"initLexicalFeatures.js","names":["getFromImportMap","initLexicalFeatures","args","clientFeatures","resolvedFeatureMapArray","sanitizedEditorConfig","resolvedFeatureMap","sort","a","b","order","featureClientSchemaMap","featureClientImportMap","featureKey","resolvedFeature","ClientFeaturePayloadComponent","ClientFeature","clientFeatureProvider","importMap","payload","PayloadComponent","schemaPath","silent","clientFeatureProps","key","clientProps","generateSchemaMap","featureSchemaPath","entry","clientFieldSchemaMap","entries","startsWith","fields","componentImports","Array","isArray","payloadComponent","Object","resolvedComponent"],"sources":["../../src/utilities/initLexicalFeatures.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\n\nimport { type ClientFieldSchemaMap, type FieldSchemaMap, type Payload } from 'payload'\nimport { getFromImportMap } from 'payload/shared'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from '../features/typesClient.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { FeatureClientSchemaMap, LexicalRichTextFieldProps } from '../types/index.js'\ntype Args = {\n clientFieldSchemaMap: ClientFieldSchemaMap\n fieldSchemaMap: FieldSchemaMap\n i18n: I18nClient\n path: string\n payload: Payload\n sanitizedEditorConfig: SanitizedServerEditorConfig\n schemaPath: string\n}\n\nexport function initLexicalFeatures(args: Args): {\n clientFeatures: LexicalRichTextFieldProps['clientFeatures']\n featureClientImportMap: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n} {\n const clientFeatures: LexicalRichTextFieldProps['clientFeatures'] = {}\n\n // turn args.resolvedFeatureMap into an array of [key, value] pairs, ordered by value.order, lowest order first:\n const resolvedFeatureMapArray = [...args.sanitizedEditorConfig.resolvedFeatureMap].sort(\n (a, b) => a[1].order - b[1].order,\n )\n\n const featureClientSchemaMap: FeatureClientSchemaMap = {}\n\n /**\n * All modules added to the import map, keyed by the provided key, if feature.componentImports with type object is used\n */\n const featureClientImportMap: Record<string, any> | undefined = {}\n\n for (const [featureKey, resolvedFeature] of resolvedFeatureMapArray) {\n clientFeatures[featureKey] = {}\n\n /**\n * Handle client features\n */\n const ClientFeaturePayloadComponent = resolvedFeature.ClientFeature\n\n if (ClientFeaturePayloadComponent) {\n const clientFeatureProvider = getFromImportMap<FeatureProviderProviderClient>({\n importMap: args.payload.importMap,\n PayloadComponent: ClientFeaturePayloadComponent,\n schemaPath: 'lexical-clientComponent',\n silent: true,\n })\n\n if (!clientFeatureProvider) {\n continue\n }\n\n const clientFeatureProps: BaseClientFeatureProps<Record<string, any>> =\n resolvedFeature.clientFeatureProps ?? {}\n clientFeatureProps.featureKey = resolvedFeature.key\n clientFeatureProps.order = resolvedFeature.order\n if (\n typeof ClientFeaturePayloadComponent === 'object' &&\n ClientFeaturePayloadComponent.clientProps\n ) {\n clientFeatureProps.clientProps = ClientFeaturePayloadComponent.clientProps\n }\n // As clientFeatureProvider is a client function, we cannot execute it on the server here. Thus, the client will have to execute clientFeatureProvider with its props\n clientFeatures[featureKey] = { clientFeatureProps, clientFeatureProvider }\n }\n\n /**\n * Handle sub-fields (formstate of those)\n */\n // The args.fieldSchemaMap generated before in buildFormState should contain all of lexical features' sub-field schemas\n // as well, as it already called feature.generateSchemaMap for each feature.\n // We will check for the existance resolvedFeature.generateSchemaMap to skip unnecessary loops for constructing featureSchemaMap, but we don't run it here\n if (resolvedFeature.generateSchemaMap) {\n const featureSchemaPath = `${args.schemaPath}.lexical_internal_feature.${featureKey}`\n\n featureClientSchemaMap[featureKey] = {}\n\n // Like args.fieldSchemaMap, we only want to include the sub-fields of the current feature\n for (const [key, entry] of args.clientFieldSchemaMap.entries()) {\n if (key.startsWith(featureSchemaPath)) {\n featureClientSchemaMap[featureKey][key] = 'fields' in entry ? entry.fields : [entry]\n }\n }\n }\n\n if (\n resolvedFeature.componentImports &&\n typeof resolvedFeature.componentImports === 'object' &&\n !Array.isArray(resolvedFeature.componentImports)\n ) {\n for (const [key, payloadComponent] of Object.entries(resolvedFeature.componentImports)) {\n const resolvedComponent = getFromImportMap({\n importMap: args.payload.importMap,\n PayloadComponent: payloadComponent,\n schemaPath: 'lexical-clientComponent',\n silent: true,\n })\n\n featureClientImportMap[`${resolvedFeature.key}.${key}`] = resolvedComponent\n }\n }\n }\n return {\n clientFeatures,\n featureClientImportMap,\n featureClientSchemaMap,\n }\n}\n"],"mappings":"AAGA,SAASA,gBAAgB,QAAQ;AAkBjC,OAAO,SAASC,oBAAoBC,IAAU;EAK5C,MAAMC,cAAA,GAA8D,CAAC;EAErE;EACA,MAAMC,uBAAA,GAA0B,C,GAAIF,IAAA,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EtC;MACA,KAAK,MAAM,CAACW,GAAA,EAAKI,KAAA,CAAM,IAAI1B,IAAA,CAAK2B,oBAAoB,CAACC,OAAO,IAAI;QAC9D,IAAIN,GAAA,CAAIO,UAAU,CAACJ,iBAAA,GAAoB;UACrChB,sBAAsB,CAACE,UAAA,CAAW,CAACW,GAAA,CAAI,GAAG,YAAYI,KAAA,GAAQA,KAAA,CAAMI,MAAM,GAAG,CAACJ,KAAA,CAAM;QACtF;MACF;IACF;IAEA,IACEd,eAAA,CAAgBmB,gBAAgB,IAChC,OAAOnB,eAAA,CAAgBmB,gBAAgB,KAAK,YAC5C,CAACC,KAAA,CAAMC,OAAO,CAACrB,eAAA,CAAgBmB,gBAAgB,GAC/C;MACA,KAAK,MAAM,CAACT,GAAA,EAAKY,gBAAA,CAAiB,IAAIC,MAAA,CAAOP,OAAO,CAAChB,eAAA,CAAgBmB,gBAAgB,GAAG;QACtF,MAAMK,iBAAA,GAAoBtC,gBAAA,CAAiB;UACzCkB,SAAA,EAAWhB,IAAA,CAAKiB,OAAO,CAACD,SAAS;UACjCE,gBAAA,EAAkBgB,gBAAA;UAClBf,UAAA,EAAY;UACZC,MAAA,EAAQ;QACV;QAEAV,sBAAsB,CAAC,GAAGE,eAAA,CAAgBU,GAAG,IAAIA,GAAA,EAAK,CAAC,GAAGc,iBAAA;MAC5D;IACF;EACF;EACA,OAAO;IACLnC,cAAA;IACAS,sBAAA;IACAD;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"initLexicalFeatures.js","names":["getFromImportMap","initLexicalFeatures","args","clientFeatures","resolvedFeatureMapArray","sanitizedEditorConfig","resolvedFeatureMap","sort","a","b","order","featureClientSchemaMap","featureClientImportMap","featureKey","resolvedFeature","ClientFeaturePayloadComponent","ClientFeature","clientFeatureProvider","importMap","payload","PayloadComponent","schemaPath","silent","clientFeatureProps","key","clientProps","generateSchemaMap","featureSchemaPath","featureEntries","getFeatureEntriesByPath","clientFieldSchemaMap","get","Map","entry","fields","componentImports","Array","isArray","payloadComponent","Object","entries","resolvedComponent","FEATURE_PATH_SEGMENT","featureEntriesCache","WeakMap","cachedEntriesByPath","entriesByPath","segmentIndex","indexOf","featureKeyStart","length","featureKeyEnd","featurePath","slice","set"],"sources":["../../src/utilities/initLexicalFeatures.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\n\nimport { type ClientFieldSchemaMap, type FieldSchemaMap, type Payload } from 'payload'\nimport { getFromImportMap } from 'payload/shared'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from '../features/typesClient.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { FeatureClientSchemaMap, LexicalRichTextFieldProps } from '../types/index.js'\ntype Args = {\n clientFieldSchemaMap: ClientFieldSchemaMap\n fieldSchemaMap: FieldSchemaMap\n i18n: I18nClient\n path: string\n payload: Payload\n sanitizedEditorConfig: SanitizedServerEditorConfig\n schemaPath: string\n}\n\nexport function initLexicalFeatures(args: Args): {\n clientFeatures: LexicalRichTextFieldProps['clientFeatures']\n featureClientImportMap: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n} {\n const clientFeatures: LexicalRichTextFieldProps['clientFeatures'] = {}\n\n // turn args.resolvedFeatureMap into an array of [key, value] pairs, ordered by value.order, lowest order first:\n const resolvedFeatureMapArray = [...args.sanitizedEditorConfig.resolvedFeatureMap].sort(\n (a, b) => a[1].order - b[1].order,\n )\n\n const featureClientSchemaMap: FeatureClientSchemaMap = {}\n\n /**\n * All modules added to the import map, keyed by the provided key, if feature.componentImports with type object is used\n */\n const featureClientImportMap: Record<string, any> | undefined = {}\n\n for (const [featureKey, resolvedFeature] of resolvedFeatureMapArray) {\n clientFeatures[featureKey] = {}\n\n /**\n * Handle client features\n */\n const ClientFeaturePayloadComponent = resolvedFeature.ClientFeature\n\n if (ClientFeaturePayloadComponent) {\n const clientFeatureProvider = getFromImportMap<FeatureProviderProviderClient>({\n importMap: args.payload.importMap,\n PayloadComponent: ClientFeaturePayloadComponent,\n schemaPath: 'lexical-clientComponent',\n silent: true,\n })\n\n if (!clientFeatureProvider) {\n continue\n }\n\n const clientFeatureProps: BaseClientFeatureProps<Record<string, any>> =\n resolvedFeature.clientFeatureProps ?? {}\n clientFeatureProps.featureKey = resolvedFeature.key\n clientFeatureProps.order = resolvedFeature.order\n if (\n typeof ClientFeaturePayloadComponent === 'object' &&\n ClientFeaturePayloadComponent.clientProps\n ) {\n clientFeatureProps.clientProps = ClientFeaturePayloadComponent.clientProps\n }\n // As clientFeatureProvider is a client function, we cannot execute it on the server here. Thus, the client will have to execute clientFeatureProvider with its props\n clientFeatures[featureKey] = { clientFeatureProps, clientFeatureProvider }\n }\n\n /**\n * Handle sub-fields (formstate of those)\n */\n // The args.fieldSchemaMap generated before in buildFormState should contain all of lexical features' sub-field schemas\n // as well, as it already called feature.generateSchemaMap for each feature.\n // We will check for the existance resolvedFeature.generateSchemaMap to skip unnecessary loops for constructing featureSchemaMap, but we don't run it here\n if (resolvedFeature.generateSchemaMap) {\n const featureSchemaPath = `${args.schemaPath}.lexical_internal_feature.${featureKey}`\n\n featureClientSchemaMap[featureKey] = {}\n\n // Like args.fieldSchemaMap, we only want to include the sub-fields of the current feature\n const featureEntries: ClientFieldSchemaMap =\n getFeatureEntriesByPath({ clientFieldSchemaMap: args.clientFieldSchemaMap }).get(\n featureSchemaPath,\n ) ?? new Map()\n\n for (const [key, entry] of featureEntries) {\n featureClientSchemaMap[featureKey][key] = 'fields' in entry ? entry.fields : [entry]\n }\n }\n\n if (\n resolvedFeature.componentImports &&\n typeof resolvedFeature.componentImports === 'object' &&\n !Array.isArray(resolvedFeature.componentImports)\n ) {\n for (const [key, payloadComponent] of Object.entries(resolvedFeature.componentImports)) {\n const resolvedComponent = getFromImportMap({\n importMap: args.payload.importMap,\n PayloadComponent: payloadComponent,\n schemaPath: 'lexical-clientComponent',\n silent: true,\n })\n\n featureClientImportMap[`${resolvedFeature.key}.${key}`] = resolvedComponent\n }\n }\n }\n return {\n clientFeatures,\n featureClientImportMap,\n featureClientSchemaMap,\n }\n}\n\nconst FEATURE_PATH_SEGMENT = '.lexical_internal_feature.'\n\nconst featureEntriesCache = new WeakMap<ClientFieldSchemaMap, Map<string, ClientFieldSchemaMap>>()\n\n/**\n * Groups the client field schema map entries by the lexical feature they belong to,\n * so each rich text field does not have to scan the whole client field schema map.\n */\nfunction getFeatureEntriesByPath({\n clientFieldSchemaMap,\n}: {\n clientFieldSchemaMap: ClientFieldSchemaMap\n}): Map<string, ClientFieldSchemaMap> {\n const cachedEntriesByPath = featureEntriesCache.get(clientFieldSchemaMap)\n\n if (cachedEntriesByPath) {\n return cachedEntriesByPath\n }\n\n const entriesByPath = new Map<string, ClientFieldSchemaMap>()\n\n for (const [key, entry] of clientFieldSchemaMap) {\n let segmentIndex = key.indexOf(FEATURE_PATH_SEGMENT)\n\n // An entry of a rich text field nested in a feature also belongs to each outer feature\n while (segmentIndex !== -1) {\n const featureKeyStart = segmentIndex + FEATURE_PATH_SEGMENT.length\n const featureKeyEnd = key.indexOf('.', featureKeyStart)\n const featurePath = featureKeyEnd === -1 ? key : key.slice(0, featureKeyEnd)\n\n let featureEntries = entriesByPath.get(featurePath)\n\n if (!featureEntries) {\n featureEntries = new Map()\n entriesByPath.set(featurePath, featureEntries)\n }\n\n featureEntries.set(key, entry)\n\n segmentIndex = key.indexOf(FEATURE_PATH_SEGMENT, featureKeyStart)\n }\n }\n\n featureEntriesCache.set(clientFieldSchemaMap, entriesByPath)\n\n return entriesByPath\n}\n"],"mappings":"AAGA,SAASA,gBAAgB,QAAQ;AAkBjC,OAAO,SAASC,oBAAoBC,IAAU;EAK5C,MAAMC,cAAA,GAA8D,CAAC;EAErE;EACA,MAAMC,uBAAA,GAA0B,C,GAAIF,IAAA,CAAKG,qBAAqB,CAACC,kBAAkB,CAAC,CAACC,IAAI,CACrF,CAACC,CAAA,EAAGC,CAAA,KAAMD,CAAC,CAAC,EAAE,CAACE,KAAK,GAAGD,CAAC,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AE/B;IACA,OAAOK,YAAA,KAAiB,CAAC,GAAG;MAC1B,MAAME,eAAA,GAAkBF,YAAA,GAAeL,oBAAA,CAAqBQ,MAAM;MAClE,MAAMC,aAAA,GAAgB3B,GAAA,CAAIwB,OAAO,CAAC,KAAKC,eAAA;MACvC,MAAMG,WAAA,GAAcD,aAAA,KAAkB,CAAC,IAAI3B,GAAA,GAAMA,GAAA,CAAI6B,KAAK,CAAC,GAAGF,aAAA;MAE9D,IAAIvB,cAAA,GAAiBkB,aAAA,CAAcf,GAAG,CAACqB,WAAA;MAEvC,IAAI,CAACxB,cAAA,EAAgB;QACnBA,cAAA,GAAiB,IAAII,GAAA;QACrBc,aAAA,CAAcQ,GAAG,CAACF,WAAA,EAAaxB,cAAA;MACjC;MAEAA,cAAA,CAAe0B,GAAG,CAAC9B,GAAA,EAAKS,KAAA;MAExBc,YAAA,GAAevB,GAAA,CAAIwB,OAAO,CAACN,oBAAA,EAAsBO,eAAA;IACnD;EACF;EAEAN,mBAAA,CAAoBW,GAAG,CAACxB,oBAAA,EAAsBgB,aAAA;EAE9C,OAAOA,aAAA;AACT","ignoreList":[]}
@@ -54,7 +54,8 @@ async function upgradeGlobal({
54
54
  slug: global.slug,
55
55
  data: document,
56
56
  depth: 0,
57
- locale: locale || undefined
57
+ locale: locale || undefined,
58
+ overrideAccess: true
58
59
  });
59
60
  }
60
61
  }
@@ -68,7 +69,8 @@ async function upgradeCollection({
68
69
  console.log(`Lexical Upgrade: ${locale}: Upgrading collection:`, collection.slug, '(' + cur + '/' + max + ')');
69
70
  const documentCount = (await payload.count({
70
71
  collection: collection.slug,
71
- locale: locale || undefined
72
+ locale: locale || undefined,
73
+ overrideAccess: true
72
74
  })).totalDocs;
73
75
  let page = 1;
74
76
  let upgraded = 0;
@@ -95,7 +97,8 @@ async function upgradeCollection({
95
97
  collection: collection.slug,
96
98
  data: document,
97
99
  depth: 0,
98
- locale: locale || undefined
100
+ locale: locale || undefined,
101
+ overrideAccess: true
99
102
  });
100
103
  }
101
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["upgradeDocumentFieldsRecursively","upgradeLexicalData","payload","collections","config","allLocales","localization","localeCodes","totalCollections","length","locale","curCollection","collection","upgradeCollection","cur","max","global","globals","upgradeGlobal","console","log","slug","document","findGlobal","depth","undefined","overrideAccess","found","upgradeDocument","fields","updateGlobal","data","documentCount","count","totalDocs","page","upgraded","documents","find","pagination","docs","id","update"],"sources":["../../../src/utilities/upgradeLexicalData/index.ts"],"sourcesContent":["import type { CollectionConfig, Field, GlobalConfig, Payload } from 'payload'\n\nimport { upgradeDocumentFieldsRecursively } from './upgradeDocumentFieldsRecursively.js'\n\n/**\n * This goes through every single document in your payload app and re-saves it, if it has a lexical editor.\n * This way, the data is automatically converted to the new format, and that automatic conversion gets applied to every single document in your app.\n *\n * @param payload\n */\nexport async function upgradeLexicalData({ payload }: { payload: Payload }) {\n const collections = payload.config.collections\n\n const allLocales = payload.config.localization ? payload.config.localization.localeCodes : [null]\n\n const totalCollections = collections.length\n for (const locale of allLocales) {\n let curCollection = 0\n for (const collection of collections) {\n curCollection++\n await upgradeCollection({\n collection,\n cur: curCollection,\n locale,\n max: totalCollections,\n payload,\n })\n }\n for (const global of payload.config.globals) {\n await upgradeGlobal({\n global,\n locale,\n payload,\n })\n }\n }\n}\n\nasync function upgradeGlobal({\n global,\n locale,\n payload,\n}: {\n global: GlobalConfig\n locale: null | string\n payload: Payload\n}) {\n console.log(`Lexical Upgrader: ${locale}: Upgrading global:`, global.slug)\n\n const document = await payload.findGlobal({\n slug: global.slug,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n })\n\n const found = upgradeDocument({\n document,\n fields: global.fields,\n payload,\n })\n\n if (found) {\n await payload.updateGlobal({\n slug: global.slug,\n data: document,\n depth: 0,\n locale: locale || undefined,\n })\n }\n}\n\nasync function upgradeCollection({\n collection,\n cur,\n locale,\n max,\n payload,\n}: {\n collection: CollectionConfig\n cur: number\n locale: null | string\n max: number\n payload: Payload\n}) {\n console.log(\n `Lexical Upgrade: ${locale}: Upgrading collection:`,\n collection.slug,\n '(' + cur + '/' + max + ')',\n )\n\n const documentCount = (\n await payload.count({\n collection: collection.slug,\n locale: locale || undefined,\n })\n ).totalDocs\n\n let page = 1\n let upgraded = 0\n\n while (upgraded < documentCount) {\n const documents = await payload.find({\n collection: collection.slug,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n page,\n pagination: true,\n })\n\n for (const document of documents.docs) {\n upgraded++\n console.log(\n `Lexical Upgrade: ${locale}: Upgrading collection:`,\n collection.slug,\n '(' +\n cur +\n '/' +\n max +\n ') - Upgrading Document: ' +\n document.id +\n ' (' +\n upgraded +\n '/' +\n documentCount +\n ')',\n )\n const found = upgradeDocument({\n document,\n fields: collection.fields,\n payload,\n })\n\n if (found) {\n await payload.update({\n id: document.id,\n collection: collection.slug,\n data: document,\n depth: 0,\n locale: locale || undefined,\n })\n }\n }\n page++\n }\n}\n\nfunction upgradeDocument({\n document,\n fields,\n payload,\n}: {\n document: Record<string, unknown>\n fields: Field[]\n payload: Payload\n}): boolean {\n return !!upgradeDocumentFieldsRecursively({\n data: document,\n fields,\n found: 0,\n payload,\n })\n}\n"],"mappings":"AAEA,SAASA,gCAAgC,QAAQ;AAEjD;;;;;;AAMA,OAAO,eAAeC,mBAAmB;EAAEC;AAAO,CAAwB;EACxE,MAAMC,WAAA,GAAcD,OAAA,CAAQE,MAAM,CAACD,WAAW;EAE9C,MAAME,UAAA,GAAaH,OAAA,CAAQE,MAAM,CAACE,YAAY,GAAGJ,OAAA,CAAQE,MAAM,CAACE,YAAY,CAACC,WAAW,GAAG,CAAC,KAAK;EAEjG,MAAMC,gBAAA,GAAmBL,WAAA,CAAYM,MAAM;EAC3C,KAAK,MAAMC,MAAA,IAAUL,UAAA,EAAY;IAC/B,IAAIM,aAAA,GAAgB;IACpB,KAAK,MAAMC,UAAA,IAAcT,WAAA,EAAa;MACpCQ,aAAA;MACA,MAAME,iBAAA,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MAAA,IAAUe;EACpB,EAAC,EACDS,SAAS;EAEX,IAAIC,IAAA,GAAO;EACX,IAAIC,QAAA,GAAW;EAEf,OAAOA,QAAA,GAAWJ,aAAA,EAAe;IAC/B,MAAMK,SAAA,GAAY,MAAMnC,OAAA,CAAQoC,IAAI,CAAC;MACnC1B,UAAA,EAAYA,UAAA,CAAWS,IAAI;MAC3BG,KAAA,EAAO;MACPd,MAAA,EAAQA,MAAA,IAAUe,SAAA;MAClBC,cAAA,EAAgB;MAChBS,IAAA;MACAI,UAAA,EAAY;IACd;IAEA,KAAK,MAAMjB,QAAA,IAAYe,SAAA,CAAUG,IAAI,EAAE;MACrCJ,QAAA;MACAjB,OAAA,CAAQC,GAAG,CACT,oBAAoBV,MAAA,yBAA+B,EACnDE,UAAA,CAAWS,IAAI,EACf,MACEP,GAAA,GACA,MACAC,GAAA,GACA,6BACAO,QAAA,CAASmB,EAAE,GACX,OACAL,QAAA,GACA,MACAJ,aAAA,GACA;MAEJ,MAAML,KAAA,GAAQC,eAAA,CAAgB;QAC5BN,QAAA;QACAO,MAAA,EAAQjB,UAAA,CAAWiB,MAAM;QACzB3B;MACF;MAEA,IAAIyB,KAAA,EAAO;QACT,MAAMzB,OAAA,CAAQwC,MAAM,CAAC;UACnBD,EAAA,EAAInB,QAAA,CAASmB,EAAE;UACf7B,UAAA,EAAYA,UAAA,CAAWS,IAAI;UAC3BU,IAAA,EAAMT,QAAA;UACNE,KAAA,EAAO;UACPd,MAAA,EAAQA,MAAA,IAAUe;QACpB;MACF;IACF;IACAU,IAAA;EACF;AACF;AAEA,SAASP,gBAAgB;EACvBN,QAAQ;EACRO,MAAM;EACN3B;AAAO,CAKR;EACC,OAAO,CAAC,CAACF,gCAAA,CAAiC;IACxC+B,IAAA,EAAMT,QAAA;IACNO,MAAA;IACAF,KAAA,EAAO;IACPzB;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["upgradeDocumentFieldsRecursively","upgradeLexicalData","payload","collections","config","allLocales","localization","localeCodes","totalCollections","length","locale","curCollection","collection","upgradeCollection","cur","max","global","globals","upgradeGlobal","console","log","slug","document","findGlobal","depth","undefined","overrideAccess","found","upgradeDocument","fields","updateGlobal","data","documentCount","count","totalDocs","page","upgraded","documents","find","pagination","docs","id","update"],"sources":["../../../src/utilities/upgradeLexicalData/index.ts"],"sourcesContent":["import type { CollectionConfig, Field, GlobalConfig, Payload } from 'payload'\n\nimport { upgradeDocumentFieldsRecursively } from './upgradeDocumentFieldsRecursively.js'\n\n/**\n * This goes through every single document in your payload app and re-saves it, if it has a lexical editor.\n * This way, the data is automatically converted to the new format, and that automatic conversion gets applied to every single document in your app.\n *\n * @param payload\n */\nexport async function upgradeLexicalData({ payload }: { payload: Payload }) {\n const collections = payload.config.collections\n\n const allLocales = payload.config.localization ? payload.config.localization.localeCodes : [null]\n\n const totalCollections = collections.length\n for (const locale of allLocales) {\n let curCollection = 0\n for (const collection of collections) {\n curCollection++\n await upgradeCollection({\n collection,\n cur: curCollection,\n locale,\n max: totalCollections,\n payload,\n })\n }\n for (const global of payload.config.globals) {\n await upgradeGlobal({\n global,\n locale,\n payload,\n })\n }\n }\n}\n\nasync function upgradeGlobal({\n global,\n locale,\n payload,\n}: {\n global: GlobalConfig\n locale: null | string\n payload: Payload\n}) {\n console.log(`Lexical Upgrader: ${locale}: Upgrading global:`, global.slug)\n\n const document = await payload.findGlobal({\n slug: global.slug,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n })\n\n const found = upgradeDocument({\n document,\n fields: global.fields,\n payload,\n })\n\n if (found) {\n await payload.updateGlobal({\n slug: global.slug,\n data: document,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n })\n }\n}\n\nasync function upgradeCollection({\n collection,\n cur,\n locale,\n max,\n payload,\n}: {\n collection: CollectionConfig\n cur: number\n locale: null | string\n max: number\n payload: Payload\n}) {\n console.log(\n `Lexical Upgrade: ${locale}: Upgrading collection:`,\n collection.slug,\n '(' + cur + '/' + max + ')',\n )\n\n const documentCount = (\n await payload.count({\n collection: collection.slug,\n locale: locale || undefined,\n overrideAccess: true,\n })\n ).totalDocs\n\n let page = 1\n let upgraded = 0\n\n while (upgraded < documentCount) {\n const documents = await payload.find({\n collection: collection.slug,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n page,\n pagination: true,\n })\n\n for (const document of documents.docs) {\n upgraded++\n console.log(\n `Lexical Upgrade: ${locale}: Upgrading collection:`,\n collection.slug,\n '(' +\n cur +\n '/' +\n max +\n ') - Upgrading Document: ' +\n document.id +\n ' (' +\n upgraded +\n '/' +\n documentCount +\n ')',\n )\n const found = upgradeDocument({\n document,\n fields: collection.fields,\n payload,\n })\n\n if (found) {\n await payload.update({\n id: document.id,\n collection: collection.slug,\n data: document,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n })\n }\n }\n page++\n }\n}\n\nfunction upgradeDocument({\n document,\n fields,\n payload,\n}: {\n document: Record<string, unknown>\n fields: Field[]\n payload: Payload\n}): boolean {\n return !!upgradeDocumentFieldsRecursively({\n data: document,\n fields,\n found: 0,\n payload,\n })\n}\n"],"mappings":"AAEA,SAASA,gCAAgC,QAAQ;AAEjD;;;;;;AAMA,OAAO,eAAeC,mBAAmB;EAAEC;AAAO,CAAwB;EACxE,MAAMC,WAAA,GAAcD,OAAA,CAAQE,MAAM,CAACD,WAAW;EAE9C,MAAME,UAAA,GAAaH,OAAA,CAAQE,MAAM,CAACE,YAAY,GAAGJ,OAAA,CAAQE,MAAM,CAACE,YAAY,CAACC,WAAW,GAAG,CAAC,KAAK;EAEjG,MAAMC,gBAAA,GAAmBL,WAAA,CAAYM,MAAM;EAC3C,KAAK,MAAMC,MAAA,IAAUL,UAAA,EAAY;IAC/B,IAAIM,aAAA,GAAgB;IACpB,KAAK,MAAMC,UAAA,IAAcT,WAAA,EAAa;MACpCQ,aAAA;MACA,MAAME,iBAAA,CAAkB;QACtBD,UAAA;QACAE,GAAA,EAAKH,aAAA;QACLD,MAAA;QAC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c } from "react/compiler-runtime";
3
4
  import { useAddClientFunction } from '@payloadcms/ui';
4
5
  import { useEditorConfigContext } from '../lexical/config/client/EditorConfigProvider.js';
5
6
  export const useLexicalFeature = (featureKey, feature) => {
7
+ const $ = _c(1);
6
8
  const {
7
9
  fieldProps: t0
8
10
  } = useEditorConfigContext();
9
11
  const {
10
12
  schemaPath: schemaPathFromFieldProps
11
13
  } = t0;
12
- const tableCell = {
13
- cellProps: {
14
- schemaPath: []
15
- }
16
- };
17
- const schemaPathFromCellProps = tableCell?.cellProps?.schemaPath ? tableCell?.cellProps?.schemaPath.join(".") : null;
14
+ let t1;
15
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
16
+ const tableCell = {
17
+ cellProps: {
18
+ schemaPath: []
19
+ }
20
+ };
21
+ t1 = tableCell?.cellProps?.schemaPath ? tableCell?.cellProps?.schemaPath.join(".") : null;
22
+ $[0] = t1;
23
+ } else {
24
+ t1 = $[0];
25
+ }
26
+ const schemaPathFromCellProps = t1;
18
27
  const schemaPath = schemaPathFromCellProps || schemaPathFromFieldProps;
19
28
  useAddClientFunction(`lexicalFeature.${schemaPath}.${featureKey}`, feature);
20
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useLexicalFeature.js","names":["useAddClientFunction","useEditorConfigContext","useLexicalFeature","featureKey","feature","fieldProps","t0","schemaPath","schemaPathFromFieldProps","tableCell","cellProps","schemaPathFromCellProps","join"],"sources":["../../src/utilities/useLexicalFeature.tsx"],"sourcesContent":["'use client'\n\nimport { useAddClientFunction } from '@payloadcms/ui'\n\nimport type { FeatureProviderClient } from '../features/typesClient.js'\n\nimport { useEditorConfigContext } from '../lexical/config/client/EditorConfigProvider.js'\n\nexport const useLexicalFeature = <ClientFeatureProps,>(\n featureKey: string,\n feature: FeatureProviderClient<ClientFeatureProps>,\n) => {\n const {\n fieldProps: { schemaPath: schemaPathFromFieldProps },\n } = useEditorConfigContext()\n const tableCell = { cellProps: { schemaPath: [] } } // TODO: get tableCell from props\n // const tableCell = useTableCell()\n\n const schemaPathFromCellProps = tableCell?.cellProps?.schemaPath\n ? tableCell?.cellProps?.schemaPath.join('.')\n : null\n\n const schemaPath = schemaPathFromCellProps || schemaPathFromFieldProps // schemaPathFromCellProps needs to have priority, as there can be cells within fields (e.g. list drawers) and the cell schemaPath needs to be used there - not the parent field schemaPath. There cannot be fields within cells.\n\n useAddClientFunction(`lexicalFeature.${schemaPath}.${featureKey}`, feature)\n}\n"],"mappings":"AAAA;;AAEA,SAASA,oBAAoB,QAAQ;AAIrC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,iBAAA,GAAoBA,CAAAC,UAAA,EAAAC,OAAA;EAI/B;IAAAC,UAAA,EAAAC;EAAA,IAEIL,sBAAA;EADU;IAAAM,UAAA,EAAAC;EAAA,IAAAF,EAAwC;EAEtD,MAAAG,SAAA;IAAAC,SAAA;MAAAH,UAAA;IAAA;EAAA;EAGA,MAAAI,uBAAA,GAAgCF,SAAA,EAAAC,SAAA,EAAAH,UAAA,GAC5BE,SAAA,EAAAC,SAAA,EAAAH,UAAA,CAAAK,IAAA,CAAsC,WACtC;EAEJ,MAAAL,UAAA,GAAmBI,uBAAA,IAA2BH,wBAAA;EAE9CR,oBAAA,CAAqB,kBAAkBO,UAAA,IAAcJ,UAAA,EAAY,EAAEC,OAAA;AAAA,CACrE","ignoreList":[]}
1
+ {"version":3,"file":"useLexicalFeature.js","names":["c","_c","useAddClientFunction","useEditorConfigContext","useLexicalFeature","featureKey","feature","$","fieldProps","t0","schemaPath","schemaPathFromFieldProps","t1","Symbol","for","tableCell","cellProps","join","schemaPathFromCellProps"],"sources":["../../src/utilities/useLexicalFeature.tsx"],"sourcesContent":["'use client'\n\nimport { useAddClientFunction } from '@payloadcms/ui'\n\nimport type { FeatureProviderClient } from '../features/typesClient.js'\n\nimport { useEditorConfigContext } from '../lexical/config/client/EditorConfigProvider.js'\n\nexport const useLexicalFeature = <ClientFeatureProps,>(\n featureKey: string,\n feature: FeatureProviderClient<ClientFeatureProps>,\n) => {\n const {\n fieldProps: { schemaPath: schemaPathFromFieldProps },\n } = useEditorConfigContext()\n const tableCell = { cellProps: { schemaPath: [] } } // TODO: get tableCell from props\n // const tableCell = useTableCell()\n\n const schemaPathFromCellProps = tableCell?.cellProps?.schemaPath\n ? tableCell?.cellProps?.schemaPath.join('.')\n : null\n\n const schemaPath = schemaPathFromCellProps || schemaPathFromFieldProps // schemaPathFromCellProps needs to have priority, as there can be cells within fields (e.g. list drawers) and the cell schemaPath needs to be used there - not the parent field schemaPath. There cannot be fields within cells.\n\n useAddClientFunction(`lexicalFeature.${schemaPath}.${featureKey}`, feature)\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,oBAAoB,QAAQ;AAIrC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,iBAAA,GAAoBA,CAAAC,UAAA,EAAAC,OAAA;EAAA,MAAAC,CAAA,GAAAN,EAAA;EAI/B;IAAAO,UAAA,EAAAC;EAAA,IAEIN,sBAAA;EADU;IAAAO,UAAA,EAAAC;EAAA,IAAAF,EAAwC;EAAA,IAAAG,EAAA;EAAA,IAAAL,CAAA,QAAAM,MAAA,CAAAC,GAAA;IAEtD,MAAAC,SAAA,GAAkB;MAAAC,SAAA,EAAa;QAAAN,UAAA,EAAc;MAAG;IAAE;IAGlBE,EAAA,GAAAG,SAAA,EAAAC,SAAsB,EAAAN,UAElD,GADAK,SAAA,EAAAC,SAAsB,EAAAN,UAAW,CAAAO,IAAK,IACtC,IAF4B,IAE5B;IAAAV,CAAA,MAAAK,EAAA;EAAA;IAAAA,EAAA,GAAAL,CAAA;EAAA;EAFJ,MAAAW,uBAAA,GAAgCN,EAE5B;EAEJ,MAAAF,UAAA,GAAmBQ,uBAA2B,IAA3BP,wBAA2B;EAE9CT,oBAAA,CAAqB,kBAAkBQ,UAAA,IAAcL,UAAA,EAAY,EAAEC,OAAA;AAAA,CACrE","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useRunDeprioritized.js","names":["c","_c","useCallback","useRef","useRunDeprioritized","t0","$","timeout","undefined","idleHandleRef","t1","fn","Promise","resolve","exec","window","current","cancelIdleCallback","requestIdleCallback","interactionResponse","then","runDeprioritized","setTimeout","requestAnimationFrame"],"sources":["../../src/utilities/useRunDeprioritized.ts"],"sourcesContent":["'use client'\nimport { useCallback, useRef } from 'react'\n\n/**\n * Simple hook that lets you run any callback once the main thread is idle\n * (via `requestIdleCallback`) or when that API is missing (Safari) - after the\n * next animation frame (`interactionResponse`).\n *\n * This will help you to avoid blocking the main thread with heavy work.\n *\n * The latest invocation wins: if a new run is queued before the previous one\n * executes, the previous task is cancelled.\n *\n * Usage:\n * ```ts\n * const runDeprioritized = useRunDeprioritized();\n *\n * const onEditorChange = (state: EditorState) => {\n * runDeprioritized(() => {\n * // heavy work here …\n * });\n * };\n * ```\n *\n * @param timeout Optional timeout (ms) for `requestIdleCallback`; defaults to 500 ms.\n * @returns A `runDeprioritized(fn)` helper.\n */\n\nexport function useRunDeprioritized(timeout = 500) {\n const idleHandleRef = useRef<number>(undefined)\n\n /**\n * Schedule `fn` and resolve when it has executed.\n */\n const runDeprioritized = useCallback(\n (fn: () => void): Promise<void> => {\n return new Promise<void>((resolve) => {\n const exec = () => {\n fn()\n resolve()\n }\n\n if ('requestIdleCallback' in window) {\n // Cancel any previously queued task so only the latest runs.\n if ('cancelIdleCallback' in window && idleHandleRef.current !== undefined) {\n // Cancel earlier scheduled value updates,\n // so that a CPU-limited event loop isn't flooded with n callbacks for n keystrokes into the rich text field,\n // but that there's only ever the latest one state update\n // dispatch task, to be executed with the next idle time,\n // or the deadline of 500ms.\n cancelIdleCallback(idleHandleRef.current)\n }\n // Schedule the state update to happen the next time the browser has sufficient resources,\n // or the latest after 500ms.\n idleHandleRef.current = requestIdleCallback(exec, { timeout })\n } else {\n // Safari fallback: rAF + setTimeout shim.\n void interactionResponse().then(exec)\n }\n })\n },\n [timeout],\n )\n\n return runDeprioritized\n}\n\nfunction interactionResponse(): Promise<unknown> {\n // Taken from https://github.com/vercel-labs/await-interaction-response/tree/main/packages/await-interaction-response/src\n\n return new Promise((resolve) => {\n setTimeout(resolve, 100) // Fallback for the case where the animation frame never fires.\n requestAnimationFrame(() => {\n setTimeout(resolve, 0)\n })\n })\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,WAAW,EAAEC,MAAM,QAAQ;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAO,SAAAC,oBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAL,EAAA;EAA6B,MAAAM,OAAA,GAAAF,EAAa,KAAAG,SAAA,SAAbH,EAAa;EAC/C,MAAAI,aAAA,GAAsBN,MAAA,CAAAK,SAAe;EAAA,IAAAE,EAAA;EAAA,IAAAJ,CAAA,QAAAC,OAAA;IAMnCG,EAAA,GAAAC,EAAA,QAAAC,OAAA,CAAAC,OAAA;MAEI,MAAAC,IAAA,GAAAA,CAAA;QACEH,EAAA;QACAE,OAAA;MAAA;MACF,IAEI,yBAAAE,MAAyB;QAAA,IAEvB,wBAAAA,MAAwB,IAAUN,aAAA,CAAAO,OAAA,KAAAR,SAA0B;UAM9DS,kBAAA,CAAmBR,aAAA,CAAAO,OAAqB;QAAA;QAI1CP,aAAA,CAAAO,OAAA,GAAwBE,mBAAA,CAAoBJ,IAAA;UAAAP;QAAA,CAAgB;MAAA;QAGvDY,mBAAA,GAAAC,IAAA,CAA2BN,IAAA;MAAA;IAAA;IAGtCR,CAAA,MAAAC,OAAA;IAAAD,CAAA,MAAAI,EAAA;EAAA;IAAAA,EAAA,GAAAJ,CAAA;EAAA;EA1BF,MAAAe,gBAAA,GAAyBX,EA2Bd;EAAA,OAGJW,gBAAA;AAAA;AAGT,SAASF,oBAAA;EACP;EAEA,OAAO,IAAIP,OAAA,CAASC,OAAA;IAClBS,UAAA,CAAWT,OAAA,EAAS,MAAK;IACzBU,qBAAA,CAAsB;MACpBD,UAAA,CAAWT,OAAA,EAAS;IACtB;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"useRunDeprioritized.js","names":["c","_c","useCallback","useRef","useRunDeprioritized","t0","$","timeout","undefined","idleHandleRef","t1","fn","Promise","resolve","exec","window","current","cancelIdleCallback","requestIdleCallback","interactionResponse","then","runDeprioritized","setTimeout","requestAnimationFrame"],"sources":["../../src/utilities/useRunDeprioritized.ts"],"sourcesContent":["'use client'\nimport { useCallback, useRef } from 'react'\n\n/**\n * Simple hook that lets you run any callback once the main thread is idle\n * (via `requestIdleCallback`) or when that API is missing (Safari) - after the\n * next animation frame (`interactionResponse`).\n *\n * This will help you to avoid blocking the main thread with heavy work.\n *\n * The latest invocation wins: if a new run is queued before the previous one\n * executes, the previous task is cancelled.\n *\n * Usage:\n * ```ts\n * const runDeprioritized = useRunDeprioritized();\n *\n * const onEditorChange = (state: EditorState) => {\n * runDeprioritized(() => {\n * // heavy work here …\n * });\n * };\n * ```\n *\n * @param timeout Optional timeout (ms) for `requestIdleCallback`; defaults to 500 ms.\n * @returns A `runDeprioritized(fn)` helper.\n */\n\nexport function useRunDeprioritized(timeout = 500) {\n const idleHandleRef = useRef<number>(undefined)\n\n /**\n * Schedule `fn` and resolve when it has executed.\n */\n const runDeprioritized = useCallback(\n (fn: () => void): Promise<void> => {\n return new Promise<void>((resolve) => {\n const exec = () => {\n fn()\n resolve()\n }\n\n if ('requestIdleCallback' in window) {\n // Cancel any previously queued task so only the latest runs.\n if ('cancelIdleCallback' in window && idleHandleRef.current !== undefined) {\n // Cancel earlier scheduled value updates,\n // so that a CPU-limited event loop isn't flooded with n callbacks for n keystrokes into the rich text field,\n // but that there's only ever the latest one state update\n // dispatch task, to be executed with the next idle time,\n // or the deadline of 500ms.\n cancelIdleCallback(idleHandleRef.current)\n }\n // Schedule the state update to happen the next time the browser has sufficient resources,\n // or the latest after 500ms.\n idleHandleRef.current = requestIdleCallback(exec, { timeout })\n } else {\n // Safari fallback: rAF + setTimeout shim.\n void interactionResponse().then(exec)\n }\n })\n },\n [timeout],\n )\n\n return runDeprioritized\n}\n\nfunction interactionResponse(): Promise<unknown> {\n // Taken from https://github.com/vercel-labs/await-interaction-response/tree/main/packages/await-interaction-response/src\n\n return new Promise((resolve) => {\n setTimeout(resolve, 100) // Fallback for the case where the animation frame never fires.\n requestAnimationFrame(() => {\n setTimeout(resolve, 0)\n })\n })\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,WAAW,EAAEC,MAAM,QAAQ;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAO,SAAAC,oBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAL,EAAA;EAA6B,MAAAM,OAAA,GAAAF,EAAa,KAAbG,SAAa,GAAb,GAAa,GAAbH,EAAa;EAC/C,MAAAI,aAAA,GAAsBN,MAAA,CAAeK,SAAA;EAAA,IAAAE,EAAA;EAAA,IAAAJ,CAAA,QAAAC,OAAA;IAMnCG,EAAA,GAAAC,EAAA,IACS,IAAIC,OAAA,CAAcC,OAAA;MACvB,MAAAC,IAAA,GAAaA,CAAA;QACXH,EAAA;QACAE,OAAA;MAAA,CACF;MAEA,IAAI,yBAAyBE,MAAA;QAE3B,IAAI,wBAAwBA,MAAoC,IAA1BN,aAAA,CAAAO,OAAqB,KAAKR,SAAA;UAM9DS,kBAAA,CAAmBR,aAAA,CAAAO,OAAqB;QAAA;QAI1CP,aAAA,CAAAO,OAAA,GAAwBE,mBAAA,CAAoBJ,IAAA,EAAM;UAAAP;QAAU,EAAvC;MAAA;QAGhBY,mBAAA,GAAAC,IAA0B,CAACN,IAAA;MAAA;IAClC,CACF,CACF;IAAAR,CAAA,MAAAC,OAAA;IAAAD,CAAA,MAAAI,EAAA;EAAA;IAAAA,EAAA,GAAAJ,CAAA;EAAA;EA1BF,MAAAe,gBAAA,GAAyBX,EA2Bd;EAAA,OAGJW,gBAAA;AAAA;AAGT,SAASF,oBAAA;EACP;EAEA,OAAO,IAAIP,OAAA,CAASC,OAAA;IAClBS,UAAA,CAAWT,OAAA,EAAS,MAAK;IACzBU,qBAAA,CAAsB;MACpBD,UAAA,CAAWT,OAAA,EAAS;IACtB;EACF;AACF","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import type { SerializedEditorState, SerializedLexicalNode } from 'lexical';
1
+ import type { SerializedEditorState } from 'lexical';
2
2
  /**
3
3
  * This function checks if the editor state is empty (has any text). If the editor state has no nodes,
4
4
  * or only an empty paragraph node (no TextNode with length > 0), it returns false.
5
5
  * Otherwise, it returns true.
6
6
  */
7
- export declare function hasText(value: null | SerializedEditorState<SerializedLexicalNode> | undefined): value is SerializedEditorState<SerializedLexicalNode>;
7
+ export declare function hasText(value: null | SerializedEditorState | undefined): value is SerializedEditorState;
8
8
  //# sourceMappingURL=hasText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hasText.d.ts","sourceRoot":"","sources":["../../src/validate/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAGtB,MAAM,SAAS,CAAA;AAEhB;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,IAAI,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,SAAS,GACrE,KAAK,IAAI,qBAAqB,CAAC,qBAAqB,CAAC,CA6BvD"}
1
+ {"version":3,"file":"hasText.d.ts","sourceRoot":"","sources":["../../src/validate/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAA+C,MAAM,SAAS,CAAA;AAEjG;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,IAAI,GAAG,qBAAqB,GAAG,SAAS,GAC9C,KAAK,IAAI,qBAAqB,CA6BhC"}
@@ -1 +1 @@
1
- {"version":3,"file":"hasText.js","names":["hasText","value","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild"],"sources":["../../src/validate/hasText.ts"],"sourcesContent":["import type {\n SerializedEditorState,\n SerializedLexicalNode,\n SerializedParagraphNode,\n SerializedTextNode,\n} from 'lexical'\n\n/**\n * This function checks if the editor state is empty (has any text). If the editor state has no nodes,\n * or only an empty paragraph node (no TextNode with length > 0), it returns false.\n * Otherwise, it returns true.\n */\nexport function hasText(\n value: null | SerializedEditorState<SerializedLexicalNode> | undefined,\n): value is SerializedEditorState<SerializedLexicalNode> {\n const hasChildren = !!value?.root?.children?.length\n if (!hasChildren) {\n return false\n }\n\n let hasOnlyEmptyParagraph = false\n if (value?.root?.children?.length === 1) {\n if (value?.root?.children[0]?.type === 'paragraph') {\n const paragraphNode = value?.root?.children[0] as SerializedParagraphNode\n\n if (!paragraphNode?.children || paragraphNode?.children?.length === 0) {\n hasOnlyEmptyParagraph = true\n } else if (paragraphNode?.children?.length === 1) {\n const paragraphNodeChild = paragraphNode?.children[0]\n if (paragraphNodeChild?.type === 'text') {\n if (!(paragraphNodeChild as SerializedTextNode | undefined)?.['text']?.length) {\n hasOnlyEmptyParagraph = true\n }\n }\n }\n }\n }\n\n if (hasOnlyEmptyParagraph) {\n return false\n }\n\n return true\n}\n"],"mappings":"AAOA;;;;GAKA,OAAO,SAASA,QACdC,KAAsE;EAEtE,MAAMC,WAAA,GAAc,CAAC,CAACD,KAAA,EAAOE,IAAA,EAAMC,QAAA,EAAUC,MAAA;EAC7C,IAAI,CAACH,WAAA,EAAa;IAChB,OAAO;EACT;EAEA,IAAII,qBAAA,GAAwB;EAC5B,IAAIL,KAAA,EAAOE,IAAA,EAAMC,QAAA,EAAUC,MAAA,KAAW,GAAG;IACvC,IAAIJ,KAAA,EAAOE,IAAA,EAAMC,QAAQ,CAAC,EAAE,EAAEG,IAAA,KAAS,aAAa;MAClD,MAAMC,aAAA,GAAgBP,KAAA,EAAOE,IAAA,EAAMC,QAAQ,CAAC,EAAE;MAE9C,IAAI,CAACI,aAAA,EAAeJ,QAAA,IAAYI,aAAA,EAAeJ,QAAA,EAAUC,MAAA,KAAW,GAAG;QACrEC,qBAAA,GAAwB;MAC1B,OAAO,IAAIE,aAAA,EAAeJ,QAAA,EAAUC,MAAA,KAAW,GAAG;QAChD,MAAMI,kBAAA,GAAqBD,aAAA,EAAeJ,QAAQ,CAAC,EAAE;QACrD,IAAIK,kBAAA,EAAoBF,IAAA,KAAS,QAAQ;UACvC,IAAI,CAAEE,kBAAA,GAAwD,OAAO,EAAEJ,MAAA,EAAQ;YAC7EC,qBAAA,GAAwB;UAC1B;QACF;MACF;IACF;EACF;EAEA,IAAIA,qBAAA,EAAuB;IACzB,OAAO;EACT;EAEA,OAAO;AACT","ignoreList":[]}
1
+ {"version":3,"file":"hasText.js","names":["hasText","value","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild"],"sources":["../../src/validate/hasText.ts"],"sourcesContent":["import type { SerializedEditorState, SerializedParagraphNode, SerializedTextNode } from 'lexical'\n\n/**\n * This function checks if the editor state is empty (has any text). If the editor state has no nodes,\n * or only an empty paragraph node (no TextNode with length > 0), it returns false.\n * Otherwise, it returns true.\n */\nexport function hasText(\n value: null | SerializedEditorState | undefined,\n): value is SerializedEditorState {\n const hasChildren = !!value?.root?.children?.length\n if (!hasChildren) {\n return false\n }\n\n let hasOnlyEmptyParagraph = false\n if (value?.root?.children?.length === 1) {\n if (value?.root?.children[0]?.type === 'paragraph') {\n const paragraphNode = value?.root?.children[0] as SerializedParagraphNode\n\n if (!paragraphNode?.children || paragraphNode?.children?.length === 0) {\n hasOnlyEmptyParagraph = true\n } else if (paragraphNode?.children?.length === 1) {\n const paragraphNodeChild = paragraphNode?.children[0]\n if (paragraphNodeChild?.type === 'text') {\n if (!(paragraphNodeChild as SerializedTextNode | undefined)?.['text']?.length) {\n hasOnlyEmptyParagraph = true\n }\n }\n }\n }\n }\n\n if (hasOnlyEmptyParagraph) {\n return false\n }\n\n return true\n}\n"],"mappings":"AAEA;;;;GAKA,OAAO,SAASA,QACdC,KAA+C;EAE/C,MAAMC,WAAA,GAAc,CAAC,CAACD,KAAA,EAAOE,IAAA,EAAMC,QAAA,EAAUC,MAAA;EAC7C,IAAI,CAACH,WAAA,EAAa;IAChB,OAAO;EACT;EAEA,IAAII,qBAAA,GAAwB;EAC5B,IAAIL,KAAA,EAAOE,IAAA,EAAMC,QAAA,EAAUC,MAAA,KAAW,GAAG;IACvC,IAAIJ,KAAA,EAAOE,IAAA,EAAMC,QAAQ,CAAC,EAAE,EAAEG,IAAA,KAAS,aAAa;MAClD,MAAMC,aAAA,GAAgBP,KAAA,EAAOE,IAAA,EAAMC,QAAQ,CAAC,EAAE;MAE9C,IAAI,CAACI,aAAA,EAAeJ,QAAA,IAAYI,aAAA,EAAeJ,QAAA,EAAUC,MAAA,KAAW,GAAG;QACrEC,qBAAA,GAAwB;MAC1B,OAAO,IAAIE,aAAA,EAAeJ,QAAA,EAAUC,MAAA,KAAW,GAAG;QAChD,MAAMI,kBAAA,GAAqBD,aAAA,EAAeJ,QAAQ,CAAC,EAAE;QACrD,IAAIK,kBAAA,EAAoBF,IAAA,KAAS,QAAQ;UACvC,IAAI,CAAEE,kBAAA,GAAwD,OAAO,EAAEJ,MAAA,EAAQ;YAC7EC,qBAAA,GAAwB;UAC1B;QACF;MACF;IACF;EACF;EAEA,IAAIA,qBAAA,EAAuB;IACzB,OAAO;EACT;EAEA,OAAO;AACT","ignoreList":[]}
@@ -3,5 +3,5 @@ import type { RichTextField, Validate } from 'payload';
3
3
  import type { SanitizedServerEditorConfig } from '../lexical/config/types.js';
4
4
  export declare const richTextValidateHOC: ({ editorConfig, }: {
5
5
  editorConfig: SanitizedServerEditorConfig;
6
- }) => Validate<SerializedEditorState<import("lexical").SerializedLexicalNode>, unknown, unknown, RichTextField>;
6
+ }) => Validate<SerializedEditorState, unknown, unknown, RichTextField>;
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAK7E,eAAO,MAAM,mBAAmB,sBAE7B;IACD,YAAY,EAAE,2BAA2B,CAAA;CAC1C,8GAiCA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAK7E,eAAO,MAAM,mBAAmB,sBAE7B;IACD,YAAY,EAAE,2BAA2B,CAAA;CAC1C,qEAiCA,CAAA"}