@payloadcms/richtext-lexical 4.0.0-internal.2fddfc0 → 4.0.0-internal.31ba7ee

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 (725) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/exports/client/Field-TCOK744G.js +2 -0
  3. package/dist/exports/client/Field-TCOK744G.js.map +7 -0
  4. package/dist/exports/client/bundled.css +1 -1
  5. package/dist/exports/client/chunk-3LRZDIIG.js +2 -0
  6. package/dist/exports/client/chunk-3LRZDIIG.js.map +7 -0
  7. package/dist/exports/client/chunk-43E5QYAA.js +2 -0
  8. package/dist/exports/client/chunk-43E5QYAA.js.map +7 -0
  9. package/dist/exports/client/{chunk-ESITTE3C.js → chunk-ZFGDYZDE.js} +2 -2
  10. package/dist/exports/client/{chunk-ESITTE3C.js.map → chunk-ZFGDYZDE.js.map} +2 -2
  11. package/dist/exports/client/component-D5QLYS7W.js +2 -0
  12. package/dist/exports/client/component-D5QLYS7W.js.map +7 -0
  13. package/dist/exports/client/componentInline-55HZXGUS.js +2 -0
  14. package/dist/exports/client/index.d.ts +1 -3
  15. package/dist/exports/client/index.d.ts.map +1 -1
  16. package/dist/exports/client/index.js +27 -28
  17. package/dist/exports/client/index.js.map +4 -4
  18. package/dist/features/align/client/toolbarAlignGroup.d.ts.map +1 -1
  19. package/dist/features/blockquote/client/index.js +2 -2
  20. package/dist/features/blockquote/client/index.js.map +1 -1
  21. package/dist/features/blockquote/server/index.js +2 -2
  22. package/dist/features/blockquote/server/index.js.map +1 -1
  23. package/dist/features/blocks/client/component/BlockReordering/index.d.ts +11 -0
  24. package/dist/features/blocks/client/component/BlockReordering/index.d.ts.map +1 -0
  25. package/dist/features/blocks/client/component/BlockReordering/index.js +18 -0
  26. package/dist/features/blocks/client/component/BlockReordering/index.js.map +1 -0
  27. package/dist/features/blocks/client/component/index.css +2 -2
  28. package/dist/features/blocks/client/component/index.d.ts +0 -6
  29. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  30. package/dist/features/blocks/client/component/index.js +133 -76
  31. package/dist/features/blocks/client/component/index.js.map +1 -1
  32. package/dist/features/blocks/client/component/useBlockReordering.d.ts +16 -0
  33. package/dist/features/blocks/client/component/useBlockReordering.d.ts.map +1 -0
  34. package/dist/features/blocks/client/component/useBlockReordering.js +178 -0
  35. package/dist/features/blocks/client/component/useBlockReordering.js.map +1 -0
  36. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts.map +1 -1
  37. package/dist/features/blocks/client/componentInline/index.css +8 -8
  38. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  39. package/dist/features/blocks/client/componentInline/index.js +2 -2
  40. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  41. package/dist/features/blocks/client/getBlockImageComponent.d.ts +1 -1
  42. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +1 -1
  43. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -1
  44. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +1 -1
  45. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -1
  46. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +1 -1
  47. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -1
  48. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +5 -2
  49. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -1
  50. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +1 -2
  51. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -1
  52. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
  53. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  54. package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
  55. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.css +1 -1
  56. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.css +2 -4
  57. package/dist/features/blocks/premade/CodeBlock/Component/index.css +5 -5
  58. package/dist/features/blocks/server/graphQLPopulationPromise.d.ts.map +1 -1
  59. package/dist/features/blocks/server/index.js +2 -2
  60. package/dist/features/blocks/server/index.js.map +1 -1
  61. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +1 -1
  62. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -1
  63. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
  64. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  65. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
  66. package/dist/features/blocks/server/schema.d.ts.map +1 -1
  67. package/dist/features/blocks/server/schema.js +3 -2
  68. package/dist/features/blocks/server/schema.js.map +1 -1
  69. package/dist/features/blocks/server/validate.d.ts.map +1 -1
  70. package/dist/features/converters/htmlToLexical/index.d.ts.map +1 -1
  71. package/dist/features/converters/lexicalToHtml/async/converters/heading.js +1 -1
  72. package/dist/features/converters/lexicalToHtml/async/converters/heading.js.map +1 -1
  73. package/dist/features/converters/lexicalToHtml/async/converters/list.d.ts.map +1 -1
  74. package/dist/features/converters/lexicalToHtml/async/converters/list.js +4 -3
  75. package/dist/features/converters/lexicalToHtml/async/converters/list.js.map +1 -1
  76. package/dist/features/converters/lexicalToHtml/shared/cssColors.d.ts.map +1 -1
  77. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.d.ts.map +1 -1
  78. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js +3 -2
  79. package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js.map +1 -1
  80. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js +1 -1
  81. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js.map +1 -1
  82. package/dist/features/converters/lexicalToHtml/sync/converters/list.d.ts.map +1 -1
  83. package/dist/features/converters/lexicalToHtml/sync/converters/list.js +4 -3
  84. package/dist/features/converters/lexicalToHtml/sync/converters/list.js.map +1 -1
  85. package/dist/features/converters/lexicalToJSX/converter/converters/heading.d.ts.map +1 -1
  86. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +2 -1
  87. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
  88. package/dist/features/converters/lexicalToJSX/converter/converters/list.d.ts.map +1 -1
  89. package/dist/features/converters/lexicalToJSX/converter/converters/list.js +2 -1
  90. package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
  91. package/dist/features/converters/lexicalToMarkdown/index.d.ts.map +1 -1
  92. package/dist/features/converters/lexicalToMarkdown/index.js +1 -1
  93. package/dist/features/converters/lexicalToMarkdown/index.js.map +1 -1
  94. package/dist/features/converters/markdownToLexical/index.d.ts.map +1 -1
  95. package/dist/features/converters/markdownToLexical/index.js +5 -2
  96. package/dist/features/converters/markdownToLexical/index.js.map +1 -1
  97. package/dist/features/converters/utilities/payloadPopulateFn.d.ts.map +1 -1
  98. package/dist/features/converters/utilities/payloadPopulateFn.js +4 -2
  99. package/dist/features/converters/utilities/payloadPopulateFn.js.map +1 -1
  100. package/dist/features/debug/jsxConverter/client/plugin/style.css +2 -2
  101. package/dist/features/debug/testRecorder/client/plugin/index.css +0 -1
  102. package/dist/features/format/bold/feature.client.js +1 -1
  103. package/dist/features/format/bold/feature.client.js.map +1 -1
  104. package/dist/features/format/bold/feature.server.d.ts.map +1 -1
  105. package/dist/features/format/bold/feature.server.js +1 -1
  106. package/dist/features/format/bold/feature.server.js.map +1 -1
  107. package/dist/features/format/inlineCode/feature.client.js +1 -1
  108. package/dist/features/format/inlineCode/feature.client.js.map +1 -1
  109. package/dist/features/format/inlineCode/feature.server.d.ts.map +1 -1
  110. package/dist/features/format/inlineCode/feature.server.js +1 -1
  111. package/dist/features/format/inlineCode/feature.server.js.map +1 -1
  112. package/dist/features/format/italic/feature.client.js +1 -1
  113. package/dist/features/format/italic/feature.client.js.map +1 -1
  114. package/dist/features/format/italic/feature.server.d.ts.map +1 -1
  115. package/dist/features/format/italic/feature.server.js +1 -1
  116. package/dist/features/format/italic/feature.server.js.map +1 -1
  117. package/dist/features/format/shared/toolbarFormatGroup.d.ts.map +1 -1
  118. package/dist/features/format/strikethrough/feature.client.js +1 -1
  119. package/dist/features/format/strikethrough/feature.client.js.map +1 -1
  120. package/dist/features/format/strikethrough/feature.server.d.ts.map +1 -1
  121. package/dist/features/format/strikethrough/feature.server.js +1 -1
  122. package/dist/features/format/strikethrough/feature.server.js.map +1 -1
  123. package/dist/features/heading/client/index.js +2 -2
  124. package/dist/features/heading/client/index.js.map +1 -1
  125. package/dist/features/heading/constants.d.ts +2 -0
  126. package/dist/features/heading/constants.d.ts.map +1 -0
  127. package/dist/features/heading/constants.js +2 -0
  128. package/dist/features/heading/constants.js.map +1 -0
  129. package/dist/features/heading/markdownTransformer.d.ts +2 -2
  130. package/dist/features/heading/markdownTransformer.d.ts.map +1 -1
  131. package/dist/features/heading/markdownTransformer.js +6 -19
  132. package/dist/features/heading/markdownTransformer.js.map +1 -1
  133. package/dist/features/heading/server/index.d.ts.map +1 -1
  134. package/dist/features/heading/server/index.js +7 -3
  135. package/dist/features/heading/server/index.js.map +1 -1
  136. package/dist/features/heading/server/schema.d.ts.map +1 -1
  137. package/dist/features/heading/server/validate.d.ts +6 -0
  138. package/dist/features/heading/server/validate.d.ts.map +1 -0
  139. package/dist/features/heading/server/validate.js +15 -0
  140. package/dist/features/heading/server/validate.js.map +1 -0
  141. package/dist/features/horizontalRule/client/index.js +2 -2
  142. package/dist/features/horizontalRule/client/index.js.map +1 -1
  143. package/dist/features/horizontalRule/client/markdownTransformer.d.ts +2 -2
  144. package/dist/features/horizontalRule/client/markdownTransformer.d.ts.map +1 -1
  145. package/dist/features/horizontalRule/client/markdownTransformer.js +1 -1
  146. package/dist/features/horizontalRule/client/markdownTransformer.js.map +1 -1
  147. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +1 -1
  148. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  149. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +1 -1
  150. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  151. package/dist/features/horizontalRule/client/plugin/index.css +2 -2
  152. package/dist/features/horizontalRule/server/index.js +2 -2
  153. package/dist/features/horizontalRule/server/index.js.map +1 -1
  154. package/dist/features/horizontalRule/server/markdownTransformer.d.ts +2 -2
  155. package/dist/features/horizontalRule/server/markdownTransformer.d.ts.map +1 -1
  156. package/dist/features/horizontalRule/server/markdownTransformer.js +1 -1
  157. package/dist/features/horizontalRule/server/markdownTransformer.js.map +1 -1
  158. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +1 -1
  159. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
  160. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +1 -1
  161. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  162. package/dist/features/indent/client/IndentPlugin.d.ts.map +1 -1
  163. package/dist/features/indent/client/IndentPlugin.js +122 -1
  164. package/dist/features/indent/client/IndentPlugin.js.map +1 -1
  165. package/dist/features/indent/client/toolbarIndentGroup.d.ts.map +1 -1
  166. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  167. package/dist/features/indent/server/i18n.js +74 -37
  168. package/dist/features/indent/server/i18n.js.map +1 -1
  169. package/dist/features/link/client/index.js +2 -2
  170. package/dist/features/link/client/index.js.map +1 -1
  171. package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
  172. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  173. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +11 -8
  174. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  175. package/dist/features/link/client/plugins/floatingLinkEditor/index.css +7 -12
  176. package/dist/features/link/markdownTransformer.d.ts +4 -4
  177. package/dist/features/link/markdownTransformer.d.ts.map +1 -1
  178. package/dist/features/link/markdownTransformer.js +2 -2
  179. package/dist/features/link/markdownTransformer.js.map +1 -1
  180. package/dist/features/link/nodes/AutoLinkNode.d.ts +1 -1
  181. package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  182. package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
  183. package/dist/features/link/nodes/LinkNode.d.ts +1 -1
  184. package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
  185. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  186. package/dist/features/link/server/baseFields.d.ts.map +1 -1
  187. package/dist/features/link/server/baseFields.js.map +1 -1
  188. package/dist/features/link/server/graphQLPopulationPromise.d.ts.map +1 -1
  189. package/dist/features/link/server/index.js +4 -4
  190. package/dist/features/link/server/index.js.map +1 -1
  191. package/dist/features/link/server/schema.d.ts.map +1 -1
  192. package/dist/features/link/server/schema.js +4 -2
  193. package/dist/features/link/server/schema.js.map +1 -1
  194. package/dist/features/link/server/validate.d.ts.map +1 -1
  195. package/dist/features/lists/checklist/client/index.js +1 -1
  196. package/dist/features/lists/checklist/client/index.js.map +1 -1
  197. package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
  198. package/dist/features/lists/checklist/server/index.js +6 -3
  199. package/dist/features/lists/checklist/server/index.js.map +1 -1
  200. package/dist/features/lists/orderedList/client/index.js +1 -1
  201. package/dist/features/lists/orderedList/client/index.js.map +1 -1
  202. package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
  203. package/dist/features/lists/orderedList/server/index.js +6 -3
  204. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  205. package/dist/features/lists/shared/constants.d.ts +2 -0
  206. package/dist/features/lists/shared/constants.d.ts.map +1 -0
  207. package/dist/features/lists/shared/constants.js +2 -0
  208. package/dist/features/lists/shared/constants.js.map +1 -0
  209. package/dist/features/lists/shared/validate.d.ts +5 -0
  210. package/dist/features/lists/shared/validate.d.ts.map +1 -0
  211. package/dist/features/lists/shared/validate.js +15 -0
  212. package/dist/features/lists/shared/validate.js.map +1 -0
  213. package/dist/features/lists/unorderedList/client/index.js +1 -1
  214. package/dist/features/lists/unorderedList/client/index.js.map +1 -1
  215. package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
  216. package/dist/features/lists/unorderedList/server/index.js +6 -3
  217. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  218. package/dist/features/relationship/client/drawer/index.d.ts.map +1 -1
  219. package/dist/features/relationship/client/index.d.ts +2 -2
  220. package/dist/features/relationship/client/index.d.ts.map +1 -1
  221. package/dist/features/relationship/client/index.js.map +1 -1
  222. package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
  223. package/dist/features/relationship/client/plugins/index.d.ts +2 -2
  224. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  225. package/dist/features/relationship/client/plugins/index.js +27 -31
  226. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  227. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts +2 -4
  228. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
  229. package/dist/features/relationship/client/utils/useEnabledRelationships.js +53 -20
  230. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  231. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +2 -2
  232. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
  233. package/dist/features/relationship/server/graphQLPopulationPromise.js +2 -2
  234. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  235. package/dist/features/relationship/server/index.d.ts +8 -1
  236. package/dist/features/relationship/server/index.d.ts.map +1 -1
  237. package/dist/features/relationship/server/index.js +28 -11
  238. package/dist/features/relationship/server/index.js.map +1 -1
  239. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  240. package/dist/features/relationship/server/schema.d.ts +5 -5
  241. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  242. package/dist/features/relationship/server/schema.js +27 -15
  243. package/dist/features/relationship/server/schema.js.map +1 -1
  244. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +1 -6
  245. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -1
  246. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +1 -5
  247. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -1
  248. package/dist/features/shared/toolbar/addDropdownGroup.d.ts.map +1 -1
  249. package/dist/features/shared/toolbar/featureButtonsGroup.d.ts.map +1 -1
  250. package/dist/features/shared/toolbar/textDropdownGroup.d.ts.map +1 -1
  251. package/dist/features/table/client/index.d.ts.map +1 -0
  252. package/dist/features/{experimental_table → table}/client/index.js +2 -2
  253. package/dist/features/table/client/index.js.map +1 -0
  254. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts +8 -0
  255. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts.map +1 -0
  256. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js +19 -0
  257. package/dist/features/table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js.map +1 -0
  258. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -0
  259. package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.js +17 -44
  260. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -0
  261. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -0
  262. package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.js +41 -18
  263. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js.map +1 -0
  264. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -0
  265. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -0
  266. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.d.ts.map +1 -0
  267. package/dist/features/table/client/plugins/TablePlugin/TableGridPopup/index.js.map +1 -0
  268. package/dist/features/table/client/plugins/TablePlugin/index.d.ts.map +1 -0
  269. package/dist/features/table/client/plugins/TablePlugin/index.js.map +1 -0
  270. package/dist/features/table/client/utils/debounce.d.ts.map +1 -0
  271. package/dist/features/table/client/utils/debounce.js.map +1 -0
  272. package/dist/features/table/client/utils/useDebounce.d.ts.map +1 -0
  273. package/dist/features/table/client/utils/useDebounce.js.map +1 -0
  274. package/dist/features/table/markdownTransformer.d.ts +5 -0
  275. package/dist/features/table/markdownTransformer.d.ts.map +1 -0
  276. package/dist/features/{experimental_table → table}/markdownTransformer.js +6 -3
  277. package/dist/features/table/markdownTransformer.js.map +1 -0
  278. package/dist/features/table/server/index.d.ts +3 -0
  279. package/dist/features/table/server/index.d.ts.map +1 -0
  280. package/dist/features/{experimental_table → table}/server/index.js +6 -6
  281. package/dist/features/table/server/index.js.map +1 -0
  282. package/dist/features/table/server/schema.d.ts.map +1 -0
  283. package/dist/features/table/server/schema.js.map +1 -0
  284. package/dist/features/textState/feature.client.js +1 -1
  285. package/dist/features/textState/feature.client.js.map +1 -1
  286. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts +8 -0
  287. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.d.ts.map +1 -0
  288. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js +80 -0
  289. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js.map +1 -0
  290. package/dist/features/toolbars/fixed/client/Toolbar/index.css +80 -8
  291. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  292. package/dist/features/toolbars/fixed/client/Toolbar/index.js +4 -1
  293. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  294. package/dist/features/toolbars/inline/client/Toolbar/index.css +2 -14
  295. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  296. package/dist/features/toolbars/inline/client/Toolbar/index.js +2 -2
  297. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  298. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  299. package/dist/features/toolbars/shared/ToolbarButton/index.js +1 -0
  300. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  301. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  302. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +85 -32
  303. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  304. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +23 -24
  305. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  306. package/dist/features/toolbars/shared/useToolbarStates.d.ts.map +1 -1
  307. package/dist/features/toolbars/shared/useToolbarStates.js +3 -1
  308. package/dist/features/toolbars/shared/useToolbarStates.js.map +1 -1
  309. package/dist/features/typesClient.d.ts +1 -1
  310. package/dist/features/typesClient.d.ts.map +1 -1
  311. package/dist/features/typesClient.js.map +1 -1
  312. package/dist/features/typesServer.d.ts +16 -11
  313. package/dist/features/typesServer.d.ts.map +1 -1
  314. package/dist/features/typesServer.js.map +1 -1
  315. package/dist/features/upload/client/component/index.css +9 -9
  316. package/dist/features/upload/client/component/index.js +2 -1
  317. package/dist/features/upload/client/component/index.js.map +1 -1
  318. package/dist/features/upload/client/drawer/index.d.ts.map +1 -1
  319. package/dist/features/upload/client/index.d.ts +3 -2
  320. package/dist/features/upload/client/index.d.ts.map +1 -1
  321. package/dist/features/upload/client/index.js.map +1 -1
  322. package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
  323. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  324. package/dist/features/upload/client/plugin/index.js +53 -56
  325. package/dist/features/upload/client/plugin/index.js.map +1 -1
  326. package/dist/features/upload/server/graphQLPopulationPromise.d.ts +2 -2
  327. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  328. package/dist/features/upload/server/graphQLPopulationPromise.js +1 -1
  329. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  330. package/dist/features/upload/server/index.d.ts +6 -2
  331. package/dist/features/upload/server/index.d.ts.map +1 -1
  332. package/dist/features/upload/server/index.js +22 -18
  333. package/dist/features/upload/server/index.js.map +1 -1
  334. package/dist/features/upload/server/markdownTransformer.d.ts +2 -2
  335. package/dist/features/upload/server/markdownTransformer.d.ts.map +1 -1
  336. package/dist/features/upload/server/markdownTransformer.js +1 -1
  337. package/dist/features/upload/server/markdownTransformer.js.map +1 -1
  338. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  339. package/dist/features/upload/server/schema.d.ts +6 -6
  340. package/dist/features/upload/server/schema.d.ts.map +1 -1
  341. package/dist/features/upload/server/schema.js +30 -14
  342. package/dist/features/upload/server/schema.js.map +1 -1
  343. package/dist/features/upload/server/validate.d.ts +2 -2
  344. package/dist/features/upload/server/validate.d.ts.map +1 -1
  345. package/dist/features/upload/server/validate.js +3 -0
  346. package/dist/features/upload/server/validate.js.map +1 -1
  347. package/dist/field/Diff/converters/listitem/index.d.ts.map +1 -1
  348. package/dist/field/Diff/converters/listitem/index.js +2 -1
  349. package/dist/field/Diff/converters/listitem/index.js.map +1 -1
  350. package/dist/field/Diff/converters/unknown/index.css +1 -1
  351. package/dist/field/Diff/index.d.ts +3 -2
  352. package/dist/field/Diff/index.d.ts.map +1 -1
  353. package/dist/field/Diff/index.js +1 -0
  354. package/dist/field/Diff/index.js.map +1 -1
  355. package/dist/field/Field.d.ts.map +1 -1
  356. package/dist/field/Field.js +18 -15
  357. package/dist/field/Field.js.map +1 -1
  358. package/dist/field/RenderLexical/index.d.ts +3 -1
  359. package/dist/field/RenderLexical/index.d.ts.map +1 -1
  360. package/dist/field/RenderLexical/index.js +23 -23
  361. package/dist/field/RenderLexical/index.js.map +1 -1
  362. package/dist/field/ViewSelector.css +1 -1
  363. package/dist/field/ViewSelector.d.ts.map +1 -1
  364. package/dist/field/ViewSelector.js +1 -0
  365. package/dist/field/ViewSelector.js.map +1 -1
  366. package/dist/field/bundled.css +1 -1
  367. package/dist/field/index.css +4 -4
  368. package/dist/i18n.d.ts.map +1 -1
  369. package/dist/i18n.js +68 -0
  370. package/dist/i18n.js.map +1 -1
  371. package/dist/index.d.ts +3 -3
  372. package/dist/index.d.ts.map +1 -1
  373. package/dist/index.js +11 -54
  374. package/dist/index.js.map +1 -1
  375. package/dist/lexical/LexicalEditor.css +29 -18
  376. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  377. package/dist/lexical/LexicalEditor.js +62 -99
  378. package/dist/lexical/LexicalEditor.js.map +1 -1
  379. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  380. package/dist/lexical/LexicalProvider.js +7 -22
  381. package/dist/lexical/LexicalProvider.js.map +1 -1
  382. package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
  383. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  384. package/dist/lexical/config/server/loader.d.ts +1 -1
  385. package/dist/lexical/config/server/loader.d.ts.map +1 -1
  386. package/dist/lexical/config/server/loader.js +2 -2
  387. package/dist/lexical/config/server/loader.js.map +1 -1
  388. package/dist/lexical/config/server/sanitize.d.ts +1 -1
  389. package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
  390. package/dist/lexical/config/server/sanitize.js +2 -2
  391. package/dist/lexical/config/server/sanitize.js.map +1 -1
  392. package/dist/lexical/plugins/DecoratorPlugin/index.css +1 -1
  393. package/dist/lexical/plugins/DecoratorPlugin/index.d.ts.map +1 -1
  394. package/dist/lexical/plugins/DecoratorPlugin/index.js +24 -21
  395. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  396. package/dist/lexical/plugins/InsertParagraphAtEnd/index.css +18 -25
  397. package/dist/lexical/plugins/InsertParagraphAtEnd/index.d.ts.map +1 -1
  398. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +27 -14
  399. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  400. package/dist/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
  401. package/dist/lexical/plugins/MarkdownShortcut/index.js +1 -1
  402. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  403. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -1
  404. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +21 -0
  405. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -1
  406. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +0 -1
  407. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  408. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +2 -21
  409. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  410. package/dist/lexical/plugins/SlashMenu/index.css +1 -6
  411. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +2 -1
  412. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +2 -2
  413. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  414. package/dist/lexical/plugins/handles/DraggableBlockPlugin/debounce.d.ts.map +1 -1
  415. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +5 -3
  416. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  417. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +17 -3
  418. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  419. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts +7 -0
  420. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts.map +1 -0
  421. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js +65 -0
  422. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js.map +1 -0
  423. package/dist/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.d.ts.map +1 -1
  424. package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  425. package/dist/lexical/plugins/handles/utils/setHandlePosition.js +2 -0
  426. package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  427. package/dist/lexical/theme/EditorTheme.css +18 -19
  428. package/dist/lexical/ui/ContentEditable.css +22 -17
  429. package/dist/lexical/ui/ContentEditable.d.ts +2 -1
  430. package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
  431. package/dist/lexical/ui/ContentEditable.js +9 -6
  432. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  433. package/dist/lexical/ui/icons/H3/index.d.ts.map +1 -1
  434. package/dist/lexical/ui/icons/H3/index.js +13 -6
  435. package/dist/lexical/ui/icons/H3/index.js.map +1 -1
  436. package/dist/lexical/ui/icons/H4/index.d.ts.map +1 -1
  437. package/dist/lexical/ui/icons/H4/index.js +13 -6
  438. package/dist/lexical/ui/icons/H4/index.js.map +1 -1
  439. package/dist/lexical/ui/icons/H5/index.d.ts.map +1 -1
  440. package/dist/lexical/ui/icons/H5/index.js +13 -6
  441. package/dist/lexical/ui/icons/H5/index.js.map +1 -1
  442. package/dist/lexical/ui/icons/H6/index.d.ts.map +1 -1
  443. package/dist/lexical/ui/icons/H6/index.js +13 -6
  444. package/dist/lexical/ui/icons/H6/index.js.map +1 -1
  445. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts +17 -0
  446. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts.map +1 -0
  447. package/dist/lexical/utils/markdown/convertFromMarkdownString.js +27 -0
  448. package/dist/lexical/utils/markdown/convertFromMarkdownString.js.map +1 -0
  449. package/dist/lexical/utils/markdown/createBlockNode.d.ts +2 -2
  450. package/dist/lexical/utils/markdown/createBlockNode.d.ts.map +1 -1
  451. package/dist/lexical/utils/markdown/createBlockNode.js.map +1 -1
  452. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts +25 -0
  453. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts.map +1 -0
  454. package/dist/lexical/utils/markdown/normalizeMarkdown.js +91 -0
  455. package/dist/lexical/utils/markdown/normalizeMarkdown.js.map +1 -0
  456. package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
  457. package/dist/lexical/utils/point.d.ts.map +1 -1
  458. package/dist/lexical/utils/rect.d.ts.map +1 -1
  459. package/dist/lexical-proxy/@lexical-markdown.d.ts +1 -1
  460. package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -1
  461. package/dist/lexical-proxy/@lexical-markdown.js +1 -1
  462. package/dist/lexical-proxy/@lexical-markdown.js.map +1 -1
  463. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.d.ts +2 -0
  464. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.d.ts.map +1 -0
  465. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.js +2 -0
  466. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.js.map +1 -0
  467. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.d.ts +2 -0
  468. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.d.ts.map +1 -0
  469. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.js +2 -0
  470. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.js.map +1 -0
  471. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.d.ts +2 -0
  472. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.d.ts.map +1 -0
  473. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.js +2 -0
  474. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.js.map +1 -0
  475. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.d.ts +2 -0
  476. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.d.ts.map +1 -0
  477. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.js +2 -0
  478. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.js.map +1 -0
  479. package/dist/lexical-proxy/@lexical-react/ReactExtension.d.ts +2 -0
  480. package/dist/lexical-proxy/@lexical-react/ReactExtension.d.ts.map +1 -0
  481. package/dist/lexical-proxy/@lexical-react/ReactExtension.js +2 -0
  482. package/dist/lexical-proxy/@lexical-react/ReactExtension.js.map +1 -0
  483. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.d.ts +2 -0
  484. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.d.ts.map +1 -0
  485. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.js +2 -0
  486. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.js.map +1 -0
  487. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.d.ts +2 -0
  488. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.d.ts.map +1 -0
  489. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.js +2 -0
  490. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.js.map +1 -0
  491. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.d.ts +2 -0
  492. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.d.ts.map +1 -0
  493. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.js +2 -0
  494. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.js.map +1 -0
  495. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.d.ts +2 -0
  496. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.d.ts.map +1 -0
  497. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.js +2 -0
  498. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.js.map +1 -0
  499. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.d.ts +2 -0
  500. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.d.ts.map +1 -0
  501. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.js +2 -0
  502. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.js.map +1 -0
  503. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.d.ts +2 -0
  504. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.d.ts.map +1 -0
  505. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.js +2 -0
  506. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.js.map +1 -0
  507. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.d.ts +2 -0
  508. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.d.ts.map +1 -0
  509. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.js +2 -0
  510. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.js.map +1 -0
  511. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.d.ts +2 -0
  512. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.d.ts.map +1 -0
  513. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.js +2 -0
  514. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.js.map +1 -0
  515. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.d.ts +2 -0
  516. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.d.ts.map +1 -0
  517. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.js +2 -0
  518. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.js.map +1 -0
  519. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.d.ts +2 -0
  520. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.d.ts.map +1 -0
  521. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.js +2 -0
  522. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.js.map +1 -0
  523. package/dist/populateGraphQL/populateLexicalPopulationPromises.d.ts.map +1 -1
  524. package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.d.ts.map +1 -1
  525. package/dist/types/index.d.ts +1 -1
  526. package/dist/types/index.d.ts.map +1 -1
  527. package/dist/types/index.js.map +1 -1
  528. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -1
  529. package/dist/types/nodeTypes.d.ts +1 -1
  530. package/dist/types/nodeTypes.d.ts.map +1 -1
  531. package/dist/types/nodeTypes.js.map +1 -1
  532. package/dist/types/schema.d.ts.map +1 -1
  533. package/dist/types/schema.js +12 -5
  534. package/dist/types/schema.js.map +1 -1
  535. package/dist/utilities/applyBaseFilterToFields.d.ts.map +1 -1
  536. package/dist/utilities/applyBaseFilterToFields.js.map +1 -1
  537. package/dist/utilities/createServerFeature.d.ts +1 -1
  538. package/dist/utilities/createServerFeature.d.ts.map +1 -1
  539. package/dist/utilities/createServerFeature.js +2 -2
  540. package/dist/utilities/createServerFeature.js.map +1 -1
  541. package/dist/utilities/editorConfigFactory.d.ts +6 -6
  542. package/dist/utilities/editorConfigFactory.d.ts.map +1 -1
  543. package/dist/utilities/editorConfigFactory.js +9 -9
  544. package/dist/utilities/editorConfigFactory.js.map +1 -1
  545. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts +1 -1
  546. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts.map +1 -1
  547. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.d.ts.map +1 -1
  548. package/dist/utilities/fieldsDrawer/useLexicalDrawer.d.ts.map +1 -1
  549. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.d.ts.map +1 -1
  550. package/dist/utilities/generateImportMap.d.ts +1 -1
  551. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  552. package/dist/utilities/generateImportMap.js +3 -7
  553. package/dist/utilities/generateImportMap.js.map +1 -1
  554. package/dist/utilities/generateSchemaMap.d.ts +1 -1
  555. package/dist/utilities/generateSchemaMap.d.ts.map +1 -1
  556. package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts +2 -2
  557. package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts.map +1 -1
  558. package/dist/utilities/getDefaultSanitizedEditorConfig.js +6 -17
  559. package/dist/utilities/getDefaultSanitizedEditorConfig.js.map +1 -1
  560. package/dist/utilities/recurseNodeTree.d.ts.map +1 -1
  561. package/dist/utilities/upgradeLexicalData/index.js +6 -3
  562. package/dist/utilities/upgradeLexicalData/index.js.map +1 -1
  563. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -1
  564. package/dist/utilities/useLexicalFeature.d.ts.map +1 -1
  565. package/dist/validate/hasText.d.ts +2 -2
  566. package/dist/validate/hasText.d.ts.map +1 -1
  567. package/dist/validate/hasText.js.map +1 -1
  568. package/dist/validate/index.d.ts +1 -1
  569. package/dist/validate/index.d.ts.map +1 -1
  570. package/package.json +96 -28
  571. package/dist/@types/assets.d.js +0 -2
  572. package/dist/@types/assets.d.js.map +0 -1
  573. package/dist/dependencyChecker.spec.js +0 -16
  574. package/dist/dependencyChecker.spec.js.map +0 -1
  575. package/dist/exports/client/Field-VW7ZGT6K.js +0 -2
  576. package/dist/exports/client/Field-VW7ZGT6K.js.map +0 -7
  577. package/dist/exports/client/chunk-4EIYXZ6H.js +0 -12
  578. package/dist/exports/client/chunk-4EIYXZ6H.js.map +0 -7
  579. package/dist/exports/client/chunk-UD4DQ4AK.js +0 -2
  580. package/dist/exports/client/chunk-UD4DQ4AK.js.map +0 -7
  581. package/dist/exports/client/component-PHZQBOJE.js +0 -2
  582. package/dist/exports/client/component-PHZQBOJE.js.map +0 -7
  583. package/dist/exports/client/componentInline-H24N7GUG.js +0 -2
  584. package/dist/exports/server/rsc.browser.d.ts +0 -11
  585. package/dist/exports/server/rsc.browser.d.ts.map +0 -1
  586. package/dist/exports/server/rsc.browser.js +0 -10
  587. package/dist/exports/server/rsc.browser.js.map +0 -1
  588. package/dist/features/blockquote/markdownTransformer.d.ts +0 -3
  589. package/dist/features/blockquote/markdownTransformer.d.ts.map +0 -1
  590. package/dist/features/blockquote/markdownTransformer.js +0 -33
  591. package/dist/features/blockquote/markdownTransformer.js.map +0 -1
  592. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js +0 -180
  593. package/dist/features/converters/lexicalToPlaintext/convertLexicalToPlaintext.spec.js.map +0 -1
  594. package/dist/features/experimental_table/client/index.d.ts.map +0 -1
  595. package/dist/features/experimental_table/client/index.js.map +0 -1
  596. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +0 -1
  597. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +0 -1
  598. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +0 -1
  599. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +0 -1
  600. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +0 -1
  601. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +0 -1
  602. package/dist/features/experimental_table/client/plugins/TablePlugin/TableGridPopup/index.d.ts.map +0 -1
  603. package/dist/features/experimental_table/client/plugins/TablePlugin/TableGridPopup/index.js.map +0 -1
  604. package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts.map +0 -1
  605. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +0 -1
  606. package/dist/features/experimental_table/client/utils/debounce.d.ts.map +0 -1
  607. package/dist/features/experimental_table/client/utils/debounce.js.map +0 -1
  608. package/dist/features/experimental_table/client/utils/useDebounce.d.ts.map +0 -1
  609. package/dist/features/experimental_table/client/utils/useDebounce.js.map +0 -1
  610. package/dist/features/experimental_table/markdownTransformer.d.ts +0 -5
  611. package/dist/features/experimental_table/markdownTransformer.d.ts.map +0 -1
  612. package/dist/features/experimental_table/markdownTransformer.js.map +0 -1
  613. package/dist/features/experimental_table/server/index.d.ts +0 -3
  614. package/dist/features/experimental_table/server/index.d.ts.map +0 -1
  615. package/dist/features/experimental_table/server/index.js.map +0 -1
  616. package/dist/features/experimental_table/server/schema.d.ts.map +0 -1
  617. package/dist/features/experimental_table/server/schema.js.map +0 -1
  618. package/dist/features/format/bold/markdownTransformers.d.ts +0 -6
  619. package/dist/features/format/bold/markdownTransformers.d.ts.map +0 -1
  620. package/dist/features/format/bold/markdownTransformers.js +0 -23
  621. package/dist/features/format/bold/markdownTransformers.js.map +0 -1
  622. package/dist/features/format/inlineCode/markdownTransformers.d.ts +0 -3
  623. package/dist/features/format/inlineCode/markdownTransformers.d.ts.map +0 -1
  624. package/dist/features/format/inlineCode/markdownTransformers.js +0 -6
  625. package/dist/features/format/inlineCode/markdownTransformers.js.map +0 -1
  626. package/dist/features/format/italic/markdownTransformers.d.ts +0 -4
  627. package/dist/features/format/italic/markdownTransformers.d.ts.map +0 -1
  628. package/dist/features/format/italic/markdownTransformers.js +0 -12
  629. package/dist/features/format/italic/markdownTransformers.js.map +0 -1
  630. package/dist/features/format/strikethrough/markdownTransformers.d.ts +0 -3
  631. package/dist/features/format/strikethrough/markdownTransformers.d.ts.map +0 -1
  632. package/dist/features/format/strikethrough/markdownTransformers.js +0 -6
  633. package/dist/features/format/strikethrough/markdownTransformers.js.map +0 -1
  634. package/dist/features/link/markdownTransformer.spec.js +0 -195
  635. package/dist/features/link/markdownTransformer.spec.js.map +0 -1
  636. package/dist/features/lists/checklist/markdownTransformers.d.ts +0 -3
  637. package/dist/features/lists/checklist/markdownTransformers.d.ts.map +0 -1
  638. package/dist/features/lists/checklist/markdownTransformers.js +0 -12
  639. package/dist/features/lists/checklist/markdownTransformers.js.map +0 -1
  640. package/dist/features/lists/orderedList/markdownTransformer.d.ts +0 -3
  641. package/dist/features/lists/orderedList/markdownTransformer.d.ts.map +0 -1
  642. package/dist/features/lists/orderedList/markdownTransformer.js +0 -12
  643. package/dist/features/lists/orderedList/markdownTransformer.js.map +0 -1
  644. package/dist/features/lists/shared/markdown.d.ts +0 -6
  645. package/dist/features/lists/shared/markdown.d.ts.map +0 -1
  646. package/dist/features/lists/shared/markdown.js +0 -57
  647. package/dist/features/lists/shared/markdown.js.map +0 -1
  648. package/dist/features/lists/unorderedList/markdownTransformer.d.ts +0 -3
  649. package/dist/features/lists/unorderedList/markdownTransformer.d.ts.map +0 -1
  650. package/dist/features/lists/unorderedList/markdownTransformer.js +0 -12
  651. package/dist/features/lists/unorderedList/markdownTransformer.js.map +0 -1
  652. package/dist/field/clientEntry.d.ts +0 -29
  653. package/dist/field/clientEntry.d.ts.map +0 -1
  654. package/dist/field/clientEntry.js +0 -86
  655. package/dist/field/clientEntry.js.map +0 -1
  656. package/dist/lexical/utils/guard.d.ts +0 -5
  657. package/dist/lexical/utils/guard.d.ts.map +0 -1
  658. package/dist/lexical/utils/guard.js +0 -9
  659. package/dist/lexical/utils/guard.js.map +0 -1
  660. package/dist/lexical/utils/url.spec.js +0 -114
  661. package/dist/lexical/utils/url.spec.js.map +0 -1
  662. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +0 -2
  663. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +0 -1
  664. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +0 -2
  665. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +0 -1
  666. package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js +0 -160
  667. package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js.map +0 -1
  668. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts +0 -14
  669. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +0 -1
  670. package/dist/packages/@lexical/markdown/MarkdownExport.js +0 -220
  671. package/dist/packages/@lexical/markdown/MarkdownExport.js.map +0 -1
  672. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +0 -19
  673. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +0 -1
  674. package/dist/packages/@lexical/markdown/MarkdownImport.js +0 -199
  675. package/dist/packages/@lexical/markdown/MarkdownImport.js.map +0 -1
  676. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts +0 -11
  677. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +0 -1
  678. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +0 -304
  679. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +0 -1
  680. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +0 -173
  681. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +0 -1
  682. package/dist/packages/@lexical/markdown/MarkdownTransformers.js +0 -352
  683. package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +0 -1
  684. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts +0 -22
  685. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +0 -1
  686. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +0 -91
  687. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +0 -1
  688. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts +0 -21
  689. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +0 -1
  690. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +0 -54
  691. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +0 -1
  692. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts +0 -18
  693. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts.map +0 -1
  694. package/dist/packages/@lexical/markdown/importTextTransformers.js +0 -54
  695. package/dist/packages/@lexical/markdown/importTextTransformers.js.map +0 -1
  696. package/dist/packages/@lexical/markdown/index.d.ts +0 -29
  697. package/dist/packages/@lexical/markdown/index.d.ts.map +0 -1
  698. package/dist/packages/@lexical/markdown/index.js +0 -39
  699. package/dist/packages/@lexical/markdown/index.js.map +0 -1
  700. package/dist/packages/@lexical/markdown/utils.d.ts +0 -34
  701. package/dist/packages/@lexical/markdown/utils.d.ts.map +0 -1
  702. package/dist/packages/@lexical/markdown/utils.js +0 -267
  703. package/dist/packages/@lexical/markdown/utils.js.map +0 -1
  704. package/dist/utilities/jsx/jsx.spec.js +0 -178
  705. package/dist/utilities/jsx/jsx.spec.js.map +0 -1
  706. /package/dist/exports/client/{componentInline-H24N7GUG.js.map → componentInline-55HZXGUS.js.map} +0 -0
  707. /package/dist/features/{experimental_table → table}/client/index.d.ts +0 -0
  708. /package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.css +0 -0
  709. /package/dist/features/{experimental_table → table}/client/plugins/TableActionMenuPlugin/index.d.ts +0 -0
  710. /package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.css +0 -0
  711. /package/dist/features/{experimental_table → table}/client/plugins/TableCellResizerPlugin/index.d.ts +0 -0
  712. /package/dist/features/{experimental_table → table}/client/plugins/TableHoverActionsPlugin/index.d.ts +0 -0
  713. /package/dist/features/{experimental_table → table}/client/plugins/TableHoverActionsPlugin/index.js +0 -0
  714. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.css +0 -0
  715. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.d.ts +0 -0
  716. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/TableGridPopup/index.js +0 -0
  717. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.css +0 -0
  718. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.d.ts +0 -0
  719. /package/dist/features/{experimental_table → table}/client/plugins/TablePlugin/index.js +0 -0
  720. /package/dist/features/{experimental_table → table}/client/utils/debounce.d.ts +0 -0
  721. /package/dist/features/{experimental_table → table}/client/utils/debounce.js +0 -0
  722. /package/dist/features/{experimental_table → table}/client/utils/useDebounce.d.ts +0 -0
  723. /package/dist/features/{experimental_table → table}/client/utils/useDebounce.js +0 -0
  724. /package/dist/features/{experimental_table → table}/server/schema.d.ts +0 -0
  725. /package/dist/features/{experimental_table → table}/server/schema.js +0 -0
