@payloadcms/richtext-lexical 3.0.0-alpha.67 → 3.0.0-alpha.68

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 (256) hide show
  1. package/dist/exports/components.d.ts +2 -2
  2. package/dist/exports/components.d.ts.map +1 -1
  3. package/dist/exports/components.js +2 -2
  4. package/dist/exports/components.js.map +1 -1
  5. package/dist/field/features/align/feature.client.d.ts.map +1 -1
  6. package/dist/field/features/align/feature.client.js +15 -21
  7. package/dist/field/features/align/feature.client.js.map +1 -1
  8. package/dist/field/features/align/inlineToolbarAlignGroup.d.ts +3 -0
  9. package/dist/field/features/align/inlineToolbarAlignGroup.d.ts.map +1 -0
  10. package/dist/field/features/align/{floatingSelectToolbarAlignDropdownSection.js → inlineToolbarAlignGroup.js} +4 -4
  11. package/dist/field/features/align/inlineToolbarAlignGroup.js.map +1 -0
  12. package/dist/field/features/blockquote/feature.client.d.ts.map +1 -1
  13. package/dist/field/features/blockquote/feature.client.js +33 -31
  14. package/dist/field/features/blockquote/feature.client.js.map +1 -1
  15. package/dist/field/features/blocks/feature.client.d.ts.map +1 -1
  16. package/dist/field/features/blocks/feature.client.js +25 -27
  17. package/dist/field/features/blocks/feature.client.js.map +1 -1
  18. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.d.ts.map +1 -1
  19. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.js.map +1 -1
  20. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.d.ts.map +1 -1
  21. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.js +1 -1
  22. package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.js.map +1 -1
  23. package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.d.ts.map +1 -1
  24. package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.js.map +1 -1
  25. package/dist/field/features/debug/{treeview → treeView}/feature.client.d.ts.map +1 -1
  26. package/dist/field/features/debug/{treeview → treeView}/feature.client.js.map +1 -1
  27. package/dist/field/features/debug/{treeview → treeView}/feature.server.d.ts.map +1 -1
  28. package/dist/field/features/debug/{treeview → treeView}/feature.server.js +1 -1
  29. package/dist/field/features/debug/{treeview → treeView}/feature.server.js.map +1 -1
  30. package/dist/field/features/debug/{treeview → treeView}/plugin/index.d.ts.map +1 -1
  31. package/dist/field/features/debug/{treeview → treeView}/plugin/index.js.map +1 -1
  32. package/dist/field/features/format/bold/feature.client.js +7 -7
  33. package/dist/field/features/format/bold/feature.client.js.map +1 -1
  34. package/dist/field/features/format/{inlinecode → inlineCode}/feature.client.d.ts.map +1 -1
  35. package/dist/field/features/format/{inlinecode → inlineCode}/feature.client.js +10 -10
  36. package/dist/field/features/format/inlineCode/feature.client.js.map +1 -0
  37. package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.d.ts.map +1 -1
  38. package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.js +1 -1
  39. package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.js.map +1 -1
  40. package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.d.ts.map +1 -1
  41. package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.js.map +1 -1
  42. package/dist/field/features/format/italic/feature.client.js +10 -10
  43. package/dist/field/features/format/italic/feature.client.js.map +1 -1
  44. package/dist/field/features/format/shared/inlineToolbarFormatGroup.d.ts +3 -0
  45. package/dist/field/features/format/shared/inlineToolbarFormatGroup.d.ts.map +1 -0
  46. package/dist/field/features/format/shared/inlineToolbarFormatGroup.js +10 -0
  47. package/dist/field/features/format/shared/inlineToolbarFormatGroup.js.map +1 -0
  48. package/dist/field/features/format/strikethrough/feature.client.js +9 -9
  49. package/dist/field/features/format/strikethrough/feature.client.js.map +1 -1
  50. package/dist/field/features/format/subscript/feature.client.js +5 -5
  51. package/dist/field/features/format/subscript/feature.client.js.map +1 -1
  52. package/dist/field/features/format/superscript/feature.client.js +5 -5
  53. package/dist/field/features/format/superscript/feature.client.js.map +1 -1
  54. package/dist/field/features/format/underline/feature.client.js +5 -5
  55. package/dist/field/features/format/underline/feature.client.js.map +1 -1
  56. package/dist/field/features/heading/feature.client.d.ts.map +1 -1
  57. package/dist/field/features/heading/feature.client.js +39 -39
  58. package/dist/field/features/heading/feature.client.js.map +1 -1
  59. package/dist/field/features/{horizontalrule → horizontalRule}/component/index.d.ts.map +1 -1
  60. package/dist/field/features/{horizontalrule → horizontalRule}/component/index.js.map +1 -1
  61. package/dist/field/features/{horizontalrule → horizontalRule}/feature.client.d.ts.map +1 -1
  62. package/dist/field/features/{horizontalrule → horizontalRule}/feature.client.js +7 -7
  63. package/dist/field/features/horizontalRule/feature.client.js.map +1 -0
  64. package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.d.ts.map +1 -1
  65. package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.js +1 -1
  66. package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.js.map +1 -1
  67. package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.d.ts.map +1 -1
  68. package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.js.map +1 -1
  69. package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.d.ts.map +1 -1
  70. package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.js.map +1 -1
  71. package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.d.ts.map +1 -1
  72. package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.js.map +1 -1
  73. package/dist/field/features/indent/feature.client.d.ts.map +1 -1
  74. package/dist/field/features/indent/feature.client.js +9 -11
  75. package/dist/field/features/indent/feature.client.js.map +1 -1
  76. package/dist/field/features/indent/inlineToolbarIndentGroup.d.ts +3 -0
  77. package/dist/field/features/indent/inlineToolbarIndentGroup.d.ts.map +1 -0
  78. package/dist/field/features/indent/inlineToolbarIndentGroup.js +10 -0
  79. package/dist/field/features/indent/inlineToolbarIndentGroup.js.map +1 -0
  80. package/dist/field/features/link/feature.client.js +28 -28
  81. package/dist/field/features/link/feature.client.js.map +1 -1
  82. package/dist/field/features/lists/checklist/feature.client.d.ts +1 -1
  83. package/dist/field/features/lists/checklist/feature.client.js +28 -28
  84. package/dist/field/features/lists/checklist/feature.client.js.map +1 -1
  85. package/dist/field/features/lists/checklist/feature.server.d.ts +1 -1
  86. package/dist/field/features/lists/checklist/feature.server.js +4 -4
  87. package/dist/field/features/lists/checklist/feature.server.js.map +1 -1
  88. package/dist/field/features/lists/checklist/markdownTransformers.js +1 -1
  89. package/dist/field/features/lists/checklist/markdownTransformers.js.map +1 -1
  90. package/dist/field/features/lists/{orderedlist → orderedList}/feature.client.d.ts.map +1 -1
  91. package/dist/field/features/lists/{orderedlist → orderedList}/feature.client.js +26 -26
  92. package/dist/field/features/lists/orderedList/feature.client.js.map +1 -0
  93. package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.d.ts.map +1 -1
  94. package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.js +1 -1
  95. package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.js.map +1 -1
  96. package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.d.ts.map +1 -1
  97. package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.js +1 -1
  98. package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.js.map +1 -1
  99. package/dist/field/features/lists/{common → shared}/markdown.d.ts.map +1 -1
  100. package/dist/field/features/lists/{common → shared}/markdown.js.map +1 -1
  101. package/dist/field/features/lists/unorderedList/feature.client.d.ts.map +1 -0
  102. package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.client.js +24 -24
  103. package/dist/field/features/lists/unorderedList/feature.client.js.map +1 -0
  104. package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.d.ts.map +1 -1
  105. package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.js +1 -1
  106. package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.js.map +1 -1
  107. package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.d.ts.map +1 -1
  108. package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.js +1 -1
  109. package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.js.map +1 -1
  110. package/dist/field/features/paragraph/feature.client.js +27 -27
  111. package/dist/field/features/paragraph/feature.client.js.map +1 -1
  112. package/dist/field/features/relationship/feature.client.js +7 -7
  113. package/dist/field/features/relationship/feature.client.js.map +1 -1
  114. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.d.ts +3 -0
  115. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.d.ts.map +1 -0
  116. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.js +10 -0
  117. package/dist/field/features/shared/inlineToolbar/featureButtonsGroup.js.map +1 -0
  118. package/dist/field/features/shared/inlineToolbar/textDropdownGroup.d.ts +3 -0
  119. package/dist/field/features/shared/inlineToolbar/textDropdownGroup.d.ts.map +1 -0
  120. package/dist/field/features/{common/floatingSelectToolbarTextDropdownSection/index.js → shared/inlineToolbar/textDropdownGroup.js} +4 -4
  121. package/dist/field/features/shared/inlineToolbar/textDropdownGroup.js.map +1 -0
  122. package/dist/field/features/types.d.ts +51 -12
  123. package/dist/field/features/types.d.ts.map +1 -1
  124. package/dist/field/features/types.js.map +1 -1
  125. package/dist/field/features/upload/feature.client.d.ts.map +1 -1
  126. package/dist/field/features/upload/feature.client.js +7 -7
  127. package/dist/field/features/upload/feature.client.js.map +1 -1
  128. package/dist/field/lexical/LexicalEditor.js +1 -1
  129. package/dist/field/lexical/LexicalEditor.js.map +1 -1
  130. package/dist/field/lexical/LexicalEditor.scss +3 -19
  131. package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
  132. package/dist/field/lexical/config/client/sanitize.js +80 -32
  133. package/dist/field/lexical/config/client/sanitize.js.map +1 -1
  134. package/dist/field/lexical/config/server/default.d.ts.map +1 -1
  135. package/dist/field/lexical/config/server/default.js +6 -6
  136. package/dist/field/lexical/config/server/default.js.map +1 -1
  137. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +9 -9
  138. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  139. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +71 -71
  140. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  141. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +4 -4
  142. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
  143. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +3 -3
  144. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  145. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts +12 -20
  146. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.d.ts.map +1 -1
  147. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js +1 -37
  148. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js.map +1 -1
  149. package/dist/field/lexical/plugins/SlashMenu/index.d.ts +2 -2
  150. package/dist/field/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
  151. package/dist/field/lexical/plugins/SlashMenu/index.js +67 -61
  152. package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
  153. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/fixed}/types.d.ts +6 -6
  154. package/dist/field/lexical/plugins/toolbars/fixed/types.d.ts.map +1 -0
  155. package/dist/field/lexical/plugins/toolbars/fixed/types.js.map +1 -0
  156. package/dist/field/lexical/plugins/toolbars/inline/Toolbar/index.d.ts.map +1 -0
  157. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline/Toolbar}/index.js +32 -32
  158. package/dist/field/lexical/plugins/toolbars/inline/Toolbar/index.js.map +1 -0
  159. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline/Toolbar}/index.scss +5 -4
  160. package/dist/field/lexical/plugins/toolbars/inline/ToolbarButton/index.d.ts +8 -0
  161. package/dist/field/lexical/plugins/toolbars/inline/ToolbarButton/index.d.ts.map +1 -0
  162. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarButton/index.js +9 -9
  163. package/dist/field/lexical/plugins/toolbars/inline/ToolbarButton/index.js.map +1 -0
  164. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarButton/index.scss +1 -1
  165. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarDropdown/DropDown.d.ts +3 -3
  166. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/DropDown.d.ts.map +1 -0
  167. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarDropdown/DropDown.js +12 -12
  168. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/DropDown.js.map +1 -0
  169. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarDropdown/index.d.ts +6 -6
  170. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/index.d.ts.map +1 -0
  171. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/index.js +42 -0
  172. package/dist/field/lexical/plugins/toolbars/inline/ToolbarDropdown/index.js.map +1 -0
  173. package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline}/ToolbarDropdown/index.scss +6 -6
  174. package/dist/field/lexical/plugins/toolbars/inline/types.d.ts +40 -0
  175. package/dist/field/lexical/plugins/toolbars/inline/types.d.ts.map +1 -0
  176. package/dist/field/lexical/plugins/toolbars/inline/types.js +3 -0
  177. package/dist/field/lexical/plugins/toolbars/inline/types.js.map +1 -0
  178. package/dist/field/lexical/theme/EditorTheme.scss +2 -6
  179. package/dist/index.d.ts +12 -11
  180. package/dist/index.d.ts.map +1 -1
  181. package/dist/index.js +11 -11
  182. package/dist/index.js.map +1 -1
  183. package/package.json +9 -9
  184. package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.d.ts +0 -3
  185. package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.d.ts.map +0 -1
  186. package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.js.map +0 -1
  187. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.d.ts +0 -3
  188. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.d.ts.map +0 -1
  189. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.js +0 -10
  190. package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.js.map +0 -1
  191. package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.d.ts +0 -3
  192. package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.d.ts.map +0 -1
  193. package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.js.map +0 -1
  194. package/dist/field/features/format/common/floatingSelectToolbarSection.d.ts +0 -3
  195. package/dist/field/features/format/common/floatingSelectToolbarSection.d.ts.map +0 -1
  196. package/dist/field/features/format/common/floatingSelectToolbarSection.js +0 -10
  197. package/dist/field/features/format/common/floatingSelectToolbarSection.js.map +0 -1
  198. package/dist/field/features/format/inlinecode/feature.client.js.map +0 -1
  199. package/dist/field/features/horizontalrule/feature.client.js.map +0 -1
  200. package/dist/field/features/indent/floatingSelectToolbarIndentSection.d.ts +0 -3
  201. package/dist/field/features/indent/floatingSelectToolbarIndentSection.d.ts.map +0 -1
  202. package/dist/field/features/indent/floatingSelectToolbarIndentSection.js +0 -10
  203. package/dist/field/features/indent/floatingSelectToolbarIndentSection.js.map +0 -1
  204. package/dist/field/features/indent/index.scss +0 -4
  205. package/dist/field/features/lists/orderedlist/feature.client.js.map +0 -1
  206. package/dist/field/features/lists/unorderedlist/feature.client.d.ts.map +0 -1
  207. package/dist/field/features/lists/unorderedlist/feature.client.js.map +0 -1
  208. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts +0 -8
  209. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts.map +0 -1
  210. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js.map +0 -1
  211. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.d.ts.map +0 -1
  212. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js.map +0 -1
  213. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.d.ts.map +0 -1
  214. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.js +0 -42
  215. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.js.map +0 -1
  216. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts.map +0 -1
  217. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +0 -1
  218. package/dist/field/lexical/plugins/FloatingSelectToolbar/types.d.ts.map +0 -1
  219. package/dist/field/lexical/plugins/FloatingSelectToolbar/types.js.map +0 -1
  220. /package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.d.ts +0 -0
  221. /package/dist/field/features/debug/{testrecorder → testRecorder}/feature.client.js +0 -0
  222. /package/dist/field/features/debug/{testrecorder → testRecorder}/feature.server.d.ts +0 -0
  223. /package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.d.ts +0 -0
  224. /package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.js +0 -0
  225. /package/dist/field/features/debug/{testrecorder → testRecorder}/plugin/index.scss +0 -0
  226. /package/dist/field/features/debug/{treeview → treeView}/feature.client.d.ts +0 -0
  227. /package/dist/field/features/debug/{treeview → treeView}/feature.client.js +0 -0
  228. /package/dist/field/features/debug/{treeview → treeView}/feature.server.d.ts +0 -0
  229. /package/dist/field/features/debug/{treeview → treeView}/plugin/index.d.ts +0 -0
  230. /package/dist/field/features/debug/{treeview → treeView}/plugin/index.js +0 -0
  231. /package/dist/field/features/debug/{treeview → treeView}/plugin/index.scss +0 -0
  232. /package/dist/field/features/format/{inlinecode → inlineCode}/feature.client.d.ts +0 -0
  233. /package/dist/field/features/format/{inlinecode → inlineCode}/feature.server.d.ts +0 -0
  234. /package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.d.ts +0 -0
  235. /package/dist/field/features/format/{inlinecode → inlineCode}/markdownTransformers.js +0 -0
  236. /package/dist/field/features/{horizontalrule → horizontalRule}/component/index.d.ts +0 -0
  237. /package/dist/field/features/{horizontalrule → horizontalRule}/component/index.js +0 -0
  238. /package/dist/field/features/{horizontalrule → horizontalRule}/feature.client.d.ts +0 -0
  239. /package/dist/field/features/{horizontalrule → horizontalRule}/feature.server.d.ts +0 -0
  240. /package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.d.ts +0 -0
  241. /package/dist/field/features/{horizontalrule → horizontalRule}/markdownTransformer.js +0 -0
  242. /package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.d.ts +0 -0
  243. /package/dist/field/features/{horizontalrule → horizontalRule}/nodes/HorizontalRuleNode.js +0 -0
  244. /package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.d.ts +0 -0
  245. /package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.js +0 -0
  246. /package/dist/field/features/{horizontalrule → horizontalRule}/plugin/index.scss +0 -0
  247. /package/dist/field/features/lists/{orderedlist → orderedList}/feature.client.d.ts +0 -0
  248. /package/dist/field/features/lists/{orderedlist → orderedList}/feature.server.d.ts +0 -0
  249. /package/dist/field/features/lists/{orderedlist → orderedList}/markdownTransformer.d.ts +0 -0
  250. /package/dist/field/features/lists/{common → shared}/markdown.d.ts +0 -0
  251. /package/dist/field/features/lists/{common → shared}/markdown.js +0 -0
  252. /package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.client.d.ts +0 -0
  253. /package/dist/field/features/lists/{unorderedlist → unorderedList}/feature.server.d.ts +0 -0
  254. /package/dist/field/features/lists/{unorderedlist → unorderedList}/markdownTransformer.d.ts +0 -0
  255. /package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/fixed}/types.js +0 -0
  256. /package/dist/field/lexical/plugins/{FloatingSelectToolbar → toolbars/inline/Toolbar}/index.d.ts +0 -0
