@payloadcms/richtext-lexical 4.0.0-internal.c3ac604 → 4.0.0-internal.c6494b5

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 (458) hide show
  1. package/dist/exports/client/Field-W2ABOM7M.js +2 -0
  2. package/dist/exports/client/Field-W2ABOM7M.js.map +7 -0
  3. package/dist/exports/client/chunk-3LRZDIIG.js +2 -0
  4. package/dist/exports/client/{chunk-SSMQFWCQ.js.map → chunk-3LRZDIIG.js.map} +4 -4
  5. package/dist/exports/client/chunk-E6LSRRP2.js +2 -0
  6. package/dist/exports/client/chunk-E6LSRRP2.js.map +7 -0
  7. package/dist/exports/client/chunk-ZQX5HXUL.js +2 -0
  8. package/dist/exports/client/{chunk-43E5QYAA.js.map → chunk-ZQX5HXUL.js.map} +3 -3
  9. package/dist/exports/client/{component-D5QLYS7W.js → component-6DQLENIE.js} +2 -2
  10. package/dist/exports/client/componentInline-HNE5G4TE.js +2 -0
  11. package/dist/exports/client/index.d.ts +1 -1
  12. package/dist/exports/client/index.d.ts.map +1 -1
  13. package/dist/exports/client/index.js +28 -28
  14. package/dist/exports/client/index.js.map +4 -4
  15. package/dist/features/blocks/client/component/BlockReordering/index.d.ts +11 -0
  16. package/dist/features/blocks/client/component/BlockReordering/index.d.ts.map +1 -0
  17. package/dist/features/blocks/client/component/BlockReordering/index.js +18 -0
  18. package/dist/features/blocks/client/component/BlockReordering/index.js.map +1 -0
  19. package/dist/features/blocks/client/component/index.d.ts +0 -6
  20. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  21. package/dist/features/blocks/client/component/index.js +169 -101
  22. package/dist/features/blocks/client/component/index.js.map +1 -1
  23. package/dist/features/blocks/client/component/useBlockReordering.d.ts +16 -0
  24. package/dist/features/blocks/client/component/useBlockReordering.d.ts.map +1 -0
  25. package/dist/features/blocks/client/component/useBlockReordering.js +178 -0
  26. package/dist/features/blocks/client/component/useBlockReordering.js.map +1 -0
  27. package/dist/features/blocks/client/componentInline/index.css +0 -1
  28. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  29. package/dist/features/blocks/client/componentInline/index.js +30 -22
  30. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  31. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts +9 -0
  32. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts.map +1 -0
  33. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js +95 -0
  34. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -0
  35. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  36. package/dist/features/blocks/client/nodes/BlocksNode.js +0 -10
  37. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  38. package/dist/features/blocks/server/index.js +2 -2
  39. package/dist/features/blocks/server/index.js.map +1 -1
  40. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  41. package/dist/features/blocks/server/nodes/BlocksNode.js +1 -12
  42. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  43. package/dist/features/blocks/server/nodes/InlineBlocksNode.js +2 -2
  44. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  45. package/dist/features/blocks/server/schema.d.ts +2 -0
  46. package/dist/features/blocks/server/schema.d.ts.map +1 -1
  47. package/dist/features/blocks/server/schema.js +7 -9
  48. package/dist/features/blocks/server/schema.js.map +1 -1
  49. package/dist/features/blocks/server/validate.js +1 -1
  50. package/dist/features/blocks/server/validate.js.map +1 -1
  51. package/dist/features/converters/lexicalToHtml/async/converters/heading.js +1 -1
  52. package/dist/features/converters/lexicalToHtml/async/converters/heading.js.map +1 -1
  53. package/dist/features/converters/lexicalToHtml/async/converters/list.d.ts.map +1 -1
  54. package/dist/features/converters/lexicalToHtml/async/converters/list.js +4 -3
  55. package/dist/features/converters/lexicalToHtml/async/converters/list.js.map +1 -1
  56. package/dist/features/converters/lexicalToHtml/async/converters/upload.js +3 -3
  57. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  58. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.d.ts.map +1 -1
  59. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js +3 -2
  60. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js.map +1 -1
  61. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js +1 -1
  62. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js.map +1 -1
  63. package/dist/features/converters/lexicalToHtml/sync/converters/list.d.ts.map +1 -1
  64. package/dist/features/converters/lexicalToHtml/sync/converters/list.js +4 -3
  65. package/dist/features/converters/lexicalToHtml/sync/converters/list.js.map +1 -1
  66. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +3 -3
  67. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
  68. package/dist/features/converters/lexicalToJSX/converter/converters/heading.d.ts.map +1 -1
  69. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +2 -1
  70. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
  71. package/dist/features/converters/lexicalToJSX/converter/converters/list.d.ts.map +1 -1
  72. package/dist/features/converters/lexicalToJSX/converter/converters/list.js +2 -1
  73. package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
  74. package/dist/features/converters/lexicalToJSX/converter/converters/upload.d.ts.map +1 -1
  75. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +4 -5
  76. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
  77. package/dist/features/converters/utilities/payloadPopulateFn.d.ts.map +1 -1
  78. package/dist/features/converters/utilities/payloadPopulateFn.js +4 -2
  79. package/dist/features/converters/utilities/payloadPopulateFn.js.map +1 -1
  80. package/dist/features/heading/constants.d.ts +2 -0
  81. package/dist/features/heading/constants.d.ts.map +1 -0
  82. package/dist/features/heading/constants.js +2 -0
  83. package/dist/features/heading/constants.js.map +1 -0
  84. package/dist/features/heading/server/index.d.ts.map +1 -1
  85. package/dist/features/heading/server/index.js +5 -1
  86. package/dist/features/heading/server/index.js.map +1 -1
  87. package/dist/features/heading/server/validate.d.ts +6 -0
  88. package/dist/features/heading/server/validate.d.ts.map +1 -0
  89. package/dist/features/heading/server/validate.js +15 -0
  90. package/dist/features/heading/server/validate.js.map +1 -0
  91. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +11 -1
  92. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  93. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +17 -0
  94. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  95. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +2 -2
  96. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  97. package/dist/features/horizontalRule/server/schema.d.ts +1 -0
  98. package/dist/features/horizontalRule/server/schema.d.ts.map +1 -1
  99. package/dist/features/horizontalRule/server/schema.js +6 -5
  100. package/dist/features/horizontalRule/server/schema.js.map +1 -1
  101. package/dist/features/indent/client/IndentPlugin.d.ts.map +1 -1
  102. package/dist/features/indent/client/IndentPlugin.js +122 -1
  103. package/dist/features/indent/client/IndentPlugin.js.map +1 -1
  104. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  105. package/dist/features/indent/server/i18n.js +74 -37
  106. package/dist/features/indent/server/i18n.js.map +1 -1
  107. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  108. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +8 -5
  109. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  110. package/dist/features/link/client/plugins/floatingLinkEditor/index.css +0 -1
  111. package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  112. package/dist/features/link/nodes/AutoLinkNode.js +2 -10
  113. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  114. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  115. package/dist/features/link/nodes/LinkNode.js +2 -15
  116. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  117. package/dist/features/link/server/index.js +2 -2
  118. package/dist/features/link/server/index.js.map +1 -1
  119. package/dist/features/link/server/validate.js +1 -1
  120. package/dist/features/link/server/validate.js.map +1 -1
  121. package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
  122. package/dist/features/lists/checklist/server/index.js +5 -2
  123. package/dist/features/lists/checklist/server/index.js.map +1 -1
  124. package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
  125. package/dist/features/lists/orderedList/server/index.js +5 -2
  126. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  127. package/dist/features/lists/shared/constants.d.ts +2 -0
  128. package/dist/features/lists/shared/constants.d.ts.map +1 -0
  129. package/dist/features/lists/shared/constants.js +2 -0
  130. package/dist/features/lists/shared/constants.js.map +1 -0
  131. package/dist/features/lists/shared/validate.d.ts +5 -0
  132. package/dist/features/lists/shared/validate.d.ts.map +1 -0
  133. package/dist/features/lists/shared/validate.js +15 -0
  134. package/dist/features/lists/shared/validate.js.map +1 -0
  135. package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
  136. package/dist/features/lists/unorderedList/server/index.js +5 -2
  137. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  138. package/dist/features/relationship/client/components/index.css +3 -6
  139. package/dist/features/relationship/client/index.d.ts +2 -2
  140. package/dist/features/relationship/client/index.d.ts.map +1 -1
  141. package/dist/features/relationship/client/index.js.map +1 -1
  142. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  143. package/dist/features/relationship/client/nodes/RelationshipNode.js +0 -3
  144. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  145. package/dist/features/relationship/client/plugins/index.d.ts +2 -2
  146. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  147. package/dist/features/relationship/client/plugins/index.js +27 -31
  148. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  149. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts +2 -4
  150. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
  151. package/dist/features/relationship/client/utils/useEnabledRelationships.js +53 -20
  152. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  153. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +2 -2
  154. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
  155. package/dist/features/relationship/server/graphQLPopulationPromise.js +2 -2
  156. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  157. package/dist/features/relationship/server/index.d.ts +8 -1
  158. package/dist/features/relationship/server/index.d.ts.map +1 -1
  159. package/dist/features/relationship/server/index.js +28 -11
  160. package/dist/features/relationship/server/index.js.map +1 -1
  161. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  162. package/dist/features/relationship/server/nodes/RelationshipNode.js +1 -5
  163. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  164. package/dist/features/relationship/server/schema.d.ts +3 -2
  165. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  166. package/dist/features/relationship/server/schema.js +9 -12
  167. package/dist/features/relationship/server/schema.js.map +1 -1
  168. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +1 -6
  169. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -1
  170. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +1 -5
  171. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -1
  172. package/dist/features/table/client/index.d.ts.map +1 -0
  173. package/dist/features/table/client/index.js.map +1 -0
  174. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts +8 -0
  175. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts.map +1 -0
  176. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js +19 -0
  177. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js.map +1 -0
  178. package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.css +0 -1
  179. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -0
  180. package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.js +17 -44
  181. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -0
  182. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -0
  183. package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.js +41 -18
  184. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js.map +1 -0
  185. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -0
  186. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -0
  187. package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.css +0 -3
  188. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.d.ts.map +1 -0
  189. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.js.map +1 -0
  190. package/dist/features/table/client/plugins/TablePlugin/index.d.ts.map +1 -0
  191. package/dist/features/table/client/plugins/TablePlugin/index.js.map +1 -0
  192. package/dist/features/table/client/utils/debounce.d.ts.map +1 -0
  193. package/dist/features/table/client/utils/debounce.js.map +1 -0
  194. package/dist/features/table/client/utils/useDebounce.d.ts.map +1 -0
  195. package/dist/features/table/client/utils/useDebounce.js.map +1 -0
  196. package/dist/features/table/markdownTransformer.d.ts.map +1 -0
  197. package/dist/features/table/markdownTransformer.js.map +1 -0
  198. package/dist/features/table/server/index.d.ts +3 -0
  199. package/dist/features/table/server/index.d.ts.map +1 -0
  200. package/dist/features/{experimental_table → table}/server/index.js +4 -4
  201. package/dist/features/table/server/index.js.map +1 -0
  202. package/dist/features/table/server/schema.d.ts.map +1 -0
  203. package/dist/features/table/server/schema.js.map +1 -0
  204. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts +8 -0
  205. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts.map +1 -0
  206. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js +80 -0
  207. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js.map +1 -0
  208. package/dist/features/toolbars/fixed/client/Toolbar/index.css +77 -3
  209. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  210. package/dist/features/toolbars/fixed/client/Toolbar/index.js +19 -1
  211. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  212. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  213. package/dist/features/toolbars/inline/client/Toolbar/index.js +17 -2
  214. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  215. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  216. package/dist/features/toolbars/shared/ToolbarButton/index.js +1 -0
  217. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  218. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  219. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +85 -32
  220. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  221. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +16 -12
  222. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts +5 -0
  223. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts.map +1 -0
  224. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js +79 -0
  225. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js.map +1 -0
  226. package/dist/features/typesServer.d.ts +17 -12
  227. package/dist/features/typesServer.d.ts.map +1 -1
  228. package/dist/features/typesServer.js.map +1 -1
  229. package/dist/features/upload/client/component/index.css +0 -2
  230. package/dist/features/upload/client/index.d.ts +3 -2
  231. package/dist/features/upload/client/index.d.ts.map +1 -1
  232. package/dist/features/upload/client/index.js.map +1 -1
  233. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  234. package/dist/features/upload/client/nodes/UploadNode.js +0 -7
  235. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  236. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  237. package/dist/features/upload/client/plugin/index.js +50 -53
  238. package/dist/features/upload/client/plugin/index.js.map +1 -1
  239. package/dist/features/upload/server/graphQLPopulationPromise.d.ts +2 -2
  240. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  241. package/dist/features/upload/server/graphQLPopulationPromise.js +1 -1
  242. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  243. package/dist/features/upload/server/index.d.ts +7 -3
  244. package/dist/features/upload/server/index.d.ts.map +1 -1
  245. package/dist/features/upload/server/index.js +20 -16
  246. package/dist/features/upload/server/index.js.map +1 -1
  247. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  248. package/dist/features/upload/server/nodes/UploadNode.js +1 -9
  249. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  250. package/dist/features/upload/server/schema.d.ts +4 -16
  251. package/dist/features/upload/server/schema.d.ts.map +1 -1
  252. package/dist/features/upload/server/schema.js +8 -10
  253. package/dist/features/upload/server/schema.js.map +1 -1
  254. package/dist/features/upload/server/validate.d.ts +2 -2
  255. package/dist/features/upload/server/validate.d.ts.map +1 -1
  256. package/dist/features/upload/server/validate.js +4 -1
  257. package/dist/features/upload/server/validate.js.map +1 -1
  258. package/dist/field/Diff/converters/listitem/index.d.ts.map +1 -1
  259. package/dist/field/Diff/converters/listitem/index.js +2 -1
  260. package/dist/field/Diff/converters/listitem/index.js.map +1 -1
  261. package/dist/field/Diff/converters/relationship/index.css +0 -1
  262. package/dist/field/Diff/converters/unknown/index.css +0 -1
  263. package/dist/field/Diff/converters/upload/index.css +0 -1
  264. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  265. package/dist/field/Diff/index.css +0 -2
  266. package/dist/field/Diff/index.d.ts +3 -2
  267. package/dist/field/Diff/index.d.ts.map +1 -1
  268. package/dist/field/Diff/index.js +3 -2
  269. package/dist/field/Diff/index.js.map +1 -1
  270. package/dist/field/Field.d.ts.map +1 -1
  271. package/dist/field/Field.js +8 -1
  272. package/dist/field/Field.js.map +1 -1
  273. package/dist/field/RenderLexical/index.d.ts +3 -1
  274. package/dist/field/RenderLexical/index.d.ts.map +1 -1
  275. package/dist/field/RenderLexical/index.js +23 -23
  276. package/dist/field/RenderLexical/index.js.map +1 -1
  277. package/dist/field/ViewSelector.d.ts.map +1 -1
  278. package/dist/field/ViewSelector.js +1 -0
  279. package/dist/field/ViewSelector.js.map +1 -1
  280. package/dist/field/bundled.css +1 -1
  281. package/dist/field/index.css +10 -11
  282. package/dist/field/rscEntry.d.ts +2 -2
  283. package/dist/field/rscEntry.d.ts.map +1 -1
  284. package/dist/field/rscEntry.js.map +1 -1
  285. package/dist/i18n.d.ts.map +1 -1
  286. package/dist/i18n.js +68 -0
  287. package/dist/i18n.js.map +1 -1
  288. package/dist/index.d.ts +5 -5
  289. package/dist/index.d.ts.map +1 -1
  290. package/dist/index.js +27 -5
  291. package/dist/index.js.map +1 -1
  292. package/dist/lexical/LexicalEditor.css +21 -10
  293. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  294. package/dist/lexical/LexicalEditor.js +61 -64
  295. package/dist/lexical/LexicalEditor.js.map +1 -1
  296. package/dist/lexical/config/server/loader.d.ts +1 -1
  297. package/dist/lexical/config/server/loader.d.ts.map +1 -1
  298. package/dist/lexical/config/server/loader.js +2 -2
  299. package/dist/lexical/config/server/loader.js.map +1 -1
  300. package/dist/lexical/config/server/sanitize.d.ts +1 -1
  301. package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
  302. package/dist/lexical/config/server/sanitize.js +2 -2
  303. package/dist/lexical/config/server/sanitize.js.map +1 -1
  304. package/dist/lexical/plugins/DecoratorPlugin/index.d.ts.map +1 -1
  305. package/dist/lexical/plugins/DecoratorPlugin/index.js +24 -21
  306. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  307. package/dist/lexical/plugins/InsertParagraphAtEnd/index.css +18 -24
  308. package/dist/lexical/plugins/InsertParagraphAtEnd/index.d.ts.map +1 -1
  309. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +27 -14
  310. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  311. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +1 -1
  312. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  313. package/dist/lexical/plugins/SlashMenu/index.css +0 -1
  314. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -0
  315. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +2 -2
  316. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  317. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +1 -0
  318. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  319. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +16 -2
  320. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  321. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts +7 -0
  322. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts.map +1 -0
  323. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js +65 -0
  324. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js.map +1 -0
  325. package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  326. package/dist/lexical/plugins/handles/utils/setHandlePosition.js +2 -0
  327. package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  328. package/dist/lexical/theme/EditorTheme.css +0 -2
  329. package/dist/lexical/ui/ContentEditable.d.ts +2 -1
  330. package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
  331. package/dist/lexical/ui/ContentEditable.js +32 -11
  332. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  333. package/dist/lexical/ui/icons/H3/index.d.ts.map +1 -1
  334. package/dist/lexical/ui/icons/H3/index.js +13 -6
  335. package/dist/lexical/ui/icons/H3/index.js.map +1 -1
  336. package/dist/lexical/ui/icons/H4/index.d.ts.map +1 -1
  337. package/dist/lexical/ui/icons/H4/index.js +13 -6
  338. package/dist/lexical/ui/icons/H4/index.js.map +1 -1
  339. package/dist/lexical/ui/icons/H5/index.d.ts.map +1 -1
  340. package/dist/lexical/ui/icons/H5/index.js +13 -6
  341. package/dist/lexical/ui/icons/H5/index.js.map +1 -1
  342. package/dist/lexical/ui/icons/H6/index.d.ts.map +1 -1
  343. package/dist/lexical/ui/icons/H6/index.js +13 -6
  344. package/dist/lexical/ui/icons/H6/index.js.map +1 -1
  345. package/dist/presets/llmInstructions.d.ts +2 -0
  346. package/dist/presets/llmInstructions.d.ts.map +1 -0
  347. package/dist/presets/llmInstructions.js +13 -0
  348. package/dist/presets/llmInstructions.js.map +1 -0
  349. package/dist/types/builtInNodes.d.ts +1 -1
  350. package/dist/types/builtInNodes.d.ts.map +1 -1
  351. package/dist/types/builtInNodes.js +8 -3
  352. package/dist/types/builtInNodes.js.map +1 -1
  353. package/dist/types/index.d.ts +4 -7
  354. package/dist/types/index.d.ts.map +1 -1
  355. package/dist/types/index.js.map +1 -1
  356. package/dist/types/jsonSchemaHelpers.d.ts +5 -1
  357. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -1
  358. package/dist/types/jsonSchemaHelpers.js +7 -2
  359. package/dist/types/jsonSchemaHelpers.js.map +1 -1
  360. package/dist/types/nodeTypes.d.ts +6 -1
  361. package/dist/types/nodeTypes.d.ts.map +1 -1
  362. package/dist/types/nodeTypes.js.map +1 -1
  363. package/dist/utilities/buildInitialState.d.ts +3 -2
  364. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  365. package/dist/utilities/buildInitialState.js +1 -0
  366. package/dist/utilities/buildInitialState.js.map +1 -1
  367. package/dist/utilities/createServerFeature.d.ts +1 -1
  368. package/dist/utilities/createServerFeature.d.ts.map +1 -1
  369. package/dist/utilities/createServerFeature.js +2 -2
  370. package/dist/utilities/createServerFeature.js.map +1 -1
  371. package/dist/utilities/editorConfigFactory.d.ts +6 -6
  372. package/dist/utilities/editorConfigFactory.d.ts.map +1 -1
  373. package/dist/utilities/editorConfigFactory.js +9 -9
  374. package/dist/utilities/editorConfigFactory.js.map +1 -1
  375. package/dist/utilities/generateImportMap.d.ts +2 -2
  376. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  377. package/dist/utilities/generateImportMap.js.map +1 -1
  378. package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts +2 -2
  379. package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts.map +1 -1
  380. package/dist/utilities/getDefaultSanitizedEditorConfig.js +6 -17
  381. package/dist/utilities/getDefaultSanitizedEditorConfig.js.map +1 -1
  382. package/dist/utilities/upgradeLexicalData/index.js +6 -3
  383. package/dist/utilities/upgradeLexicalData/index.js.map +1 -1
  384. package/dist/validate/hasText.d.ts +2 -2
  385. package/dist/validate/hasText.d.ts.map +1 -1
  386. package/dist/validate/hasText.js.map +1 -1
  387. package/dist/validate/index.d.ts +1 -1
  388. package/dist/validate/index.d.ts.map +1 -1
  389. package/package.json +24 -24
  390. package/dist/dependencyChecker.spec.js +0 -16
  391. package/dist/dependencyChecker.spec.js.map +0 -1
  392. package/dist/exports/client/Field-IZKDIUJY.js +0 -2
  393. package/dist/exports/client/Field-IZKDIUJY.js.map +0 -7
  394. package/dist/exports/client/bundled.css +0 -1
  395. package/dist/exports/client/chunk-43E5QYAA.js +0 -2
  396. package/dist/exports/client/chunk-ESITTE3C.js +0 -2
  397. package/dist/exports/client/chunk-ESITTE3C.js.map +0 -7
  398. package/dist/exports/client/chunk-SSMQFWCQ.js +0 -2
  399. package/dist/exports/client/componentInline-H24N7GUG.js +0 -2
  400. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts +0 -11
  401. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts.map +0 -1
  402. package/dist/features/blocks/client/component/removeEmptyArrayValues.js +0 -20
  403. package/dist/features/blocks/client/component/removeEmptyArrayValues.js.map +0 -1
  404. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js +0 -180
  405. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js.map +0 -1
  406. package/dist/features/experimental_table/client/index.d.ts.map +0 -1
  407. package/dist/features/experimental_table/client/index.js.map +0 -1
  408. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +0 -1
  409. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +0 -1
  410. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +0 -1
  411. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +0 -1
  412. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +0 -1
  413. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +0 -1
  414. package/dist/features/experimental_table/client/plugins/TablePlugin/TableGridPopup/index.d.ts.map +0 -1
  415. package/dist/features/experimental_table/client/plugins/TablePlugin/TableGridPopup/index.js.map +0 -1
  416. package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts.map +0 -1
  417. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +0 -1
  418. package/dist/features/experimental_table/client/utils/debounce.d.ts.map +0 -1
  419. package/dist/features/experimental_table/client/utils/debounce.js.map +0 -1
  420. package/dist/features/experimental_table/client/utils/useDebounce.d.ts.map +0 -1
  421. package/dist/features/experimental_table/client/utils/useDebounce.js.map +0 -1
  422. package/dist/features/experimental_table/markdownTransformer.d.ts.map +0 -1
  423. package/dist/features/experimental_table/markdownTransformer.js.map +0 -1
  424. package/dist/features/experimental_table/server/index.d.ts +0 -3
  425. package/dist/features/experimental_table/server/index.d.ts.map +0 -1
  426. package/dist/features/experimental_table/server/index.js.map +0 -1
  427. package/dist/features/experimental_table/server/schema.d.ts.map +0 -1
  428. package/dist/features/experimental_table/server/schema.js.map +0 -1
  429. package/dist/features/link/markdownTransformer.spec.js +0 -195
  430. package/dist/features/link/markdownTransformer.spec.js.map +0 -1
  431. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js +0 -88
  432. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js.map +0 -1
  433. package/dist/lexical/utils/url.spec.js +0 -114
  434. package/dist/lexical/utils/url.spec.js.map +0 -1
  435. package/dist/utilities/jsx/jsx.spec.js +0 -178
  436. package/dist/utilities/jsx/jsx.spec.js.map +0 -1
  437. /package/dist/exports/client/{component-D5QLYS7W.js.map → component-6DQLENIE.js.map} +0 -0
  438. /package/dist/exports/client/{componentInline-H24N7GUG.js.map → componentInline-HNE5G4TE.js.map} +0 -0
  439. /package/dist/features/{experimental_table → table}/client/index.d.ts +0 -0
  440. /package/dist/features/{experimental_table → table}/client/index.js +0 -0
  441. /package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.d.ts +0 -0
  442. /package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.css +0 -0
  443. /package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.d.ts +0 -0
  444. /package/dist/features/{experimental_table → table}/client/plugins/TableHoverActionsPlugin/index.d.ts +0 -0
  445. /package/dist/features/{experimental_table → table}/client/plugins/TableHoverActionsPlugin/index.js +0 -0
  446. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.d.ts +0 -0
  447. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.js +0 -0
  448. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.css +0 -0
  449. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.d.ts +0 -0
  450. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.js +0 -0
  451. /package/dist/features/{experimental_table → table}/client/utils/debounce.d.ts +0 -0
  452. /package/dist/features/{experimental_table → table}/client/utils/debounce.js +0 -0
  453. /package/dist/features/{experimental_table → table}/client/utils/useDebounce.d.ts +0 -0
  454. /package/dist/features/{experimental_table → table}/client/utils/useDebounce.js +0 -0
  455. /package/dist/features/{experimental_table → table}/markdownTransformer.d.ts +0 -0
  456. /package/dist/features/{experimental_table → table}/markdownTransformer.js +0 -0
  457. /package/dist/features/{experimental_table → table}/server/schema.d.ts +0 -0
  458. /package/dist/features/{experimental_table → table}/server/schema.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Tooltip","useTranslation","$addUpdateTag","React","useCallback","useEffect","useMemo","useRef","useState","useEditorConfigContext","baseClass","ToolbarButton","active","children","editor","enabled","item","i18n","fieldProps","featureClientSchemaMap","schemaPath","showTooltip","setShowTooltip","buttonRef","current","removeAttribute","tooltipLabel","label","key","replace","c","toUpperCase","className","filter","Boolean","join","handleClick","focus","update","onSelect","isActive","handleMouseDown","e","preventDefault","currentTarget","setAttribute","_jsxs","disabled","onClick","onMouseDown","onPointerEnter","onPointerLeave","ref","type","_jsx","show"],"sources":["../../../../../src/features/toolbars/shared/ToolbarButton/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { Tooltip, useTranslation } from '@payloadcms/ui'\nimport { $addUpdateTag } from 'lexical'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { ToolbarGroupItem } from '../../types.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport './index.css'\n\nconst baseClass = 'toolbar-popup__button'\n\nexport const ToolbarButton = ({\n active = false,\n children,\n editor,\n enabled = true,\n item,\n}: {\n active?: boolean\n children: React.JSX.Element\n editor: LexicalEditor\n enabled?: boolean\n item: ToolbarGroupItem\n}) => {\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const [showTooltip, setShowTooltip] = useState(false)\n const buttonRef = useRef<HTMLButtonElement>(null)\n\n // Clear pressing state when active prop changes (React has re-rendered)\n useEffect(() => {\n buttonRef.current?.removeAttribute('data-pressing')\n }, [active])\n\n const tooltipLabel = useMemo(() => {\n if (item.label) {\n return typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n // Convert camelCase key to Title Case (e.g. \"inlineCode\" -> \"Inline Code\")\n return item.key.replace(/([a-z])([A-Z])/g, '$1 $2').replace(/^./, (c) => c.toUpperCase())\n }, [featureClientSchemaMap, i18n, schemaPath, item])\n\n const className = useMemo(() => {\n return [\n baseClass,\n !enabled ? 'disabled' : '',\n active ? 'active' : '',\n item.key ? `${baseClass}-${item.key}` : '',\n ]\n .filter(Boolean)\n .join(' ')\n }, [active, enabled, item.key])\n\n const handleClick = useCallback(() => {\n if (!enabled) {\n return\n }\n\n editor.focus(() => {\n editor.update(() => {\n $addUpdateTag('toolbar')\n })\n // We need to wrap the onSelect in the callback, so the editor is properly focused before the onSelect is called.\n item.onSelect?.({\n editor,\n isActive: active,\n })\n })\n }, [editor, item, active, enabled])\n\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n // Suppress hover flash between mouseup and React adding .active class\n ;(e.currentTarget as HTMLElement).setAttribute('data-pressing', '')\n }, [])\n\n return (\n <button\n aria-label={tooltipLabel}\n className={className}\n data-button-key={item.key}\n disabled={!enabled}\n onClick={handleClick}\n onMouseDown={handleMouseDown}\n onPointerEnter={() => setShowTooltip(true)}\n onPointerLeave={() => {\n setShowTooltip(false)\n buttonRef.current?.removeAttribute('data-pressing')\n }}\n ref={buttonRef}\n type=\"button\"\n >\n <Tooltip className={`${baseClass}__tooltip`} show={showTooltip}>\n {tooltipLabel}\n </Tooltip>\n {children}\n </button>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,OAAO,EAAEC,cAAc,QAAQ;AACxC,SAASC,aAAa,QAAQ;AAC9B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAIzE,SAASC,sBAAsB,QAAQ;AACvC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,aAAA,GAAgBA,CAAC;EAC5BC,MAAA,GAAS,KAAK;EACdC,QAAQ;EACRC,MAAM;EACNC,OAAA,GAAU,IAAI;EACdC;AAAI,CAOL;EACC,MAAM;IAAEC;EAAI,CAAE,GAAGhB,cAAA;EACjB,MAAM;IACJiB,UAAA,EAAY;MAAEC,sBAAsB;MAAEC;IAAU;EAAE,CACnD,GAAGX,sBAAA;EAEJ,MAAM,CAACY,WAAA,EAAaC,cAAA,CAAe,GAAGd,QAAA,CAAS;EAC/C,MAAMe,SAAA,GAAYhB,MAAA,CAA0B;EAE5C;EACAF,SAAA,CAAU;IACRkB,SAAA,CAAUC,OAAO,EAAEC,eAAA,CAAgB;EACrC,GAAG,CAACb,MAAA,CAAO;EAEX,MAAMc,YAAA,GAAepB,OAAA,CAAQ;IAC3B,IAAIU,IAAA,CAAKW,KAAK,EAAE;MACd,OAAO,OAAOX,IAAA,CAAKW,KAAK,KAAK,aACzBX,IAAA,CAAKW,KAAK,CAAC;QAAER,sBAAA;QAAwBF,IAAA;QAAMG;MAAW,KACtDJ,IAAA,CAAKW,KAAK;IAChB;IACA;IACA,OAAOX,IA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ACrC6B,cAAA,EAAgBA,CAAA;MACd7B,cAAA,CAAe;MACfC,SAAA,CAAUC,OAAO,EAAEC,eAAA,CAAgB;IACrC;IACA2B,GAAA,EAAK7B,SAAA;IACL8B,IAAA,EAAK;4BAELC,IAAA,CAACtD,OAAA;MAAQgC,SAAA,EAAW,GAAGtB,SAAA,WAAoB;MAAE6C,IAAA,EAAMlC,WAAA;gBAChDK;QAEFb,QAAA;;AAGP","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["Tooltip","useTranslation","$addUpdateTag","React","useCallback","useEffect","useMemo","useRef","useState","useEditorConfigContext","baseClass","ToolbarButton","active","children","editor","enabled","item","i18n","fieldProps","featureClientSchemaMap","schemaPath","showTooltip","setShowTooltip","buttonRef","current","removeAttribute","tooltipLabel","label","key","replace","c","toUpperCase","className","filter","Boolean","join","handleClick","focus","update","onSelect","isActive","handleMouseDown","e","preventDefault","currentTarget","setAttribute","_jsxs","undefined","disabled","onClick","onMouseDown","onPointerEnter","onPointerLeave","ref","type","_jsx","show"],"sources":["../../../../../src/features/toolbars/shared/ToolbarButton/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { Tooltip, useTranslation } from '@payloadcms/ui'\nimport { $addUpdateTag } from 'lexical'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { ToolbarGroupItem } from '../../types.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport './index.css'\n\nconst baseClass = 'toolbar-popup__button'\n\nexport const ToolbarButton = ({\n active = false,\n children,\n editor,\n enabled = true,\n item,\n}: {\n active?: boolean\n children: React.JSX.Element\n editor: LexicalEditor\n enabled?: boolean\n item: ToolbarGroupItem\n}) => {\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const [showTooltip, setShowTooltip] = useState(false)\n const buttonRef = useRef<HTMLButtonElement>(null)\n\n // Clear pressing state when active prop changes (React has re-rendered)\n useEffect(() => {\n buttonRef.current?.removeAttribute('data-pressing')\n }, [active])\n\n const tooltipLabel = useMemo(() => {\n if (item.label) {\n return typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n // Convert camelCase key to Title Case (e.g. \"inlineCode\" -> \"Inline Code\")\n return item.key.replace(/([a-z])([A-Z])/g, '$1 $2').replace(/^./, (c) => c.toUpperCase())\n }, [featureClientSchemaMap, i18n, schemaPath, item])\n\n const className = useMemo(() => {\n return [\n baseClass,\n !enabled ? 'disabled' : '',\n active ? 'active' : '',\n item.key ? `${baseClass}-${item.key}` : '',\n ]\n .filter(Boolean)\n .join(' ')\n }, [active, enabled, item.key])\n\n const handleClick = useCallback(() => {\n if (!enabled) {\n return\n }\n\n editor.focus(() => {\n editor.update(() => {\n $addUpdateTag('toolbar')\n })\n // We need to wrap the onSelect in the callback, so the editor is properly focused before the onSelect is called.\n item.onSelect?.({\n editor,\n isActive: active,\n })\n })\n }, [editor, item, active, enabled])\n\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n // Suppress hover flash between mouseup and React adding .active class\n ;(e.currentTarget as HTMLElement).setAttribute('data-pressing', '')\n }, [])\n\n return (\n <button\n aria-label={tooltipLabel}\n aria-pressed={item.isActive ? active : undefined}\n className={className}\n data-button-key={item.key}\n disabled={!enabled}\n onClick={handleClick}\n onMouseDown={handleMouseDown}\n onPointerEnter={() => setShowTooltip(true)}\n onPointerLeave={() => {\n setShowTooltip(false)\n buttonRef.current?.removeAttribute('data-pressing')\n }}\n ref={buttonRef}\n type=\"button\"\n >\n <Tooltip className={`${baseClass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,EAAK;4BAELC,IAAA,CAACvD,OAAA;MAAQgC,SAAA,EAAW,GAAGtB,SAAA,WAAoB;MAAE8C,IAAA,EAAMnC,WAAA;gBAChDK;QAEFb,QAAA;;AAGP","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../../../src/features/toolbars/shared/ToolbarDropdown/DropDown.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AACtE,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AAGhG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAUtD,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,QAAQ,EACR,MAAM,EACN,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,GACR,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,MAAM,EAAE,aAAa,CAAA;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,IAAI,EAAE,gBAAgB,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,GAAG,KAAK,CAAC,SAAS,CAiElB;AAyFD,wBAAgB,QAAQ,CAAC,EACvB,eAAe,EACf,eAAe,EACf,QAAQ,EACR,QAAgB,EAChB,WAAW,EACX,IAAI,EACJ,wBAAwB,EACxB,KAAK,EACL,oBAAoB,GACrB,EAAE;IACD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACf,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,GAAG,KAAK,CAAC,SAAS,CA0FlB"}
1
+ {"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../../../src/features/toolbars/shared/ToolbarDropdown/DropDown.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AACtE,OAAO,KAAK,EAAE,EACZ,KAAK,SAAS,EAOf,MAAM,OAAO,CAAA;AAEd,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAUtD,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,QAAQ,EACR,MAAM,EACN,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,GACR,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,MAAM,EAAE,aAAa,CAAA;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,IAAI,EAAE,gBAAgB,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,GAAG,KAAK,CAAC,SAAS,CAoElB;AAqGD,wBAAgB,QAAQ,CAAC,EACvB,eAAe,EACf,eAAe,EACf,QAAQ,EACR,QAAgB,EAChB,WAAW,EACX,IAAI,EACJ,wBAAwB,EACxB,KAAK,EACL,oBAAoB,GACrB,EAAE;IACD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACf,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,GAAG,KAAK,CAAC,SAAS,CAkIlB"}
@@ -3,8 +3,7 @@
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { Button } from '@payloadcms/ui';
5
5
  import { $addUpdateTag, isDOMNode } from 'lexical';
6
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
- import { createPortal } from 'react-dom';
6
+ import React, { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
8
7
  const baseClass = 'toolbar-popup__dropdown-item';
9
8
  const DropDownContext = /*#__PURE__*/React.createContext(null);
10
9
  export function DropDownItem({
@@ -39,7 +38,10 @@ export function DropDownItem({
39
38
  className: className,
40
39
  disabled: enabled === false,
41
40
  extraButtonProps: {
42
- 'data-item-key': itemKey
41
+ 'aria-checked': item.isActive ? Boolean(active) : undefined,
42
+ 'data-item-key': itemKey,
43
+ role: item.isActive ? 'menuitemcheckbox' : 'menuitem',
44
+ tabIndex: -1
43
45
  },
44
46
  icon: Icon,
45
47
  iconPosition: "left",
@@ -69,11 +71,13 @@ export function DropDownItem({
69
71
  });
70
72
  }
71
73
  function DropDownItems({
74
+ id,
72
75
  children,
73
76
  dropdownKey,
74
77
  dropDownRef,
75
78
  itemsContainerClassNames,
76
- onClose
79
+ onClose,
80
+ shouldAutoFocus
77
81
  }) {
78
82
  const [items, setItems] = useState();
79
83
  const [highlightedItem, setHighlightedItem] = useState();
@@ -87,25 +91,31 @@ function DropDownItems({
87
91
  const {
88
92
  key
89
93
  } = event;
90
- if (['ArrowDown', 'ArrowUp', 'Escape', 'Tab'].includes(key)) {
94
+ const enabledItems = items.filter(item => !item.current?.disabled);
95
+ if (['ArrowDown', 'ArrowUp', 'Escape'].includes(key)) {
91
96
  event.preventDefault();
92
97
  }
93
- if (key === 'Escape' || key === 'Tab') {
98
+ if (key === 'Escape') {
94
99
  onClose();
100
+ } else if (key === 'Tab') {
101
+ setTimeout(() => onClose({
102
+ restoreFocus: false
103
+ }));
95
104
  } else if (key === 'ArrowUp') {
96
105
  setHighlightedItem(prev_0 => {
97
106
  if (prev_0 == null) {
98
- return items[0];
107
+ return enabledItems[0];
99
108
  }
100
- const index = items.indexOf(prev_0) - 1;
101
- return items[index === -1 ? items.length - 1 : index];
109
+ const index = enabledItems.indexOf(prev_0) - 1;
110
+ return enabledItems[index === -1 ? enabledItems.length - 1 : index];
102
111
  });
103
112
  } else if (key === 'ArrowDown') {
104
113
  setHighlightedItem(prev_1 => {
105
114
  if (prev_1 == null) {
106
- return items[0];
115
+ return enabledItems[0];
107
116
  }
108
- return items[items.indexOf(prev_1) + 1];
117
+ const index_0 = enabledItems.indexOf(prev_1);
118
+ return enabledItems[index_0 === enabledItems.length - 1 ? 0 : index_0 + 1];
109
119
  });
110
120
  }
111
121
  };
@@ -113,21 +123,25 @@ function DropDownItems({
113
123
  registerItem
114
124
  }), [registerItem]);
115
125
  useEffect(() => {
116
- if (items != null && highlightedItem == null) {
117
- setHighlightedItem(items[0]);
126
+ if (shouldAutoFocus && items != null && highlightedItem == null) {
127
+ setHighlightedItem(items.find(item_0 => !item_0.current?.disabled));
118
128
  }
119
129
  if (highlightedItem != null && highlightedItem?.current != null) {
120
130
  highlightedItem.current.focus();
121
131
  }
122
- }, [items, highlightedItem]);
132
+ }, [items, highlightedItem, shouldAutoFocus]);
123
133
  return /*#__PURE__*/_jsx(DropDownContext, {
124
134
  value: contextValue,
125
135
  children: /*#__PURE__*/_jsx("div", {
126
136
  className: (itemsContainerClassNames ?? ['toolbar-popup__dropdown-items']).join(' '),
127
137
  "data-dropdown-key": dropdownKey,
128
138
  "data-theme": "dark",
139
+ id: id,
129
140
  onKeyDown: handleKeyDown,
141
+ popover: "manual",
130
142
  ref: dropDownRef,
143
+ role: "menu",
144
+ tabIndex: -1,
131
145
  children: children
132
146
  })
133
147
  });
@@ -145,10 +159,15 @@ export function DropDown({
145
159
  }) {
146
160
  const dropDownRef = useRef(null);
147
161
  const buttonRef = useRef(null);
162
+ const openedViaKeyboardRef = useRef(false);
163
+ const generatedId = useId();
164
+ const menuId = `toolbar-dropdown-${dropdownKey}-${generatedId}`;
148
165
  const [showDropDown, setShowDropDown] = useState(false);
149
- const handleClose = () => {
166
+ const handleClose = ({
167
+ restoreFocus = true
168
+ } = {}) => {
150
169
  setShowDropDown(false);
151
- if (buttonRef?.current != null) {
170
+ if (restoreFocus && buttonRef?.current != null) {
152
171
  buttonRef.current.focus();
153
172
  }
154
173
  };
@@ -156,13 +175,37 @@ export function DropDown({
156
175
  const button = buttonRef.current;
157
176
  const dropDown = dropDownRef.current;
158
177
  if (showDropDown && button !== null && dropDown !== null) {
159
- const {
160
- left,
161
- top
162
- } = button.getBoundingClientRect();
163
- const scrollTopOffset = window.scrollY || document.documentElement.scrollTop;
164
- dropDown.style.top = `${top + scrollTopOffset + button.offsetHeight + 5}px`;
165
- dropDown.style.left = `${Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20)}px`;
178
+ if (!dropDown.matches(':popover-open')) {
179
+ dropDown.showPopover();
180
+ }
181
+ const updatePosition = () => {
182
+ const {
183
+ bottom,
184
+ left,
185
+ top
186
+ } = button.getBoundingClientRect();
187
+ const offset = 8;
188
+ const gap = 5;
189
+ const below = bottom + gap;
190
+ const above = top - dropDown.offsetHeight - gap;
191
+ const maxTop = Math.max(offset, window.innerHeight - dropDown.offsetHeight - offset);
192
+ const preferredTop = below + dropDown.offsetHeight + offset <= window.innerHeight ? below : above >= offset ? above : below;
193
+ dropDown.style.position = 'fixed';
194
+ dropDown.style.top = `${Math.max(offset, Math.min(preferredTop, maxTop))}px`;
195
+ dropDown.style.left = `${Math.max(8, Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20))}px`;
196
+ };
197
+ updatePosition();
198
+ window.addEventListener('resize', updatePosition);
199
+ window.addEventListener('scroll', updatePosition, {
200
+ capture: true,
201
+ passive: true
202
+ });
203
+ return () => {
204
+ window.removeEventListener('resize', updatePosition);
205
+ window.removeEventListener('scroll', updatePosition, {
206
+ capture: true
207
+ });
208
+ };
166
209
  }
167
210
  }, [dropDownRef, buttonRef, showDropDown]);
168
211
  useEffect(() => {
@@ -188,23 +231,27 @@ export function DropDown({
188
231
  };
189
232
  }
190
233
  }, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf]);
191
- const portal = /*#__PURE__*/createPortal(/*#__PURE__*/_jsx(DropDownItems, {
192
- dropdownKey: dropdownKey,
193
- dropDownRef: dropDownRef,
194
- itemsContainerClassNames: itemsContainerClassNames,
195
- onClose: handleClose,
196
- children: children
197
- }), document.body);
198
234
  return /*#__PURE__*/_jsxs(React.Fragment, {
199
235
  children: [/*#__PURE__*/_jsxs("button", {
236
+ "aria-controls": menuId,
237
+ "aria-expanded": showDropDown,
238
+ "aria-haspopup": "menu",
200
239
  "aria-label": buttonAriaLabel,
201
240
  className: buttonClassName + (showDropDown ? ' active' : ''),
202
241
  "data-dropdown-key": dropdownKey,
203
242
  disabled: disabled,
204
243
  onClick: event_0 => {
205
244
  event_0.preventDefault();
245
+ openedViaKeyboardRef.current = false;
206
246
  setShowDropDown(!showDropDown);
207
247
  },
248
+ onKeyDown: event_1 => {
249
+ if (event_1.key === 'Enter' || event_1.key === ' ') {
250
+ event_1.preventDefault();
251
+ openedViaKeyboardRef.current = true;
252
+ setShowDropDown(!showDropDown);
253
+ }
254
+ },
208
255
  onMouseDown: e => {
209
256
  // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).
210
257
  // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025
@@ -219,8 +266,14 @@ export function DropDown({
219
266
  }), /*#__PURE__*/_jsx("i", {
220
267
  className: "toolbar-popup__dropdown-caret"
221
268
  })]
222
- }), showDropDown && /*#__PURE__*/_jsx(React.Fragment, {
223
- children: portal
269
+ }), showDropDown && /*#__PURE__*/_jsx(DropDownItems, {
270
+ dropdownKey: dropdownKey,
271
+ dropDownRef: dropDownRef,
272
+ id: menuId,
273
+ itemsContainerClassNames: itemsContainerClassNames,
274
+ onClose: handleClose,
275
+ shouldAutoFocus: openedViaKeyboardRef.current,
276
+ children: children
224
277
  })]
225
278
  });
226
279
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DropDown.js","names":["Button","$addUpdateTag","isDOMNode","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","baseClass","DropDownContext","createContext","DropDownItem","active","children","editor","enabled","Icon","item","itemKey","tooltip","className","key","filter","Boolean","join","ref","dropDownContext","use","Error","registerItem","current","_jsx","buttonStyle","disabled","extraButtonProps","icon","iconPosition","onClick","focus","update","onSelect","isActive","onMouseDown","e","preventDefault","type","DropDownItems","dropdownKey","dropDownRef","itemsContainerClassNames","onClose","items","setItems","highlightedItem","setHighlightedItem","itemRef","prev","handleKeyDown","event","includes","index","indexOf","length","contextValue","value","onKeyDown","DropDown","buttonAriaLabel","buttonClassName","label","stopCloseOnClickSelf","buttonRef","showDropDown","setShowDropDown","handleClose","button","dropDown","left","top","getBoundingClientRect","scrollTopOffset","window","scrollY","document","documentElement","scrollTop","style","offsetHeight","Math","min","innerWidth","offsetWidth","handle","target","contains","addEventListener","removeEventListener","portal","body","_jsxs","Fragment"],"sources":["../../../../../src/features/toolbars/shared/ToolbarDropdown/DropDown.tsx"],"sourcesContent":["'use client'\nimport { Button } from '@payloadcms/ui'\nimport { $addUpdateTag, isDOMNode, type LexicalEditor } from 'lexical'\nimport React, { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { ToolbarGroupItem } from '../../types.js'\n\nconst baseClass = 'toolbar-popup__dropdown-item'\n\ninterface DropDownContextType {\n registerItem: (ref: React.RefObject<HTMLButtonElement | null>) => void\n}\n\nconst DropDownContext = React.createContext<DropDownContextType | null>(null)\n\nexport function DropDownItem({\n active,\n children,\n editor,\n enabled,\n Icon,\n item,\n itemKey,\n tooltip,\n}: {\n active?: boolean\n children: React.ReactNode\n editor: LexicalEditor\n enabled?: boolean\n Icon: React.ReactNode\n item: ToolbarGroupItem\n itemKey: string\n tooltip?: string\n}): React.ReactNode {\n const className = useMemo(() => {\n return [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n item?.key ? `${baseClass}-${item.key}` : '',\n ]\n .filter(Boolean)\n .join(' ')\n }, [enabled, active, item.key])\n\n const ref = useRef<HTMLButtonElement>(null)\n\n const dropDownContext = React.use(DropDownContext)\n\n if (dropDownContext === null) {\n throw new Error('DropDownItem must be used within a DropDown')\n }\n\n const { registerItem } = dropDownContext\n\n useEffect(() => {\n if (ref?.current != null) {\n registerItem(ref)\n }\n }, [ref, registerItem])\n\n return (\n <Button\n aria-label={tooltip}\n buttonStyle=\"ghost\"\n className={className}\n disabled={enabled === false}\n extraButtonProps={{\n 'data-item-key': itemKey,\n }}\n icon={Icon}\n iconPosition=\"left\"\n onClick={() => {\n if (enabled !== false) {\n editor.focus(() => {\n editor.update(() => {\n $addUpdateTag('toolbar')\n })\n // We need to wrap the onSelect in the callback, so the editor is properly focused before the onSelect is called.\n item.onSelect?.({\n editor,\n isActive: active!,\n })\n })\n }\n }}\n onMouseDown={(e) => {\n // This is required for Firefox compatibility. Without it, the dropdown will disappear without the onClick being called.\n // This only happens in Firefox. Must be something about how Firefox handles focus events differently.\n e.preventDefault()\n }}\n ref={ref}\n tooltip={tooltip}\n type=\"button\"\n >\n {children}\n </Button>\n )\n}\n\nfunction DropDownItems({\n children,\n dropdownKey,\n dropDownRef,\n itemsContainerClassNames,\n onClose,\n}: {\n children: React.ReactNode\n dropdownKey?: string\n dropDownRef: React.Ref<HTMLDivElement>\n itemsContainerClassNames?: string[]\n onClose: () => void\n}): React.ReactElement {\n const [items, setItems] = useState<Array<React.RefObject<HTMLButtonElement | null>>>()\n const [highlightedItem, setHighlightedItem] =\n useState<React.RefObject<HTMLButtonElement | null>>()\n\n const registerItem = useCallback(\n (itemRef: React.RefObject<HTMLButtonElement | null>) => {\n setItems((prev) => (prev != null ? [...prev, itemRef] : [itemRef]))\n },\n [setItems],\n )\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>): void => {\n if (items == null) {\n return\n }\n\n const { key } = event\n\n if (['ArrowDown', 'ArrowUp', 'Escape', 'Tab'].includes(key)) {\n event.preventDefault()\n }\n\n if (key === 'Escape' || key === 'Tab') {\n onClose()\n } else if (key === 'ArrowUp') {\n setHighlightedItem((prev) => {\n if (prev == null) {\n return items[0]\n }\n const index = items.indexOf(prev) - 1\n return items[index === -1 ? items.length - 1 : index]\n })\n } else if (key === 'ArrowDown') {\n setHighlightedItem((prev) => {\n if (prev == null) {\n return items[0]\n }\n return items[items.indexOf(prev) + 1]\n })\n }\n }\n\n const contextValue = useMemo(\n () => ({\n registerItem,\n }),\n [registerItem],\n )\n\n useEffect(() => {\n if (items != null && highlightedItem == null) {\n setHighlightedItem(items[0])\n }\n\n if (highlightedItem != null && highlightedItem?.current != null) {\n highlightedItem.current.focus()\n }\n }, [items, highlightedItem])\n\n return (\n <DropDownContext value={contextValue}>\n <div\n className={(itemsContainerClassNames ?? ['toolbar-popup__dropdown-items']).join(' ')}\n data-dropdown-key={dropdownKey}\n data-theme=\"dark\"\n onKeyDown={handleKeyDown}\n ref={dropDownRef}\n >\n {children}\n </div>\n </DropDownContext>\n )\n}\n\nexport function DropDown({\n buttonAriaLabel,\n buttonClassName,\n children,\n disabled = false,\n dropdownKey,\n Icon,\n itemsContainerClassNames,\n label,\n stopCloseOnClickSelf,\n}: {\n buttonAriaLabel?: string\n buttonClassName: string\n children: ReactNode\n disabled?: boolean\n dropdownKey: string\n Icon?: React.FC\n itemsContainerClassNames?: string[]\n label?: string\n stopCloseOnClickSelf?: boolean\n}): React.ReactNode {\n const dropDownRef = useRef<HTMLDivElement>(null)\n const buttonRef = useRef<HTMLButtonElement>(null)\n const [showDropDown, setShowDropDown] = useState(false)\n\n const handleClose = (): void => {\n setShowDropDown(false)\n if (buttonRef?.current != null) {\n buttonRef.current.focus()\n }\n }\n\n useEffect(() => {\n const button = buttonRef.current\n const dropDown = dropDownRef.current\n\n if (showDropDown && button !== null && dropDown !== null) {\n const { left, top } = button.getBoundingClientRect()\n const scrollTopOffset = window.scrollY || document.documentElement.scrollTop\n dropDown.style.top = `${top + scrollTopOffset + button.offsetHeight + 5}px`\n dropDown.style.left = `${Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20)}px`\n }\n }, [dropDownRef, buttonRef, showDropDown])\n\n useEffect(() => {\n const button = buttonRef.current\n\n if (button !== null && showDropDown) {\n const handle = (event: MouseEvent): void => {\n const target = event.target\n if (!isDOMNode(target)) {\n return\n }\n if (stopCloseOnClickSelf) {\n if (dropDownRef.current && dropDownRef.current.contains(target)) {\n return\n }\n }\n if (!button.contains(target)) {\n setShowDropDown(false)\n }\n }\n document.addEventListener('click', handle)\n\n return () => {\n document.removeEventListener('click', handle)\n }\n }\n }, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf])\n\n const portal = createPortal(\n <DropDownItems\n dropdownKey={dropdownKey}\n dropDownRef={dropDownRef}\n itemsContainerClassNames={itemsContainerClassNames}\n onClose={handleClose}\n >\n {children}\n </DropDownItems>,\n document.body,\n )\n\n return (\n <React.Fragment>\n <button\n aria-label={buttonAriaLabel}\n className={buttonClassName + (showDropDown ? ' active' : '')}\n data-dropdown-key={dropdownKey}\n disabled={disabled}\n onClick={(event) => {\n event.preventDefault()\n setShowDropDown(!showDropDown)\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n ref={buttonRef}\n type=\"button\"\n >\n {Icon && <Icon />}\n {label && <span className=\"toolbar-popup__dropdown-label\">{label}</span>}\n <i className=\"toolbar-popup__dropdown-caret\" />\n </button>\n\n {showDropDown && <React.Fragment>{portal}</React.Fragment>}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,MAAM,QAAQ;AACvB,SAASC,aAAa,EAAEC,SAAS,QAA4B;AAC7D,OAAOC,KAAA,IAAyBC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AACzF,SAASC,YAAY,QAAQ;AAI7B,MAAMC,SAAA,GAAY;AAMlB,MAAMC,eAAA,gBAAkBR,KAAA,CAAMS,aAAa,CAA6B;AAExE,OAAO,SAASC,aAAa;EAC3BC,MAAM;EACNC,QAAQ;EACRC,MAAM;EACNC,OAAO;EACPC,IAAI;EACJC,IAAI;EACJC,OAAO;EACPC;AAAO,CAUR;EACC,MAAMC,SAAA,GAAYhB,OAAA,CAAQ;IACxB,OAAO,CACLI,SAAA,EACAO,OAAA,KAAY,QAAQ,aAAa,IACjCH,MAAA,GAAS,WAAW,IACpBK,IAAA,EAAMI,GAAA,GAAM,GAAGb,SAAA,IAAaS,IAAA,CAAKI,GAAG,EAAE,GAAG,GAC1C,CACEC,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;EACV,GAAG,CAACT,OAAA,EAASH,MAAA,EAAQK,IAAA,CAAKI,GAAG,CAAC;EAE9B,MAAMI,GAAA,GAAMpB,MAAA,CAA0B;EAEtC,MAAMqB,eAAA,GAAkBzB,KAAA,CAAM0B,GAAG,CAAClB,eAAA;EAElC,IAAIiB,eAAA,KAAoB,MAAM;IAC5B,MAAM,IAAIE,KAAA,CAAM;EAClB;EAEA,MAAM;IAAEC;EAAY,CAAE,GAAGH,eAAA;EAEzBvB,SAAA,CAAU;IACR,IAAIsB,GAAA,EAAKK,OAAA,IAAW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;QACAA,CAAA,CAAEC,cAAc;MAClB;MACAnB,GAAA,EAAK8C,SAAA;MACL1B,IAAA,EAAK;iBAEJ7B,IAAA,iBAAQe,IAAA,CAACf,IAAA,OACTqD,KAAA,iBAAStC,IAAA,CAAC;QAAKX,SAAA,EAAU;kBAAiCiD;uBAC3DtC,IAAA,CAAC;QAAEX,SAAA,EAAU;;QAGdoD,YAAA,iBAAgBzC,IAAA,CAAC9B,KAAA,CAAMmG,QAAQ;gBAAEH;;;AAGxC","ignoreList":[]}
1
+ {"version":3,"file":"DropDown.js","names":["Button","$addUpdateTag","isDOMNode","React","useCallback","useEffect","useId","useMemo","useRef","useState","baseClass","DropDownContext","createContext","DropDownItem","active","children","editor","enabled","Icon","item","itemKey","tooltip","className","key","filter","Boolean","join","ref","dropDownContext","use","Error","registerItem","current","_jsx","buttonStyle","disabled","extraButtonProps","isActive","undefined","role","tabIndex","icon","iconPosition","onClick","focus","update","onSelect","onMouseDown","e","preventDefault","type","DropDownItems","id","dropdownKey","dropDownRef","itemsContainerClassNames","onClose","shouldAutoFocus","items","setItems","highlightedItem","setHighlightedItem","itemRef","prev","handleKeyDown","event","enabledItems","includes","setTimeout","restoreFocus","index","indexOf","length","contextValue","find","value","onKeyDown","popover","DropDown","buttonAriaLabel","buttonClassName","label","stopCloseOnClickSelf","buttonRef","openedViaKeyboardRef","generatedId","menuId","showDropDown","setShowDropDown","handleClose","button","dropDown","matches","showPopover","updatePosition","bottom","left","top","getBoundingClientRect","offset","gap","below","above","offsetHeight","maxTop","Math","max","window","innerHeight","preferredTop","style","position","min","innerWidth","offsetWidth","addEventListener","capture","passive","removeEventListener","handle","target","contains","document","_jsxs","Fragment"],"sources":["../../../../../src/features/toolbars/shared/ToolbarDropdown/DropDown.tsx"],"sourcesContent":["'use client'\nimport { Button } from '@payloadcms/ui'\nimport { $addUpdateTag, isDOMNode, type LexicalEditor } from 'lexical'\nimport React, {\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport type { ToolbarGroupItem } from '../../types.js'\n\nconst baseClass = 'toolbar-popup__dropdown-item'\n\ninterface DropDownContextType {\n registerItem: (ref: React.RefObject<HTMLButtonElement | null>) => void\n}\n\nconst DropDownContext = React.createContext<DropDownContextType | null>(null)\n\nexport function DropDownItem({\n active,\n children,\n editor,\n enabled,\n Icon,\n item,\n itemKey,\n tooltip,\n}: {\n active?: boolean\n children: React.ReactNode\n editor: LexicalEditor\n enabled?: boolean\n Icon: React.ReactNode\n item: ToolbarGroupItem\n itemKey: string\n tooltip?: string\n}): React.ReactNode {\n const className = useMemo(() => {\n return [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n item?.key ? `${baseClass}-${item.key}` : '',\n ]\n .filter(Boolean)\n .join(' ')\n }, [enabled, active, item.key])\n\n const ref = useRef<HTMLButtonElement>(null)\n\n const dropDownContext = React.use(DropDownContext)\n\n if (dropDownContext === null) {\n throw new Error('DropDownItem must be used within a DropDown')\n }\n\n const { registerItem } = dropDownContext\n\n useEffect(() => {\n if (ref?.current != null) {\n registerItem(ref)\n }\n }, [ref, registerItem])\n\n return (\n <Button\n aria-label={tooltip}\n buttonStyle=\"ghost\"\n className={className}\n disabled={enabled === false}\n extraButtonProps={{\n 'aria-checked': item.isActive ? Boolean(active) : undefined,\n 'data-item-key': itemKey,\n role: item.isActive ? 'menuitemcheckbox' : 'menuitem',\n tabIndex: -1,\n }}\n icon={Icon}\n iconPosition=\"left\"\n onClick={() => {\n if (enabled !== false) {\n editor.focus(() => {\n editor.update(() => {\n $addUpdateTag('toolbar')\n })\n // We need to wrap the onSelect in the callback, so the editor is properly focused before the onSelect is called.\n item.onSelect?.({\n editor,\n isActive: active!,\n })\n })\n }\n }}\n onMouseDown={(e: React.MouseEvent) => {\n // This is required for Firefox compatibility. Without it, the dropdown will disappear without the onClick being called.\n // This only happens in Firefox. Must be something about how Firefox handles focus events differently.\n e.preventDefault()\n }}\n ref={ref}\n tooltip={tooltip}\n type=\"button\"\n >\n {children}\n </Button>\n )\n}\n\nfunction DropDownItems({\n id,\n children,\n dropdownKey,\n dropDownRef,\n itemsContainerClassNames,\n onClose,\n shouldAutoFocus,\n}: {\n children: React.ReactNode\n dropdownKey?: string\n dropDownRef: React.Ref<HTMLDivElement>\n id: string\n itemsContainerClassNames?: string[]\n onClose: (options?: { restoreFocus?: boolean }) => void\n shouldAutoFocus: boolean\n}): React.ReactElement {\n const [items, setItems] = useState<Array<React.RefObject<HTMLButtonElement | null>>>()\n const [highlightedItem, setHighlightedItem] =\n useState<React.RefObject<HTMLButtonElement | null>>()\n\n const registerItem = useCallback(\n (itemRef: React.RefObject<HTMLButtonElement | null>) => {\n setItems((prev) => (prev != null ? [...prev, itemRef] : [itemRef]))\n },\n [setItems],\n )\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>): void => {\n if (items == null) {\n return\n }\n\n const { key } = event\n const enabledItems = items.filter((item) => !item.current?.disabled)\n\n if (['ArrowDown', 'ArrowUp', 'Escape'].includes(key)) {\n event.preventDefault()\n }\n\n if (key === 'Escape') {\n onClose()\n } else if (key === 'Tab') {\n setTimeout(() => onClose({ restoreFocus: false }))\n } else if (key === 'ArrowUp') {\n setHighlightedItem((prev) => {\n if (prev == null) {\n return enabledItems[0]\n }\n const index = enabledItems.indexOf(prev) - 1\n return enabledItems[index === -1 ? enabledItems.length - 1 : index]\n })\n } else if (key === 'ArrowDown') {\n setHighlightedItem((prev) => {\n if (prev == null) {\n return enabledItems[0]\n }\n const index = enabledItems.indexOf(prev)\n return enabledItems[index === enabledItems.length - 1 ? 0 : index + 1]\n })\n }\n }\n\n const contextValue = useMemo(\n () => ({\n registerItem,\n }),\n [registerItem],\n )\n\n useEffect(() => {\n if (shouldAutoFocus && items != null && highlightedItem == null) {\n setHighlightedItem(items.find((item) => !item.current?.disabled))\n }\n\n if (highlightedItem != null && highlightedItem?.current != null) {\n highlightedItem.current.focus()\n }\n }, [items, highlightedItem, shouldAutoFocus])\n\n return (\n <DropDownContext value={contextValue}>\n <div\n className={(itemsContainerClassNames ?? ['toolbar-popup__dropdown-items']).join(' ')}\n data-dropdown-key={dropdownKey}\n data-theme=\"dark\"\n id={id}\n onKeyDown={handleKeyDown}\n popover=\"manual\"\n ref={dropDownRef}\n role=\"menu\"\n tabIndex={-1}\n >\n {children}\n </div>\n </DropDownContext>\n )\n}\n\nexport function DropDown({\n buttonAriaLabel,\n buttonClassName,\n children,\n disabled = false,\n dropdownKey,\n Icon,\n itemsContainerClassNames,\n label,\n stopCloseOnClickSelf,\n}: {\n buttonAriaLabel?: string\n buttonClassName: string\n children: ReactNode\n disabled?: boolean\n dropdownKey: string\n Icon?: React.FC\n itemsContainerClassNames?: string[]\n label?: string\n stopCloseOnClickSelf?: boolean\n}): React.ReactNode {\n const dropDownRef = useRef<HTMLDivElement>(null)\n const buttonRef = useRef<HTMLButtonElement>(null)\n const openedViaKeyboardRef = useRef(false)\n const generatedId = useId()\n const menuId = `toolbar-dropdown-${dropdownKey}-${generatedId}`\n const [showDropDown, setShowDropDown] = useState(false)\n\n const handleClose = ({ restoreFocus = true }: { restoreFocus?: boolean } = {}): void => {\n setShowDropDown(false)\n if (restoreFocus && buttonRef?.current != null) {\n buttonRef.current.focus()\n }\n }\n\n useEffect(() => {\n const button = buttonRef.current\n const dropDown = dropDownRef.current\n\n if (showDropDown && button !== null && dropDown !== null) {\n if (!dropDown.matches(':popover-open')) {\n dropDown.showPopover()\n }\n\n const updatePosition = (): void => {\n const { bottom, left, top } = button.getBoundingClientRect()\n const offset = 8\n const gap = 5\n const below = bottom + gap\n const above = top - dropDown.offsetHeight - gap\n const maxTop = Math.max(offset, window.innerHeight - dropDown.offsetHeight - offset)\n const preferredTop =\n below + dropDown.offsetHeight + offset <= window.innerHeight\n ? below\n : above >= offset\n ? above\n : below\n\n dropDown.style.position = 'fixed'\n dropDown.style.top = `${Math.max(offset, Math.min(preferredTop, maxTop))}px`\n dropDown.style.left = `${Math.max(8, Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20))}px`\n }\n\n updatePosition()\n window.addEventListener('resize', updatePosition)\n window.addEventListener('scroll', updatePosition, { capture: true, passive: true })\n\n return () => {\n window.removeEventListener('resize', updatePosition)\n window.removeEventListener('scroll', updatePosition, { capture: true })\n }\n }\n }, [dropDownRef, buttonRef, showDropDown])\n\n useEffect(() => {\n const button = buttonRef.current\n\n if (button !== null && showDropDown) {\n const handle = (event: MouseEvent): void => {\n const target = event.target\n if (!isDOMNode(target)) {\n return\n }\n if (stopCloseOnClickSelf) {\n if (dropDownRef.current && dropDownRef.current.contains(target)) {\n return\n }\n }\n if (!button.contains(target)) {\n setShowDropDown(false)\n }\n }\n document.addEventListener('click', handle)\n\n return () => {\n document.removeEventListener('click', handle)\n }\n }\n }, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf])\n\n return (\n <React.Fragment>\n <button\n aria-controls={menuId}\n aria-expanded={showDropDown}\n aria-haspopup=\"menu\"\n aria-label={buttonAriaLabel}\n className={buttonClassName + (showDropDown ? ' active' : '')}\n data-dropdown-key={dropdownKey}\n disabled={disabled}\n onClick={(event) => {\n event.preventDefault()\n openedViaKeyboardRef.current = false\n setShowDropDown(!showDropDown)\n }}\n onKeyDown={(event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n openedViaKeyboardRef.current = true\n setShowDropDown(!showDropDown)\n }\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n ref={buttonRef}\n type=\"button\"\n >\n {Icon && <Icon />}\n {label && <span className=\"toolbar-popup__dropdown-label\">{label}</span>}\n <i className=\"toolbar-popup__dropdown-caret\" />\n </button>\n\n {showDropDown && (\n <DropDownItems\n dropdownKey={dropdownKey}\n dropDownRef={dropDownRef}\n id={menuId}\n itemsContainerClassNames={itemsContainerClassNames}\n onClose={handleClose}\n shouldAutoFocus={openedViaKeyboardRef.current}\n >\n {children}\n </DropDownItems>\n )}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,MAAM,QAAQ;AACvB,SAASC,aAAa,EAAEC,SAAS,QAA4B;AAC7D,OAAOC,KAAA,IAELC,WAAW,EACXC,SAAS,EACTC,KAAK,EACLC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH;AAIP,MAAMC,SAAA,GAAY;AAMlB,MAAMC,eAAA,gBAAkBR,KAAA,CAAMS,aAAa,CAA6B;AAExE,OAAO,SAASC,aAAa;EAC3BC,MAAM;EACNC,QAAQ;EACRC,MAAM;EACNC,OAAO;EACPC,IAAI;EACJC,IAAI;EACJC,OAAO;EACPC;AAAO,CAUR;EACC,MAAMC,SAAA,GAAYf,OAAA,CAAQ;IACxB,OAAO,CACLG,SAAA,EACAO,OAAA,KAAY,QAAQ,aAAa,IACjCH,MAAA,GAAS,WAAW,IACpBK,IAAA,EAAMI,GAAA,GAAM,GAAGb,SAAA,IAAaS,IAAA,CAAKI,GAAG,EAAE,GAAG,GAC1C,CACEC,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;EACV,GAAG,CAACT,OAAA,EAASH,MAAA,EAAQK,IAAA,CAAKI,GAAG,CAAC;EAE9B,MAAMI,GAAA,GAAMnB,MAAA,CAA0B;EAEtC,MAAMoB,eAAA,GAAkBzB,KAAA,CAAM0B,GAAG,CAAClB,eAAA;EAElC,IAAIiB,eAAA,KAAoB,MAAM;IAC5B,MAAM,IAAIE,KAAA,CAAM;EAClB;EAEA,MAAM;IAAEC;EAAY,CAAE,GAAGH,eAAA;EAEzBvB,SAAA,CAAU;IACR,IAAIsB,GAAA,EAAKK,OAAA,IAAW,MAAM;MACxBD,YAAA,CAAaJ,GAAA;IACf;EACF,GAAG,CAACA,G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KAAA,CAAMyH,QAAQ;4BACbD,KAAA,CAAC;MACC,iBAAerC,MAAA;MACf,iBAAeC,YAAA;MACf,iBAAc;MACd,cAAYR,eAAA;MACZzD,SAAA,EAAW0D,eAAA,IAAmBO,YAAA,GAAe,YAAY,EAAC;MAC1D,qBAAmBlC,WAAA;MACnBlB,QAAA,EAAUA,QAAA;MACVQ,OAAA,EAAUsB,OAAA;QACRA,OAAA,CAAMhB,cAAc;QACpBmC,oBAAA,CAAqBpD,OAAO,GAAG;QAC/BwD,eAAA,CAAgB,CAACD,YAAA;MACnB;MACAX,SAAA,EAAYX,OAAA;QACV,IAAIA,OAAA,CAAM1C,GAAG,KAAK,WAAW0C,OAAA,CAAM1C,GAAG,KAAK,KAAK;UAC9C0C,OAAA,CAAMhB,cAAc;UACpBmC,oBAAA,CAAqBpD,OAAO,GAAG;UAC/BwD,eAAA,CAAgB,CAACD,YAAA;QACnB;MACF;MACAxC,WAAA,EAAcC,CAAA;QACZ;QACA;QACA;QACAA,CAAA,CAAEC,cAAc;MAClB;MACAtB,GAAA,EAAKwD,SAAA;MACLjC,IAAA,EAAK;iBAEJhC,IAAA,iBAAQe,IAAA,CAACf,IAAA,OACT+D,KAAA,iBAAShD,IAAA,CAAC;QAAKX,SAAA,EAAU;kBAAiC2D;uBAC3DhD,IAAA,CAAC;QAAEX,SAAA,EAAU;;QAGdiE,YAAA,iBACCtD,IAAA,CAACkB,aAAA;MACCE,WAAA,EAAaA,WAAA;MACbC,WAAA,EAAaA,WAAA;MACbF,EAAA,EAAIkC,MAAA;MACJ/B,wBAAA,EAA0BA,wBAAA;MAC1BC,OAAA,EAASiC,WAAA;MACThC,eAAA,EAAiB2B,oBAAA,CAAqBpD,OAAO;gBAE5CjB;;;AAKX","ignoreList":[]}
@@ -70,11 +70,15 @@
70
70
  .toolbar-popup__dropdown-items {
71
71
  --dropdown-min-width: 5rem;
72
72
  position: absolute;
73
+ inset: auto;
74
+ margin: 0;
73
75
  background: var(--color-bg-elevated);
74
76
  color: var(--color-text);
75
77
  border-radius: var(--radius-large);
76
78
  padding: var(--spacer-2);
77
79
  min-width: var(--dropdown-min-width);
80
+ max-height: calc(100vh - var(--spacer-3));
81
+ overflow-y: auto;
78
82
  z-index: 100;
79
83
  box-shadow: var(--elevation-300-tooltip);
80
84
 
@@ -83,7 +87,6 @@
83
87
  cursor: pointer;
84
88
  color: var(--color-text);
85
89
  position: relative;
86
- font-family: var(--text-body-medium-font-family);
87
90
  font-size: var(--text-body-medium-font-size);
88
91
  font-weight: var(--text-body-medium-font-weight);
89
92
  line-height: var(--text-body-medium-line-height);
@@ -185,20 +188,21 @@
185
188
  }
186
189
 
187
190
  [data-dropdown-key='text'] {
188
- & .toolbar-popup__dropdown-item {
189
- padding: 0 var(--spacer-4);
191
+ /* Reserved on every item, not just the active one, so the checkmark never overlaps the item icon. */
192
+ & .toolbar-popup__dropdown-item::before {
193
+ content: '';
194
+ flex-shrink: 0;
195
+ width: var(--spacer-3);
196
+ height: var(--spacer-3);
197
+ background-color: currentColor;
198
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M12.277 3.584a.5.5 0 0 1 .139.693l-5 7.5a.5.5 0 0 1-.77.077l-3-3a.5.5 0 0 1 .708-.708l2.568 2.57 4.662-6.993a.5.5 0 0 1 .693-.139' fill='black'/%3E%3C/svg%3E");
199
+ mask-size: contain;
200
+ mask-repeat: no-repeat;
201
+ visibility: hidden;
190
202
  }
191
203
 
192
204
  & .toolbar-popup__dropdown-item.active::before {
193
- content: '';
194
- position: absolute;
195
- inset-inline-start: var(--spacer-2-5);
196
- top: 50%;
197
- width: var(--spacer-1);
198
- height: var(--spacer-2);
199
- border: solid var(--color-text-onselected-strong);
200
- border-width: 0 1px 1px 0;
201
- transform: translateY(-60%) rotate(45deg);
205
+ visibility: visible;
202
206
  }
203
207
 
204
208
  .btn__icon {
@@ -0,0 +1,5 @@
1
+ import type { RefObject } from 'react';
2
+ export declare function useToolbarKeyboardNavigation({ toolbarRef, }: {
3
+ toolbarRef: RefObject<HTMLDivElement | null>;
4
+ }): void;
5
+ //# sourceMappingURL=useToolbarKeyboardNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToolbarKeyboardNavigation.d.ts","sourceRoot":"","sources":["../../../../src/features/toolbars/shared/useToolbarKeyboardNavigation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,wBAAgB,4BAA4B,CAAC,EAC3C,UAAU,GACX,EAAE;IACD,UAAU,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;CAC7C,QAwFA"}
@@ -0,0 +1,79 @@
1
+ 'use client';
2
+
3
+ import { useEffect } from 'react';
4
+ export function useToolbarKeyboardNavigation({
5
+ toolbarRef
6
+ }) {
7
+ useEffect(() => {
8
+ const toolbar = toolbarRef.current;
9
+ if (!toolbar) {
10
+ return;
11
+ }
12
+ let activeButton;
13
+ const getButtons = () => Array.from(toolbar.querySelectorAll('button')).filter(button => !button.closest('[role="menu"]') && button.closest('[role="toolbar"]') === toolbar);
14
+ const updateTabStops = () => {
15
+ const buttons = getButtons();
16
+ const enabledButtons = buttons.filter(button_0 => !button_0.disabled);
17
+ if (!activeButton || !enabledButtons.includes(activeButton)) {
18
+ activeButton = enabledButtons[0];
19
+ }
20
+ for (const button_1 of buttons) {
21
+ button_1.tabIndex = button_1 === activeButton ? 0 : -1;
22
+ }
23
+ };
24
+ const handleFocus = event => {
25
+ const button_3 = getButtons().find(button_2 => button_2 === event.target);
26
+ if (button_3) {
27
+ activeButton = button_3;
28
+ updateTabStops();
29
+ }
30
+ };
31
+ const handleKeyDown = event_0 => {
32
+ if (event_0.altKey || event_0.ctrlKey || event_0.metaKey || event_0.shiftKey) {
33
+ return;
34
+ }
35
+ const buttons_0 = getButtons().filter(button_4 => !button_4.disabled);
36
+ const index = buttons_0.findIndex(button_5 => button_5 === event_0.target);
37
+ // Dropdown menus and custom inputs retain their own keyboard behavior.
38
+ if (index === -1) {
39
+ return;
40
+ }
41
+ const isRTL = getComputedStyle(toolbar).direction === 'rtl';
42
+ let nextIndex;
43
+ switch (event_0.key) {
44
+ case 'ArrowLeft':
45
+ nextIndex = index + (isRTL ? 1 : -1);
46
+ break;
47
+ case 'ArrowRight':
48
+ nextIndex = index + (isRTL ? -1 : 1);
49
+ break;
50
+ case 'End':
51
+ nextIndex = buttons_0.length - 1;
52
+ break;
53
+ case 'Home':
54
+ nextIndex = 0;
55
+ break;
56
+ default:
57
+ return;
58
+ }
59
+ event_0.preventDefault();
60
+ event_0.stopPropagation();
61
+ buttons_0[(nextIndex + buttons_0.length) % buttons_0.length]?.focus();
62
+ };
63
+ updateTabStops();
64
+ const observer = new MutationObserver(updateTabStops);
65
+ observer.observe(toolbar, {
66
+ attributeFilter: ['disabled'],
67
+ childList: true,
68
+ subtree: true
69
+ });
70
+ toolbar.addEventListener('focusin', handleFocus);
71
+ toolbar.addEventListener('keydown', handleKeyDown);
72
+ return () => {
73
+ observer.disconnect();
74
+ toolbar.removeEventListener('focusin', handleFocus);
75
+ toolbar.removeEventListener('keydown', handleKeyDown);
76
+ };
77
+ }, [toolbarRef]);
78
+ }
79
+ //# sourceMappingURL=useToolbarKeyboardNavigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToolbarKeyboardNavigation.js","names":["useEffect","useToolbarKeyboardNavigation","toolbarRef","toolbar","current","activeButton","getButtons","Array","from","querySelectorAll","filter","button","closest","updateTabStops","buttons","enabledButtons","disabled","includes","tabIndex","handleFocus","event","find","target","handleKeyDown","altKey","ctrlKey","metaKey","shiftKey","index","findIndex","isRTL","getComputedStyle","direction","nextIndex","key","length","preventDefault","stopPropagation","focus","observer","MutationObserver","observe","attributeFilter","childList","subtree","addEventListener","disconnect","removeEventListener"],"sources":["../../../../src/features/toolbars/shared/useToolbarKeyboardNavigation.ts"],"sourcesContent":["'use client'\n\nimport type { RefObject } from 'react'\n\nimport { useEffect } from 'react'\n\nexport function useToolbarKeyboardNavigation({\n toolbarRef,\n}: {\n toolbarRef: RefObject<HTMLDivElement | null>\n}) {\n useEffect(() => {\n const toolbar = toolbarRef.current\n\n if (!toolbar) {\n return\n }\n\n let activeButton: HTMLButtonElement | undefined\n const getButtons = () =>\n Array.from(toolbar.querySelectorAll<HTMLButtonElement>('button')).filter(\n (button) =>\n !button.closest('[role=\"menu\"]') && button.closest('[role=\"toolbar\"]') === toolbar,\n )\n\n const updateTabStops = () => {\n const buttons = getButtons()\n const enabledButtons = buttons.filter((button) => !button.disabled)\n\n if (!activeButton || !enabledButtons.includes(activeButton)) {\n activeButton = enabledButtons[0]\n }\n\n for (const button of buttons) {\n button.tabIndex = button === activeButton ? 0 : -1\n }\n }\n\n const handleFocus = (event: FocusEvent) => {\n const button = getButtons().find((button) => button === event.target)\n\n if (button) {\n activeButton = button\n updateTabStops()\n }\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {\n return\n }\n\n const buttons = getButtons().filter((button) => !button.disabled)\n const index = buttons.findIndex((button) => button === event.target)\n\n // Dropdown menus and custom inputs retain their own keyboard behavior.\n if (index === -1) {\n return\n }\n\n const isRTL = getComputedStyle(toolbar).direction === 'rtl'\n let nextIndex: number\n\n switch (event.key) {\n case 'ArrowLeft':\n nextIndex = index + (isRTL ? 1 : -1)\n break\n case 'ArrowRight':\n nextIndex = index + (isRTL ? -1 : 1)\n break\n case 'End':\n nextIndex = buttons.length - 1\n break\n case 'Home':\n nextIndex = 0\n break\n default:\n return\n }\n\n event.preventDefault()\n event.stopPropagation()\n buttons[(nextIndex + buttons.length) % buttons.length]?.focus()\n }\n\n updateTabStops()\n const observer = new MutationObserver(updateTabStops)\n\n observer.observe(toolbar, { attributeFilter: ['disabled'], childList: true, subtree: true })\n toolbar.addEventListener('focusin', handleFocus)\n toolbar.addEventListener('keydown', handleKeyDown)\n\n return () => {\n observer.disconnect()\n toolbar.removeEventListener('focusin', handleFocus)\n toolbar.removeEventListener('keydown', handleKeyDown)\n }\n }, [toolbarRef])\n}\n"],"mappings":"AAAA;;AAIA,SAASA,SAAS,QAAQ;AAE1B,OAAO,SAASC,6BAA6B;EAC3CC;AAAU,CAGX;EACCF,SAAA,CAAU;IACR,MAAMG,OAAA,GAAUD,UAAA,CAAWE,OAAO;IAElC,IAAI,CAACD,OAAA,EAAS;MACZ;IACF;IAEA,IAAIE,YAAA;IACJ,MAAMC,UAAA,GAAaA,CAAA,KACjBC,KAAA,CAAMC,IAAI,CAACL,OAAA,CAAQM,gBAAgB,CAAoB,WAAWC,MAAM,CACrEC,MAAA,IACC,CAACA,MAAA,CAAOC,OAAO,CAAC,oBAAoBD,MAAA,CAAOC,OAAO,CAAC,wBAAwBT,OAAA;IAGjF,MAAMU,cAAA,GAAiBA,CAAA;MACrB,MAAMC,OAAA,GAAUR,UAAA;MAChB,MAAMS,cAAA,GAAiBD,OAAA,CAAQJ,MAAM,CAAEC,QAAA,IAAW,CAACA,QAAA,CAAOK,QAAQ;MAElE,IAAI,CAACX,YAAA,IAAgB,CAACU,cAAA,CAAeE,QAAQ,CAACZ,YAAA,GAAe;QAC3DA,YAAA,GAAeU,cAAc,CAAC,EAAE;MAClC;MAEA,KAAK,MAAMJ,QAAA,IAAUG,OAAA,EAAS;QAC5BH,QAAA,CAAOO,QAAQ,GAAGP,QAAA,KAAWN,YAAA,GAAe,IAAI,CAAC;MACnD;IACF;IAEA,MAAMc,WAAA,GAAeC,KAAA;MACnB,MAAMT,QAAA,GAASL,UAAA,GAAae,IAAI,CAAEV,QAAA,IAAWA,QAAA,KAAWS,KAAA,CAAME,MAAM;MAEpE,IAAIX,QAAA,EAAQ;QACVN,YAAA,GAAeM,QAAA;QACfE,cAAA;MACF;IACF;IAEA,MAAMU,aAAA,GAAiBH,OAAA;MACrB,IAAIA,OAAA,CAAMI,MAAM,IAAIJ,OA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B3C,OAAA,CAAQ4C,mBAAmB,CAAC,WAAW5B,WAAA;MACvChB,OAAA,CAAQ4C,mBAAmB,CAAC,WAAWxB,aAAA;IACzC;EACF,GAAG,CAACrB,UAAA,CAAW;AACjB","ignoreList":[]}
@@ -2,7 +2,7 @@ import type { Transformer } from '@lexical/markdown';
2
2
  import type { GenericLanguages, I18nClient } from '@payloadcms/translations';
3
3
  import type { JSONSchema4 } from 'json-schema';
4
4
  import type { Klass, LexicalNode, LexicalNodeReplacement, SerializedEditorState, SerializedLexicalNode } from 'lexical';
5
- import type { Field, FieldSchemaMap, FieldsToJSONSchemaArgs, ImportMapGenerators, JsonObject, PayloadComponent, PayloadRequest, PopulateType, ReplaceAny, RequestContext, RichTextField, RichTextHooks, SanitizedConfig, TypedFallbackLocale, ValidateOptions, ValidationFieldError } from 'payload';
5
+ import type { Field, FieldOperation, FieldSchemaMap, FieldsToJSONSchemaArgs, ImportMapGenerators, JsonObject, PayloadComponent, PayloadRequest, PopulateType, ReplaceAny, RequestContext, RichTextField, RichTextHooks, SanitizedConfig, TypedFallbackLocale, ValidateOptions, ValidationFieldError } from 'payload';
6
6
  import type { ServerEditorConfig } from '../lexical/config/types.js';
7
7
  import type { LexicalRichTextField } from '../types/index.js';
8
8
  import type { ElementNodeSchemaFn } from '../types/jsonSchemaHelpers.js';
@@ -58,7 +58,7 @@ export type FeatureProviderServer<UnSanitizedServerFeatureProps = undefined, Ser
58
58
  parentIsLocalized: boolean;
59
59
  resolvedFeatures: ResolvedServerFeatureMap;
60
60
  unSanitizedEditorConfig: ServerEditorConfig;
61
- }) => Promise<ServerFeature<ServerFeatureProps, ClientFeatureProps>> | ServerFeature<ServerFeatureProps, ClientFeatureProps>) | ServerFeature<ServerFeatureProps, ClientFeatureProps>;
61
+ }) => ServerFeature<ServerFeatureProps, ClientFeatureProps>) | ServerFeature<ServerFeatureProps, ClientFeatureProps>;
62
62
  key: string;
63
63
  /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */
64
64
  serverFeatureProps: UnSanitizedServerFeatureProps;
@@ -116,7 +116,7 @@ export type AfterChangeNodeHookArgs<T extends SerializedLexicalNode> = {
116
116
  };
117
117
  export type BeforeValidateNodeHookArgs<T extends SerializedLexicalNode> = {
118
118
  /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */
119
- operation: 'create' | 'delete' | 'read' | 'update';
119
+ operation: FieldOperation;
120
120
  /** The value of the node before any changes. Not available in afterRead hooks */
121
121
  originalNode: T;
122
122
  overrideAccess: boolean;
@@ -128,7 +128,7 @@ export type BeforeChangeNodeHookArgs<T extends SerializedLexicalNode> = {
128
128
  errors: ValidationFieldError[];
129
129
  mergeLocaleActions: (() => Promise<void> | void)[];
130
130
  /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */
131
- operation: 'create' | 'delete' | 'read' | 'update';
131
+ operation: FieldOperation;
132
132
  /** The value of the node before any changes. Not available in afterRead hooks */
133
133
  originalNode: T;
134
134
  /**
@@ -159,6 +159,10 @@ export type JSONSchemaArgs = {
159
159
  nodeUnionName: string;
160
160
  } & Pick<FieldsToJSONSchemaArgs, 'collectionIDFieldTypes' | 'config' | 'i18n' | 'interfaceNameDefinitions' | 'typeStringDefinitions' | 'variant'>;
161
161
  export type JSONSchemaFn = (args: JSONSchemaArgs) => JSONSchema4;
162
+ type SerializedNodeJSON<T extends LexicalNode> = T['exportJSON'] extends {
163
+ (compact?: false): infer Serialized extends SerializedLexicalNode;
164
+ (compact: boolean): unknown;
165
+ } ? Serialized : never;
162
166
  export type NodeWithHooks<T extends LexicalNode = any> = {
163
167
  /**
164
168
  * If a node includes sub-fields (e.g. block and link nodes), passing those subFields here will make payload
@@ -168,14 +172,14 @@ export type NodeWithHooks<T extends LexicalNode = any> = {
168
172
  /**
169
173
  * Optional. If not provided, all possible sub-fields should be returned.
170
174
  */
171
- node?: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>;
175
+ node?: SerializedNodeJSON<ReplaceAny<T, LexicalNode>>;
172
176
  req?: PayloadRequest;
173
177
  }) => Field[] | null;
174
178
  /**
175
179
  * If a node includes sub-fields, the sub-fields data needs to be returned here, alongside `getSubFields` which returns their schema.
176
180
  */
177
181
  getSubFieldsData?: (args: {
178
- node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>;
182
+ node: SerializedNodeJSON<ReplaceAny<T, LexicalNode>>;
179
183
  req: PayloadRequest;
180
184
  }) => JsonObject;
181
185
  /**
@@ -184,15 +188,15 @@ export type NodeWithHooks<T extends LexicalNode = any> = {
184
188
  * This is because the Rest API hooks do not have access to the 'depth' property provided by graphQL.
185
189
  * In order for them to be populated correctly in graphQL, the population logic needs to be provided here.
186
190
  */
187
- graphQLPopulationPromises?: Array<PopulationPromise<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>;
191
+ graphQLPopulationPromises?: Array<PopulationPromise<SerializedNodeJSON<ReplaceAny<T, LexicalNode>>>>;
188
192
  /**
189
193
  * Just like payload fields, you can provide hooks which are run for this specific node. These are called Node Hooks.
190
194
  */
191
195
  hooks?: {
192
- afterChange?: Array<AfterChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>;
193
- afterRead?: Array<AfterReadNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>;
194
- beforeChange?: Array<BeforeChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>;
195
- beforeValidate?: Array<BeforeValidateNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>;
196
+ afterChange?: Array<AfterChangeNodeHook<SerializedNodeJSON<ReplaceAny<T, LexicalNode>>>>;
197
+ afterRead?: Array<AfterReadNodeHook<SerializedNodeJSON<ReplaceAny<T, LexicalNode>>>>;
198
+ beforeChange?: Array<BeforeChangeNodeHook<SerializedNodeJSON<ReplaceAny<T, LexicalNode>>>>;
199
+ beforeValidate?: Array<BeforeValidateNodeHook<SerializedNodeJSON<ReplaceAny<T, LexicalNode>>>>;
196
200
  };
197
201
  /**
198
202
  * Returns the JSON Schema for this node, plus optional standalone TS
@@ -208,7 +212,7 @@ export type NodeWithHooks<T extends LexicalNode = any> = {
208
212
  * This allows you to provide node validations, which are run when your document is being validated, alongside other payload fields.
209
213
  * You can use it to throw a validation error for a specific node in case its data is incorrect.
210
214
  */
211
- validations?: Array<NodeValidation<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>;
215
+ validations?: Array<NodeValidation<SerializedNodeJSON<ReplaceAny<T, LexicalNode>>>>;
212
216
  };
213
217
  export type ServerFeature<ServerProps, ClientFeatureProps> = {
214
218
  ClientFeature?: PayloadComponent<never, BaseClientFeatureProps<ClientFeatureProps>>;
@@ -289,4 +293,5 @@ export type SanitizedServerFeatures = {
289
293
  /** The node types mapped to their validations */
290
294
  validations: Map<string, Array<NodeValidation>>;
291
295
  } & Required<Pick<ResolvedServerFeature<any, any>, 'i18n' | 'nodes'>>;
296
+ export {};
292
297
  //# sourceMappingURL=typesServer.d.ts.map