@@ -2,9 +2,29 @@
2
2
 
3
3
  import { c as _c } from "react/compiler-runtime";
4
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
5
+ import { $getRoot } from 'lexical';
5
6
  import { useEffect } from 'react';
6
7
  import { useRichTextView } from '../../../field/RichTextViewProvider.js';
7
8
  import { clearEditorNodeViews, registerEditorNodeViews } from '../../nodes/index.js';
9
+ // `LexicalComposer` re-mounts with a new `editor` whenever `currentView` changes,
10
+ // so decorator nodes run their initial `decorate()` before this effect registers the view's overrides.
11
+ // Mark existing block decorators dirty after registering so they re-decorate with the resolved custom `Block` component.
12
+ function refreshBlockDecorators(editor) {
13
+ editor.update(() => {
14
+ const walk = node => {
15
+ const type = node.getType();
16
+ if (type === 'block' || type === 'inlineBlock') {
17
+ node.markDirty();
18
+ }
19
+ if ('getChildren' in node && typeof node.getChildren === 'function') {
20
+ for (const child of node.getChildren()) {
21
+ walk(child);
22
+ }
23
+ }
24
+ };
25
+ walk($getRoot());
26
+ });
27
+ }
8
28
  export function NodeViewOverridePlugin() {
9
29
  const $ = _c(5);
10
30
  const [editor] = useLexicalComposerContext();
@@ -31,6 +51,7 @@ export function NodeViewOverridePlugin() {
31
51
  registerEditorNodeViews(editor, views[currentView]?.nodes);
32
52
  }
33
53
  }