@@ -28,7 +28,7 @@ const scrollIntoViewIfNeeded = (target)=>{
28
28
  */ function getFullMatchOffset(documentText, entryText, offset) {
29
29
  let triggerOffset = offset;
30
30
  for(let i = triggerOffset; i <= entryText.length; i++){
31
- if (documentText.substr(-i) === entryText.substr(0, i)) {
31
+ if (documentText.substring(documentText.length - i) === entryText.substring(0, i)) {
32
32
  triggerOffset = i;
33
33
  }
34
34
  }
@@ -139,50 +139,50 @@ export function useDynamicPositioning(resolution, targetElement, onReposition, o
139
139
  ]);
140
140
  }
141
141
  export const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND');
142
- export function LexicalMenu({ anchorElementRef, close, editor, // groupsWithOptions filtering is already handled in SlashMenu/index.tsx. Thus, groupsWithOptions always contains the matching options.
143
- groupsWithOptions, menuRenderFn, onSelectOption, resolution, shouldSplitNodeWithQuery = false }) {
144
- const [selectedOptionKey, setSelectedOptionKey] = useState(null);
142
+ export function LexicalMenu({ anchorElementRef, close, editor, // groups filtering is already handled in SlashMenu/index.tsx. Thus, groups always contains the matching items.
143
+ groups, menuRenderFn, onSelectItem, resolution, shouldSplitNodeWithQuery = false }) {
144
+ const [selectedItemKey, setSelectedItemKey] = useState(null);
145
145
  const matchingString = resolution.match && resolution.match.matchingString || '';
146
- const updateSelectedOption = useCallback((option)=>{
146
+ const updateSelectedItem = useCallback((item)=>{
147
147
  const rootElem = editor.getRootElement();
148
148
  if (rootElem !== null) {
149
- rootElem.setAttribute('aria-activedescendant', `${baseClass}__item-${option.key}`);
150
- setSelectedOptionKey(option.key);
149
+ rootElem.setAttribute('aria-activedescendant', `${baseClass}__item-${item.key}`);
150
+ setSelectedItemKey(item.key);
151
151
  }
152
152
  }, [
153
153
  editor
154
154
  ]);
155
- const setSelectedOptionKeyToFirstMatchingOption = useCallback(()=>{
156
- // set selected option to the first of the matching ones
157
- if (groupsWithOptions !== null && matchingString != null) {
158
- // groupsWithOptions filtering is already handled in SlashMenu/index.tsx. Thus, groupsWithOptions always contains the matching options.
159
- const allOptions = groupsWithOptions.flatMap((group)=>group.options);
160
- if (allOptions.length) {
161
- const firstMatchingOption = allOptions[0];
162
- updateSelectedOption(firstMatchingOption);
155
+ const setSelectedItemKeyToFirstMatchingItem = useCallback(()=>{
156
+ // set selected item to the first of the matching ones
157
+ if (groups !== null && matchingString != null) {
158
+ // groups filtering is already handled in SlashMenu/index.tsx. Thus, groups always contains the matching items.
159
+ const allItems = groups.flatMap((group)=>group.items);
160
+ if (allItems.length) {
161
+ const firstMatchingItem = allItems[0];
162
+ updateSelectedItem(firstMatchingItem);
163
163
  }
164
164
  }
165
165
  }, [
166
- groupsWithOptions,
167
- updateSelectedOption,
166
+ groups,
167
+ updateSelectedItem,
168
168
  matchingString
169
169
  ]);
170
170
  useEffect(()=>{
171
- setSelectedOptionKeyToFirstMatchingOption();
171
+ setSelectedItemKeyToFirstMatchingItem();
172
172
  }, [
173
173
  matchingString,
174
- setSelectedOptionKeyToFirstMatchingOption
174
+ setSelectedItemKeyToFirstMatchingItem
175
175
  ]);
176
- const selectOptionAndCleanUp = useCallback((selectedOption)=>{
176
+ const selectItemAndCleanUp = useCallback((selectedItem)=>{
177
177
  editor.update(()=>{
178
178
  const textNodeContainingQuery = resolution.match != null && shouldSplitNodeWithQuery ? $splitNodeContainingQuery(resolution.match) : null;
179
- onSelectOption(selectedOption, textNodeContainingQuery, close, resolution.match ? resolution.match.matchingString : '');
179
+ onSelectItem(selectedItem, textNodeContainingQuery, close, resolution.match ? resolution.match.matchingString : '');
180
180
  });
181
181
  }, [
182
182
  editor,
183
183
  shouldSplitNodeWithQuery,
184
184
  resolution.match,
185
- onSelectOption,
185
+ onSelectItem,
186
186
  close
187
187
  ]);
188
188
  useEffect(()=>{
@@ -196,42 +196,42 @@ groupsWithOptions, menuRenderFn, onSelectOption, resolution, shouldSplitNodeWith
196
196
  editor
197
197
  ]);
198
198
  useLayoutEffect(()=>{
199
- if (groupsWithOptions === null) {
200
- setSelectedOptionKey(null);
201
- } else if (selectedOptionKey === null) {
202
- setSelectedOptionKeyToFirstMatchingOption();
199
+ if (groups === null) {
200
+ setSelectedItemKey(null);
201
+ } else if (selectedItemKey === null) {
202
+ setSelectedItemKeyToFirstMatchingItem();
203
203
  }
204
204
  }, [
205
- groupsWithOptions,
206
- selectedOptionKey,
207
- updateSelectedOption,
208
- setSelectedOptionKeyToFirstMatchingOption
205
+ groups,
206
+ selectedItemKey,
207
+ updateSelectedItem,
208
+ setSelectedItemKeyToFirstMatchingItem
209
209
  ]);
210
210
  useEffect(()=>{
211
- return mergeRegister(editor.registerCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, ({ option })=>{
212
- if (option.ref && option.ref.current != null) {
213
- scrollIntoViewIfNeeded(option.ref.current);
211
+ return mergeRegister(editor.registerCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, ({ item })=>{
212
+ if (item.ref && item.ref.current != null) {
213
+ scrollIntoViewIfNeeded(item.ref.current);
214
214
  return true;
215
215
  }
216
216
  return false;
217
217
  }, COMMAND_PRIORITY_LOW));
218
218
  }, [
219
219
  editor,
220
- updateSelectedOption
220
+ updateSelectedItem
221
221
  ]);
222
222
  useEffect(()=>{
223
223
  return mergeRegister(editor.registerCommand(KEY_ARROW_DOWN_COMMAND, (payload)=>{
224
224
  const event = payload;
225
- if (groupsWithOptions !== null && groupsWithOptions.length && selectedOptionKey !== null) {
226
- const allOptions = groupsWithOptions.flatMap((group)=>group.options);
227
- const selectedIndex = allOptions.findIndex((option)=>option.key === selectedOptionKey);
228
- const newSelectedIndex = selectedIndex !== allOptions.length - 1 ? selectedIndex + 1 : 0;
229
- const newSelectedOption = allOptions[newSelectedIndex];
230
- updateSelectedOption(newSelectedOption);
231
- if (newSelectedOption.ref != null && newSelectedOption.ref.current) {
225
+ if (groups !== null && groups.length && selectedItemKey !== null) {
226
+ const allItems = groups.flatMap((group)=>group.items);
227
+ const selectedIndex = allItems.findIndex((item)=>item.key === selectedItemKey);
228
+ const newSelectedIndex = selectedIndex !== allItems.length - 1 ? selectedIndex + 1 : 0;
229
+ const newSelectedItem = allItems[newSelectedIndex];
230
+ updateSelectedItem(newSelectedItem);
231
+ if (newSelectedItem.ref != null && newSelectedItem.ref.current) {
232
232
  editor.dispatchCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, {
233
233
  index: newSelectedIndex,
234
- option: newSelectedOption
234
+ item: newSelectedItem
235
235
  });
236
236
  }
237
237
  event.preventDefault();
@@ -240,14 +240,14 @@ groupsWithOptions, menuRenderFn, onSelectOption, resolution, shouldSplitNodeWith
240
240
  return true;
241
241
  }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ARROW_UP_COMMAND, (payload)=>{
242
242
  const event = payload;
243
- if (groupsWithOptions !== null && groupsWithOptions.length && selectedOptionKey !== null) {
244
- const allOptions = groupsWithOptions.flatMap((group)=>group.options);
245
- const selectedIndex = allOptions.findIndex((option)=>option.key === selectedOptionKey);
246
- const newSelectedIndex = selectedIndex !== 0 ? selectedIndex - 1 : allOptions.length - 1;
247
- const newSelectedOption = allOptions[newSelectedIndex];
248
- updateSelectedOption(newSelectedOption);
249
- if (newSelectedOption.ref != null && newSelectedOption.ref.current) {
250
- scrollIntoViewIfNeeded(newSelectedOption.ref.current);
243
+ if (groups !== null && groups.length && selectedItemKey !== null) {
244
+ const allItems = groups.flatMap((group)=>group.items);
245
+ const selectedIndex = allItems.findIndex((item)=>item.key === selectedItemKey);
246
+ const newSelectedIndex = selectedIndex !== 0 ? selectedIndex - 1 : allItems.length - 1;
247
+ const newSelectedItem = allItems[newSelectedIndex];
248
+ updateSelectedItem(newSelectedItem);
249
+ if (newSelectedItem.ref != null && newSelectedItem.ref.current) {
250
+ scrollIntoViewIfNeeded(newSelectedItem.ref.current);
251
251
  }
252
252
  event.preventDefault();
253
253
  event.stopImmediatePropagation();
@@ -261,51 +261,51 @@ groupsWithOptions, menuRenderFn, onSelectOption, resolution, shouldSplitNodeWith
261
261
  return true;
262
262
  }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_TAB_COMMAND, (payload)=>{
263
263
  const event = payload;
264
- if (groupsWithOptions === null || selectedOptionKey === null) {
264
+ if (groups === null || selectedItemKey === null) {
265
265
  return false;
266
266
  }
267
- const allOptions = groupsWithOptions.flatMap((group)=>group.options);
268
- const selectedOption = allOptions.find((option)=>option.key === selectedOptionKey);
269
- if (!selectedOption) {
267
+ const allItems = groups.flatMap((group)=>group.items);
268
+ const selectedItem = allItems.find((item)=>item.key === selectedItemKey);
269
+ if (!selectedItem) {
270
270
  return false;
271
271
  }
272
272
  event.preventDefault();
273
273
  event.stopImmediatePropagation();
274
- selectOptionAndCleanUp(selectedOption);
274
+ selectItemAndCleanUp(selectedItem);
275
275
  return true;
276
276
  }, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ENTER_COMMAND, (event)=>{
277
- if (groupsWithOptions === null || selectedOptionKey === null) {
277
+ if (groups === null || selectedItemKey === null) {
278
278
  return false;
279
279
  }
280
- const allOptions = groupsWithOptions.flatMap((group)=>group.options);
281
- const selectedOption = allOptions.find((option)=>option.key === selectedOptionKey);
282
- if (!selectedOption) {
280
+ const allItems = groups.flatMap((group)=>group.items);
281
+ const selectedItem = allItems.find((item)=>item.key === selectedItemKey);
282
+ if (!selectedItem) {
283
283
  return false;
284
284
  }
285
285
  if (event !== null) {
286
286
  event.preventDefault();
287
287
  event.stopImmediatePropagation();
288
288
  }
289
- selectOptionAndCleanUp(selectedOption);
289
+ selectItemAndCleanUp(selectedItem);
290
290
  return true;
291
291
  }, COMMAND_PRIORITY_LOW));
292
292
  }, [
293
- selectOptionAndCleanUp,
293
+ selectItemAndCleanUp,
294
294
  close,
295
295
  editor,
296
- groupsWithOptions,
297
- selectedOptionKey,
298
- updateSelectedOption
296
+ groups,
297
+ selectedItemKey,
298
+ updateSelectedItem
299
299
  ]);
300
300
  const listItemProps = useMemo(()=>({
301
- groupsWithOptions,
302
- selectOptionAndCleanUp,
303
- selectedOptionKey,
304
- setSelectedOptionKey
301
+ groups,
302
+ selectItemAndCleanUp,
303
+ selectedItemKey,
304
+ setSelectedItemKey
305
305
  }), [
306
- selectOptionAndCleanUp,
307
- selectedOptionKey,
308
- groupsWithOptions
306
+ selectItemAndCleanUp,
307
+ selectedItemKey,
308
+ groups
309
309
  ]);
310
310
  return menuRenderFn(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : '');
311
311
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand, LexicalEditor, TextNode } from 'lexical'\nimport type { MutableRefObject, ReactPortal } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n COMMAND_PRIORITY_LOW,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_ENTER_COMMAND,\n KEY_ESCAPE_COMMAND,\n KEY_TAB_COMMAND,\n createCommand,\n} from 'lexical'\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport type { MenuTextMatch } from '../useMenuTriggerMatch.js'\nimport type { SlashMenuGroup, SlashMenuOption } from './types.js'\n\nexport type MenuResolution = {\n getRect: () => DOMRect\n match?: MenuTextMatch\n}\n\nconst baseClass = 'slash-menu-popup'\n\nexport type MenuRenderFn = (\n anchorElementRef: MutableRefObject<HTMLElement | null>,\n itemProps: {\n groupsWithOptions: Array<SlashMenuGroup>\n selectOptionAndCleanUp: (selectedOption: SlashMenuOption) => void\n selectedOptionKey: null | string\n setSelectedOptionKey: (optionKey: string) => void\n },\n matchingString: null | string,\n) => JSX.Element | ReactPortal | null\n\nconst scrollIntoViewIfNeeded = (target: HTMLElement) => {\n const typeaheadContainerNode = document.getElementById('slash-menu')\n if (!typeaheadContainerNode) return\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): number {\n let triggerOffset = offset\n for (let i = triggerOffset; i <= entryText.length; i++) {\n if (documentText.substr(-i) === entryText.substr(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 | null {\n const selection = $getSelection()\n if (!$isRangeSelection(selection) || !selection.isCollapsed()) {\n return null\n }\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return null\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return null\n }\n const selectionOffset = anchor.offset\n const textContent = anchorNode.getTextContent().slice(0, selectionOffset)\n // eslint-disable-next-line react/destructuring-assignment\n const characterOffset = match.replaceableString.length\n // eslint-disable-next-line react/destructuring-assignment\n const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset)\n const startOffset = selectionOffset - queryOffset\n if (startOffset < 0) {\n return null\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 targetElement: HTMLElement | null,\n onReposition: () => void,\n onVisibilityChange?: (isInView: boolean) => void,\n) {\n const [editor] = useLexicalComposerContext()\n useEffect(() => {\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.unobserve(targetElement)\n window.removeEventListener('resize', onReposition)\n document.removeEventListener('scroll', handleScroll, true)\n }\n }\n }, [targetElement, editor, onVisibilityChange, onReposition, resolution])\n}\n\nexport const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{\n index: number\n option: SlashMenuOption\n}> = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND')\n\nexport function LexicalMenu({\n anchorElementRef,\n close,\n editor,\n // groupsWithOptions filtering is already handled in SlashMenu/index.tsx. Thus, groupsWithOptions always contains the matching options.\n groupsWithOptions,\n menuRenderFn,\n onSelectOption,\n resolution,\n shouldSplitNodeWithQuery = false,\n}: {\n anchorElementRef: MutableRefObject<HTMLElement>\n close: () => void\n editor: LexicalEditor\n groupsWithOptions: Array<SlashMenuGroup>\n menuRenderFn: MenuRenderFn\n onSelectOption: (\n option: SlashMenuOption,\n textNodeContainingQuery: TextNode | null,\n closeMenu: () => void,\n matchingString: string,\n ) => void\n resolution: MenuResolution\n shouldSplitNodeWithQuery?: boolean\n}): JSX.Element | null {\n const [selectedOptionKey, setSelectedOptionKey] = useState<null | string>(null)\n\n const matchingString = (resolution.match && resolution.match.matchingString) || ''\n\n const updateSelectedOption = useCallback(\n (option: SlashMenuOption) => {\n const rootElem = editor.getRootElement()\n if (rootElem !== null) {\n rootElem.setAttribute('aria-activedescendant', `${baseClass}__item-${option.key}`)\n setSelectedOptionKey(option.key)\n }\n },\n [editor],\n )\n\n const setSelectedOptionKeyToFirstMatchingOption = useCallback(() => {\n // set selected option to the first of the matching ones\n if (groupsWithOptions !== null && matchingString != null) {\n // groupsWithOptions filtering is already handled in SlashMenu/index.tsx. Thus, groupsWithOptions always contains the matching options.\n const allOptions = groupsWithOptions.flatMap((group) => group.options)\n\n if (allOptions.length) {\n const firstMatchingOption = allOptions[0]\n updateSelectedOption(firstMatchingOption)\n }\n }\n }, [groupsWithOptions, updateSelectedOption, matchingString])\n\n useEffect(() => {\n setSelectedOptionKeyToFirstMatchingOption()\n }, [matchingString, setSelectedOptionKeyToFirstMatchingOption])\n\n const selectOptionAndCleanUp = useCallback(\n (selectedOption: SlashMenuOption) => {\n editor.update(() => {\n const textNodeContainingQuery =\n resolution.match != null && shouldSplitNodeWithQuery\n ? $splitNodeContainingQuery(resolution.match)\n : null\n\n onSelectOption(\n selectedOption,\n textNodeContainingQuery,\n close,\n resolution.match ? resolution.match.matchingString : '',\n )\n })\n },\n [editor, shouldSplitNodeWithQuery, resolution.match, onSelectOption, 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 (groupsWithOptions === null) {\n setSelectedOptionKey(null)\n } else if (selectedOptionKey === null) {\n setSelectedOptionKeyToFirstMatchingOption()\n }\n }, [\n groupsWithOptions,\n selectedOptionKey,\n updateSelectedOption,\n setSelectedOptionKeyToFirstMatchingOption,\n ])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,\n ({ option }) => {\n if (option.ref && option.ref.current != null) {\n scrollIntoViewIfNeeded(option.ref.current)\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateSelectedOption])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<KeyboardEvent>(\n KEY_ARROW_DOWN_COMMAND,\n (payload) => {\n const event = payload\n if (\n groupsWithOptions !== null &&\n groupsWithOptions.length &&\n selectedOptionKey !== null\n ) {\n const allOptions = groupsWithOptions.flatMap((group) => group.options)\n const selectedIndex = allOptions.findIndex((option) => option.key === selectedOptionKey)\n\n const newSelectedIndex = selectedIndex !== allOptions.length - 1 ? selectedIndex + 1 : 0\n\n const newSelectedOption = allOptions[newSelectedIndex]\n\n updateSelectedOption(newSelectedOption)\n if (newSelectedOption.ref != null && newSelectedOption.ref.current) {\n editor.dispatchCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, {\n index: newSelectedIndex,\n option: newSelectedOption,\n })\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_ARROW_UP_COMMAND,\n (payload) => {\n const event = payload\n if (\n groupsWithOptions !== null &&\n groupsWithOptions.length &&\n selectedOptionKey !== null\n ) {\n const allOptions = groupsWithOptions.flatMap((group) => group.options)\n const selectedIndex = allOptions.findIndex((option) => option.key === selectedOptionKey)\n\n const newSelectedIndex = selectedIndex !== 0 ? selectedIndex - 1 : allOptions.length - 1\n\n const newSelectedOption = allOptions[newSelectedIndex]\n\n updateSelectedOption(newSelectedOption)\n if (newSelectedOption.ref != null && newSelectedOption.ref.current) {\n scrollIntoViewIfNeeded(newSelectedOption.ref.current)\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\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 (groupsWithOptions === null || selectedOptionKey === null) {\n return false\n }\n const allOptions = groupsWithOptions.flatMap((group) => group.options)\n const selectedOption = allOptions.find((option) => option.key === selectedOptionKey)\n if (!selectedOption) {\n return false\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n selectOptionAndCleanUp(selectedOption)\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ENTER_COMMAND,\n (event: KeyboardEvent | null) => {\n if (groupsWithOptions === null || selectedOptionKey === null) {\n return false\n }\n const allOptions = groupsWithOptions.flatMap((group) => group.options)\n const selectedOption = allOptions.find((option) => option.key === selectedOptionKey)\n if (!selectedOption) {\n return false\n }\n\n if (event !== null) {\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n selectOptionAndCleanUp(selectedOption)\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [\n selectOptionAndCleanUp,\n close,\n editor,\n groupsWithOptions,\n selectedOptionKey,\n updateSelectedOption,\n ])\n\n const listItemProps = useMemo(\n () => ({\n groupsWithOptions,\n selectOptionAndCleanUp,\n selectedOptionKey,\n setSelectedOptionKey,\n }),\n [selectOptionAndCleanUp, selectedOptionKey, groupsWithOptions],\n )\n\n return menuRenderFn(\n anchorElementRef,\n listItemProps,\n resolution.match ? resolution.match.matchingString : '',\n )\n}\n\nexport function useMenuAnchorRef(\n anchorElem: HTMLElement,\n resolution: MenuResolution | null,\n setResolution: (r: MenuResolution | null) => void,\n className?: string,\n): MutableRefObject<HTMLElement> {\n const [editor] = useLexicalComposerContext()\n const anchorElementRef = useRef<HTMLElement>(document.createElement('div'))\n const positionMenu = useCallback(() => {\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 if (left + menuWidth > rootElementRect.right) {\n containerDiv.style.left = `${rootElementRect.right - menuWidth + 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 if (className != null) {\n containerDiv.className = className\n }\n containerDiv.setAttribute('aria-label', 'Slash menu')\n containerDiv.setAttribute('id', 'slash-menu')\n containerDiv.setAttribute('role', 'listbox')\n containerDiv.style.display = 'block'\n containerDiv.style.position = 'absolute'\n anchorElem.append(containerDiv)\n }\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 }\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.current, positionMenu, onVisibilityChange)\n\n return anchorElementRef\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","COMMAND_PRIORITY_LOW","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_ENTER_COMMAND","KEY_ESCAPE_COMMAND","KEY_TAB_COMMAND","createCommand","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","baseClass","scrollIntoViewIfNeeded","target","typeaheadContainerNode","document","getElementById","typeaheadRect","getBoundingClientRect","top","height","window","innerHeight","scrollIntoView","block","getFullMatchOffset","documentText","entryText","offset","triggerOffset","i","length","substr","$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","parent","parentElement","test","overflow","overflowY","overflowX","isTriggerVisibleInNearestScrollContainer","targetElement","containerElement","tRect","cRect","bottom","useDynamicPositioning","resolution","onReposition","onVisibilityChange","editor","rootElement","getRootElement","rootScrollParent","ticking","previousIsInView","handleScroll","requestAnimationFrame","isInView","resizeObserver","ResizeObserver","addEventListener","capture","passive","observe","unobserve","removeEventListener","SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND","LexicalMenu","anchorElementRef","close","groupsWithOptions","menuRenderFn","onSelectOption","shouldSplitNodeWithQuery","selectedOptionKey","setSelectedOptionKey","updateSelectedOption","option","rootElem","setAttribute","key","setSelectedOptionKeyToFirstMatchingOption","allOptions","flatMap","group","options","firstMatchingOption","selectOptionAndCleanUp","selectedOption","update","textNodeContainingQuery","removeAttribute","registerCommand","ref","current","payload","event","selectedIndex","findIndex","newSelectedIndex","newSelectedOption","dispatchCommand","index","preventDefault","stopImmediatePropagation","find","listItemProps","useMenuAnchorRef","anchorElem","setResolution","className","createElement","positionMenu","containerDiv","VERTICAL_OFFSET","menuEle","firstChild","width","getRect","left","rawTop","scrollY","scrollX","menuRect","menuHeight","menuWidth","rootElementRect","right","wouldGoOffBottomOfScreen","wouldGoOffTopOfScreen","margin","isConnected","display","append","remove"],"rangeMappings":";;;;;;;;;;;;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;QAAclE;KAAW;IAErC,MAAME,qBAAqBxE,YACzB,CAACiF;QACC,IAAIX,eAAe,MAAM;YACvB,IAAI,CAACW,UAAU;gBACboD,cAAc;YAChB;QACF;IACF,GACA;QAAC/D;QAAY+D;KAAc;IAG7BhE,sBAAsBC,YAAYsB,iBAAiB0B,OAAO,EAAEkB,cAAchE;IAE1E,OAAOoB;AACT"}
1
+ {"version":3,"sources":["../../../../../../src/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand, LexicalEditor, TextNode } from 'lexical'\nimport type { MutableRefObject, ReactPortal } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n COMMAND_PRIORITY_LOW,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_ENTER_COMMAND,\n KEY_ESCAPE_COMMAND,\n KEY_TAB_COMMAND,\n createCommand,\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\nexport type MenuResolution = {\n getRect: () => DOMRect\n match?: MenuTextMatch\n}\n\nconst baseClass = 'slash-menu-popup'\n\nexport type MenuRenderFn = (\n anchorElementRef: MutableRefObject<HTMLElement | null>,\n itemProps: {\n groups: Array<SlashMenuGroupInternal>\n selectItemAndCleanUp: (selectedItem: SlashMenuItem) => void\n selectedItemKey: null | string\n setSelectedItemKey: (itemKey: string) => void\n },\n matchingString: null | string,\n) => JSX.Element | ReactPortal | null\n\nconst scrollIntoViewIfNeeded = (target: HTMLElement) => {\n const typeaheadContainerNode = document.getElementById('slash-menu')\n if (!typeaheadContainerNode) return\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 | null {\n const selection = $getSelection()\n if (!$isRangeSelection(selection) || !selection.isCollapsed()) {\n return null\n }\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return null\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return null\n }\n const selectionOffset = anchor.offset\n const textContent = anchorNode.getTextContent().slice(0, selectionOffset)\n // eslint-disable-next-line react/destructuring-assignment\n const characterOffset = match.replaceableString.length\n // eslint-disable-next-line react/destructuring-assignment\n const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset)\n const startOffset = selectionOffset - queryOffset\n if (startOffset < 0) {\n return null\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 targetElement: HTMLElement | null,\n onReposition: () => void,\n onVisibilityChange?: (isInView: boolean) => void,\n) {\n const [editor] = useLexicalComposerContext()\n useEffect(() => {\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.unobserve(targetElement)\n window.removeEventListener('resize', onReposition)\n document.removeEventListener('scroll', handleScroll, true)\n }\n }\n }, [targetElement, editor, onVisibilityChange, onReposition, resolution])\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 onSelectItem,\n resolution,\n shouldSplitNodeWithQuery = false,\n}: {\n anchorElementRef: MutableRefObject<HTMLElement>\n close: () => void\n editor: LexicalEditor\n groups: Array<SlashMenuGroupInternal>\n menuRenderFn: MenuRenderFn\n onSelectItem: (\n item: SlashMenuItem,\n textNodeContainingQuery: TextNode | null,\n closeMenu: () => void,\n matchingString: string,\n ) => void\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 editor.update(() => {\n const textNodeContainingQuery =\n resolution.match != null && shouldSplitNodeWithQuery\n ? $splitNodeContainingQuery(resolution.match)\n : null\n\n onSelectItem(\n selectedItem,\n textNodeContainingQuery,\n close,\n resolution.match ? resolution.match.matchingString : '',\n )\n })\n },\n [editor, shouldSplitNodeWithQuery, resolution.match, onSelectItem, 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\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_LOW,\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\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_LOW,\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_LOW,\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_LOW,\n ),\n )\n }, [selectItemAndCleanUp, close, editor, groups, selectedItemKey, updateSelectedItem])\n\n const listItemProps = useMemo(\n () => ({\n groups,\n selectItemAndCleanUp,\n selectedItemKey,\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\nexport function useMenuAnchorRef(\n anchorElem: HTMLElement,\n resolution: MenuResolution | null,\n setResolution: (r: MenuResolution | null) => void,\n className?: string,\n): MutableRefObject<HTMLElement> {\n const [editor] = useLexicalComposerContext()\n const anchorElementRef = useRef<HTMLElement>(document.createElement('div'))\n const positionMenu = useCallback(() => {\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 if (left + menuWidth > rootElementRect.right) {\n containerDiv.style.left = `${rootElementRect.right - menuWidth + 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 if (className != null) {\n containerDiv.className = className\n }\n containerDiv.setAttribute('aria-label', 'Slash menu')\n containerDiv.setAttribute('id', 'slash-menu')\n containerDiv.setAttribute('role', 'listbox')\n containerDiv.style.display = 'block'\n containerDiv.style.position = 'absolute'\n anchorElem.append(containerDiv)\n }\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 }\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.current, positionMenu, onVisibilityChange)\n\n return anchorElementRef\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","COMMAND_PRIORITY_LOW","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_ENTER_COMMAND","KEY_ESCAPE_COMMAND","KEY_TAB_COMMAND","createCommand","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","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","parent","parentElement","test","overflow","overflowY","overflowX","isTriggerVisibleInNearestScrollContainer","targetElement","containerElement","tRect","cRect","bottom","useDynamicPositioning","resolution","onReposition","onVisibilityChange","editor","rootElement","getRootElement","rootScrollParent","ticking","previousIsInView","handleScroll","requestAnimationFrame","isInView","resizeObserver","ResizeObserver","addEventListener","capture","passive","observe","unobserve","removeEventListener","SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND","LexicalMenu","anchorElementRef","close","groups","menuRenderFn","onSelectItem","shouldSplitNodeWithQuery","selectedItemKey","setSelectedItemKey","updateSelectedItem","item","rootElem","setAttribute","key","setSelectedItemKeyToFirstMatchingItem","allItems","flatMap","group","items","firstMatchingItem","selectItemAndCleanUp","selectedItem","update","textNodeContainingQuery","removeAttribute","registerCommand","ref","current","payload","event","selectedIndex","findIndex","newSelectedIndex","newSelectedItem","dispatchCommand","index","preventDefault","stopImmediatePropagation","find","listItemProps","useMenuAnchorRef","anchorElem","setResolution","className","createElement","positionMenu","containerDiv","VERTICAL_OFFSET","menuEle","firstChild","width","getRect","left","rawTop","scrollY","scrollX","menuRect","menuHeight","menuWidth","rootElementRect","right","wouldGoOffBottomOfScreen","wouldGoOffTopOfScreen","margin","isConnected","display","append","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SACEC,aAAa,EACbC,iBAAiB,EACjBC,oBAAoB,EACpBC,sBAAsB,EACtBC,oBAAoB,EACpBC,iBAAiB,EACjBC,kBAAkB,EAClBC,eAAe,EACfC,aAAa,QACR,UAAS;AAChB,SAASC,WAAW,EAAEC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G,QAAQ,GAAG;gBAC9B8E,WAAWyB,MAAM,CAACpB;YACpB;YACA7C,iBAAiB0B,OAAO,GAAGmB;YAC3B/D,YAAY6B,YAAY,CAAC,iBAAiB;QAC5C;IACF,GAAG;QAAC9B;QAAQH;QAAYgE;QAAWF;KAAW;IAE9CnI,UAAU;QACR,MAAMyE,cAAcD,OAAOE,cAAc;QACzC,IAAIL,eAAe,MAAM;YACvBkE;YACA,OAAO;gBACL,IAAI9D,gBAAgB,MAAM;oBACxBA,YAAYyC,eAAe,CAAC;gBAC9B;gBAEA,MAAMsB,eAAe7C,iBAAiB0B,OAAO;gBAC7C,IAAImB,iBAAiB,QAAQA,aAAakB,WAAW,EAAE;oBACrDlB,aAAaqB,MAAM;gBACrB;YACF;QACF;IACF,GAAG;QAACrF;QAAQ+D;QAAclE;KAAW;IAErC,MAAME,qBAAqBxE,YACzB,CAACiF;QACC,IAAIX,eAAe,MAAM;YACvB,IAAI,CAACW,UAAU;gBACboD,cAAc;YAChB;QACF;IACF,GACA;QAAC/D;QAAY+D;KAAc;IAG7BhE,sBAAsBC,YAAYsB,iBAAiB0B,OAAO,EAAEkB,cAAchE;IAE1E,OAAOoB;AACT"}
@@ -2,24 +2,24 @@
2
2
  import type { LexicalCommand, ParagraphNode, TextNode } from 'lexical';
3
3
  import type { MenuTextMatch, TriggerFn } from '../useMenuTriggerMatch.js';
4
4
  import type { MenuRenderFn, MenuResolution } from './LexicalMenu.js';
5
- import type { SlashMenuGroup, SlashMenuOption } from './types.js';
5
+ import type { SlashMenuGroupInternal, SlashMenuItem } from './types.js';
6
6
  export declare const PUNCTUATION = "\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";
7
7
  export declare function getScrollParent(element: HTMLElement, includeHidden: boolean): HTMLBodyElement | HTMLElement;
8
8
  export { useDynamicPositioning } from './LexicalMenu.js';
9
9
  export type TypeaheadMenuPluginProps = {
10
10
  anchorClassName?: string;
11
11
  anchorElem: HTMLElement;
12
- groupsWithOptions: Array<SlashMenuGroup>;
12
+ groups: Array<SlashMenuGroupInternal>;
13
13
  menuRenderFn: MenuRenderFn;
14
14
  onClose?: () => void;
15
15
  onOpen?: (resolution: MenuResolution) => void;
16
16
  onQueryChange: (matchingString: null | string) => void;
17
- onSelectOption: (option: SlashMenuOption, textNodeContainingQuery: TextNode | null, closeMenu: () => void, matchingString: string) => void;
17
+ onSelectItem: (item: SlashMenuItem, textNodeContainingQuery: TextNode | null, closeMenu: () => void, matchingString: string) => void;
18
18
  triggerFn: TriggerFn;
19
19
  };
20
20
  export declare const ENABLE_SLASH_MENU_COMMAND: LexicalCommand<{
21
21
  node: ParagraphNode;
22
22
  }>;
23
- export declare function LexicalTypeaheadMenuPlugin({ anchorClassName, anchorElem, groupsWithOptions, menuRenderFn, onClose, onOpen, onQueryChange, onSelectOption, triggerFn, }: TypeaheadMenuPluginProps): JSX.Element | null;
23
+ export declare function LexicalTypeaheadMenuPlugin({ anchorClassName, anchorElem, groups, menuRenderFn, onClose, onOpen, onQueryChange, onSelectItem, triggerFn, }: TypeaheadMenuPluginProps): JSX.Element | null;
24
24
  export type { MenuRenderFn, MenuResolution, MenuTextMatch, TriggerFn };
25
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EACV,cAAc,EAEd,aAAa,EAEb,QAAQ,EACT,MAAM,SAAS,CAAA;AAchB,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjE,eAAO,MAAM,WAAW,iEAAiE,CAAA;AA4EzF,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,EACpB,aAAa,EAAE,OAAO,GACrB,eAAe,GAAG,WAAW,CAiB/B;AAED,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,MAAM,MAAM,wBAAwB,GAAG;IACrC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,WAAW,CAAA;IACvB,iBAAiB,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;IACxC,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAA;IAC7C,aAAa,EAAE,CAAC,cAAc,EAAE,IAAI,GAAG,MAAM,KAAK,IAAI,CAAA;IACtD,cAAc,EAAE,CACd,MAAM,EAAE,eAAe,EACvB,uBAAuB,EAAE,QAAQ,GAAG,IAAI,EACxC,SAAS,EAAE,MAAM,IAAI,EACrB,cAAc,EAAE,MAAM,KACnB,IAAI,CAAA;IACT,SAAS,EAAE,SAAS,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,cAAc,CAAC;IACrD,IAAI,EAAE,aAAa,CAAA;CACpB,CAA8C,CAAA;AAE/C,wBAAgB,0BAA0B,CAAC,EACzC,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,MAAM,EACN,aAAa,EACb,cAAc,EACd,SAAS,GACV,EAAE,wBAAwB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAyH/C;AAED,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EACV,cAAc,EAEd,aAAa,E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AAwB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAyH/C;AAED,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,CAAA"}
@@ -92,7 +92,7 @@ export function getScrollParent(element, includeHidden) {
92
92
  }
93
93
  export { useDynamicPositioning } from './LexicalMenu.js';
94
94
  export const ENABLE_SLASH_MENU_COMMAND = createCommand('ENABLE_SLASH_MENU_COMMAND');
95
- export function LexicalTypeaheadMenuPlugin({ anchorClassName, anchorElem, groupsWithOptions, menuRenderFn, onClose, onOpen, onQueryChange, onSelectOption, triggerFn }) {
95
+ export function LexicalTypeaheadMenuPlugin({ anchorClassName, anchorElem, groups, menuRenderFn, onClose, onOpen, onQueryChange, onSelectItem, triggerFn }) {
96
96
  const [editor] = useLexicalComposerContext();
97
97
  const [resolution, setResolution] = useState(null);
98
98
  const anchorElementRef = useMenuAnchorRef(anchorElem, resolution, setResolution, anchorClassName);
@@ -193,9 +193,9 @@ export function LexicalTypeaheadMenuPlugin({ anchorClassName, anchorElem, groups
193
193
  anchorElementRef: anchorElementRef,
194
194
  close: closeTypeahead,
195
195
  editor: editor,
196
- groupsWithOptions: groupsWithOptions,
196
+ groups: groups,
197
197
  menuRenderFn: menuRenderFn,
198
- onSelectOption: onSelectOption,
198
+ onSelectItem: onSelectItem,
199
199
  resolution: resolution,
200
200
  shouldSplitNodeWithQuery: true
201
201
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type {\n LexicalCommand,\n LexicalEditor,\n ParagraphNode,\n RangeSelection,\n TextNode,\n} from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n createCommand,\n} from 'lexical'\nimport { useCallback, useEffect, useState } from 'react'\nimport * as React from 'react'\n\nimport type { MenuTextMatch, TriggerFn } from '../useMenuTriggerMatch.js'\nimport type { MenuRenderFn, MenuResolution } from './LexicalMenu.js'\nimport type { SlashMenuGroup, SlashMenuOption } from './types.js'\n\nimport { LexicalMenu, useMenuAnchorRef } from './LexicalMenu.js'\n\nexport const PUNCTUATION = '\\\\.,\\\\+\\\\*\\\\?\\\\$\\\\@\\\\|#{}\\\\(\\\\)\\\\^\\\\-\\\\[\\\\]\\\\\\\\/!%\\'\"~=<>_:;'\n\nfunction getTextUpToAnchor(selection: RangeSelection): null | string {\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return null\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return null\n }\n const anchorOffset = anchor.offset\n return anchorNode.getTextContent().slice(0, anchorOffset)\n}\n\nfunction tryToPositionRange(leadOffset: number, range: Range, editorWindow: Window): boolean {\n const domSelection = editorWindow.getSelection()\n if (domSelection === null || !domSelection.isCollapsed) {\n return false\n }\n const anchorNode = domSelection.anchorNode\n const startOffset = leadOffset\n const endOffset = domSelection.anchorOffset\n\n if (anchorNode == null || endOffset == null) {\n return false\n }\n\n try {\n range.setStart(anchorNode, startOffset)\n // if endOffset is 0, positioning the range for when you click the plus button to open the slash menu will fial\n range.setEnd(anchorNode, endOffset > 1 ? endOffset : 1)\n } catch (error) {\n return false\n }\n\n return true\n}\n\nfunction getQueryTextForSearch(editor: LexicalEditor): null | string {\n let text = null\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) {\n return\n }\n text = getTextUpToAnchor(selection)\n })\n return text\n}\n\nfunction isSelectionOnEntityBoundary(editor: LexicalEditor, offset: number): boolean {\n if (offset !== 0) {\n return false\n }\n return editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const anchor = selection.anchor\n const anchorNode = anchor.getNode()\n const prevSibling = anchorNode.getPreviousSibling()\n return $isTextNode(prevSibling) && prevSibling.isTextEntity()\n }\n return false\n })\n}\n\nfunction startTransition(callback: () => void) {\n if (React.startTransition) {\n React.startTransition(callback)\n } else {\n callback()\n }\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\nexport { useDynamicPositioning } from './LexicalMenu.js'\n\nexport type TypeaheadMenuPluginProps = {\n anchorClassName?: string\n anchorElem: HTMLElement\n groupsWithOptions: Array<SlashMenuGroup>\n menuRenderFn: MenuRenderFn\n onClose?: () => void\n onOpen?: (resolution: MenuResolution) => void\n onQueryChange: (matchingString: null | string) => void\n onSelectOption: (\n option: SlashMenuOption,\n textNodeContainingQuery: TextNode | null,\n closeMenu: () => void,\n matchingString: string,\n ) => void\n triggerFn: TriggerFn\n}\n\nexport const ENABLE_SLASH_MENU_COMMAND: LexicalCommand<{\n node: ParagraphNode\n}> = createCommand('ENABLE_SLASH_MENU_COMMAND')\n\nexport function LexicalTypeaheadMenuPlugin({\n anchorClassName,\n anchorElem,\n groupsWithOptions,\n menuRenderFn,\n onClose,\n onOpen,\n onQueryChange,\n onSelectOption,\n triggerFn,\n}: TypeaheadMenuPluginProps): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n const [resolution, setResolution] = useState<MenuResolution | null>(null)\n const anchorElementRef = useMenuAnchorRef(anchorElem, resolution, setResolution, anchorClassName)\n\n const closeTypeahead = useCallback(() => {\n setResolution(null)\n if (onClose != null && resolution !== null) {\n onClose()\n }\n }, [onClose, resolution])\n\n const openTypeahead = useCallback(\n (res: MenuResolution) => {\n setResolution(res)\n if (onOpen != null && resolution === null) {\n onOpen(res)\n }\n },\n [onOpen, resolution],\n )\n\n // This is mainly used for the AddBlockHandlePlugin, so that the slash menu can be opened from there\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n ENABLE_SLASH_MENU_COMMAND,\n ({ node }) => {\n editor.getEditorState().read(() => {\n const match: MenuTextMatch = {\n leadOffset: 0,\n matchingString: '',\n replaceableString: '',\n }\n if (match !== null && !isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n if (node !== null) {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n }\n\n return\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, openTypeahead])\n\n useEffect(() => {\n const updateListener = () => {\n editor.getEditorState().read(() => {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n const selection = $getSelection()\n const text = getQueryTextForSearch(editor)\n\n if (\n !$isRangeSelection(selection) ||\n !selection.isCollapsed() ||\n text === null ||\n range === null\n ) {\n closeTypeahead()\n return\n }\n\n const match = triggerFn({ editor, query: text })\n onQueryChange(match ? match.matchingString : null)\n\n if (match !== null && !isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n return\n }\n }\n closeTypeahead()\n })\n }\n\n const removeUpdateListener = editor.registerUpdateListener(updateListener)\n\n return () => {\n removeUpdateListener()\n }\n }, [editor, triggerFn, onQueryChange, resolution, closeTypeahead, openTypeahead])\n\n return resolution === null || editor === null ? null : (\n <LexicalMenu\n anchorElementRef={anchorElementRef}\n close={closeTypeahead}\n editor={editor}\n groupsWithOptions={groupsWithOptions}\n menuRenderFn={menuRenderFn}\n onSelectOption={onSelectOption}\n resolution={resolution}\n shouldSplitNodeWithQuery\n />\n )\n}\n\nexport type { MenuRenderFn, MenuResolution, MenuTextMatch, TriggerFn }\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","createCommand","useCallback","useEffect","useState","React","LexicalMenu","useMenuAnchorRef","PUNCTUATION","getTextUpToAnchor","selection","anchor","type","anchorNode","getNode","isSimpleText","anchorOffset","offset","getTextContent","slice","tryToPositionRange","leadOffset","range","editorWindow","domSelection","getSelection","isCollapsed","startOffset","endOffset","setStart","setEnd","error","getQueryTextForSearch","editor","text","getEditorState","read","isSelectionOnEntityBoundary","prevSibling","getPreviousSibling","isTextEntity","startTransition","callback","getScrollParent","element","includeHidden","style","getComputedStyle","excludeStaticParent","position","overflowRegex","document","body","parent","parentElement","test","overflow","overflowY","overflowX","useDynamicPositioning","ENABLE_SLASH_MENU_COMMAND","LexicalTypeaheadMenuPlugin","anchorClassName","anchorElem","groupsWithOptions","menuRenderFn","onClose","onOpen","onQueryChange","onSelectOption","triggerFn","resolution","setResolution","anchorElementRef","closeTypeahead","openTypeahead","res","registerCommand","node","match","matchingString","replaceableString","_window","window","createRange","isRangePositioned","getRect","getBoundingClientRect","updateListener","query","removeUpdateListener","registerUpdateListener","close","shouldSplitNodeWithQuery"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AASA,SAASA,yBAAy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AMqF,iBAAiB;YACrBvD,OAAOE,cAAc,GAAGC,IAAI,CAAC;gBAC3B,MAAMb,eAAeU,OAAOiD,OAAO,IAAIC;gBACvC,MAAM7D,QAAQC,aAAa4B,QAAQ,CAACiC,WAAW;gBAC/C,MAAM1E,YAAYb;gBAClB,MAAMqC,OAAOF,sBAAsBC;gBAEnC,IACE,CAACnC,kBAAkBY,cACnB,CAACA,UAAUgB,WAAW,MACtBQ,SAAS,QACTZ,UAAU,MACV;oBACAoD;oBACA;gBACF;gBAEA,MAAMK,QAAQT,UAAU;oBAAErC;oBAAQwD,OAAOvD;gBAAK;gBAC9CkC,cAAcW,QAAQA,MAAMC,cAAc,GAAG;gBAE7C,IAAID,UAAU,QAAQ,CAAC1C,4BAA4BJ,QAAQ8C,MAAM1D,UAAU,GAAG;oBAC5E,MAAMgE,oBAAoBjE,mBAAmB2D,MAAM1D,UAAU,EAAEC,OAAOC;oBACtE,IAAI8D,sBAAsB,MAAM;wBAC9B5C,gBAAgB,IACdkC,cAAc;gCACZW,SAAS;oCACP,OAAOhE,MAAMiE,qBAAqB;gCACpC;gCACAR;4BACF;wBAEF;oBACF;gBACF;gBACAL;YACF;QACF;QAEA,MAAMgB,uBAAuBzD,OAAO0D,sBAAsB,CAACH;QAE3D,OAAO;YACLE;QACF;IACF,GAAG;QAACzD;QAAQqC;QAAWF;QAAeG;QAAYG;QAAgBC;KAAc;IAEhF,OAAOJ,eAAe,QAAQtC,WAAW,OAAO,qBAC9C,oBAAC3B;QACCmE,kBAAkBA;QAClBmB,OAAOlB;QACPzC,QAAQA;QACR+B,mBAAmBA;QACnBC,cAAcA;QACdI,gBAAgBA;QAChBE,YAAYA;QACZsB,0BAAAA;;AAGN"}
1
+ {"version":3,"sources":["../../../../../../src/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type {\n LexicalCommand,\n LexicalEditor,\n ParagraphNode,\n RangeSelection,\n TextNode,\n} from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n createCommand,\n} from 'lexical'\nimport { useCallback, useEffect, useState } from 'react'\nimport * as React from 'react'\n\nimport type { MenuTextMatch, TriggerFn } from '../useMenuTriggerMatch.js'\nimport type { MenuRenderFn, MenuResolution } from './LexicalMenu.js'\nimport type { SlashMenuGroup, SlashMenuGroupInternal, SlashMenuItem } from './types.js'\n\nimport { LexicalMenu, useMenuAnchorRef } from './LexicalMenu.js'\n\nexport const PUNCTUATION = '\\\\.,\\\\+\\\\*\\\\?\\\\$\\\\@\\\\|#{}\\\\(\\\\)\\\\^\\\\-\\\\[\\\\]\\\\\\\\/!%\\'\"~=<>_:;'\n\nfunction getTextUpToAnchor(selection: RangeSelection): null | string {\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return null\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return null\n }\n const anchorOffset = anchor.offset\n return anchorNode.getTextContent().slice(0, anchorOffset)\n}\n\nfunction tryToPositionRange(leadOffset: number, range: Range, editorWindow: Window): boolean {\n const domSelection = editorWindow.getSelection()\n if (domSelection === null || !domSelection.isCollapsed) {\n return false\n }\n const anchorNode = domSelection.anchorNode\n const startOffset = leadOffset\n const endOffset = domSelection.anchorOffset\n\n if (anchorNode == null || endOffset == null) {\n return false\n }\n\n try {\n range.setStart(anchorNode, startOffset)\n // if endOffset is 0, positioning the range for when you click the plus button to open the slash menu will fial\n range.setEnd(anchorNode, endOffset > 1 ? endOffset : 1)\n } catch (error) {\n return false\n }\n\n return true\n}\n\nfunction getQueryTextForSearch(editor: LexicalEditor): null | string {\n let text = null\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (!$isRangeSelection(selection)) {\n return\n }\n text = getTextUpToAnchor(selection)\n })\n return text\n}\n\nfunction isSelectionOnEntityBoundary(editor: LexicalEditor, offset: number): boolean {\n if (offset !== 0) {\n return false\n }\n return editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const anchor = selection.anchor\n const anchorNode = anchor.getNode()\n const prevSibling = anchorNode.getPreviousSibling()\n return $isTextNode(prevSibling) && prevSibling.isTextEntity()\n }\n return false\n })\n}\n\nfunction startTransition(callback: () => void) {\n if (React.startTransition) {\n React.startTransition(callback)\n } else {\n callback()\n }\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\nexport { useDynamicPositioning } from './LexicalMenu.js'\n\nexport type TypeaheadMenuPluginProps = {\n anchorClassName?: string\n anchorElem: HTMLElement\n groups: Array<SlashMenuGroupInternal>\n menuRenderFn: MenuRenderFn\n onClose?: () => void\n onOpen?: (resolution: MenuResolution) => void\n onQueryChange: (matchingString: null | string) => void\n onSelectItem: (\n item: SlashMenuItem,\n textNodeContainingQuery: TextNode | null,\n closeMenu: () => void,\n matchingString: string,\n ) => void\n triggerFn: TriggerFn\n}\n\nexport const ENABLE_SLASH_MENU_COMMAND: LexicalCommand<{\n node: ParagraphNode\n}> = createCommand('ENABLE_SLASH_MENU_COMMAND')\n\nexport function LexicalTypeaheadMenuPlugin({\n anchorClassName,\n anchorElem,\n groups,\n menuRenderFn,\n onClose,\n onOpen,\n onQueryChange,\n onSelectItem,\n triggerFn,\n}: TypeaheadMenuPluginProps): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n const [resolution, setResolution] = useState<MenuResolution | null>(null)\n const anchorElementRef = useMenuAnchorRef(anchorElem, resolution, setResolution, anchorClassName)\n\n const closeTypeahead = useCallback(() => {\n setResolution(null)\n if (onClose != null && resolution !== null) {\n onClose()\n }\n }, [onClose, resolution])\n\n const openTypeahead = useCallback(\n (res: MenuResolution) => {\n setResolution(res)\n if (onOpen != null && resolution === null) {\n onOpen(res)\n }\n },\n [onOpen, resolution],\n )\n\n // This is mainly used for the AddBlockHandlePlugin, so that the slash menu can be opened from there\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n ENABLE_SLASH_MENU_COMMAND,\n ({ node }) => {\n editor.getEditorState().read(() => {\n const match: MenuTextMatch = {\n leadOffset: 0,\n matchingString: '',\n replaceableString: '',\n }\n if (match !== null && !isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n if (node !== null) {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n }\n\n return\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, openTypeahead])\n\n useEffect(() => {\n const updateListener = () => {\n editor.getEditorState().read(() => {\n const editorWindow = editor._window ?? window\n const range = editorWindow.document.createRange()\n const selection = $getSelection()\n const text = getQueryTextForSearch(editor)\n\n if (\n !$isRangeSelection(selection) ||\n !selection.isCollapsed() ||\n text === null ||\n range === null\n ) {\n closeTypeahead()\n return\n }\n\n const match = triggerFn({ editor, query: text })\n onQueryChange(match ? match.matchingString : null)\n\n if (match !== null && !isSelectionOnEntityBoundary(editor, match.leadOffset)) {\n const isRangePositioned = tryToPositionRange(match.leadOffset, range, editorWindow)\n if (isRangePositioned !== null) {\n startTransition(() =>\n openTypeahead({\n getRect: () => {\n return range.getBoundingClientRect()\n },\n match,\n }),\n )\n return\n }\n }\n closeTypeahead()\n })\n }\n\n const removeUpdateListener = editor.registerUpdateListener(updateListener)\n\n return () => {\n removeUpdateListener()\n }\n }, [editor, triggerFn, onQueryChange, resolution, closeTypeahead, openTypeahead])\n\n return resolution === null || editor === null ? null : (\n <LexicalMenu\n anchorElementRef={anchorElementRef}\n close={closeTypeahead}\n editor={editor}\n groups={groups}\n menuRenderFn={menuRenderFn}\n onSelectItem={onSelectItem}\n resolution={resolution}\n shouldSplitNodeWithQuery\n />\n )\n}\n\nexport type { MenuRenderFn, MenuResolution, MenuTextMatch, TriggerFn }\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","createCommand","useCallback","useEffect","useState","React","LexicalMenu","useMenuAnchorRef","PUNCTUATION","getTextUpToAnchor","selection","anchor","type","anchorNode","getNode","isSimpleText","anchorOffset","offset","getTextContent","slice","tryToPositionRange","leadOffset","range","editorWindow","domSelection","getSelection","isCollapsed","startOffset","endOffset","setStart","setEnd","error","getQueryTextForSearch","editor","text","getEditorState","read","isSelectionOnEntityBoundary","prevSibling","getPreviousSibling","isTextEntity","startTransition","callback","getScrollParent","element","includeHidden","style","getComputedStyle","excludeStaticParent","position","overflowRegex","document","body","parent","parentElement","test","overflow","overflowY","overflowX","useDynamicPositioning","ENABLE_SLASH_MENU_COMMAND","LexicalTypeaheadMenuPlugin","anchorClassName","anchorElem","groups","menuRenderFn","onClose","onOpen","onQueryChange","onSelectItem","triggerFn","resolution","setResolution","anchorElementRef","closeTypeahead","openTypeahead","res","registerCommand","node","match","matchingString","replaceableString","_window","window","createRange","isRangePositioned","getRect","getBoundingClientRect","updateListener","query","removeUpdateListener","registerUpdateListener","close","shouldSplitNodeWithQuery"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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from '@payloadcms/translations';
2
2
  import type { LexicalEditor } from 'lexical';
3
3
  import type { MutableRefObject } from 'react';
4
4
  import type React from 'react';
5
- export declare class SlashMenuOption {
5
+ export type SlashMenuItem = {
6
6
  Icon: React.FC;
7
7
  displayName?: (({ i18n }: {
8
8
  i18n: I18n;
9
9
  }) => string) | string;
10
10
  key: string;
11
11
  keyboardShortcut?: string;
12
- keywords: Array<string>;
12
+ keywords?: Array<string>;
13
13
  onSelect: ({ editor, queryString }: {
14
14
  editor: LexicalEditor;
15
15
  queryString: string;
16
16
  }) => void;
17
- ref?: MutableRefObject<HTMLElement | null>;
18
- constructor(key: string, options: {
19
- Icon: React.FC;
20
- displayName?: (({ i18n }: {
21
- i18n: I18n;
22
- }) => string) | string;
23
- keyboardShortcut?: string;
24
- keywords?: Array<string>;
25
- onSelect: ({ editor, queryString }: {
26
- editor: LexicalEditor;
27
- queryString: string;
28
- }) => void;
29
- });
30
- setRefElement(element: HTMLElement | null): void;
31
- }
32
- export declare class SlashMenuGroup {
17
+ };
18
+ export type SlashMenuGroup = {
33
19
  displayName?: (({ i18n }: {
34
20
  i18n: I18n;
35
21
  }) => string) | string;
22
+ items: Array<SlashMenuItem>;
36
23
  key: string;
37
- options: Array<SlashMenuOption>;
38
- }
24
+ };
25
+ export type SlashMenuItemInternal = SlashMenuItem & {
26
+ ref: MutableRefObject<HTMLButtonElement | null>;
27
+ };
28
+ export type SlashMenuGroupInternal = SlashMenuGroup & {
29
+ items: Array<SlashMenuItemInternal>;
30
+ };
39
31
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EAAE,g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