@payloadcms/richtext-lexical 4.0.0-internal.293e026 → 4.0.0-internal.2a3c3bc

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 (794) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/exports/client/Field-MT4FK3IP.js +2 -0
  3. package/dist/exports/client/Field-MT4FK3IP.js.map +7 -0
  4. package/dist/exports/client/chunk-3LRZDIIG.js +2 -0
  5. package/dist/exports/client/chunk-3LRZDIIG.js.map +7 -0
  6. package/dist/exports/client/chunk-E6LSRRP2.js +2 -0
  7. package/dist/exports/client/chunk-E6LSRRP2.js.map +7 -0
  8. package/dist/exports/client/chunk-ZQX5HXUL.js +2 -0
  9. package/dist/exports/client/chunk-ZQX5HXUL.js.map +7 -0
  10. package/dist/exports/client/component-6DQLENIE.js +2 -0
  11. package/dist/exports/client/component-6DQLENIE.js.map +7 -0
  12. package/dist/exports/client/componentInline-HNE5G4TE.js +2 -0
  13. package/dist/exports/client/index.d.ts +1 -3
  14. package/dist/exports/client/index.d.ts.map +1 -1
  15. package/dist/exports/client/index.js +28 -29
  16. package/dist/exports/client/index.js.map +4 -4
  17. package/dist/features/align/client/toolbarAlignGroup.d.ts.map +1 -1
  18. package/dist/features/blockquote/client/index.js +2 -2
  19. package/dist/features/blockquote/client/index.js.map +1 -1
  20. package/dist/features/blockquote/server/index.js +2 -2
  21. package/dist/features/blockquote/server/index.js.map +1 -1
  22. package/dist/features/blocks/client/component/BlockReordering/index.d.ts +11 -0
  23. package/dist/features/blocks/client/component/BlockReordering/index.d.ts.map +1 -0
  24. package/dist/features/blocks/client/component/BlockReordering/index.js +18 -0
  25. package/dist/features/blocks/client/component/BlockReordering/index.js.map +1 -0
  26. package/dist/features/blocks/client/component/index.css +2 -2
  27. package/dist/features/blocks/client/component/index.d.ts +0 -6
  28. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  29. package/dist/features/blocks/client/component/index.js +169 -101
  30. package/dist/features/blocks/client/component/index.js.map +1 -1
  31. package/dist/features/blocks/client/component/useBlockReordering.d.ts +16 -0
  32. package/dist/features/blocks/client/component/useBlockReordering.d.ts.map +1 -0
  33. package/dist/features/blocks/client/component/useBlockReordering.js +178 -0
  34. package/dist/features/blocks/client/component/useBlockReordering.js.map +1 -0
  35. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts.map +1 -1
  36. package/dist/features/blocks/client/componentInline/index.css +8 -9
  37. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  38. package/dist/features/blocks/client/componentInline/index.js +30 -22
  39. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  40. package/dist/features/blocks/client/getBlockImageComponent.d.ts +1 -1
  41. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts +9 -0
  42. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts.map +1 -0
  43. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js +95 -0
  44. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -0
  45. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +1 -1
  46. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -1
  47. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +1 -1
  48. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -1
  49. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +1 -1
  50. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -1
  51. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +5 -2
  52. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -1
  53. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +1 -2
  54. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -1
  55. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
  56. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  57. package/dist/features/blocks/client/nodes/BlocksNode.js +0 -10
  58. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  59. package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
  60. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.css +1 -1
  61. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.css +2 -4
  62. package/dist/features/blocks/premade/CodeBlock/Component/index.css +5 -5
  63. package/dist/features/blocks/server/graphQLPopulationPromise.d.ts.map +1 -1
  64. package/dist/features/blocks/server/index.js +2 -2
  65. package/dist/features/blocks/server/index.js.map +1 -1
  66. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +1 -1
  67. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -1
  68. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
  69. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  70. package/dist/features/blocks/server/nodes/BlocksNode.js +1 -12
  71. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  72. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
  73. package/dist/features/blocks/server/nodes/InlineBlocksNode.js +2 -2
  74. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  75. package/dist/features/blocks/server/schema.d.ts +2 -0
  76. package/dist/features/blocks/server/schema.d.ts.map +1 -1
  77. package/dist/features/blocks/server/schema.js +10 -11
  78. package/dist/features/blocks/server/schema.js.map +1 -1
  79. package/dist/features/blocks/server/validate.d.ts.map +1 -1
  80. package/dist/features/blocks/server/validate.js +1 -1
  81. package/dist/features/blocks/server/validate.js.map +1 -1
  82. package/dist/features/converters/htmlToLexical/index.d.ts.map +1 -1
  83. package/dist/features/converters/lexicalToHtml/async/converters/heading.js +1 -1
  84. package/dist/features/converters/lexicalToHtml/async/converters/heading.js.map +1 -1
  85. package/dist/features/converters/lexicalToHtml/async/converters/list.d.ts.map +1 -1
  86. package/dist/features/converters/lexicalToHtml/async/converters/list.js +4 -3
  87. package/dist/features/converters/lexicalToHtml/async/converters/list.js.map +1 -1
  88. package/dist/features/converters/lexicalToHtml/async/converters/upload.js +3 -3
  89. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  90. package/dist/features/converters/lexicalToHtml/shared/cssColors.d.ts.map +1 -1
  91. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.d.ts.map +1 -1
  92. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js +3 -2
  93. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js.map +1 -1
  94. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js +1 -1
  95. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js.map +1 -1
  96. package/dist/features/converters/lexicalToHtml/sync/converters/list.d.ts.map +1 -1
  97. package/dist/features/converters/lexicalToHtml/sync/converters/list.js +4 -3
  98. package/dist/features/converters/lexicalToHtml/sync/converters/list.js.map +1 -1
  99. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +3 -3
  100. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
  101. package/dist/features/converters/lexicalToJSX/converter/converters/heading.d.ts.map +1 -1
  102. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +2 -1
  103. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
  104. package/dist/features/converters/lexicalToJSX/converter/converters/list.d.ts.map +1 -1
  105. package/dist/features/converters/lexicalToJSX/converter/converters/list.js +2 -1
  106. package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
  107. package/dist/features/converters/lexicalToJSX/converter/converters/upload.d.ts.map +1 -1
  108. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +4 -5
  109. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
  110. package/dist/features/converters/lexicalToMarkdown/index.d.ts.map +1 -1
  111. package/dist/features/converters/lexicalToMarkdown/index.js +1 -1
  112. package/dist/features/converters/lexicalToMarkdown/index.js.map +1 -1
  113. package/dist/features/converters/markdownToLexical/index.d.ts.map +1 -1
  114. package/dist/features/converters/markdownToLexical/index.js +5 -2
  115. package/dist/features/converters/markdownToLexical/index.js.map +1 -1
  116. package/dist/features/converters/utilities/payloadPopulateFn.d.ts.map +1 -1
  117. package/dist/features/converters/utilities/payloadPopulateFn.js +4 -2
  118. package/dist/features/converters/utilities/payloadPopulateFn.js.map +1 -1
  119. package/dist/features/debug/jsxConverter/client/plugin/style.css +2 -2
  120. package/dist/features/debug/testRecorder/client/plugin/index.css +0 -1
  121. package/dist/features/format/bold/feature.client.js +1 -1
  122. package/dist/features/format/bold/feature.client.js.map +1 -1
  123. package/dist/features/format/bold/feature.server.d.ts.map +1 -1
  124. package/dist/features/format/bold/feature.server.js +1 -1
  125. package/dist/features/format/bold/feature.server.js.map +1 -1
  126. package/dist/features/format/inlineCode/feature.client.js +1 -1
  127. package/dist/features/format/inlineCode/feature.client.js.map +1 -1
  128. package/dist/features/format/inlineCode/feature.server.d.ts.map +1 -1
  129. package/dist/features/format/inlineCode/feature.server.js +1 -1
  130. package/dist/features/format/inlineCode/feature.server.js.map +1 -1
  131. package/dist/features/format/italic/feature.client.js +1 -1
  132. package/dist/features/format/italic/feature.client.js.map +1 -1
  133. package/dist/features/format/italic/feature.server.d.ts.map +1 -1
  134. package/dist/features/format/italic/feature.server.js +1 -1
  135. package/dist/features/format/italic/feature.server.js.map +1 -1
  136. package/dist/features/format/shared/toolbarFormatGroup.d.ts.map +1 -1
  137. package/dist/features/format/strikethrough/feature.client.js +1 -1
  138. package/dist/features/format/strikethrough/feature.client.js.map +1 -1
  139. package/dist/features/format/strikethrough/feature.server.d.ts.map +1 -1
  140. package/dist/features/format/strikethrough/feature.server.js +1 -1
  141. package/dist/features/format/strikethrough/feature.server.js.map +1 -1
  142. package/dist/features/heading/client/index.js +2 -2
  143. package/dist/features/heading/client/index.js.map +1 -1
  144. package/dist/features/heading/constants.d.ts +2 -0
  145. package/dist/features/heading/constants.d.ts.map +1 -0
  146. package/dist/features/heading/constants.js +2 -0
  147. package/dist/features/heading/constants.js.map +1 -0
  148. package/dist/features/heading/markdownTransformer.d.ts +2 -2
  149. package/dist/features/heading/markdownTransformer.d.ts.map +1 -1
  150. package/dist/features/heading/markdownTransformer.js +6 -19
  151. package/dist/features/heading/markdownTransformer.js.map +1 -1
  152. package/dist/features/heading/server/index.d.ts.map +1 -1
  153. package/dist/features/heading/server/index.js +7 -3
  154. package/dist/features/heading/server/index.js.map +1 -1
  155. package/dist/features/heading/server/schema.d.ts.map +1 -1
  156. package/dist/features/heading/server/validate.d.ts +6 -0
  157. package/dist/features/heading/server/validate.d.ts.map +1 -0
  158. package/dist/features/heading/server/validate.js +15 -0
  159. package/dist/features/heading/server/validate.js.map +1 -0
  160. package/dist/features/horizontalRule/client/index.js +2 -2
  161. package/dist/features/horizontalRule/client/index.js.map +1 -1
  162. package/dist/features/horizontalRule/client/markdownTransformer.d.ts +2 -2
  163. package/dist/features/horizontalRule/client/markdownTransformer.d.ts.map +1 -1
  164. package/dist/features/horizontalRule/client/markdownTransformer.js +1 -1
  165. package/dist/features/horizontalRule/client/markdownTransformer.js.map +1 -1
  166. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +12 -2
  167. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  168. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +18 -1
  169. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  170. package/dist/features/horizontalRule/client/plugin/index.css +2 -2
  171. package/dist/features/horizontalRule/server/index.js +2 -2
  172. package/dist/features/horizontalRule/server/index.js.map +1 -1
  173. package/dist/features/horizontalRule/server/markdownTransformer.d.ts +2 -2
  174. package/dist/features/horizontalRule/server/markdownTransformer.d.ts.map +1 -1
  175. package/dist/features/horizontalRule/server/markdownTransformer.js +1 -1
  176. package/dist/features/horizontalRule/server/markdownTransformer.js.map +1 -1
  177. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +1 -1
  178. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
  179. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +3 -3
  180. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  181. package/dist/features/horizontalRule/server/schema.d.ts +1 -0
  182. package/dist/features/horizontalRule/server/schema.d.ts.map +1 -1
  183. package/dist/features/horizontalRule/server/schema.js +6 -5
  184. package/dist/features/horizontalRule/server/schema.js.map +1 -1
  185. package/dist/features/indent/client/IndentPlugin.d.ts.map +1 -1
  186. package/dist/features/indent/client/IndentPlugin.js +122 -1
  187. package/dist/features/indent/client/IndentPlugin.js.map +1 -1
  188. package/dist/features/indent/client/toolbarIndentGroup.d.ts.map +1 -1
  189. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  190. package/dist/features/indent/server/i18n.js +74 -37
  191. package/dist/features/indent/server/i18n.js.map +1 -1
  192. package/dist/features/link/client/index.js +2 -2
  193. package/dist/features/link/client/index.js.map +1 -1
  194. package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
  195. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  196. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +11 -8
  197. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  198. package/dist/features/link/client/plugins/floatingLinkEditor/index.css +7 -13
  199. package/dist/features/link/markdownTransformer.d.ts +4 -4
  200. package/dist/features/link/markdownTransformer.d.ts.map +1 -1
  201. package/dist/features/link/markdownTransformer.js +2 -2
  202. package/dist/features/link/markdownTransformer.js.map +1 -1
  203. package/dist/features/link/nodes/AutoLinkNode.d.ts +1 -1
  204. package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  205. package/dist/features/link/nodes/AutoLinkNode.js +2 -10
  206. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  207. package/dist/features/link/nodes/LinkNode.d.ts +1 -1
  208. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  209. package/dist/features/link/nodes/LinkNode.js +2 -15
  210. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  211. package/dist/features/link/server/baseFields.d.ts.map +1 -1
  212. package/dist/features/link/server/baseFields.js.map +1 -1
  213. package/dist/features/link/server/graphQLPopulationPromise.d.ts.map +1 -1
  214. package/dist/features/link/server/index.js +4 -4
  215. package/dist/features/link/server/index.js.map +1 -1
  216. package/dist/features/link/server/schema.d.ts.map +1 -1
  217. package/dist/features/link/server/schema.js +4 -2
  218. package/dist/features/link/server/schema.js.map +1 -1
  219. package/dist/features/link/server/validate.d.ts.map +1 -1
  220. package/dist/features/link/server/validate.js +1 -1
  221. package/dist/features/link/server/validate.js.map +1 -1
  222. package/dist/features/lists/checklist/client/index.js +1 -1
  223. package/dist/features/lists/checklist/client/index.js.map +1 -1
  224. package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
  225. package/dist/features/lists/checklist/server/index.js +6 -3
  226. package/dist/features/lists/checklist/server/index.js.map +1 -1
  227. package/dist/features/lists/orderedList/client/index.js +1 -1
  228. package/dist/features/lists/orderedList/client/index.js.map +1 -1
  229. package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
  230. package/dist/features/lists/orderedList/server/index.js +6 -3
  231. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  232. package/dist/features/lists/shared/constants.d.ts +2 -0
  233. package/dist/features/lists/shared/constants.d.ts.map +1 -0
  234. package/dist/features/lists/shared/constants.js +2 -0
  235. package/dist/features/lists/shared/constants.js.map +1 -0
  236. package/dist/features/lists/shared/validate.d.ts +5 -0
  237. package/dist/features/lists/shared/validate.d.ts.map +1 -0
  238. package/dist/features/lists/shared/validate.js +15 -0
  239. package/dist/features/lists/shared/validate.js.map +1 -0
  240. package/dist/features/lists/unorderedList/client/index.js +1 -1
  241. package/dist/features/lists/unorderedList/client/index.js.map +1 -1
  242. package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
  243. package/dist/features/lists/unorderedList/server/index.js +6 -3
  244. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  245. package/dist/features/relationship/client/components/index.css +3 -6
  246. package/dist/features/relationship/client/drawer/index.d.ts.map +1 -1
  247. package/dist/features/relationship/client/index.d.ts +2 -2
  248. package/dist/features/relationship/client/index.d.ts.map +1 -1
  249. package/dist/features/relationship/client/index.js.map +1 -1
  250. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  251. package/dist/features/relationship/client/nodes/RelationshipNode.js +0 -3
  252. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  253. package/dist/features/relationship/client/plugins/index.d.ts +2 -2
  254. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  255. package/dist/features/relationship/client/plugins/index.js +27 -31
  256. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  257. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts +2 -4
  258. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
  259. package/dist/features/relationship/client/utils/useEnabledRelationships.js +53 -20
  260. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  261. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +2 -2
  262. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
  263. package/dist/features/relationship/server/graphQLPopulationPromise.js +2 -2
  264. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  265. package/dist/features/relationship/server/index.d.ts +8 -1
  266. package/dist/features/relationship/server/index.d.ts.map +1 -1
  267. package/dist/features/relationship/server/index.js +28 -11
  268. package/dist/features/relationship/server/index.js.map +1 -1
  269. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  270. package/dist/features/relationship/server/nodes/RelationshipNode.js +1 -5
  271. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  272. package/dist/features/relationship/server/schema.d.ts +6 -5
  273. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  274. package/dist/features/relationship/server/schema.js +31 -17
  275. package/dist/features/relationship/server/schema.js.map +1 -1
  276. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +1 -6
  277. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -1
  278. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +1 -5
  279. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -1
  280. package/dist/features/shared/toolbar/addDropdownGroup.d.ts.map +1 -1
  281. package/dist/features/shared/toolbar/featureButtonsGroup.d.ts.map +1 -1
  282. package/dist/features/shared/toolbar/textDropdownGroup.d.ts.map +1 -1
  283. package/dist/features/table/client/index.d.ts.map +1 -0
  284. package/dist/features/{experimental_table → table}/client/index.js +2 -2
  285. package/dist/features/table/client/index.js.map +1 -0
  286. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts +8 -0
  287. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts.map +1 -0
  288. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js +19 -0
  289. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js.map +1 -0
  290. package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.css +0 -1
  291. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -0
  292. package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.js +17 -44
  293. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -0
  294. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -0
  295. package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.js +41 -18
  296. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js.map +1 -0
  297. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -0
  298. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -0
  299. package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.css +0 -3
  300. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.d.ts.map +1 -0
  301. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.js.map +1 -0
  302. package/dist/features/table/client/plugins/TablePlugin/index.d.ts.map +1 -0
  303. package/dist/features/table/client/plugins/TablePlugin/index.js.map +1 -0
  304. package/dist/features/table/client/utils/debounce.d.ts.map +1 -0
  305. package/dist/features/table/client/utils/debounce.js.map +1 -0
  306. package/dist/features/table/client/utils/useDebounce.d.ts.map +1 -0
  307. package/dist/features/table/client/utils/useDebounce.js.map +1 -0
  308. package/dist/features/table/markdownTransformer.d.ts +5 -0
  309. package/dist/features/table/markdownTransformer.d.ts.map +1 -0
  310. package/dist/features/{experimental_table → table}/markdownTransformer.js +6 -3
  311. package/dist/features/table/markdownTransformer.js.map +1 -0
  312. package/dist/features/table/server/index.d.ts +3 -0
  313. package/dist/features/table/server/index.d.ts.map +1 -0
  314. package/dist/features/{experimental_table → table}/server/index.js +6 -6
  315. package/dist/features/table/server/index.js.map +1 -0
  316. package/dist/features/table/server/schema.d.ts.map +1 -0
  317. package/dist/features/table/server/schema.js.map +1 -0
  318. package/dist/features/textState/feature.client.js +1 -1
  319. package/dist/features/textState/feature.client.js.map +1 -1
  320. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts +8 -0
  321. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts.map +1 -0
  322. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js +80 -0
  323. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js.map +1 -0
  324. package/dist/features/toolbars/fixed/client/Toolbar/index.css +80 -8
  325. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  326. package/dist/features/toolbars/fixed/client/Toolbar/index.js +19 -1
  327. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  328. package/dist/features/toolbars/inline/client/Toolbar/index.css +2 -14
  329. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  330. package/dist/features/toolbars/inline/client/Toolbar/index.js +17 -2
  331. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  332. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  333. package/dist/features/toolbars/shared/ToolbarButton/index.js +1 -0
  334. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  335. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  336. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +85 -32
  337. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  338. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +23 -25
  339. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  340. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  341. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts +5 -0
  342. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts.map +1 -0
  343. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js +79 -0
  344. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js.map +1 -0
  345. package/dist/features/toolbars/shared/useToolbarStates.d.ts.map +1 -1
  346. package/dist/features/toolbars/shared/useToolbarStates.js +3 -1
  347. package/dist/features/toolbars/shared/useToolbarStates.js.map +1 -1
  348. package/dist/features/typesClient.d.ts +1 -1
  349. package/dist/features/typesClient.d.ts.map +1 -1
  350. package/dist/features/typesClient.js.map +1 -1
  351. package/dist/features/typesServer.d.ts +19 -14
  352. package/dist/features/typesServer.d.ts.map +1 -1
  353. package/dist/features/typesServer.js.map +1 -1
  354. package/dist/features/upload/client/component/index.css +9 -11
  355. package/dist/features/upload/client/component/index.js +2 -1
  356. package/dist/features/upload/client/component/index.js.map +1 -1
  357. package/dist/features/upload/client/drawer/index.d.ts.map +1 -1
  358. package/dist/features/upload/client/index.d.ts +3 -2
  359. package/dist/features/upload/client/index.d.ts.map +1 -1
  360. package/dist/features/upload/client/index.js.map +1 -1
  361. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  362. package/dist/features/upload/client/nodes/UploadNode.js +0 -7
  363. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  364. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  365. package/dist/features/upload/client/plugin/index.js +53 -56
  366. package/dist/features/upload/client/plugin/index.js.map +1 -1
  367. package/dist/features/upload/server/graphQLPopulationPromise.d.ts +2 -2
  368. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  369. package/dist/features/upload/server/graphQLPopulationPromise.js +1 -1
  370. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  371. package/dist/features/upload/server/index.d.ts +7 -3
  372. package/dist/features/upload/server/index.d.ts.map +1 -1
  373. package/dist/features/upload/server/index.js +22 -18
  374. package/dist/features/upload/server/index.js.map +1 -1
  375. package/dist/features/upload/server/markdownTransformer.d.ts +2 -2
  376. package/dist/features/upload/server/markdownTransformer.d.ts.map +1 -1
  377. package/dist/features/upload/server/markdownTransformer.js +1 -1
  378. package/dist/features/upload/server/markdownTransformer.js.map +1 -1
  379. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  380. package/dist/features/upload/server/nodes/UploadNode.js +1 -9
  381. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  382. package/dist/features/upload/server/schema.d.ts +6 -18
  383. package/dist/features/upload/server/schema.d.ts.map +1 -1
  384. package/dist/features/upload/server/schema.js +34 -16
  385. package/dist/features/upload/server/schema.js.map +1 -1
  386. package/dist/features/upload/server/validate.d.ts +2 -2
  387. package/dist/features/upload/server/validate.d.ts.map +1 -1
  388. package/dist/features/upload/server/validate.js +4 -1
  389. package/dist/features/upload/server/validate.js.map +1 -1
  390. package/dist/field/Diff/converters/listitem/index.d.ts.map +1 -1
  391. package/dist/field/Diff/converters/listitem/index.js +2 -1
  392. package/dist/field/Diff/converters/listitem/index.js.map +1 -1
  393. package/dist/field/Diff/converters/relationship/index.css +0 -1
  394. package/dist/field/Diff/converters/unknown/index.css +1 -2
  395. package/dist/field/Diff/converters/upload/index.css +0 -1
  396. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  397. package/dist/field/Diff/index.css +0 -2
  398. package/dist/field/Diff/index.d.ts +3 -2
  399. package/dist/field/Diff/index.d.ts.map +1 -1
  400. package/dist/field/Diff/index.js +3 -2
  401. package/dist/field/Diff/index.js.map +1 -1
  402. package/dist/field/Field.d.ts.map +1 -1
  403. package/dist/field/Field.js +26 -16
  404. package/dist/field/Field.js.map +1 -1
  405. package/dist/field/RenderLexical/index.d.ts +3 -1
  406. package/dist/field/RenderLexical/index.d.ts.map +1 -1
  407. package/dist/field/RenderLexical/index.js +23 -23
  408. package/dist/field/RenderLexical/index.js.map +1 -1
  409. package/dist/field/ViewSelector.css +1 -1
  410. package/dist/field/ViewSelector.d.ts.map +1 -1
  411. package/dist/field/ViewSelector.js +1 -0
  412. package/dist/field/ViewSelector.js.map +1 -1
  413. package/dist/field/bundled.css +1 -1
  414. package/dist/field/index.css +7 -5
  415. package/dist/field/rscEntry.d.ts +2 -2
  416. package/dist/field/rscEntry.d.ts.map +1 -1
  417. package/dist/field/rscEntry.js.map +1 -1
  418. package/dist/i18n.d.ts.map +1 -1
  419. package/dist/i18n.js +68 -0
  420. package/dist/i18n.js.map +1 -1
  421. package/dist/index.d.ts +6 -6
  422. package/dist/index.d.ts.map +1 -1
  423. package/dist/index.js +33 -54
  424. package/dist/index.js.map +1 -1
  425. package/dist/lexical/LexicalEditor.css +30 -19
  426. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  427. package/dist/lexical/LexicalEditor.js +62 -99
  428. package/dist/lexical/LexicalEditor.js.map +1 -1
  429. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  430. package/dist/lexical/LexicalProvider.js +7 -22
  431. package/dist/lexical/LexicalProvider.js.map +1 -1
  432. package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
  433. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  434. package/dist/lexical/config/server/loader.d.ts +1 -1
  435. package/dist/lexical/config/server/loader.d.ts.map +1 -1
  436. package/dist/lexical/config/server/loader.js +2 -2
  437. package/dist/lexical/config/server/loader.js.map +1 -1
  438. package/dist/lexical/config/server/sanitize.d.ts +1 -1
  439. package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
  440. package/dist/lexical/config/server/sanitize.js +2 -2
  441. package/dist/lexical/config/server/sanitize.js.map +1 -1
  442. package/dist/lexical/plugins/DecoratorPlugin/index.css +1 -1
  443. package/dist/lexical/plugins/DecoratorPlugin/index.d.ts.map +1 -1
  444. package/dist/lexical/plugins/DecoratorPlugin/index.js +24 -21
  445. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  446. package/dist/lexical/plugins/InsertParagraphAtEnd/index.css +18 -25
  447. package/dist/lexical/plugins/InsertParagraphAtEnd/index.d.ts.map +1 -1
  448. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +27 -14
  449. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  450. package/dist/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
  451. package/dist/lexical/plugins/MarkdownShortcut/index.js +1 -1
  452. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  453. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -1
  454. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +21 -0
  455. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -1
  456. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +0 -1
  457. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  458. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +2 -21
  459. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  460. package/dist/lexical/plugins/SlashMenu/index.css +1 -7
  461. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +2 -1
  462. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +2 -2
  463. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  464. package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts.map +1 -1
  465. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +5 -3
  466. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  467. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +17 -3
  468. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  469. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts +7 -0
  470. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts.map +1 -0
  471. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js +65 -0
  472. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js.map +1 -0
  473. package/dist/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.d.ts.map +1 -1
  474. package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  475. package/dist/lexical/plugins/handles/utils/setHandlePosition.js +2 -0
  476. package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  477. package/dist/lexical/theme/EditorTheme.css +18 -21
  478. package/dist/lexical/ui/ContentEditable.css +22 -17
  479. package/dist/lexical/ui/ContentEditable.d.ts +2 -1
  480. package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
  481. package/dist/lexical/ui/ContentEditable.js +21 -7
  482. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  483. package/dist/lexical/ui/icons/H3/index.d.ts.map +1 -1
  484. package/dist/lexical/ui/icons/H3/index.js +13 -6
  485. package/dist/lexical/ui/icons/H3/index.js.map +1 -1
  486. package/dist/lexical/ui/icons/H4/index.d.ts.map +1 -1
  487. package/dist/lexical/ui/icons/H4/index.js +13 -6
  488. package/dist/lexical/ui/icons/H4/index.js.map +1 -1
  489. package/dist/lexical/ui/icons/H5/index.d.ts.map +1 -1
  490. package/dist/lexical/ui/icons/H5/index.js +13 -6
  491. package/dist/lexical/ui/icons/H5/index.js.map +1 -1
  492. package/dist/lexical/ui/icons/H6/index.d.ts.map +1 -1
  493. package/dist/lexical/ui/icons/H6/index.js +13 -6
  494. package/dist/lexical/ui/icons/H6/index.js.map +1 -1
  495. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts +17 -0
  496. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts.map +1 -0
  497. package/dist/lexical/utils/markdown/convertFromMarkdownString.js +27 -0
  498. package/dist/lexical/utils/markdown/convertFromMarkdownString.js.map +1 -0
  499. package/dist/lexical/utils/markdown/createBlockNode.d.ts +2 -2
  500. package/dist/lexical/utils/markdown/createBlockNode.d.ts.map +1 -1
  501. package/dist/lexical/utils/markdown/createBlockNode.js.map +1 -1
  502. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts +25 -0
  503. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts.map +1 -0
  504. package/dist/lexical/utils/markdown/normalizeMarkdown.js +91 -0
  505. package/dist/lexical/utils/markdown/normalizeMarkdown.js.map +1 -0
  506. package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
  507. package/dist/lexical/utils/point.d.ts.map +1 -1
  508. package/dist/lexical/utils/rect.d.ts.map +1 -1
  509. package/dist/lexical-proxy/@lexical-markdown.d.ts +1 -1
  510. package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -1
  511. package/dist/lexical-proxy/@lexical-markdown.js +1 -1
  512. package/dist/lexical-proxy/@lexical-markdown.js.map +1 -1
  513. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.d.ts +2 -0
  514. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.d.ts.map +1 -0
  515. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.js +2 -0
  516. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.js.map +1 -0
  517. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.d.ts +2 -0
  518. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.d.ts.map +1 -0
  519. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.js +2 -0
  520. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.js.map +1 -0
  521. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.d.ts +2 -0
  522. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.d.ts.map +1 -0
  523. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.js +2 -0
  524. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.js.map +1 -0
  525. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.d.ts +2 -0
  526. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.d.ts.map +1 -0
  527. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.js +2 -0
  528. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.js.map +1 -0
  529. package/dist/lexical-proxy/@lexical-react/ReactExtension.d.ts +2 -0
  530. package/dist/lexical-proxy/@lexical-react/ReactExtension.d.ts.map +1 -0
  531. package/dist/lexical-proxy/@lexical-react/ReactExtension.js +2 -0
  532. package/dist/lexical-proxy/@lexical-react/ReactExtension.js.map +1 -0
  533. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.d.ts +2 -0
  534. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.d.ts.map +1 -0
  535. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.js +2 -0
  536. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.js.map +1 -0
  537. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.d.ts +2 -0
  538. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.d.ts.map +1 -0
  539. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.js +2 -0
  540. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.js.map +1 -0
  541. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.d.ts +2 -0
  542. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.d.ts.map +1 -0
  543. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.js +2 -0
  544. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.js.map +1 -0
  545. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.d.ts +2 -0
  546. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.d.ts.map +1 -0
  547. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.js +2 -0
  548. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.js.map +1 -0
  549. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.d.ts +2 -0
  550. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.d.ts.map +1 -0
  551. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.js +2 -0
  552. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.js.map +1 -0
  553. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.d.ts +2 -0
  554. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.d.ts.map +1 -0
  555. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.js +2 -0
  556. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.js.map +1 -0
  557. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.d.ts +2 -0
  558. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.d.ts.map +1 -0
  559. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.js +2 -0
  560. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.js.map +1 -0
  561. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.d.ts +2 -0
  562. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.d.ts.map +1 -0
  563. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.js +2 -0
  564. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.js.map +1 -0
  565. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.d.ts +2 -0
  566. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.d.ts.map +1 -0
  567. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.js +2 -0
  568. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.js.map +1 -0
  569. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.d.ts +2 -0
  570. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.d.ts.map +1 -0
  571. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.js +2 -0
  572. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.js.map +1 -0
  573. package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts.map +1 -1
  574. package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.d.ts.map +1 -1
  575. package/dist/presets/llmInstructions.d.ts +2 -0
  576. package/dist/presets/llmInstructions.d.ts.map +1 -0
  577. package/dist/presets/llmInstructions.js +13 -0
  578. package/dist/presets/llmInstructions.js.map +1 -0
  579. package/dist/types/builtInNodes.d.ts +1 -1
  580. package/dist/types/builtInNodes.d.ts.map +1 -1
  581. package/dist/types/builtInNodes.js +8 -3
  582. package/dist/types/builtInNodes.js.map +1 -1
  583. package/dist/types/index.d.ts +4 -7
  584. package/dist/types/index.d.ts.map +1 -1
  585. package/dist/types/index.js.map +1 -1
  586. package/dist/types/jsonSchemaHelpers.d.ts +5 -1
  587. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -1
  588. package/dist/types/jsonSchemaHelpers.js +7 -2
  589. package/dist/types/jsonSchemaHelpers.js.map +1 -1
  590. package/dist/types/nodeTypes.d.ts +6 -1
  591. package/dist/types/nodeTypes.d.ts.map +1 -1
  592. package/dist/types/nodeTypes.js.map +1 -1
  593. package/dist/types/schema.d.ts.map +1 -1
  594. package/dist/types/schema.js +12 -5
  595. package/dist/types/schema.js.map +1 -1
  596. package/dist/utilities/applyBaseFilterToFields.d.ts.map +1 -1
  597. package/dist/utilities/applyBaseFilterToFields.js.map +1 -1
  598. package/dist/utilities/buildInitialState.d.ts +3 -2
  599. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  600. package/dist/utilities/buildInitialState.js +1 -0
  601. package/dist/utilities/buildInitialState.js.map +1 -1
  602. package/dist/utilities/createServerFeature.d.ts +1 -1
  603. package/dist/utilities/createServerFeature.d.ts.map +1 -1
  604. package/dist/utilities/createServerFeature.js +2 -2
  605. package/dist/utilities/createServerFeature.js.map +1 -1
  606. package/dist/utilities/editorConfigFactory.d.ts +6 -6
  607. package/dist/utilities/editorConfigFactory.d.ts.map +1 -1
  608. package/dist/utilities/editorConfigFactory.js +9 -9
  609. package/dist/utilities/editorConfigFactory.js.map +1 -1
  610. package/dist/utilities/fieldsDrawer/index.css +4 -4
  611. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts +1 -1
  612. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts.map +1 -1
  613. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.d.ts.map +1 -1
  614. package/dist/utilities/fieldsDrawer/useLexicalDrawer.d.ts.map +1 -1
  615. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.d.ts.map +1 -1
  616. package/dist/utilities/generateImportMap.d.ts +3 -3
  617. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  618. package/dist/utilities/generateImportMap.js +3 -7
  619. package/dist/utilities/generateImportMap.js.map +1 -1
  620. package/dist/utilities/generateSchemaMap.d.ts +1 -1
  621. package/dist/utilities/generateSchemaMap.d.ts.map +1 -1
  622. package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts +2 -2
  623. package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts.map +1 -1
  624. package/dist/utilities/getDefaultSanitizedEditorConfig.js +6 -17
  625. package/dist/utilities/getDefaultSanitizedEditorConfig.js.map +1 -1
  626. package/dist/utilities/recurseNodeTree.d.ts.map +1 -1
  627. package/dist/utilities/upgradeLexicalData/index.js +6 -3
  628. package/dist/utilities/upgradeLexicalData/index.js.map +1 -1
  629. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -1
  630. package/dist/utilities/useLexicalFeature.d.ts.map +1 -1
  631. package/dist/validate/hasText.d.ts +2 -2
  632. package/dist/validate/hasText.d.ts.map +1 -1
  633. package/dist/validate/hasText.js.map +1 -1
  634. package/dist/validate/index.d.ts +1 -1
  635. package/dist/validate/index.d.ts.map +1 -1
  636. package/package.json +98 -30
  637. package/dist/@types/assets.d.js +0 -2
  638. package/dist/@types/assets.d.js.map +0 -1
  639. package/dist/dependencyChecker.spec.js +0 -16
  640. package/dist/dependencyChecker.spec.js.map +0 -1
  641. package/dist/exports/client/Field-VYBSMSRY.js +0 -2
  642. package/dist/exports/client/Field-VYBSMSRY.js.map +0 -7
  643. package/dist/exports/client/bundled.css +0 -1
  644. package/dist/exports/client/chunk-ESITTE3C.js +0 -2
  645. package/dist/exports/client/chunk-ESITTE3C.js.map +0 -7
  646. package/dist/exports/client/chunk-LH634DPU.js +0 -12
  647. package/dist/exports/client/chunk-LH634DPU.js.map +0 -7
  648. package/dist/exports/client/chunk-UD4DQ4AK.js +0 -2
  649. package/dist/exports/client/chunk-UD4DQ4AK.js.map +0 -7
  650. package/dist/exports/client/component-PHZQBOJE.js +0 -2
  651. package/dist/exports/client/component-PHZQBOJE.js.map +0 -7
  652. package/dist/exports/client/componentInline-H24N7GUG.js +0 -2
  653. package/dist/exports/server/rsc.browser.d.ts +0 -11
  654. package/dist/exports/server/rsc.browser.d.ts.map +0 -1
  655. package/dist/exports/server/rsc.browser.js +0 -10
  656. package/dist/exports/server/rsc.browser.js.map +0 -1
  657. package/dist/features/blockquote/markdownTransformer.d.ts +0 -3
  658. package/dist/features/blockquote/markdownTransformer.d.ts.map +0 -1
  659. package/dist/features/blockquote/markdownTransformer.js +0 -33
  660. package/dist/features/blockquote/markdownTransformer.js.map +0 -1
  661. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts +0 -11
  662. package/dist/features/blocks/client/component/removeEmptyArrayValues.d.ts.map +0 -1
  663. package/dist/features/blocks/client/component/removeEmptyArrayValues.js +0 -20
  664. package/dist/features/blocks/client/component/removeEmptyArrayValues.js.map +0 -1
  665. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js +0 -180
  666. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js.map +0 -1
  667. package/dist/features/experimental_table/client/index.d.ts.map +0 -1
  668. package/dist/features/experimental_table/client/index.js.map +0 -1
  669. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +0 -1
  670. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +0 -1
  671. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +0 -1
  672. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +0 -1
  673. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +0 -1
  674. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +0 -1
  675. package/dist/features/experimental_table/client/plugins/TablePlugin/TableGridPopup/index.d.ts.map +0 -1
  676. package/dist/features/experimental_table/client/plugins/TablePlugin/TableGridPopup/index.js.map +0 -1
  677. package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts.map +0 -1
  678. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +0 -1
  679. package/dist/features/experimental_table/client/utils/debounce.d.ts.map +0 -1
  680. package/dist/features/experimental_table/client/utils/debounce.js.map +0 -1
  681. package/dist/features/experimental_table/client/utils/useDebounce.d.ts.map +0 -1
  682. package/dist/features/experimental_table/client/utils/useDebounce.js.map +0 -1
  683. package/dist/features/experimental_table/markdownTransformer.d.ts +0 -5
  684. package/dist/features/experimental_table/markdownTransformer.d.ts.map +0 -1
  685. package/dist/features/experimental_table/markdownTransformer.js.map +0 -1
  686. package/dist/features/experimental_table/server/index.d.ts +0 -3
  687. package/dist/features/experimental_table/server/index.d.ts.map +0 -1
  688. package/dist/features/experimental_table/server/index.js.map +0 -1
  689. package/dist/features/experimental_table/server/schema.d.ts.map +0 -1
  690. package/dist/features/experimental_table/server/schema.js.map +0 -1
  691. package/dist/features/format/bold/markdownTransformers.d.ts +0 -6
  692. package/dist/features/format/bold/markdownTransformers.d.ts.map +0 -1
  693. package/dist/features/format/bold/markdownTransformers.js +0 -23
  694. package/dist/features/format/bold/markdownTransformers.js.map +0 -1
  695. package/dist/features/format/inlineCode/markdownTransformers.d.ts +0 -3
  696. package/dist/features/format/inlineCode/markdownTransformers.d.ts.map +0 -1
  697. package/dist/features/format/inlineCode/markdownTransformers.js +0 -6
  698. package/dist/features/format/inlineCode/markdownTransformers.js.map +0 -1
  699. package/dist/features/format/italic/markdownTransformers.d.ts +0 -4
  700. package/dist/features/format/italic/markdownTransformers.d.ts.map +0 -1
  701. package/dist/features/format/italic/markdownTransformers.js +0 -12
  702. package/dist/features/format/italic/markdownTransformers.js.map +0 -1
  703. package/dist/features/format/strikethrough/markdownTransformers.d.ts +0 -3
  704. package/dist/features/format/strikethrough/markdownTransformers.d.ts.map +0 -1
  705. package/dist/features/format/strikethrough/markdownTransformers.js +0 -6
  706. package/dist/features/format/strikethrough/markdownTransformers.js.map +0 -1
  707. package/dist/features/link/markdownTransformer.spec.js +0 -195
  708. package/dist/features/link/markdownTransformer.spec.js.map +0 -1
  709. package/dist/features/lists/checklist/markdownTransformers.d.ts +0 -3
  710. package/dist/features/lists/checklist/markdownTransformers.d.ts.map +0 -1
  711. package/dist/features/lists/checklist/markdownTransformers.js +0 -12
  712. package/dist/features/lists/checklist/markdownTransformers.js.map +0 -1
  713. package/dist/features/lists/orderedList/markdownTransformer.d.ts +0 -3
  714. package/dist/features/lists/orderedList/markdownTransformer.d.ts.map +0 -1
  715. package/dist/features/lists/orderedList/markdownTransformer.js +0 -12
  716. package/dist/features/lists/orderedList/markdownTransformer.js.map +0 -1
  717. package/dist/features/lists/shared/markdown.d.ts +0 -6
  718. package/dist/features/lists/shared/markdown.d.ts.map +0 -1
  719. package/dist/features/lists/shared/markdown.js +0 -57
  720. package/dist/features/lists/shared/markdown.js.map +0 -1
  721. package/dist/features/lists/unorderedList/markdownTransformer.d.ts +0 -3
  722. package/dist/features/lists/unorderedList/markdownTransformer.d.ts.map +0 -1
  723. package/dist/features/lists/unorderedList/markdownTransformer.js +0 -12
  724. package/dist/features/lists/unorderedList/markdownTransformer.js.map +0 -1
  725. package/dist/field/clientEntry.d.ts +0 -29
  726. package/dist/field/clientEntry.d.ts.map +0 -1
  727. package/dist/field/clientEntry.js +0 -86
  728. package/dist/field/clientEntry.js.map +0 -1
  729. package/dist/lexical/utils/guard.d.ts +0 -5
  730. package/dist/lexical/utils/guard.d.ts.map +0 -1
  731. package/dist/lexical/utils/guard.js +0 -9
  732. package/dist/lexical/utils/guard.js.map +0 -1
  733. package/dist/lexical/utils/url.spec.js +0 -114
  734. package/dist/lexical/utils/url.spec.js.map +0 -1
  735. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +0 -2
  736. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +0 -1
  737. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +0 -2
  738. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +0 -1
  739. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts +0 -14
  740. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +0 -1
  741. package/dist/packages/@lexical/markdown/MarkdownExport.js +0 -213
  742. package/dist/packages/@lexical/markdown/MarkdownExport.js.map +0 -1
  743. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +0 -19
  744. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +0 -1
  745. package/dist/packages/@lexical/markdown/MarkdownImport.js +0 -198
  746. package/dist/packages/@lexical/markdown/MarkdownImport.js.map +0 -1
  747. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts +0 -11
  748. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +0 -1
  749. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +0 -304
  750. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +0 -1
  751. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +0 -147
  752. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +0 -1
  753. package/dist/packages/@lexical/markdown/MarkdownTransformers.js +0 -268
  754. package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +0 -1
  755. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts +0 -22
  756. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +0 -1
  757. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +0 -91
  758. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +0 -1
  759. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts +0 -21
  760. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +0 -1
  761. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +0 -54
  762. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +0 -1
  763. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts +0 -18
  764. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts.map +0 -1
  765. package/dist/packages/@lexical/markdown/importTextTransformers.js +0 -54
  766. package/dist/packages/@lexical/markdown/importTextTransformers.js.map +0 -1
  767. package/dist/packages/@lexical/markdown/index.d.ts +0 -29
  768. package/dist/packages/@lexical/markdown/index.d.ts.map +0 -1
  769. package/dist/packages/@lexical/markdown/index.js +0 -39
  770. package/dist/packages/@lexical/markdown/index.js.map +0 -1
  771. package/dist/packages/@lexical/markdown/utils.d.ts +0 -34
  772. package/dist/packages/@lexical/markdown/utils.d.ts.map +0 -1
  773. package/dist/packages/@lexical/markdown/utils.js +0 -267
  774. package/dist/packages/@lexical/markdown/utils.js.map +0 -1
  775. package/dist/utilities/jsx/jsx.spec.js +0 -178
  776. package/dist/utilities/jsx/jsx.spec.js.map +0 -1
  777. /package/dist/exports/client/{componentInline-H24N7GUG.js.map → componentInline-HNE5G4TE.js.map} +0 -0
  778. /package/dist/features/{experimental_table → table}/client/index.d.ts +0 -0
  779. /package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.d.ts +0 -0
  780. /package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.css +0 -0
  781. /package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.d.ts +0 -0
  782. /package/dist/features/{experimental_table → table}/client/plugins/TableHoverActionsPlugin/index.d.ts +0 -0
  783. /package/dist/features/{experimental_table → table}/client/plugins/TableHoverActionsPlugin/index.js +0 -0
  784. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.d.ts +0 -0
  785. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.js +0 -0
  786. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.css +0 -0
  787. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.d.ts +0 -0
  788. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.js +0 -0
  789. /package/dist/features/{experimental_table → table}/client/utils/debounce.d.ts +0 -0
  790. /package/dist/features/{experimental_table → table}/client/utils/debounce.js +0 -0
  791. /package/dist/features/{experimental_table → table}/client/utils/useDebounce.d.ts +0 -0
  792. /package/dist/features/{experimental_table → table}/client/utils/useDebounce.js +0 -0
  793. /package/dist/features/{experimental_table → table}/server/schema.d.ts +0 -0
  794. /package/dist/features/{experimental_table → table}/server/schema.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalEditable","mergeRegister","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","getDOMSelection","SELECTION_CHANGE_COMMAND","useCallback","useEffect","useMemo","useRef","useState","React","createPortal","useEditorConfigContext","getDOMRangeRect","setFloatingElemPosition","ToolbarButton","ToolbarDropdown","useToolbarStates","ButtonGroupItem","active","anchorElem","editor","enabled","item","Component","_jsx","key","ChildComponent","ToolbarGroupComponent","group","index","toolbarStates","editorConfig","groupState","groupStates","get","DropdownIcon","type","undefined","activeItem","activeItems","_jsxs","className","items","length","Icon","map","itemState","itemStates","features","toolbarInline","groups","InlineToolbar","floatingToolbarRef","caretRef","closeFloatingToolbar","current","isOpacityZero","style","opacity","isPointerEventsNone","pointerEvents","mouseMoveListener","e","buttons","x","clientX","y","clientY","elementUnderMouse","document","elementFromPoint","contains","mouseUpListener","addEventListener","removeEventListener","$updateTextFormatFloatingToolbar","selection","nativeSelection","_window","possibleLinkEditor","querySelector","isLinkEditorVisible","rootElement","getRootElement","isCollapsed","anchorNode","rangeRect","offsetIfFlipped","alwaysDisplayOnTop","floatingElem","horizontalPosition","targetRect","anchorFlippedOffset","horizontalOffset","specialHandlingForCaret","verticalGap","scrollerElem","parentElement","update","getEditorState","read","window","registerUpdateListener","editorState","registerCommand","ref","i","useInlineToolbar","$","isText","setIsText","isEditable","t0","isComposing","getTextContent","nodes","getNodes","foundNodeWithText","node","rawTextContent","replace","updatePopup","t1","t2","t3","t4","registerRootListener","t5","InlineToolbarPlugin"],"sources":["../../../../../../src/features/toolbars/inline/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n getDOMSelection,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponentWithAnchor } from '../../../../typesClient.js'\nimport type { ToolbarStates } from '../../../shared/useToolbarStates.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { getDOMRangeRect } from '../../../../../lexical/utils/getDOMRangeRect.js'\nimport { setFloatingElemPosition } from '../../../../../lexical/utils/setFloatingElemPosition.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\nimport { useToolbarStates } from '../../../shared/useToolbarStates.js'\nimport './index.css'\n\nfunction ButtonGroupItem({\n active,\n anchorElem,\n editor,\n enabled,\n item,\n}: {\n active: boolean\n anchorElem: HTMLElement\n editor: LexicalEditor\n enabled: boolean\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton active={active} editor={editor} enabled={enabled} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n group,\n index,\n toolbarStates,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n group: ToolbarGroup\n index: number\n toolbarStates: ToolbarStates\n}): React.ReactNode {\n const { editorConfig } = useEditorConfigContext()\n\n const groupState = toolbarStates.groupStates.get(group.key)\n\n const DropdownIcon = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItem = groupState?.activeItems?.[0]\n return activeItem?.ChildComponent ?? group.ChildComponent\n }, [group, groupState?.activeItems])\n\n return (\n <div\n className={`inline-toolbar-popup__group inline-toolbar-popup__group-${group.key}`}\n data-toolbar-group-key={group.key}\n key={group.key}\n >\n {group.type === 'dropdown' && group.items.length && groupState ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n groupState={groupState}\n Icon={DropdownIcon}\n />\n ) : null}\n {group.type === 'buttons' && group.items.length\n ? group.items.map((item) => {\n const itemState = toolbarStates.itemStates.get(item.key)\n return (\n <ButtonGroupItem\n active={itemState?.active ?? false}\n anchorElem={anchorElem}\n editor={editor}\n enabled={itemState?.enabled ?? true}\n item={item}\n key={item.key}\n />\n )\n })\n : null}\n {index < editorConfig.features.toolbarInline?.groups.length - 1 && (\n <div className=\"divider\" />\n )}\n </div>\n )\n}\n\nfunction InlineToolbar({\n anchorElem,\n editor,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n}): React.ReactNode {\n const floatingToolbarRef = useRef<HTMLDivElement | null>(null)\n const caretRef = useRef<HTMLDivElement | null>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const toolbarStates = useToolbarStates(editor, editorConfig?.features?.toolbarInline?.groups)\n\n const closeFloatingToolbar = useCallback(() => {\n if (floatingToolbarRef?.current) {\n const isOpacityZero = floatingToolbarRef.current.style.opacity === '0'\n const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none'\n\n if (!isOpacityZero) {\n floatingToolbarRef.current.style.opacity = '0'\n }\n if (!isPointerEventsNone) {\n floatingToolbarRef.current.style.pointerEvents = 'none'\n }\n }\n }, [floatingToolbarRef])\n\n const mouseMoveListener = useCallback(\n (e: MouseEvent) => {\n if (floatingToolbarRef?.current && (e.buttons === 1 || e.buttons === 3)) {\n const isOpacityZero = floatingToolbarRef.current.style.opacity === '0'\n const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none'\n if (!isOpacityZero || !isPointerEventsNone) {\n // Check if the mouse is not over the popup\n const x = e.clientX\n const y = e.clientY\n const elementUnderMouse = document.elementFromPoint(x, y)\n if (!floatingToolbarRef.current.contains(elementUnderMouse)) {\n // Mouse is not over the target element => not a normal click, but probably a drag\n closeFloatingToolbar()\n }\n }\n }\n },\n [closeFloatingToolbar],\n )\n\n const mouseUpListener = useCallback(() => {\n if (floatingToolbarRef?.current) {\n if (floatingToolbarRef.current.style.opacity !== '1') {\n floatingToolbarRef.current.style.opacity = '1'\n }\n if (floatingToolbarRef.current.style.pointerEvents !== 'auto') {\n floatingToolbarRef.current.style.pointerEvents = 'auto'\n }\n }\n }, [])\n\n useEffect(() => {\n document.addEventListener('mousemove', mouseMoveListener)\n document.addEventListener('mouseup', mouseUpListener)\n\n return () => {\n document.removeEventListener('mousemove', mouseMoveListener)\n document.removeEventListener('mouseup', mouseUpListener)\n }\n }, [floatingToolbarRef, mouseMoveListener, mouseUpListener])\n\n const $updateTextFormatFloatingToolbar = useCallback(() => {\n const selection = $getSelection()\n\n const nativeSelection = getDOMSelection(editor._window)\n\n if (floatingToolbarRef.current === null) {\n return\n }\n\n const possibleLinkEditor = anchorElem.querySelector(':scope > .link-editor')\n const isLinkEditorVisible =\n possibleLinkEditor !== null &&\n 'style' in possibleLinkEditor &&\n possibleLinkEditor?.style?.['opacity' as keyof typeof possibleLinkEditor.style] === '1'\n\n const rootElement = editor.getRootElement()\n if (\n selection !== null &&\n nativeSelection !== null &&\n !nativeSelection.isCollapsed &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n const rangeRect = getDOMRangeRect(nativeSelection, rootElement)\n\n // Position floating toolbar\n const offsetIfFlipped = setFloatingElemPosition({\n alwaysDisplayOnTop: isLinkEditorVisible,\n anchorElem,\n floatingElem: floatingToolbarRef.current,\n horizontalPosition: 'center',\n targetRect: rangeRect,\n })\n\n // Position caret\n if (caretRef.current) {\n setFloatingElemPosition({\n anchorElem: floatingToolbarRef.current,\n anchorFlippedOffset: offsetIfFlipped,\n floatingElem: caretRef.current,\n horizontalOffset: 5,\n horizontalPosition: 'center',\n specialHandlingForCaret: true,\n targetRect: rangeRect,\n verticalGap: 8,\n })\n }\n } else {\n closeFloatingToolbar()\n }\n }, [editor, closeFloatingToolbar, anchorElem])\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement\n\n const update = () => {\n editor.getEditorState().read(() => {\n $updateTextFormatFloatingToolbar()\n })\n }\n\n window.addEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.addEventListener('scroll', update)\n }\n\n return () => {\n window.removeEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.removeEventListener('scroll', update)\n }\n }\n }, [editor, $updateTextFormatFloatingToolbar, anchorElem])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n $updateTextFormatFloatingToolbar()\n })\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n $updateTextFormatFloatingToolbar()\n })\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n $updateTextFormatFloatingToolbar()\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, $updateTextFormatFloatingToolbar])\n\n return (\n <div className=\"inline-toolbar-popup\" ref={floatingToolbarRef}>\n <div className=\"caret\" ref={caretRef} />\n {editorConfig?.features &&\n editorConfig.features?.toolbarInline?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n index={i}\n key={group.key}\n toolbarStates={toolbarStates}\n />\n )\n })}\n </div>\n )\n}\n\nfunction useInlineToolbar(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n): null | React.ReactElement {\n const [isText, setIsText] = useState(false)\n const isEditable = useLexicalEditable()\n\n const updatePopup = useCallback(() => {\n editor.getEditorState().read(() => {\n // Should not to pop up the floating toolbar when using IME input\n if (editor.isComposing()) {\n return\n }\n const selection = $getSelection()\n const nativeSelection = getDOMSelection(editor._window)\n const rootElement = editor.getRootElement()\n\n if (\n nativeSelection !== null &&\n (!$isRangeSelection(selection) ||\n rootElement === null ||\n !rootElement.contains(nativeSelection.anchorNode))\n ) {\n setIsText(false)\n return\n }\n\n if (!$isRangeSelection(selection)) {\n return\n }\n\n if (selection.getTextContent() !== '') {\n const nodes = selection.getNodes()\n let foundNodeWithText = false\n for (const node of nodes) {\n if ($isTextNode(node)) {\n setIsText(true)\n foundNodeWithText = true\n break\n }\n }\n if (!foundNodeWithText) {\n setIsText(false)\n }\n } else {\n setIsText(false)\n }\n\n const rawTextContent = selection.getTextContent().replace(/\\n/g, '')\n if (!selection.isCollapsed() && rawTextContent === '') {\n setIsText(false)\n return\n }\n })\n }, [editor])\n\n useEffect(() => {\n document.addEventListener('selectionchange', updatePopup)\n document.addEventListener('mouseup', updatePopup)\n return () => {\n document.removeEventListener('selectionchange', updatePopup)\n document.removeEventListener('mouseup', updatePopup)\n }\n }, [updatePopup])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updatePopup()\n }),\n editor.registerRootListener(() => {\n if (editor.getRootElement() === null) {\n setIsText(false)\n }\n }),\n )\n }, [editor, updatePopup])\n\n if (!isText || !isEditable) {\n return null\n }\n\n return createPortal(<InlineToolbar anchorElem={anchorElem} editor={editor} />, anchorElem)\n}\n\nexport const InlineToolbarPlugin: PluginComponentWithAnchor<undefined> = ({ anchorElem }) => {\n const [editor] = useLexicalComposerContext()\n\n return useInlineToolbar(editor, anchorElem)\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC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,EAAA,GAAArH,YAAA,CAAac,IAAA,CAAA2B,aAAA;MAAAhC,UAAA;MAAAC;IAAA,C,GAA2DD,UAAA;IAAAyF,CAAA,MAAAzF,UAAA;IAAAyF,CAAA,OAAAxF,MAAA;IAAAwF,CAAA,OAAAmB,EAAA;EAAA;IAAAA,EAAA,GAAAnB,CAAA;EAAA;EAAA,OAAxEmB,EAAwE;AAAA;AAGjF,OAAO,MAAMC,mBAAA,GAA4DhB,EAAA;EAAC;IAAA7F;EAAA,IAAA6F,EAAc;EACtF,OAAA5F,MAAA,IAAiBzB,yBAAA;EAAA,OAEVgH,gBAAA,CAAiBvF,MAAA,EAAQD,UAAA;AAAA,CAClC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalEditable","mergeRegister","getTranslation","useTranslation","$getSelection","$isRangeSelection","$isTextNode","$onUpdate","COMMAND_PRIORITY_LOW","getDOMSelection","SELECTION_CHANGE_COMMAND","useCallback","useEffect","useMemo","useRef","useState","React","createPortal","useEditorConfigContext","getDOMRangeRect","setFloatingElemPosition","ToolbarButton","ToolbarDropdown","useToolbarKeyboardNavigation","useToolbarStates","ButtonGroupItem","active","anchorElem","editor","enabled","item","Component","_jsx","key","ChildComponent","ToolbarGroupComponent","group","index","toolbarStates","editorConfig","groupState","groupStates","get","DropdownIcon","type","undefined","activeItem","activeItems","_jsxs","className","items","length","Icon","map","itemState","itemStates","features","toolbarInline","groups","InlineToolbar","floatingToolbarRef","keyboardNavigationOptions","toolbarRef","fieldProps","i18n","caretRef","closeFloatingToolbar","current","isOpacityZero","style","opacity","isPointerEventsNone","pointerEvents","mouseMoveListener","e","buttons","x","clientX","y","clientY","elementUnderMouse","document","elementFromPoint","contains","mouseUpListener","addEventListener","removeEventListener","$updateTextFormatFloatingToolbar","selection","nativeSelection","_window","possibleLinkEditor","querySelector","isLinkEditorVisible","rootElement","getRootElement","isCollapsed","anchorNode","rangeRect","offsetIfFlipped","alwaysDisplayOnTop","floatingElem","horizontalPosition","targetRect","anchorFlippedOffset","horizontalOffset","specialHandlingForCaret","verticalGap","scrollerElem","parentElement","update","getEditorState","read","window","registerUpdateListener","editorState","registerCommand","field","label","path","ref","role","i","useInlineToolbar","$","isText","setIsText","isEditable","t0","isComposing","getTextContent","nodes","getNodes","foundNodeWithText","node","rawTextContent","replace","updatePopup","t1","t2","t3","t4","registerRootListener","t5","InlineToolbarPlugin"],"sources":["../../../../../../src/features/toolbars/inline/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { useTranslation } from '@payloadcms/ui'\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n $onUpdate,\n COMMAND_PRIORITY_LOW,\n getDOMSelection,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponentWithAnchor } from '../../../../typesClient.js'\nimport type { ToolbarStates } from '../../../shared/useToolbarStates.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { getDOMRangeRect } from '../../../../../lexical/utils/getDOMRangeRect.js'\nimport { setFloatingElemPosition } from '../../../../../lexical/utils/setFloatingElemPosition.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\nimport { useToolbarKeyboardNavigation } from '../../../shared/useToolbarKeyboardNavigation.js'\nimport { useToolbarStates } from '../../../shared/useToolbarStates.js'\nimport './index.css'\n\nfunction ButtonGroupItem({\n active,\n anchorElem,\n editor,\n enabled,\n item,\n}: {\n active: boolean\n anchorElem: HTMLElement\n editor: LexicalEditor\n enabled: boolean\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton active={active} editor={editor} enabled={enabled} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n group,\n index,\n toolbarStates,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n group: ToolbarGroup\n index: number\n toolbarStates: ToolbarStates\n}): React.ReactNode {\n const { editorConfig } = useEditorConfigContext()\n\n const groupState = toolbarStates.groupStates.get(group.key)\n\n const DropdownIcon = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItem = groupState?.activeItems?.[0]\n return activeItem?.ChildComponent ?? group.ChildComponent\n }, [group, groupState?.activeItems])\n\n return (\n <div\n className={`inline-toolbar-popup__group inline-toolbar-popup__group-${group.key}`}\n data-toolbar-group-key={group.key}\n key={group.key}\n >\n {group.type === 'dropdown' && group.items.length && groupState ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n groupState={groupState}\n Icon={DropdownIcon}\n />\n ) : null}\n {group.type === 'buttons' && group.items.length\n ? group.items.map((item) => {\n const itemState = toolbarStates.itemStates.get(item.key)\n return (\n <ButtonGroupItem\n active={itemState?.active ?? false}\n anchorElem={anchorElem}\n editor={editor}\n enabled={itemState?.enabled ?? true}\n item={item}\n key={item.key}\n />\n )\n })\n : null}\n {index < editorConfig.features.toolbarInline?.groups.length - 1 && (\n <div className=\"divider\" />\n )}\n </div>\n )\n}\n\nfunction InlineToolbar({\n anchorElem,\n editor,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n}): React.ReactNode {\n const floatingToolbarRef = useRef<HTMLDivElement | null>(null)\n const keyboardNavigationOptions = useMemo(() => ({ toolbarRef: floatingToolbarRef }), [])\n const { fieldProps } = useEditorConfigContext()\n const { i18n } = useTranslation()\n\n useToolbarKeyboardNavigation(keyboardNavigationOptions)\n\n const caretRef = useRef<HTMLDivElement | null>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const toolbarStates = useToolbarStates(editor, editorConfig?.features?.toolbarInline?.groups)\n\n const closeFloatingToolbar = useCallback(() => {\n if (floatingToolbarRef?.current) {\n const isOpacityZero = floatingToolbarRef.current.style.opacity === '0'\n const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none'\n\n if (!isOpacityZero) {\n floatingToolbarRef.current.style.opacity = '0'\n }\n if (!isPointerEventsNone) {\n floatingToolbarRef.current.style.pointerEvents = 'none'\n }\n }\n }, [floatingToolbarRef])\n\n const mouseMoveListener = useCallback(\n (e: MouseEvent) => {\n if (floatingToolbarRef?.current && (e.buttons === 1 || e.buttons === 3)) {\n const isOpacityZero = floatingToolbarRef.current.style.opacity === '0'\n const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none'\n if (!isOpacityZero || !isPointerEventsNone) {\n // Check if the mouse is not over the popup\n const x = e.clientX\n const y = e.clientY\n const elementUnderMouse = document.elementFromPoint(x, y)\n if (!floatingToolbarRef.current.contains(elementUnderMouse)) {\n // Mouse is not over the target element => not a normal click, but probably a drag\n closeFloatingToolbar()\n }\n }\n }\n },\n [closeFloatingToolbar],\n )\n\n const mouseUpListener = useCallback(() => {\n if (floatingToolbarRef?.current) {\n if (floatingToolbarRef.current.style.opacity !== '1') {\n floatingToolbarRef.current.style.opacity = '1'\n }\n if (floatingToolbarRef.current.style.pointerEvents !== 'auto') {\n floatingToolbarRef.current.style.pointerEvents = 'auto'\n }\n }\n }, [])\n\n useEffect(() => {\n document.addEventListener('mousemove', mouseMoveListener)\n document.addEventListener('mouseup', mouseUpListener)\n\n return () => {\n document.removeEventListener('mousemove', mouseMoveListener)\n document.removeEventListener('mouseup', mouseUpListener)\n }\n }, [floatingToolbarRef, mouseMoveListener, mouseUpListener])\n\n const $updateTextFormatFloatingToolbar = useCallback(() => {\n const selection = $getSelection()\n\n const nativeSelection = getDOMSelection(editor._window)\n\n if (floatingToolbarRef.current === null) {\n return\n }\n\n const possibleLinkEditor = anchorElem.querySelector(':scope > .link-editor')\n const isLinkEditorVisible =\n possibleLinkEditor !== null &&\n 'style' in possibleLinkEditor &&\n possibleLinkEditor?.style?.['opacity' as keyof typeof possibleLinkEditor.style] === '1'\n\n const rootElement = editor.getRootElement()\n if (\n selection !== null &&\n nativeSelection !== null &&\n !nativeSelection.isCollapsed &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n const rangeRect = getDOMRangeRect(nativeSelection, rootElement)\n\n // Position floating toolbar\n const offsetIfFlipped = setFloatingElemPosition({\n alwaysDisplayOnTop: isLinkEditorVisible,\n anchorElem,\n floatingElem: floatingToolbarRef.current,\n horizontalPosition: 'center',\n targetRect: rangeRect,\n })\n\n // Position caret\n if (caretRef.current) {\n setFloatingElemPosition({\n anchorElem: floatingToolbarRef.current,\n anchorFlippedOffset: offsetIfFlipped,\n floatingElem: caretRef.current,\n horizontalOffset: 5,\n horizontalPosition: 'center',\n specialHandlingForCaret: true,\n targetRect: rangeRect,\n verticalGap: 8,\n })\n }\n } else {\n closeFloatingToolbar()\n }\n }, [editor, closeFloatingToolbar, anchorElem])\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement\n\n const update = () => {\n editor.getEditorState().read(() => {\n $updateTextFormatFloatingToolbar()\n })\n }\n\n window.addEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.addEventListener('scroll', update)\n }\n\n return () => {\n window.removeEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.removeEventListener('scroll', update)\n }\n }\n }, [editor, $updateTextFormatFloatingToolbar, anchorElem])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n $updateTextFormatFloatingToolbar()\n })\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n $updateTextFormatFloatingToolbar()\n })\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n $onUpdate(() => editor.read('latest', $updateTextFormatFloatingToolbar))\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, $updateTextFormatFloatingToolbar])\n\n return (\n <div\n aria-label={\n getTranslation(fieldProps.field.label || fieldProps.path, i18n) || fieldProps.path\n }\n className=\"inline-toolbar-popup\"\n ref={floatingToolbarRef}\n role=\"toolbar\"\n >\n <div className=\"caret\" ref={caretRef} />\n {editorConfig?.features &&\n editorConfig.features?.toolbarInline?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n index={i}\n key={group.key}\n toolbarStates={toolbarStates}\n />\n )\n })}\n </div>\n )\n}\n\nfunction useInlineToolbar(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n): null | React.ReactElement {\n const [isText, setIsText] = useState(false)\n const isEditable = useLexicalEditable()\n\n const updatePopup = useCallback(() => {\n editor.getEditorState().read(() => {\n // Should not to pop up the floating toolbar when using IME input\n if (editor.isComposing()) {\n return\n }\n const selection = $getSelection()\n const nativeSelection = getDOMSelection(editor._window)\n const rootElement = editor.getRootElement()\n\n if (\n nativeSelection !== null &&\n (!$isRangeSelection(selection) ||\n rootElement === null ||\n !rootElement.contains(nativeSelection.anchorNode))\n ) {\n setIsText(false)\n return\n }\n\n if (!$isRangeSelection(selection)) {\n return\n }\n\n if (selection.getTextContent() !== '') {\n const nodes = selection.getNodes()\n let foundNodeWithText = false\n for (const node of nodes) {\n if ($isTextNode(node)) {\n setIsText(true)\n foundNodeWithText = true\n break\n }\n }\n if (!foundNodeWithText) {\n setIsText(false)\n }\n } else {\n setIsText(false)\n }\n\n const rawTextContent = selection.getTextContent().replace(/\\n/g, '')\n if (!selection.isCollapsed() && rawTextContent === '') {\n setIsText(false)\n return\n }\n })\n }, [editor])\n\n useEffect(() => {\n document.addEventListener('selectionchange', updatePopup)\n document.addEventListener('mouseup', updatePopup)\n return () => {\n document.removeEventListener('selectionchange', updatePopup)\n document.removeEventListener('mouseup', updatePopup)\n }\n }, [updatePopup])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updatePopup()\n }),\n editor.registerRootListener(() => {\n if (editor.getRootElement() === null) {\n setIsText(false)\n }\n }),\n )\n }, [editor, updatePopup])\n\n if (!isText || !isEditable) {\n return null\n }\n\n return createPortal(<InlineToolbar anchorElem={anchorElem} editor={editor} />, anchorElem)\n}\n\nexport const InlineToolbarPlugin: PluginComponentWithAnchor<undefined> = ({ anchorElem }) => {\n const [editor] = useLexicalComposerContext()\n\n return useInlineToolbar(editor, anchorElem)\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SACEC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,SAAS,EACTC,oBAAoB,EACpBC,eAAe,EACfC,wBAAwB,QACnB;AACP,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,YAAY,QAAQ;AAM7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,eAAe,QAAQ;AAChC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,gBAAgB,QAAQ;AACjC,OAAO;AAEP,SAASC,gBAAgB;EACvBC,MAAM;EACNC,UAAU;EACVC,MAAM;EACNC,OAAO;EACPC;AAAI,CAOL;EACC,IAAIA,IAAA,CAAKC,SAAS,EAAE;IAClB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;IAAAiG,CAAA,OAAAhG,MAAA;IAAAgG,CAAA,OAAAmB,EAAA;EAAA;IAAAA,EAAA,GAAAnB,CAAA;EAAA;EAAA,OAAxEmB,EAAwE;AAAA;AAGjF,OAAO,MAAMC,mBAAA,GAA4DhB,EAAA;EAAC;IAAArG;EAAA,IAAAqG,EAAc;EACtF,OAAApG,MAAA,IAAiB7B,yBAAA;EAAA,OAEV4H,gBAAA,CAAiB/F,MAAA,EAAQD,UAAA;AAAA,CAClC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/toolbars/shared/ToolbarButton/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAI5C,OAAO,KAA4D,MAAM,OAAO,CAAA;AAEhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGtD,OAAO,aAAa,CAAA;AAIpB,eAAO,MAAM,aAAa,GAAI,8CAM3B;IACD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAA;IAC3B,MAAM,EAAE,aAAa,CAAA;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,gBAAgB,CAAA;CACvB,sBAmFA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/toolbars/shared/ToolbarButton/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAI5C,OAAO,KAA4D,MAAM,OAAO,CAAA;AAEhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGtD,OAAO,aAAa,CAAA;AAIpB,eAAO,MAAM,aAAa,iDAMvB;IACD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAA;IAC3B,MAAM,EAAE,aAAa,CAAA;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,gBAAgB,CAAA;CACvB,sBAoFA,CAAA"}
@@ -67,6 +67,7 @@ export const ToolbarButton = ({
67
67
  }, []);
68
68
  return /*#__PURE__*/_jsxs("button", {
69
69
  "aria-label": tooltipLabel,
70
+ "aria-pressed": item.isActive ? active : undefined,
70
71
  className: className,
71
72
  "data-button-key": item.key,
72
73
  disabled: !enabled,
@@ -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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,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}__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,EAAE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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.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;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"],"m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C,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":[]}
@@ -19,7 +19,6 @@
19
19
  border-radius: var(--radius-medium);
20
20
  cursor: pointer;
21
21
  position: relative;
22
- transition: background-color 0.15s cubic-bezier(0, 0.2, 0.2, 1);
23
22
  min-width: calc(var(--spacer-4) + var(--spacer-2-5));
24
23
 
25
24
  &:disabled {
@@ -60,7 +59,7 @@
60
59
  align-items: center;
61
60
  justify-content: center;
62
61
  width: 6px;
63
- margin: 0 4px 0 2px;
62
+ margin: 0 var(--spacer-1) 0 calc(var(--spacer-1) / 2);
64
63
  height: 4px;
65
64
  background-color: var(--color-icon);
66
65
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='4' viewBox='0 0 6 4' fill='none'%3E%3Cpath d='M4.38921 0.146406C4.58445 -0.0488286 4.90098 -0.0487744 5.09624 0.146406C5.29151 0.341668 5.29151 0.658175 5.09624 0.853437L2.97515 2.97453C2.77987 3.16959 2.46332 3.16972 2.26812 2.97453L0.146049 0.853437C-0.0487219 0.6583 -0.0486443 0.341591 0.146049 0.146406C0.341285 -0.0488288 0.658788 -0.0487749 0.854057 0.146406L2.62164 1.91398L4.38921 0.146406Z' fill='black'/%3E%3C/svg%3E");
@@ -71,25 +70,23 @@
71
70
  .toolbar-popup__dropdown-items {
72
71
  --dropdown-min-width: 5rem;
73
72
  position: absolute;
73
+ inset: auto;
74
+ margin: 0;
74
75
  background: var(--color-bg-elevated);
75
76
  color: var(--color-text);
76
77
  border-radius: var(--radius-large);
77
78
  padding: var(--spacer-2);
78
79
  min-width: var(--dropdown-min-width);
80
+ max-height: calc(100vh - var(--spacer-3));
81
+ overflow-y: auto;
79
82
  z-index: 100;
80
- box-shadow:
81
- 0 2px 6px 0 rgba(0, 0, 0, 0.12),
82
- 0 10px 16px 0 rgba(0, 0, 0, 0.08),
83
- 0 0 0.5px 0 rgba(0, 0, 0, 0.12),
84
- 0 0 0 1px rgba(0, 0, 0, 0.04);
83
+ box-shadow: var(--elevation-300-tooltip);
85
84
 
86
85
  .toolbar-popup__dropdown-item {
87
86
  all: unset;
88
87
  cursor: pointer;
89
88
  color: var(--color-text);
90
- transition: background-color 0.15s cubic-bezier(0, 0.2, 0.2, 1);
91
89
  position: relative;
92
- font-family: var(--text-body-medium-font-family);
93
90
  font-size: var(--text-body-medium-font-size);
94
91
  font-weight: var(--text-body-medium-font-weight);
95
92
  line-height: var(--text-body-medium-line-height);
@@ -101,7 +98,7 @@
101
98
  display: flex;
102
99
  align-items: center;
103
100
  gap: var(--spacer-1);
104
- margin-right: -var(--spacer-3);
101
+ margin-inline-end: -var(--spacer-3);
105
102
 
106
103
  .text {
107
104
  overflow: hidden;
@@ -168,15 +165,15 @@
168
165
  }
169
166
 
170
167
  .btn__tooltip {
171
- background-color: var(--ramp-grey-900);
172
- color: var(--ramp-grey-100);
168
+ background-color: var(--color-bg-tooltip);
169
+ color: var(--color-text-ontooltip);
173
170
 
174
171
  &.tooltip--position-top::after {
175
- border-top-color: var(--ramp-grey-900);
172
+ border-top-color: var(--color-bg-tooltip);
176
173
  }
177
174
 
178
175
  &.tooltip--position-bottom::after {
179
- border-bottom-color: var(--ramp-grey-900);
176
+ border-bottom-color: var(--color-bg-tooltip);
180
177
  }
181
178
  }
182
179
  }
@@ -191,20 +188,21 @@
191
188
  }
192
189
 
193
190
  [data-dropdown-key='text'] {
194
- & .toolbar-popup__dropdown-item {
195
- 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;
196
202
  }
197
203
 
198
204
  & .toolbar-popup__dropdown-item.active::before {
199
- content: '';
200
- position: absolute;
201
- left: var(--spacer-2-5);
202
- top: 50%;
203
- width: var(--spacer-1);
204
- height: var(--spacer-2);
205
- border: solid var(--color-text-onselected-strong);
206
- border-width: 0 1px 1px 0;
207
- transform: translateY(-60%) rotate(45deg);
205
+ visibility: visible;
208
206
  }
209
207
 
210
208
  .btn__icon {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/toolbars/shared/ToolbarDropdown/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAItC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAI5C,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,gBAAgB,CAAA;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAG/D,OAAO,aAAa,CAAA;AAsEpB,eAAO,MAAM,eAAe,GAAI,+FAS7B;IACD,UAAU,EAAE,WAAW,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,MAAM,EAAE,aAAa,CAAA;IACrB,KAAK,EAAE,oBAAoB,CAAA;IAC3B,UAAU,EAAE,iBAAiB,CAAA;IAC7B,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACf,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,sBAmCA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/toolbars/shared/ToolbarDropdown/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAItC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAI5C,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,gBAAgB,CAAA;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAG/D,OAAO,aAAa,CAAA;AAsEpB,eAAO,MAAM,eAAe,kGASzB;IACD,UAAU,EAAE,WAAW,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,MAAM,EAAE,aAAa,CAAA;IACrB,KAAK,EAAE,oBAAoB,CAA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