54
+ refreshBlockDecorators(editor);
34
55
  };
35
56
  t1 = [editor, views, currentView];
36
57
  $[0] = currentView;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useEffect","useRichTextView","clearEditorNodeViews","registerEditorNodeViews","NodeViewOverridePlugin","$","editor","currentView","views","t0","t1","default","nodes"],"sources":["../../../../src/lexical/plugins/NodeViewOverridePlugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useEffect } from 'react'\n\nimport { useRichTextView } from '../../../field/RichTextViewProvider.js'\nimport { clearEditorNodeViews, registerEditorNodeViews } from '../../nodes/index.js'\n\nexport function NodeViewOverridePlugin(): null {\n const [editor] = useLexicalComposerContext()\n const { currentView, views } = useRichTextView()\n\n useEffect(() => {\n if (!views) {\n return\n }\n\n if (currentView === 'default') {\n if (views.default) {\n registerEditorNodeViews(editor, views.default?.nodes)\n } else {\n clearEditorNodeViews(editor)\n }\n } else if (views[currentView]) {\n clearEditorNodeViews(editor)\n registerEditorNodeViews(editor, views[currentView]?.nodes)\n }\n }, [editor, views, currentView])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,SAAS,QAAQ;AAE1B,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,EAAEC,uBAAuB,QAAQ;AAE9D,OAAO,SAAAC,uBAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EACL,OAAAQ,MAAA,IAAiBP,yBAAA;EACjB;IAAAQ,WAAA;IAAAC;EAAA,IAA+BP,eAAA;EAAA,IAAAQ,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAL,CAAA,QAAAE,WAAA,IAAAF,CAAA,QAAAC,MAAA,IAAAD,CAAA,QAAAG,KAAA;IAErBC,EAAA,GAAAA,CAAA;MAAA,KACHD,KAAA;QAAA;MAAA;MAAA,IAIDD,WAAA,KAAgB;QAAA,IACdC,KAAA,CAAAG,OAAA;UACFR,uBAAA,CAAwBG,MAAA,EAAQE,KAAA,CAAAG,OAAA,EAAAC,KAAe;QAAA;UAE/CV,oBAAA,CAAqBI,MAAA;QAAA;MAAA;QAAA,IAEdE,KAAK,CAACD,WAAA;UACfL,oBAAA,CAAqBI,MAAA;UACrBH,uBAAA,CAAwBG,MAAA,EAAQE,KAAK,CAACD,WAAA,GAAAK,KAAc;QAAA;MAAA;IAAA;IAErDF,EAAA,IAACJ,MAAA,EAAQE,KAAA,EAAOD,WAAA;IAAYF,CAAA,MAAAE,WAAA;IAAAF,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAG,KAAA;IAAAH,CAAA,MAAAI,EAAA;IAAAJ,CAAA,MAAAK,EAAA;EAAA;IAAAD,EAAA,GAAAJ,CAAA;IAAAK,EAAA,GAAAL,CAAA;EAAA;EAf/BL,SAAA,CAAUS,EAeV,EAAGC,EAA4B;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$getRoot","useEffect","useRichTextView","clearEditorNodeViews","registerEditorNodeViews","refreshBlockDecorators","editor","update","walk","node","type","getType","markDirty","getChildren","child","NodeViewOverridePlugin","$","currentView","views","t0","t1","default","nodes"],"sources":["../../../../src/lexical/plugins/NodeViewOverridePlugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $getRoot, type LexicalNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport { useRichTextView } from '../../../field/RichTextViewProvider.js'\nimport { clearEditorNodeViews, registerEditorNodeViews } from '../../nodes/index.js'\n\n// `LexicalComposer` re-mounts with a new `editor` whenever `currentView` changes,\n// so decorator nodes run their initial `decorate()` before this effect registers the view's overrides.\n// Mark existing block decorators dirty after registering so they re-decorate with the resolved custom `Block` component.\nfunction refreshBlockDecorators(editor: ReturnType<typeof useLexicalComposerContext>[0]): void {\n editor.update(() => {\n const walk = (node: LexicalNode): void => {\n const type = node.getType()\n if (type === 'block' || type === 'inlineBlock') {\n node.markDirty()\n }\n if ('getChildren' in node && typeof node.getChildren === 'function') {\n for (const child of node.getChildren() as LexicalNode[]) {\n walk(child)\n }\n }\n }\n walk($getRoot())\n })\n}\n\nexport function NodeViewOverridePlugin(): null {\n const [editor] = useLexicalComposerContext()\n const { currentView, views } = useRichTextView()\n\n useEffect(() => {\n if (!views) {\n return\n }\n\n if (currentView === 'default') {\n if (views.default) {\n registerEditorNodeViews(editor, views.default?.nodes)\n } else {\n clearEditorNodeViews(editor)\n }\n } else if (views[currentView]) {\n clearEditorNodeViews(editor)\n registerEditorNodeViews(editor, views[currentView]?.nodes)\n }\n\n refreshBlockDecorators(editor)\n }, [editor, views, currentView])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,QAAQ,QAA0B;AAC3C,SAASC,SAAS,QAAQ;AAE1B,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,EAAEC,uBAAuB,QAAQ;AAE9D;AACA;AACA;AACA,SAASC,uBAAuBC,MAAuD;EACrFA,MAAA,CAAOC,MAAM,CAAC;IACZ,MAAMC,IAAA,GAAQC,IAAA;MACZ,MAAMC,IAAA,GAAOD,IAAA,CAAKE,OAAO;MACzB,IAAID,IAAA,KAAS,WAAWA,IAAA,KAAS,eAAe;QAC9CD,IAAA,CAAKG,SAAS;MAChB;MACA,IAAI,iBAAiBH,IAAA,IAAQ,OAAOA,IAAA,CAAKI,WAAW,KAAK,YAAY;QACnE,KAAK,MAAMC,KAAA,IAASL,IAAA,CAAKI,WAAW,IAAqB;UACvDL,IAAA,CAAKM,KAAA;QACP;MACF;IACF;IACAN,IAAA,CAAKR,QAAA;EACP;AACF;AAEA,OAAO,SAAAe,uBAAA;EAAA,MAAAC,CAAA,GAAAlB,EAAA;EACL,OAAAQ,MAAA,IAAiBP,yBAAA;EACjB;IAAAkB,WAAA;IAAAC;EAAA,IAA+BhB,eAAA;EAAA,IAAAiB,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAJ,CAAA,QAAAC,WAAA,IAAAD,CAAA,QAAAV,MAAA,IAAAU,CAAA,QAAAE,KAAA;IAErBC,EAAA,GAAAA,CAAA;MAAA,KACHD,KAAA;QAAA;MAAA;MAAA,IAIDD,WAAA,KAAgB;QAAA,IACdC,KAAA,CAAAG,OAAA;UACFjB,uBAAA,CAAwBE,MAAA,EAAQY,KAAA,CAAAG,OAAA,EAAAC,KAAe;QAAA;UAE/CnB,oBAAA,CAAqBG,MAAA;QAAA;MAAA;QAAA,IAEdY,KAAK,CAACD,WAAA;UACfd,oBAAA,CAAqBG,MAAA;UACrBF,uBAAA,CAAwBE,MAAA,EAAQY,KAAK,CAACD,WAAA,GAAAK,KAAc;QAAA;MAAA;MAGtDjB,sBAAA,CAAuBC,MAAA;IAAA;IACtBc,EAAA,IAACd,MAAA,EAAQY,KAAA,EAAOD,WAAA;IAAYD,CAAA,MAAAC,WAAA;IAAAD,CAAA,MAAAV,MAAA;IAAAU,CAAA,MAAAE,KAAA;IAAAF,CAAA,MAAAG,EAAA;IAAAH,CAAA,MAAAI,EAAA;EAAA;IAAAD,EAAA,GAAAH,CAAA;IAAAI,EAAA,GAAAJ,CAAA;EAAA;EAjB/Bf,SAAA,CAAUkB,EAiBV,EAAGC,EAA4B;EAAA;AAAA","ignoreList":[]}
@@ -12,7 +12,6 @@ export type MenuRenderFn = (anchorElementRef: RefObject<HTMLElement | null>, ite
12
12
  selectItemAndCleanUp: (selectedItem: SlashMenuItem) => void;
13
13
  setSelectedItemKey: (itemKey: string) => void;
14
14
  }, matchingString: null | string) => JSX.Element | null | ReactPortal;
15
- export declare function getScrollParent(element: HTMLElement, includeHidden: boolean): HTMLBodyElement | HTMLElement;
16
15
  export declare function useDynamicPositioning(resolution: MenuResolution | null, targetElementRef: RefObject<HTMLElement | null>, onReposition: () => void, onVisibilityChange?: (isInView: boolean) => void): void;
17
16
  export declare const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{
18
17
  index: number;
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalMenu.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,cAAc,EAAE,aAAa,EAAY,MAAM,SAAS,CAAA;AACrF,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EA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E,CAAC,CAAC,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,EACjD,SAAS,CAAC,EAAE,MAAM,GACjB,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAoG/B"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { c as _c } from "react/compiler-runtime";
4
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
5
- import { mergeRegister } from '@lexical/utils';
5
+ import { getScrollParent, mergeRegister } from '@lexical/utils';
6
6
  import { $getSelection, $isRangeSelection, $setSelection, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, createCommand, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND } from 'lexical';
7
7
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
8
8
  import { CAN_USE_DOM } from '../../../utils/canUseDOM.js';
@@ -73,25 +73,6 @@ function $splitNodeContainingQuery(match) {
73
73
  }
74
74
  return newNode;
75
75
  }
76
- // Got from https://stackoverflow.com/a/42543908/2013580
77
- export function getScrollParent(element, includeHidden) {
78
- let style = getComputedStyle(element);
79
- const excludeStaticParent = style.position === 'absolute';
80
- const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
81
- if (style.position === 'fixed') {
82
- return document.body;
83
- }
84
- for (let parent1 = element; parent1 = parent1.parentElement;) {
85
- style = getComputedStyle(parent1);
86
- if (excludeStaticParent && style.position === 'static') {
87
- continue;
88
- }
89
- if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) {
90
- return parent1;
91
- }
92
- }
93
- return document.body;
94
- }
95
76
  function isTriggerVisibleInNearestScrollContainer(targetElement, containerElement) {
96
77
  const tRect = targetElement.getBoundingClientRect();
97
78
  const cRect = containerElement.getBoundingClientRect();
@@ -286,7 +267,7 @@ export function LexicalMenu({
286
267
  event_1.stopImmediatePropagation();
287
268
  close();
288
269
  return true;
289
- }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_TAB_COMMAND, payload_2 => {
270
+ }, COMMAND_PRIORITY_NORMAL), editor.registerCommand(KEY_TAB_COMMAND, payload_2 => {
290
271
  const event_2 = payload_2;
291
272
  if (groups === null || selectedItemKey === null) {
292
273
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalMenu.js","names":["c","_c","useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$setSelection","COMMAND_PRIORITY_LOW","COMMAND_PRIORITY_NORMAL","createCommand","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_ENTER_COMMAND","KEY_ESCAPE_COMMAND","KEY_TAB_COMMAND","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","CAN_USE_DOM","baseClass","scrollIntoViewIfNeeded","target","typeaheadContainerNode","document","getElementById","typeaheadRect","getBoundingClientRect","top","height","window","innerHeight","scrollIntoView","block","getFullMatchOffset","documentText","entryText","offset","triggerOffset","i","length","substring","$splitNodeContainingQuery","match","selection","isCollapsed","anchor","type","anchorNode","getNode","isSimpleText","selectionOffset","textContent","getTextContent","slice","characterOffset","replaceableString","queryOffset","matchingString","startOffset","newNode","splitText","getScrollParent","element","includeHidden","style","getComputedStyle","excludeStaticParent","position","overflowRegex","body","parent1","parentElement","test","overflow","overflowY","overflowX","isTriggerVisibleInNearestScrollContainer","targetElement","containerElement","tRect","cRect","bottom","useDynamicPositioning","resolution","targetElementRef","onReposition","onVisibilityChange","$","editor","t0","t1","current","rootElement","getRootElement","rootScrollParent","ticking","previousIsInView","handleScroll","requestAnimationFrame","isInView","resizeObserver","ResizeObserver","addEventListener","capture","passive","observe","disconnect","removeEventListener","SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND","LexicalMenu","anchorElementRef","close","groups","menuRenderFn","shouldSplitNodeWithQuery","selectedItemKey","setSelectedItemKey","updateSelectedItem","item","rootElem","setAttribute","key","setSelectedItemKeyToFirstMatchingItem","allItems","flatMap","group","items","firstMatchingItem","selectItemAndCleanUp","selectedItem","update","textNodeContainingQuery","remove","setTimeout","read","clone","onSelect","queryString","removeAttribute","registerCommand","ref","payload","event","selectedIndex","findIndex","newSelectedIndex","newSelectedItem","dispatchCommand","index","preventDefault","stopImmediatePropagation","find","listItemProps","setContainerDivAttributes","containerDiv","className","display","useMenuAnchorRef","anchorElem","setResolution","Symbol","for","createElement","parent","undefined","menuEle","firstChild","width","getRect","left","rawTop","scrollY","scrollX","menuRect","menuHeight","menuWidth","rootElementRect","isRTL","dir","documentElement","anchorRect","leftBoundary","Math","max","right","newLeft","wouldGoOffBottomOfScreen","wouldGoOffTopOfScreen","isConnected","append","positionMenu","t2","t3","rootElement_0","containerDiv_0","t4"],"sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.tsx"],"sourcesContent":["'use client'\nimport type { BaseSelection, LexicalCommand, LexicalEditor, TextNode } from 'lexical'\nimport type { JSX, ReactPortal, RefObject } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_LOW,\n COMMAND_PRIORITY_NORMAL,\n createCommand,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_ENTER_COMMAND,\n KEY_ESCAPE_COMMAND,\n KEY_TAB_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport type { MenuTextMatch } from '../useMenuTriggerMatch.js'\nimport type { SlashMenuGroupInternal, SlashMenuItem, SlashMenuItemInternal } from './types.js'\n\nimport { CAN_USE_DOM } from '../../../utils/canUseDOM.js'\n\nexport type MenuResolution = {\n getRect: () => DOMRect\n match?: MenuTextMatch\n}\n\nconst baseClass = 'slash-menu-popup'\n\nexport type MenuRenderFn = (\n anchorElementRef: RefObject<HTMLElement | null>,\n itemProps: {\n groups: Array<SlashMenuGroupInternal>\n selectedItemKey: null | string\n selectItemAndCleanUp: (selectedItem: SlashMenuItem) => void\n setSelectedItemKey: (itemKey: string) => void\n },\n matchingString: null | string,\n) => JSX.Element | null | ReactPortal\n\nconst scrollIntoViewIfNeeded = (target: HTMLElement) => {\n const typeaheadContainerNode = document.getElementById('slash-menu')\n if (!typeaheadContainerNode) {\n return\n }\n\n const typeaheadRect = typeaheadContainerNode.getBoundingClientRect()\n\n if (typeaheadRect.top + typeaheadRect.height > window.innerHeight) {\n typeaheadContainerNode.scrollIntoView({\n block: 'center',\n })\n }\n\n if (typeaheadRect.top < 0) {\n typeaheadContainerNode.scrollIntoView({\n block: 'center',\n })\n }\n\n target.scrollIntoView({ block: 'nearest' })\n}\n\n/**\n * Walk backwards along user input and forward through entity title to try\n * and replace more of the user's text with entity.\n */\nfunction getFullMatchOffset(documentText: string, entryText: string, offset: number) {\n let triggerOffset = offset\n for (let i = triggerOffset; i <= entryText.length; i++) {\n if (documentText.substring(documentText.length - i) === entryText.substring(0, i)) {\n triggerOffset = i\n }\n }\n return triggerOffset\n}\n\n/**\n * Split Lexical TextNode and return a new TextNode only containing matched text.\n * Common use cases include: removing the node, replacing with a new node.\n */\nfunction $splitNodeContainingQuery(match: MenuTextMatch): TextNode | undefined {\n const selection = $getSelection()\n if (!$isRangeSelection(selection) || !selection.isCollapsed()) {\n return\n }\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return\n }\n const selectionOffset = anchor.offset\n const textContent = anchorNode.getTextContent().slice(0, selectionOffset)\n const characterOffset = match.replaceableString.length\n const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset)\n const startOffset = selectionOffset - queryOffset\n if (startOffset < 0) {\n return\n }\n let newNode\n if (startOffset === 0) {\n ;[newNode] = anchorNode.splitText(selectionOffset)\n } else {\n ;[, newNode] = anchorNode.splitText(startOffset, selectionOffset)\n }\n\n return newNode\n}\n\n// Got from https://stackoverflow.com/a/42543908/2013580\nexport function getScrollParent(\n element: HTMLElement,\n includeHidden: boolean,\n): HTMLBodyElement | HTMLElement {\n let style = getComputedStyle(element)\n const excludeStaticParent = style.position === 'absolute'\n const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/\n if (style.position === 'fixed') {\n return document.body\n }\n for (let parent: HTMLElement | null = element; (parent = parent.parentElement); ) {\n style = getComputedStyle(parent)\n if (excludeStaticParent && style.position === 'static') {\n continue\n }\n if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) {\n return parent\n }\n }\n return document.body\n}\n\nfunction isTriggerVisibleInNearestScrollContainer(\n targetElement: HTMLElement,\n containerElement: HTMLElement,\n): boolean {\n const tRect = targetElement.getBoundingClientRect()\n const cRect = containerElement.getBoundingClientRect()\n return tRect.top > cRect.top && tRect.top < cRect.bottom\n}\n\n// Reposition the menu on scroll, window resize, and element resize.\nexport function useDynamicPositioning(\n resolution: MenuResolution | null,\n targetElementRef: RefObject<HTMLElement | null>,\n onReposition: () => void,\n onVisibilityChange?: (isInView: boolean) => void,\n) {\n const [editor] = useLexicalComposerContext()\n useEffect(() => {\n const targetElement = targetElementRef.current\n if (targetElement != null && resolution != null) {\n const rootElement = editor.getRootElement()\n const rootScrollParent =\n rootElement != null ? getScrollParent(rootElement, false) : document.body\n let ticking = false\n let previousIsInView = isTriggerVisibleInNearestScrollContainer(\n targetElement,\n rootScrollParent,\n )\n const handleScroll = function () {\n if (!ticking) {\n window.requestAnimationFrame(function () {\n onReposition()\n ticking = false\n })\n ticking = true\n }\n const isInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent)\n if (isInView !== previousIsInView) {\n previousIsInView = isInView\n if (onVisibilityChange != null) {\n onVisibilityChange(isInView)\n }\n }\n }\n const resizeObserver = new ResizeObserver(onReposition)\n window.addEventListener('resize', onReposition)\n document.addEventListener('scroll', handleScroll, {\n capture: true,\n passive: true,\n })\n resizeObserver.observe(targetElement)\n return () => {\n resizeObserver.disconnect()\n window.removeEventListener('resize', onReposition)\n document.removeEventListener('scroll', handleScroll, true)\n }\n }\n }, [editor, onVisibilityChange, onReposition, resolution, targetElementRef])\n}\n\nexport const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{\n index: number\n item: SlashMenuItemInternal\n}> = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND')\n\nexport function LexicalMenu({\n anchorElementRef,\n close,\n editor,\n // groups filtering is already handled in SlashMenu/index.tsx. Thus, groups always contains the matching items.\n groups,\n menuRenderFn,\n resolution,\n shouldSplitNodeWithQuery = false,\n}: {\n anchorElementRef: RefObject<HTMLElement | null>\n close: () => void\n editor: LexicalEditor\n groups: Array<SlashMenuGroupInternal>\n menuRenderFn: MenuRenderFn\n resolution: MenuResolution\n shouldSplitNodeWithQuery?: boolean\n}): JSX.Element | null {\n const [selectedItemKey, setSelectedItemKey] = useState<null | string>(null)\n\n const matchingString = (resolution.match && resolution.match.matchingString) || ''\n\n const updateSelectedItem = useCallback(\n (item: SlashMenuItem) => {\n const rootElem = editor.getRootElement()\n if (rootElem !== null) {\n rootElem.setAttribute('aria-activedescendant', `${baseClass}__item-${item.key}`)\n setSelectedItemKey(item.key)\n }\n },\n [editor],\n )\n\n const setSelectedItemKeyToFirstMatchingItem = useCallback(() => {\n // set selected item to the first of the matching ones\n if (groups !== null && matchingString != null) {\n // groups filtering is already handled in SlashMenu/index.tsx. Thus, groups always contains the matching items.\n const allItems = groups.flatMap((group) => group.items)\n\n if (allItems.length) {\n const firstMatchingItem = allItems[0]!\n updateSelectedItem(firstMatchingItem)\n }\n }\n }, [groups, updateSelectedItem, matchingString])\n\n useEffect(() => {\n setSelectedItemKeyToFirstMatchingItem()\n }, [matchingString, setSelectedItemKeyToFirstMatchingItem])\n\n const selectItemAndCleanUp = useCallback(\n (selectedItem: SlashMenuItem) => {\n close()\n\n editor.update(() => {\n const textNodeContainingQuery =\n resolution.match != null && shouldSplitNodeWithQuery\n ? $splitNodeContainingQuery(resolution.match)\n : null\n\n if (textNodeContainingQuery) {\n textNodeContainingQuery.remove()\n }\n })\n\n setTimeout(() => {\n // Needed in Firefox. See https://github.com/payloadcms/payload/issues/10724\n let selection: BaseSelection | undefined\n editor.read(() => {\n selection = $getSelection()?.clone()\n })\n editor.update(() => {\n if (selection) {\n $setSelection(selection)\n }\n })\n\n selectedItem.onSelect({\n editor,\n queryString: resolution.match ? resolution.match.matchingString : '',\n })\n }, 0)\n },\n [editor, shouldSplitNodeWithQuery, resolution.match, close],\n )\n\n useEffect(() => {\n return () => {\n const rootElem = editor.getRootElement()\n if (rootElem !== null) {\n rootElem.removeAttribute('aria-activedescendant')\n }\n }\n }, [editor])\n\n useLayoutEffect(() => {\n if (groups === null) {\n setSelectedItemKey(null)\n } else if (selectedItemKey === null) {\n setSelectedItemKeyToFirstMatchingItem()\n }\n }, [groups, selectedItemKey, updateSelectedItem, setSelectedItemKeyToFirstMatchingItem])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,\n ({ item }) => {\n if (item.ref && item.ref.current != null) {\n scrollIntoViewIfNeeded(item.ref.current)\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateSelectedItem])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<KeyboardEvent>(\n KEY_ARROW_DOWN_COMMAND,\n (payload) => {\n const event = payload\n if (groups !== null && groups.length && selectedItemKey !== null) {\n const allItems = groups.flatMap((group) => group.items)\n const selectedIndex = allItems.findIndex((item) => item.key === selectedItemKey)\n\n const newSelectedIndex = selectedIndex !== allItems.length - 1 ? selectedIndex + 1 : 0\n\n const newSelectedItem = allItems[newSelectedIndex]\n if (!newSelectedItem) {\n return false\n }\n\n updateSelectedItem(newSelectedItem)\n if (newSelectedItem.ref != null && newSelectedItem.ref.current) {\n editor.dispatchCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, {\n index: newSelectedIndex,\n item: newSelectedItem,\n })\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_ARROW_UP_COMMAND,\n (payload) => {\n const event = payload\n if (groups !== null && groups.length && selectedItemKey !== null) {\n const allItems = groups.flatMap((group) => group.items)\n const selectedIndex = allItems.findIndex((item) => item.key === selectedItemKey)\n\n const newSelectedIndex = selectedIndex !== 0 ? selectedIndex - 1 : allItems.length - 1\n\n const newSelectedItem = allItems[newSelectedIndex]\n if (!newSelectedItem) {\n return false\n }\n\n updateSelectedItem(newSelectedItem)\n if (newSelectedItem.ref != null && newSelectedItem.ref.current) {\n scrollIntoViewIfNeeded(newSelectedItem.ref.current)\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_ESCAPE_COMMAND,\n (payload) => {\n const event = payload\n event.preventDefault()\n event.stopImmediatePropagation()\n close()\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_TAB_COMMAND,\n (payload) => {\n const event = payload\n\n if (groups === null || selectedItemKey === null) {\n return false\n }\n const allItems = groups.flatMap((group) => group.items)\n const selectedItem = allItems.find((item) => item.key === selectedItemKey)\n if (!selectedItem) {\n return false\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n selectItemAndCleanUp(selectedItem)\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n editor.registerCommand(\n KEY_ENTER_COMMAND,\n (event: KeyboardEvent | null) => {\n if (groups === null || selectedItemKey === null) {\n return false\n }\n const allItems = groups.flatMap((group) => group.items)\n const selectedItem = allItems.find((item) => item.key === selectedItemKey)\n if (!selectedItem) {\n return false\n }\n\n if (event !== null) {\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n selectItemAndCleanUp(selectedItem)\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n )\n }, [selectItemAndCleanUp, close, editor, groups, selectedItemKey, updateSelectedItem])\n\n const listItemProps = useMemo(\n () => ({\n groups,\n selectedItemKey,\n selectItemAndCleanUp,\n setSelectedItemKey,\n }),\n [selectItemAndCleanUp, selectedItemKey, groups],\n )\n\n return menuRenderFn(\n anchorElementRef,\n listItemProps,\n resolution.match ? resolution.match.matchingString : '',\n )\n}\n\nfunction setContainerDivAttributes(containerDiv: HTMLElement, className?: string) {\n if (className != null) {\n containerDiv.className = className\n }\n containerDiv.setAttribute('aria-label', 'Slash menu')\n containerDiv.setAttribute('role', 'listbox')\n containerDiv.style.display = 'block'\n containerDiv.style.position = 'absolute'\n}\n\nexport function useMenuAnchorRef(\n anchorElem: HTMLElement,\n resolution: MenuResolution | null,\n setResolution: (r: MenuResolution | null) => void,\n className?: string,\n): RefObject<HTMLElement | null> {\n const [editor] = useLexicalComposerContext()\n const anchorElementRef = useRef<HTMLElement | null>(\n CAN_USE_DOM ? document.createElement('div') : null,\n )\n const positionMenu = useCallback(() => {\n if (anchorElementRef.current === null || parent === undefined) {\n return\n }\n const rootElement = editor.getRootElement()\n const containerDiv = anchorElementRef.current\n\n const VERTICAL_OFFSET = 32\n\n const menuEle = containerDiv.firstChild as Element\n if (rootElement !== null && resolution !== null) {\n const { height, width } = resolution.getRect()\n let { left, top } = resolution.getRect()\n\n const rawTop = top\n top -= anchorElem.getBoundingClientRect().top + window.scrollY\n left -= anchorElem.getBoundingClientRect().left + window.scrollX\n containerDiv.style.left = `${left + window.scrollX}px`\n containerDiv.style.height = `${height}px`\n containerDiv.style.width = `${width}px`\n if (menuEle !== null) {\n const menuRect = menuEle.getBoundingClientRect()\n const menuHeight = menuRect.height\n const menuWidth = menuRect.width\n\n const rootElementRect = rootElement.getBoundingClientRect()\n\n const isRTL = document.dir === 'rtl' || document.documentElement.dir === 'rtl'\n const anchorRect = anchorElem.getBoundingClientRect()\n const leftBoundary = Math.max(0, rootElementRect.left)\n\n if (!isRTL && left + menuWidth > rootElementRect.right) {\n containerDiv.style.left = `${rootElementRect.right - menuWidth + window.scrollX}px`\n } else if (isRTL && menuRect.left < leftBoundary) {\n const newLeft = leftBoundary + menuWidth - anchorRect.left\n containerDiv.style.left = `${newLeft + window.scrollX}px`\n }\n\n const wouldGoOffBottomOfScreen = rawTop + menuHeight + VERTICAL_OFFSET > window.innerHeight\n //const wouldGoOffBottomOfContainer = top + menuHeight > rootElementRect.bottom\n const wouldGoOffTopOfScreen = rawTop < 0\n\n // Position slash menu above the cursor instead of below (default) if it would otherwise go off the bottom of the screen.\n if (wouldGoOffBottomOfScreen && !wouldGoOffTopOfScreen) {\n const margin = 24\n containerDiv.style.top = `${\n top + VERTICAL_OFFSET - menuHeight + window.scrollY - (height + margin)\n }px`\n } else {\n containerDiv.style.top = `${top + window.scrollY + VERTICAL_OFFSET}px`\n }\n }\n\n if (!containerDiv.isConnected) {\n setContainerDivAttributes(containerDiv, className)\n anchorElem.append(containerDiv)\n }\n containerDiv.setAttribute('id', 'slash-menu')\n anchorElementRef.current = containerDiv\n rootElement.setAttribute('aria-controls', 'slash-menu')\n }\n }, [editor, resolution, className, anchorElem])\n\n useEffect(() => {\n const rootElement = editor.getRootElement()\n if (resolution !== null) {\n positionMenu()\n return () => {\n if (rootElement !== null) {\n rootElement.removeAttribute('aria-controls')\n }\n\n const containerDiv = anchorElementRef.current\n if (containerDiv !== null && containerDiv.isConnected) {\n containerDiv.remove()\n containerDiv.removeAttribute('id')\n }\n }\n }\n }, [editor, positionMenu, resolution])\n\n const onVisibilityChange = useCallback(\n (isInView: boolean) => {\n if (resolution !== null) {\n if (!isInView) {\n setResolution(null)\n }\n }\n },\n [resolution, setResolution],\n )\n\n useDynamicPositioning(resolution, anchorElementRef, positionMenu, onVisibilityChange)\n\n return anchorElementRef\n}\n"],"mappings":"AAAA;;A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G7BjH,qBAAA,CAAsBC,UAAA,EAAY2B,gBAAA,EAAkBgF,YAAA,EAAcxG,kBAAA;EAAA,OAE3DwB,gBAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"LexicalMenu.js","names":["c","_c","useLexicalComposerContext","getScrollParent","mergeRegister","$getSelection","$isRangeSelection","$setSelection","COMMAND_PRIORITY_LOW","COMMAND_PRIORITY_NORMAL","createCommand","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_ENTER_COMMAND","KEY_ESCAPE_COMMAND","KEY_TAB_COMMAND","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","CAN_USE_DOM","baseClass","scrollIntoViewIfNeeded","target","typeaheadContainerNode","document","getElementById","typeaheadRect","getBoundingClientRect","top","height","window","innerHeight","scrollIntoView","block","getFullMatchOffset","documentText","entryText","offset","triggerOffset","i","length","substring","$splitNodeContainingQuery","match","selection","isCollapsed","anchor","type","anchorNode","getNode","isSimpleText","selectionOffset","textContent","getTextContent","slice","characterOffset","replaceableString","queryOffset","matchingString","startOffset","newNode","splitText","isTriggerVisibleInNearestScrollContainer","targetElement","containerElement","tRect","cRect","bottom","useDynamicPositioning","resolution","targetElementRef","onReposition","onVisibilityChange","$","editor","t0","t1","current","rootElement","getRootElement","rootScrollParent","body","ticking","previousIsInView","handleScroll","requestAnimationFrame","isInView","resizeObserver","ResizeObserver","addEventListener","capture","passive","observe","disconnect","removeEventListener","SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND","LexicalMenu","anchorElementRef","close","groups","menuRenderFn","shouldSplitNodeWithQuery","selectedItemKey","setSelectedItemKey","updateSelectedItem","item","rootElem","setAttribute","key","setSelectedItemKeyToFirstMatchingItem","allItems","flatMap","group","items","firstMatchingItem","selectItemAndCleanUp","selectedItem","update","textNodeContainingQuery","remove","setTimeout","read","clone","onSelect","queryString","removeAttribute","registerCommand","ref","payload","event","selectedIndex","findIndex","newSelectedIndex","newSelectedItem","dispatchCommand","index","preventDefault","stopImmediatePropagation","find","listItemProps","setContainerDivAttributes","containerDiv","className","style","display","position","useMenuAnchorRef","anchorElem","setResolution","Symbol","for","createElement","parent","undefined","menuEle","firstChild","width","getRect","left","rawTop","scrollY","scrollX","menuRect","menuHeight","menuWidth","rootElementRect","isRTL","dir","documentElement","anchorRect","leftBoundary","Math","max","right","newLeft","wouldGoOffBottomOfScreen","wouldGoOffTopOfScreen","isConnected","append","positionMenu","t2","t3","rootElement_0","containerDiv_0","t4"],"sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.tsx"],"sourcesContent":["'use client'\nimport type { BaseSelection, LexicalCommand, LexicalEditor, TextNode } from 'lexical'\nimport type { JSX, ReactPortal, RefObject } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getScrollParent, mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_LOW,\n COMMAND_PRIORITY_NORMAL,\n createCommand,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_ENTER_COMMAND,\n KEY_ESCAPE_COMMAND,\n KEY_TAB_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport type { MenuTextMatch } from '../useMenuTriggerMatch.js'\nimport type { SlashMenuGroupInternal, SlashMenuItem, SlashMenuItemInternal } from './types.js'\n\nimport { CAN_USE_DOM } from '../../../utils/canUseDOM.js'\n\nexport type MenuResolution = {\n getRect: () => DOMRect\n match?: MenuTextMatch\n}\n\nconst baseClass = 'slash-menu-popup'\n\nexport type MenuRenderFn = (\n anchorElementRef: RefObject<HTMLElement | null>,\n itemProps: {\n groups: Array<SlashMenuGroupInternal>\n selectedItemKey: null | string\n selectItemAndCleanUp: (selectedItem: SlashMenuItem) => void\n setSelectedItemKey: (itemKey: string) => void\n },\n matchingString: null | string,\n) => JSX.Element | null | ReactPortal\n\nconst scrollIntoViewIfNeeded = (target: HTMLElement) => {\n const typeaheadContainerNode = document.getElementById('slash-menu')\n if (!typeaheadContainerNode) {\n return\n }\n\n const typeaheadRect = typeaheadContainerNode.getBoundingClientRect()\n\n if (typeaheadRect.top + typeaheadRect.height > window.innerHeight) {\n typeaheadContainerNode.scrollIntoView({\n block: 'center',\n })\n }\n\n if (typeaheadRect.top < 0) {\n typeaheadContainerNode.scrollIntoView({\n block: 'center',\n })\n }\n\n target.scrollIntoView({ block: 'nearest' })\n}\n\n/**\n * Walk backwards along user input and forward through entity title to try\n * and replace more of the user's text with entity.\n */\nfunction getFullMatchOffset(documentText: string, entryText: string, offset: number) {\n let triggerOffset = offset\n for (let i = triggerOffset; i <= entryText.length; i++) {\n if (documentText.substring(documentText.length - i) === entryText.substring(0, i)) {\n triggerOffset = i\n }\n }\n return triggerOffset\n}\n\n/**\n * Split Lexical TextNode and return a new TextNode only containing matched text.\n * Common use cases include: removing the node, replacing with a new node.\n */\nfunction $splitNodeContainingQuery(match: MenuTextMatch): TextNode | undefined {\n const selection = $getSelection()\n if (!$isRangeSelection(selection) || !selection.isCollapsed()) {\n return\n }\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return\n }\n const selectionOffset = anchor.offset\n const textContent = anchorNode.getTextContent().slice(0, selectionOffset)\n const characterOffset = match.replaceableString.length\n const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset)\n const startOffset = selectionOffset - queryOffset\n if (startOffset < 0) {\n return\n }\n let newNode\n if (startOffset === 0) {\n ;[newNode] = anchorNode.splitText(selectionOffset)\n } else {\n ;[, newNode] = anchorNode.splitText(startOffset, selectionOffset)\n }\n\n return newNode\n}\n\nfunction isTriggerVisibleInNearestScrollContainer(\n targetElement: HTMLElement,\n containerElement: HTMLElement,\n): boolean {\n const tRect = targetElement.getBoundingClientRect()\n const cRect = containerElement.getBoundingClientRect()\n return tRect.top > cRect.top && tRect.top < cRect.bottom\n}\n\n// Reposition the menu on scroll, window resize, and element resize.\nexport function useDynamicPositioning(\n resolution: MenuResolution | null,\n targetElementRef: RefObject<HTMLElement | null>,\n onReposition: () => void,\n onVisibilityChange?: (isInView: boolean) => void,\n) {\n const [editor] = useLexicalComposerContext()\n useEffect(() => {\n const targetElement = targetElementRef.current\n if (targetElement != null && resolution != null) {\n const rootElement = editor.getRootElement()\n const rootScrollParent =\n rootElement != null ? getScrollParent(rootElement, false) : document.body\n let ticking = false\n let previousIsInView = isTriggerVisibleInNearestScrollContainer(\n targetElement,\n rootScrollParent,\n )\n const handleScroll = function () {\n if (!ticking) {\n window.requestAnimationFrame(function () {\n onReposition()\n ticking = false\n })\n ticking = true\n }\n const isInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent)\n if (isInView !== previousIsInView) {\n previousIsInView = isInView\n if (onVisibilityChange != null) {\n onVisibilityChange(isInView)\n }\n }\n }\n const resizeObserver = new ResizeObserver(onReposition)\n window.addEventListener('resize', onReposition)\n document.addEventListener('scroll', handleScroll, {\n capture: true,\n passive: true,\n })\n resizeObserver.observe(targetElement)\n return () => {\n resizeObserver.disconnect()\n window.removeEventListener('resize', onReposition)\n document.removeEventListener('scroll', handleScroll, true)\n }\n }\n }, [editor, onVisibilityChange, onReposition, resolution, targetElementRef])\n}\n\nexport const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{\n index: number\n item: SlashMenuItemInternal\n}> = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND')\n\nexport function LexicalMenu({\n anchorElementRef,\n close,\n editor,\n // groups filtering is already handled in SlashMenu/index.tsx. Thus, groups always contains the matching items.\n groups,\n menuRenderFn,\n resolution,\n shouldSplitNodeWithQuery = false,\n}: {\n anchorElementRef: RefObject<HTMLElement | null>\n close: () => void\n editor: LexicalEditor\n groups: Array<SlashMenuGroupInternal>\n menuRenderFn: MenuRenderFn\n resolution: MenuResolution\n shouldSplitNodeWithQuery?: boolean\n}): JSX.Element | null {\n const [selectedItemKey, setSelectedItemKey] = useState<null | string>(null)\n\n const matchingString = (resolution.match && resolution.match.matchingString) || ''\n\n const updateSelectedItem = useCallback(\n (item: SlashMenuItem) => {\n const rootElem = editor.getRootElement()\n if (rootElem !== null) {\n rootElem.setAttribute('aria-activedescendant', `${baseClass}__item-${item.key}`)\n setSelectedItemKey(item.key)\n }\n },\n [editor],\n )\n\n const setSelectedItemKeyToFirstMatchingItem = useCallback(() => {\n // set selected item to the first of the matching ones\n if (groups !== null && matchingString != null) {\n // groups filtering is already handled in SlashMenu/index.tsx. Thus, groups always contains the matching items.\n const allItems = groups.flatMap((group) => group.items)\n\n if (allItems.length) {\n const firstMatchingItem = allItems[0]!\n updateSelectedItem(firstMatchingItem)\n }\n }\n }, [groups, updateSelectedItem, matchingString])\n\n useEffect(() => {\n setSelectedItemKeyToFirstMatchingItem()\n }, [matchingString, setSelectedItemKeyToFirstMatchingItem])\n\n const selectItemAndCleanUp = useCallback(\n (selectedItem: SlashMenuItem) => {\n close()\n\n editor.update(() => {\n const textNodeContainingQuery =\n resolution.match != null && shouldSplitNodeWithQuery\n ? $splitNodeContainingQuery(resolution.match)\n : null\n\n if (textNodeContainingQuery) {\n textNodeContainingQuery.remove()\n }\n })\n\n setTimeout(() => {\n // Needed in Firefox. See https://github.com/payloadcms/payload/issues/10724\n let selection: BaseSelection | undefined\n editor.read(() => {\n selection = $getSelection()?.clone()\n })\n editor.update(() => {\n if (selection) {\n $setSelection(selection)\n }\n })\n\n selectedItem.onSelect({\n editor,\n queryString: resolution.match ? resolution.match.matchingString : '',\n })\n }, 0)\n },\n [editor, shouldSplitNodeWithQuery, resolution.match, close],\n )\n\n useEffect(() => {\n return () => {\n const rootElem = editor.getRootElement()\n if (rootElem !== null) {\n rootElem.removeAttribute('aria-activedescendant')\n }\n }\n }, [editor])\n\n useLayoutEffect(() => {\n if (groups === null) {\n setSelectedItemKey(null)\n } else if (selectedItemKey === null) {\n setSelectedItemKeyToFirstMatchingItem()\n }\n }, [groups, selectedItemKey, updateSelectedItem, setSelectedItemKeyToFirstMatchingItem])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,\n ({ item }) => {\n if (item.ref && item.ref.current != null) {\n scrollIntoViewIfNeeded(item.ref.current)\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateSelectedItem])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<KeyboardEvent>(\n KEY_ARROW_DOWN_COMMAND,\n (payload) => {\n const event = payload\n if (groups !== null && groups.length && selectedItemKey !== null) {\n const allItems = groups.flatMap((group) => group.items)\n const selectedIndex = allItems.findIndex((item) => item.key === selectedItemKey)\n\n const newSelectedIndex = selectedIndex !== allItems.length - 1 ? selectedIndex + 1 : 0\n\n const newSelectedItem = allItems[newSelectedIndex]\n if (!newSelectedItem) {\n return false\n }\n\n updateSelectedItem(newSelectedItem)\n if (newSelectedItem.ref != null && newSelectedItem.ref.current) {\n editor.dispatchCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, {\n index: newSelectedIndex,\n item: newSelectedItem,\n })\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_ARROW_UP_COMMAND,\n (payload) => {\n const event = payload\n if (groups !== null && groups.length && selectedItemKey !== null) {\n const allItems = groups.flatMap((group) => group.items)\n const selectedIndex = allItems.findIndex((item) => item.key === selectedItemKey)\n\n const newSelectedIndex = selectedIndex !== 0 ? selectedIndex - 1 : allItems.length - 1\n\n const newSelectedItem = allItems[newSelectedIndex]\n if (!newSelectedItem) {\n return false\n }\n\n updateSelectedItem(newSelectedItem)\n if (newSelectedItem.ref != null && newSelectedItem.ref.current) {\n scrollIntoViewIfNeeded(newSelectedItem.ref.current)\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_ESCAPE_COMMAND,\n (payload) => {\n const event = payload\n event.preventDefault()\n event.stopImmediatePropagation()\n close()\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_TAB_COMMAND,\n (payload) => {\n const event = payload\n\n if (groups === null || selectedItemKey === null) {\n return false\n }\n const allItems = groups.flatMap((group) => group.items)\n const selectedItem = allItems.find((item) => item.key === selectedItemKey)\n if (!selectedItem) {\n return false\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n selectItemAndCleanUp(selectedItem)\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n editor.registerCommand(\n KEY_ENTER_COMMAND,\n (event: KeyboardEvent | null) => {\n if (groups === null || selectedItemKey === null) {\n return false\n }\n const allItems = groups.flatMap((group) => group.items)\n const selectedItem = allItems.find((item) => item.key === selectedItemKey)\n if (!selectedItem) {\n return false\n }\n\n if (event !== null) {\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n selectItemAndCleanUp(selectedItem)\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n )\n }, [selectItemAndCleanUp, close, editor, groups, selectedItemKey, updateSelectedItem])\n\n const listItemProps = useMemo(\n () => ({\n groups,\n selectedItemKey,\n selectItemAndCleanUp,\n setSelectedItemKey,\n }),\n [selectItemAndCleanUp, selectedItemKey, groups],\n )\n\n return menuRenderFn(\n anchorElementRef,\n listItemProps,\n resolution.match ? resolution.match.matchingString : '',\n )\n}\n\nfunction setContainerDivAttributes(containerDiv: HTMLElement, className?: string) {\n if (className != null) {\n containerDiv.className = className\n }\n containerDiv.setAttribute('aria-label', 'Slash menu')\n containerDiv.setAttribute('role', 'listbox')\n containerDiv.style.display = 'block'\n containerDiv.style.position = 'absolute'\n}\n\nexport function useMenuAnchorRef(\n anchorElem: HTMLElement,\n resolution: MenuResolution | null,\n setResolution: (r: MenuResolution | null) => void,\n className?: string,\n): RefObject<HTMLElement | null> {\n const [editor] = useLexicalComposerContext()\n const anchorElementRef = useRef<HTMLElement | null>(\n CAN_USE_DOM ? document.createElement('div') : null,\n )\n const positionMenu = useCallback(() => {\n if (anchorElementRef.current === null || parent === undefined) {\n return\n }\n const rootElement = editor.getRootElement()\n const containerDiv = anchorElementRef.current\n\n const VERTICAL_OFFSET = 32\n\n const menuEle = containerDiv.firstChild as Element\n if (rootElement !== null && resolution !== null) {\n const { height, width } = resolution.getRect()\n let { left, top } = resolution.getRect()\n\n const rawTop = top\n top -= anchorElem.getBoundingClientRect().top + window.scrollY\n left -= anchorElem.getBoundingClientRect().left + window.scrollX\n containerDiv.style.left = `${left + window.scrollX}px`\n containerDiv.style.height = `${height}px`\n containerDiv.style.width = `${width}px`\n if (menuEle !== null) {\n const menuRect = menuEle.getBoundingClientRect()\n const menuHeight = menuRect.height\n const menuWidth = menuRect.width\n\n const rootElementRect = rootElement.getBoundingClientRect()\n\n const isRTL = document.dir === 'rtl' || document.documentElement.dir === 'rtl'\n const anchorRect = anchorElem.getBoundingClientRect()\n const leftBoundary = Math.max(0, rootElementRect.left)\n\n if (!isRTL && left + menuWidth > rootElementRect.right) {\n containerDiv.style.left = `${rootElementRect.right - menuWidth + window.scrollX}px`\n } else if (isRTL && menuRect.left < leftBoundary) {\n const newLeft = leftBoundary + menuWidth - anchorRect.left\n containerDiv.style.left = `${newLeft + window.scrollX}px`\n }\n\n const wouldGoOffBottomOfScreen = rawTop + menuHeight + VERTICAL_OFFSET > window.innerHeight\n //const wouldGoOffBottomOfContainer = top + menuHeight > rootElementRect.bottom\n const wouldGoOffTopOfScreen = rawTop < 0\n\n // Position slash menu above the cursor instead of below (default) if it would otherwise go off the bottom of the screen.\n if (wouldGoOffBottomOfScreen && !wouldGoOffTopOfScreen) {\n const margin = 24\n containerDiv.style.top = `${\n top + VERTICAL_OFFSET - menuHeight + window.scrollY - (height + margin)\n }px`\n } else {\n containerDiv.style.top = `${top + window.scrollY + VERTICAL_OFFSET}px`\n }\n }\n\n if (!containerDiv.isConnected) {\n setContainerDivAttributes(containerDiv, className)\n anchorElem.append(containerDiv)\n }\n containerDiv.setAttribute('id', 'slash-menu')\n anchorElementRef.current = containerDiv\n rootElement.setAttribute('aria-controls', 'slash-menu')\n }\n }, [editor, resolution, className, anchorElem])\n\n useEffect(() => {\n const rootElement = editor.getRootElement()\n if (resolution !== null) {\n positionMenu()\n return () => {\n if (rootElement !== null) {\n rootElement.removeAttribute('aria-controls')\n }\n\n const containerDiv = anchorElementRef.current\n if (containerDiv !== null && containerDiv.isConnected) {\n containerDiv.remove()\n containerDiv.removeAttribute('id')\n }\n }\n }\n }, [editor, positionMenu, resolution])\n\n const onVisibilityChange = useCallback(\n (isInView: boolean) => {\n if (resolution !== null) {\n if (!isInView) {\n setResolution(null)\n }\n }\n },\n [resolution, setResolution],\n )\n\n useDynamicPositioning(resolution, anchorElementRef, positionMenu, onVisibilityChange)\n\n return anchorElementRef\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,eAAe,EAAEC,aAAa,QAAQ;AAC/C,SACEC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,EACbC,oBAAoB,EACpBC,uBAAuB,EACvBC,aAAa,EACbC,sBAAsB,EACtBC,oBAAoB,EACpBC,iBAAiB,EACjBC,kBAAkB,EAClBC,eAAe,QACV;AACP,SAASC,WAAW,EAAEC,SAAS,EAAEC,eAAe,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAKnF,SAASC,WAAW,QAAQ;AAO5B,MAAMC,SAAA,GAAY;AAalB,MAAMC,sBAAA,GAA0BC,MAAA;EAC9B,MAAMC,sBAAA,GAAyBC,QAAA,CAASC,cAAc,CAAC;EACvD,IAAI,CAACF,sBAAA,EAAwB;IA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,qBAAA,CAAsBC,UAAA,EAAY4B,gBAAA,EAAkBkF,YAAA,EAAc3G,kBAAA;EAAA,OAE3DyB,gBAAA;AAAA","ignoreList":[]}
@@ -16,11 +16,7 @@
16
16
  overflow-y: auto;
17
17
  z-index: 10;
18
18
  position: absolute;
19
- box-shadow:
20
- 0 2px 6px 0 rgba(0, 0, 0, 0.12),
21
- 0 10px 16px 0 rgba(0, 0, 0, 0.08),
22
- 0 0 0.5px 0 rgba(0, 0, 0, 0.12),
23
- 0 0 0 1px rgba(0, 0, 0, 0.04);
19
+ box-shadow: var(--elevation-400-menu-panel);
24
20
  }
25
21
 
26
22
  .slash-menu-popup__group {
@@ -46,7 +42,6 @@
46
42
  border-radius: var(--radius-medium);
47
43
  cursor: pointer;
48
44
  gap: var(--spacer-1);
49
- transition: background-color 0.15s cubic-bezier(0, 0.2, 0.2, 1);
50
45
 
51
46
  .icon {
52
47
  color: var(--color-icon-secondary);
@@ -5,8 +5,9 @@
5
5
  padding: 0;
6
6
  cursor: pointer;
7
7
  opacity: 0;
8
+ visibility: hidden;
8
9
  position: absolute;
9
- left: 0;
10
+ inset-inline-start: 0;
10
11
  top: 0;
11
12
  will-change: transform;
12
13
 
@@ -83,8 +83,8 @@ function useAddBlockHandle(editor, anchorElem, isEditable) {
83
83
  };
84
84
  }, [scrollerElem, anchorElem, editor, hoveredElement]);
85
85
  useEffect(() => {
86
- if (menuRef.current && hoveredElement?.node) {
87
- setHandlePosition(hoveredElement?.elem, menuRef.current, anchorElem, blockHandleHorizontalOffset);
86
+ if (menuRef.current) {
87
+ setHandlePosition(hoveredElement?.elem ?? null, menuRef.current, anchorElem, blockHandleHorizontalOffset);
88
88
  }
89
89
  }, [anchorElem, hoveredElement, blockHandleHorizontalOffset]);
90
90
  const handleAddClick = useCallback(event_0 => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useLexicalComposerContext","$createParagraphNode","isHTMLElement","React","useCallback","useEffect","useRef","useState","createPortal","useEditorConfigContext","Point","ENABLE_SLASH_MENU_COMMAND","calculateDistanceFromScrollerElem","getNodeCloseToPoint","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","ADD_BLOCK_MENU_CLASSNAME","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","useAddBlockHandle","editor","anchorElem","isEditable","scrollerElem","parentElement","editorConfig","blockHandleHorizontalOffset","admin","hideGutter","menuRef","hoveredElement","setHoveredElement","onDocumentMouseMove","event","target","distanceFromScrollerElem","pageX","pageY","topLevelNodeKeys","blockElem","_emptyBlockElem","blockNode","foundAtIndex","cache_threshold","horizontalOffset","point","x","y","returnEmptyParagraphs","startIndex","length","useEdgeAsDefault","node","elem","document","addEventListener","removeEventListener","current","handleAddClick","hoveredElementToUse","update","isEmptyParagraph","getType","getTextContent","newParagraph","insertAfter","setTimeout","getElementByKey","getKey","focus","select","dispatchCommand","stopPropagation","preventDefault","_jsx","Fragment","className","onClick","ref","type","AddBlockHandlePlugin","t0","t1","undefined","body","_editable"],"sources":["../../../../../src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor, LexicalNode, ParagraphNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode, isHTMLElement } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { Point } from '../../../utils/point.js'\nimport { ENABLE_SLASH_MENU_COMMAND } from '../../SlashMenu/LexicalTypeaheadMenuPlugin/index.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport './index.css'\n\nconst ADD_BLOCK_MENU_CLASSNAME = 'add-block-menu'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction useAddBlockHandle(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const { editorConfig } = useEditorConfigContext()\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -24 : 12\n\n const menuRef = useRef<HTMLButtonElement>(null)\n const [hoveredElement, setHoveredElement] = useState<{\n elem: HTMLElement\n node: LexicalNode\n } | null>(null)\n\n useEffect(() => {\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n\n if (distanceFromScrollerElem === -1) {\n setHoveredElement(null)\n return\n }\n\n if (isOnHandleElement(target, ADD_BLOCK_MENU_CLASSNAME)) {\n return\n }\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _emptyBlockElem,\n blockNode,\n foundAtIndex,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n returnEmptyParagraphs: true,\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n })\n\n prevIndex = foundAtIndex\n\n if (!_emptyBlockElem) {\n return\n }\n if (\n blockNode &&\n (hoveredElement?.node !== blockNode || hoveredElement?.elem !== _emptyBlockElem)\n ) {\n setHoveredElement({\n elem: _emptyBlockElem,\n node: blockNode,\n })\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, hoveredElement])\n\n useEffect(() => {\n if (menuRef.current && hoveredElement?.node) {\n setHandlePosition(\n hoveredElement?.elem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, hoveredElement, blockHandleHorizontalOffset])\n\n const handleAddClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n let hoveredElementToUse = hoveredElement\n if (!hoveredElementToUse?.node) {\n return\n }\n\n // 1. Update hoveredElement.node to a new paragraph node if the hoveredElement.node is not a paragraph node\n editor.update(() => {\n // Check if blockNode is an empty text node\n let isEmptyParagraph = true\n if (\n hoveredElementToUse?.node.getType() !== 'paragraph' ||\n hoveredElementToUse.node.getTextContent() !== ''\n ) {\n isEmptyParagraph = false\n }\n\n if (!isEmptyParagraph) {\n const newParagraph = $createParagraphNode()\n hoveredElementToUse?.node.insertAfter(newParagraph)\n\n setTimeout(() => {\n hoveredElementToUse = {\n elem: editor.getElementByKey(newParagraph.getKey())!,\n node: newParagraph,\n }\n setHoveredElement(hoveredElementToUse)\n }, 0)\n }\n })\n\n // 2. Focus on the new paragraph node\n setTimeout(() => {\n editor.update(() => {\n editor.focus()\n\n if (\n hoveredElementToUse?.node &&\n 'select' in hoveredElementToUse.node &&\n typeof hoveredElementToUse.node.select === 'function'\n ) {\n hoveredElementToUse.node.select()\n }\n })\n }, 1)\n\n // Make sure this is called AFTER the focusing has been processed by the browser\n // Otherwise, this won't work\n setTimeout(() => {\n editor.dispatchCommand(ENABLE_SLASH_MENU_COMMAND, {\n node: hoveredElementToUse?.node as ParagraphNode,\n })\n }, 2)\n\n event.stopPropagation()\n event.preventDefault()\n },\n [editor, hoveredElement],\n )\n\n return createPortal(\n <React.Fragment>\n <button\n aria-label=\"Add block\"\n className=\"icon add-block-menu\"\n onClick={(event) => {\n handleAddClick(event)\n }}\n ref={menuRef}\n type=\"button\"\n >\n <div className={isEditable ? 'icon' : ''} />\n </button>\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function AddBlockHandlePlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useAddBlockHandle(editor, anchorElem, editor._editable)\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,EAAEC,aAAa,QAAQ;AACpD,YAAYC,KAAA,MAAW;AACvB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AACzD,SAASC,YAAY,QAAQ;AAE7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,KAAK,QAAQ;AACtB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,iCAAiC,QAAQ;AAClD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,iBAAiB,QAAQ;AAClC,OAAO;AAEP,MAAMC,wBAAA,GAA2B;AAEjC,IAAIC,SAAA,GAAYC,QAAA;AAEhB,SAASC,gBAAgBC,UAAkB;EACzC,IAAIA,UAAA,KAAe,GAAG;IACpB,OAAOF,QAAA;EACT;EACA,IAAID,SAAA,IAAa,KAAKA,SAAA,GAAYG,UAAA,EAAY;IAC5C,OAAOH,SAAA;EACT;EAEA,OAAOI,IAAA,CAAKC,KAAK,CAACF,UAAA,GAAa;AACjC;AAEA,SAASG,kBACPC,MAAqB,EACrBC,UAAuB,EACvBC,UAAmB;EAEnB,MAAMC,YAAA,GAAeF,UAAA,CAAWG,aAAa;EAE7C,MAAM;IAAEC;EAAY,CAAE,GAAGrB,sBAAA;EACzB,MAAMsB,2BAAA,GAA8BD,YAAA,EAAcE,KAAA,EAAOC,UAAA,GAAa,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,IAAA,IACrB,YAAYO,mBAAA,CAAoBP,IAAI,IACpC,OAAOO,mBAAA,CAAoBP,IAAI,CAACkB,MAAM,KAAK,YAC3C;UACAX,mBAAA,CAAoBP,IAAI,CAACkB,MAAM;QACjC;MACF;IACF,GAAG;IAEH;IACA;IACAJ,UAAA,CAAW;MACT9C,MAAA,CAAOmD,eAAe,CAACjE,yBAAA,EAA2B;QAChD8C,IAAA,EAAMO,mBAAA,EAAqBP;MAC7B;IACF,GAAG;IAEHnB,OAAA,CAAMuC,eAAe;IACrBvC,OAAA,CAAMwC,cAAc;EACtB,GACA,CAACrD,MAAA,EAAQU,cAAA,CAAe;EAG1B,oBAAO3B,YAAA,cACLuE,IAAA,CAAC5E,KAAA,CAAM6E,QAAQ;cACb,aAAAD,IAAA,CAAC;MACC,cAAW;MACXE,SAAA,EAAU;MACVC,OAAA,EAAU5C,OAAA;QACRyB,cAAA,CAAezB,OAAA;MACjB;MACA6C,GAAA,EAAKjD,OAAA;MACLkD,IAAA,EAAK;gBAEL,aAAAL,IAAA,CAAC;QAAIE,SAAA,EAAWtD,UAAA,GAAa,SAAS;;;MAG1CD,UAAA;AAEJ;AAEA,OAAO,SAAA2D,qBAAAC,EAAA;EAA8B;IAAA5D,UAAA,EAAA6D;EAAA,IAAAD,EAIpC;EAHC,MAAA5D,UAAA,GAAA6D,EAA0B,KAAAC,SAAA,GAAA7B,QAAA,CAAA8B,IAAA,GAA1BF,EAA0B;EAI1B,OAAA9D,MAAA,IAAiBzB,yBAAA;EAAA,OACVwB,iBAAA,CAAkBC,MAAA,EAAQC,UAAA,EAAYD,MAAA,CAAAiE,SAAgB;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useLexicalComposerContext","$createParagraphNode","isHTMLElement","React","useCallback","useEffect","useRef","useState","createPortal","useEditorConfigContext","Point","ENABLE_SLASH_MENU_COMMAND","calculateDistanceFromScrollerElem","getNodeCloseToPoint","getTopLevelNodeKeys","isOnHandleElement","setHandlePosition","ADD_BLOCK_MENU_CLASSNAME","prevIndex","Infinity","getCurrentIndex","keysLength","Math","floor","useAddBlockHandle","editor","anchorElem","isEditable","scrollerElem","parentElement","editorConfig","blockHandleHorizontalOffset","admin","hideGutter","menuRef","hoveredElement","setHoveredElement","onDocumentMouseMove","event","target","distanceFromScrollerElem","pageX","pageY","topLevelNodeKeys","blockElem","_emptyBlockElem","blockNode","foundAtIndex","cache_threshold","horizontalOffset","point","x","y","returnEmptyParagraphs","startIndex","length","useEdgeAsDefault","node","elem","document","addEventListener","removeEventListener","current","handleAddClick","hoveredElementToUse","update","isEmptyParagraph","getType","getTextContent","newParagraph","insertAfter","setTimeout","getElementByKey","getKey","focus","select","dispatchCommand","stopPropagation","preventDefault","_jsx","Fragment","className","onClick","ref","type","AddBlockHandlePlugin","t0","t1","undefined","body","_editable"],"sources":["../../../../../src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor, LexicalNode, ParagraphNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode, isHTMLElement } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { Point } from '../../../utils/point.js'\nimport { ENABLE_SLASH_MENU_COMMAND } from '../../SlashMenu/LexicalTypeaheadMenuPlugin/index.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport './index.css'\n\nconst ADD_BLOCK_MENU_CLASSNAME = 'add-block-menu'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction useAddBlockHandle(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const { editorConfig } = useEditorConfigContext()\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -24 : 12\n\n const menuRef = useRef<HTMLButtonElement>(null)\n const [hoveredElement, setHoveredElement] = useState<{\n elem: HTMLElement\n node: LexicalNode\n } | null>(null)\n\n useEffect(() => {\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n\n if (distanceFromScrollerElem === -1) {\n setHoveredElement(null)\n return\n }\n\n if (isOnHandleElement(target, ADD_BLOCK_MENU_CLASSNAME)) {\n return\n }\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _emptyBlockElem,\n blockNode,\n foundAtIndex,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n returnEmptyParagraphs: true,\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n })\n\n prevIndex = foundAtIndex\n\n if (!_emptyBlockElem) {\n return\n }\n if (\n blockNode &&\n (hoveredElement?.node !== blockNode || hoveredElement?.elem !== _emptyBlockElem)\n ) {\n setHoveredElement({\n elem: _emptyBlockElem,\n node: blockNode,\n })\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, hoveredElement])\n\n useEffect(() => {\n if (menuRef.current) {\n setHandlePosition(\n hoveredElement?.elem ?? null,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, hoveredElement, blockHandleHorizontalOffset])\n\n const handleAddClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n let hoveredElementToUse = hoveredElement\n if (!hoveredElementToUse?.node) {\n return\n }\n\n // 1. Update hoveredElement.node to a new paragraph node if the hoveredElement.node is not a paragraph node\n editor.update(() => {\n // Check if blockNode is an empty text node\n let isEmptyParagraph = true\n if (\n hoveredElementToUse?.node.getType() !== 'paragraph' ||\n hoveredElementToUse.node.getTextContent() !== ''\n ) {\n isEmptyParagraph = false\n }\n\n if (!isEmptyParagraph) {\n const newParagraph = $createParagraphNode()\n hoveredElementToUse?.node.insertAfter(newParagraph)\n\n setTimeout(() => {\n hoveredElementToUse = {\n elem: editor.getElementByKey(newParagraph.getKey())!,\n node: newParagraph,\n }\n setHoveredElement(hoveredElementToUse)\n }, 0)\n }\n })\n\n // 2. Focus on the new paragraph node\n setTimeout(() => {\n editor.update(() => {\n editor.focus()\n\n if (\n hoveredElementToUse?.node &&\n 'select' in hoveredElementToUse.node &&\n typeof hoveredElementToUse.node.select === 'function'\n ) {\n hoveredElementToUse.node.select()\n }\n })\n }, 1)\n\n // Make sure this is called AFTER the focusing has been processed by the browser\n // Otherwise, this won't work\n setTimeout(() => {\n editor.dispatchCommand(ENABLE_SLASH_MENU_COMMAND, {\n node: hoveredElementToUse?.node as ParagraphNode,\n })\n }, 2)\n\n event.stopPropagation()\n event.preventDefault()\n },\n [editor, hoveredElement],\n )\n\n return createPortal(\n <React.Fragment>\n <button\n aria-label=\"Add block\"\n className=\"icon add-block-menu\"\n onClick={(event) => {\n handleAddClick(event)\n }}\n ref={menuRef}\n type=\"button\"\n >\n <div className={isEditable ? 'icon' : ''} />\n </button>\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function AddBlockHandlePlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useAddBlockHandle(editor, anchorElem, editor._editable)\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,EAAEC,aAAa,QAAQ;AACpD,YAAYC,KAAA,MAAW;AACvB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AACzD,SAASC,YAAY,QAAQ;AAE7B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,KAAK,QAAQ;AACtB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,iCAAiC,QAAQ;AAClD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,iBAAiB,QAAQ;AAClC,OAAO;AAEP,MAAMC,wBAAA,GAA2B;AAEjC,IAAIC,SAAA,GAAYC,QAAA;AAEhB,SAASC,gBAAgBC,UAAkB;EACzC,IAAIA,UAAA,KAAe,GAAG;IACpB,OAAOF,QAAA;EACT;EACA,IAAID,SAAA,IAAa,KAAKA,SAAA,GAAYG,UAAA,EAAY;IAC5C,OAAOH,SAAA;EACT;EAEA,OAAOI,IAAA,CAAKC,KAAK,CAACF,UAAA,GAAa;AACjC;AAEA,SAASG,kBACPC,MAAqB,EACrBC,UAAuB,EACvBC,UAAmB;EAEnB,MAAMC,YAAA,GAAeF,UAAA,CAAWG,aAAa;EAE7C,MAAM;IAAEC;EAAY,CAAE,GAAGrB,sBAAA;EACzB,MAAMsB,2BAAA,GAA8BD,YAAA,EAAcE,KAAA,EAAOC,UAAA,GAAa,CAAC,KAAK;EAE5E,MAAMC,OAAA,GAAU5B,MAAA,CAA0B;EAC1C,MAAM,CAAC6B,cAAA,EAAgBC,iBAAA,CAAkB,GAA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AACkB,MAAM;QACjC;MACF;IACF,GAAG;IAEH;IACA;IACAJ,UAAA,CAAW;MACT9C,MAAA,CAAOmD,eAAe,CAACjE,yBAAA,EAA2B;QAChD8C,IAAA,EAAMO,mBAAA,EAAqBP;MAC7B;IACF,GAAG;IAEHnB,OAAA,CAAMuC,eAAe;IACrBvC,OAAA,CAAMwC,cAAc;EACtB,GACA,CAACrD,MAAA,EAAQU,cAAA,CAAe;EAG1B,oBAAO3B,YAAA,cACLuE,IAAA,CAAC5E,KAAA,CAAM6E,QAAQ;cACb,aAAAD,IAAA,CAAC;MACC,cAAW;MACXE,SAAA,EAAU;MACVC,OAAA,EAAU5C,OAAA;QACRyB,cAAA,CAAezB,OAAA;MACjB;MACA6C,GAAA,EAAKjD,OAAA;MACLkD,IAAA,EAAK;gBAEL,aAAAL,IAAA,CAAC;QAAIE,SAAA,EAAWtD,UAAA,GAAa,SAAS;;;MAG1CD,UAAA;AAEJ;AAEA,OAAO,SAAA2D,qBAAAC,EAAA;EAA8B;IAAA5D,UAAA,EAAA6D;EAAA,IAAAD,EAIpC;EAHC,MAAA5D,UAAA,GAAA6D,EAA0B,KAAAC,SAAA,GAAA7B,QAAA,CAAA8B,IAAA,GAA1BF,EAA0B;EAI1B,OAAA9D,MAAA,IAAiBzB,yBAAA;EAAA,OACVwB,iBAAA,CAAkBC,MAAA,EAAQC,UAAA,EAAYD,MAAA,CAAAiE,SAAgB;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/debounce.ts"],"names":[],"mappings":"AACA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,SAAS,EAAE,KAAK,IAAI,EAAE,IAAI,EAAE,MAAM,IAExD,GAAG,MAAM,SAAS,EAAE,UAUtC"}
1
+ {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/debounce.ts"],"names":[],"mappings":"AACA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,SAAS,EAAE,KAAK,IAAI,EAAE,IAAI,EAAE,MAAM,aAE/C,SAAS,EAAE,UAUtC"}
@@ -5,8 +5,9 @@
5
5
  padding: 0;
6
6
  cursor: grab;
7
7
  opacity: 0;
8
+ visibility: hidden;
8
9
  position: absolute;
9
- left: 0;
10
+ inset-inline-start: 0;
10
11
  top: 0;
11
12
  will-change: transform;
12
13
  background-color: var(--color-bg);
@@ -46,11 +47,12 @@
46
47
 
47
48
  .rich-text-lexical--show-gutter
48
49
  > .rich-text-lexical__wrap
50
+ > .rich-text-lexical__editor-content
49
51
  > .editor-container
50
52
  > .editor-scroller
51
53
  > .editor {
52
54
  > .draggable-block-target-line {
53
- left: var(--spacer-5);
55
+ inset-inline-start: var(--spacer-5);
54
56
  }
55
57
  }
56
58
 
@@ -60,7 +62,7 @@
60
62
  border-radius: var(--radius-small);
61
63
  height: var(--spacer-1);
62
64
  position: absolute;
63
- left: 0;
65
+ inset-inline-start: 0;
64
66
  top: 0;
65
67
  opacity: 0;
66
68
  will-change: transform;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,OAAO,aAAa,CAAA;AA6apB,wBAAgB,oBAAoB,CAAC,EACnC,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,KAAK,CAAC,YAAY,CAGrB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/plugins/handles/DraggableBlockPlugin/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,OAAO,aAAa,CAAA;AAqbpB,wBAAgB,oBAAoB,CAAC,EACnC,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,KAAK,CAAC,YAAY,CAGrB"}
@@ -3,9 +3,10 @@
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
5
5
  import { eventFiles } from '@lexical/rich-text';
6
+ import { useTranslation } from '@payloadcms/ui';
6
7
  import { $getNearestNodeFromDOMNode, $getNodeByKey, isHTMLElement } from 'lexical';
7
8
  import * as React from 'react';
8
- import { useEffect, useRef, useState } from 'react';
9
+ import { useEffect, useId, useRef, useState } from 'react';
9
10
  import { createPortal } from 'react-dom';
10
11
  import { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js';
11
12
  import { Point } from '../../../utils/point.js';
@@ -17,6 +18,7 @@ import { setHandlePosition } from '../utils/setHandlePosition.js';
17
18
  import { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js';
18
19
  import './index.css';
19
20
  import { setTargetLine } from './setTargetLine.js';
21
+ import { useKeyboardReordering } from './useKeyboardReordering.js';
20
22
  const DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu';
21
23
  const DRAG_DATA_FORMAT = 'application/x-lexical-drag-block';
22
24
  let prevIndex = Infinity;
@@ -53,6 +55,14 @@ function hideTargetLine(targetLineElem, lastTargetBlockElem) {
53
55
  }
54
56
  function useDraggableBlockMenu(editor, anchorElem, isEditable) {
55
57
  const scrollerElem = anchorElem.parentElement;
58
+ const instructionsID = useId();
59
+ const {
60
+ t
61
+ } = useTranslation();
62
+ useKeyboardReordering({
63
+ editor,
64
+ instructionsID
65
+ });
56
66
  const menuRef = useRef(null);
57
67
  const targetLineRef = useRef(null);
58
68
  const debugHighlightRef = useRef(null);
@@ -271,7 +281,7 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
271
281
  }
272
282
  const highlightElem = document.createElement('div');
273
283
  highlightElem.className = 'lexical-block-highlighter';
274
- highlightElem.style.backgroundColor = 'var(--theme-elevation-1000';
284
+ highlightElem.style.backgroundColor = 'var(--color-bg-inverse)';
275
285
  highlightElem.style.transition = 'opacity 0.5s ease-in-out';
276
286
  highlightElem.style.zIndex = '1';
277
287
  highlightElem.style.pointerEvents = 'none';
@@ -332,7 +342,11 @@ function useDraggableBlockMenu(editor, anchorElem, isEditable) {
332
342
  }
333
343
  }
334
344
  return /*#__PURE__*/createPortal(/*#__PURE__*/_jsxs(React.Fragment, {
335
- children: [/*#__PURE__*/_jsx("button", {
345
+ children: [/*#__PURE__*/_jsxs("span", {
346
+ className: "sr-only",
347
+ id: instructionsID,
348
+ children: [t('general:moveUp'), ": Alt + Shift + ↑. ", t('general:moveDown'), ": Alt + Shift + ↓."]
349
+ }), /*#__PURE__*/_jsx("button", {
336
350
  "aria-label": "Drag to move",
337
351
  className: "icon draggable-block-menu",
338
352
  draggable: true,