@payloadcms/richtext-lexical 3.0.0-beta.19 → 3.0.0-beta.20

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 (266) hide show
  1. package/dist/cell/index.d.ts +1 -1
  2. package/dist/cell/index.d.ts.map +1 -1
  3. package/dist/cell/index.js +2 -4
  4. package/dist/cell/index.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 +1 -2
  7. package/dist/field/features/align/feature.client.js.map +1 -1
  8. package/dist/field/features/blockquote/feature.client.d.ts.map +1 -1
  9. package/dist/field/features/blockquote/feature.client.js +3 -6
  10. package/dist/field/features/blockquote/feature.client.js.map +1 -1
  11. package/dist/field/features/blockquote/feature.server.d.ts.map +1 -1
  12. package/dist/field/features/blockquote/feature.server.js +1 -2
  13. package/dist/field/features/blockquote/feature.server.js.map +1 -1
  14. package/dist/field/features/blockquote/markdownTransformer.d.ts.map +1 -1
  15. package/dist/field/features/blockquote/markdownTransformer.js +2 -4
  16. package/dist/field/features/blockquote/markdownTransformer.js.map +1 -1
  17. package/dist/field/features/blocks/component/BlockContent.d.ts.map +1 -1
  18. package/dist/field/features/blocks/component/BlockContent.js +3 -5
  19. package/dist/field/features/blocks/component/BlockContent.js.map +1 -1
  20. package/dist/field/features/blocks/drawer/index.d.ts.map +1 -1
  21. package/dist/field/features/blocks/drawer/index.js +2 -4
  22. package/dist/field/features/blocks/drawer/index.js.map +1 -1
  23. package/dist/field/features/blocks/nodes/BlocksNode.d.ts +1 -3
  24. package/dist/field/features/blocks/nodes/BlocksNode.d.ts.map +1 -1
  25. package/dist/field/features/blocks/nodes/BlocksNode.js +1 -2
  26. package/dist/field/features/blocks/nodes/BlocksNode.js.map +1 -1
  27. package/dist/field/features/blocks/plugin/commands.d.ts.map +1 -1
  28. package/dist/field/features/blocks/plugin/commands.js +1 -2
  29. package/dist/field/features/blocks/plugin/commands.js.map +1 -1
  30. package/dist/field/features/blocks/plugin/index.d.ts.map +1 -1
  31. package/dist/field/features/blocks/plugin/index.js +3 -6
  32. package/dist/field/features/blocks/plugin/index.js.map +1 -1
  33. package/dist/field/features/debug/testrecorder/plugin/index.d.ts.map +1 -1
  34. package/dist/field/features/debug/testrecorder/plugin/index.js +2 -4
  35. package/dist/field/features/debug/testrecorder/plugin/index.js.map +1 -1
  36. package/dist/field/features/debug/treeview/plugin/index.d.ts.map +1 -1
  37. package/dist/field/features/debug/treeview/plugin/index.js +2 -4
  38. package/dist/field/features/debug/treeview/plugin/index.js.map +1 -1
  39. package/dist/field/features/format/bold/feature.client.d.ts.map +1 -1
  40. package/dist/field/features/format/bold/feature.client.js +1 -2
  41. package/dist/field/features/format/bold/feature.client.js.map +1 -1
  42. package/dist/field/features/format/inlinecode/feature.client.d.ts.map +1 -1
  43. package/dist/field/features/format/inlinecode/feature.client.js +1 -2
  44. package/dist/field/features/format/inlinecode/feature.client.js.map +1 -1
  45. package/dist/field/features/format/italic/feature.client.d.ts.map +1 -1
  46. package/dist/field/features/format/italic/feature.client.js +1 -2
  47. package/dist/field/features/format/italic/feature.client.js.map +1 -1
  48. package/dist/field/features/format/strikethrough/feature.client.d.ts.map +1 -1
  49. package/dist/field/features/format/strikethrough/feature.client.js +1 -2
  50. package/dist/field/features/format/strikethrough/feature.client.js.map +1 -1
  51. package/dist/field/features/format/subscript/feature.client.d.ts.map +1 -1
  52. package/dist/field/features/format/subscript/feature.client.js +1 -2
  53. package/dist/field/features/format/subscript/feature.client.js.map +1 -1
  54. package/dist/field/features/format/superscript/feature.client.d.ts.map +1 -1
  55. package/dist/field/features/format/superscript/feature.client.js +1 -2
  56. package/dist/field/features/format/superscript/feature.client.js.map +1 -1
  57. package/dist/field/features/format/underline/feature.client.d.ts.map +1 -1
  58. package/dist/field/features/format/underline/feature.client.js +1 -2
  59. package/dist/field/features/format/underline/feature.client.js.map +1 -1
  60. package/dist/field/features/heading/feature.client.d.ts.map +1 -1
  61. package/dist/field/features/heading/feature.client.js +3 -6
  62. package/dist/field/features/heading/feature.client.js.map +1 -1
  63. package/dist/field/features/heading/feature.server.d.ts.map +1 -1
  64. package/dist/field/features/heading/feature.server.js +1 -2
  65. package/dist/field/features/heading/feature.server.js.map +1 -1
  66. package/dist/field/features/heading/markdownTransformer.d.ts.map +1 -1
  67. package/dist/field/features/heading/markdownTransformer.js +1 -2
  68. package/dist/field/features/heading/markdownTransformer.js.map +1 -1
  69. package/dist/field/features/horizontalrule/component/index.d.ts.map +1 -1
  70. package/dist/field/features/horizontalrule/component/index.js +2 -4
  71. package/dist/field/features/horizontalrule/component/index.js.map +1 -1
  72. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.d.ts +1 -3
  73. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.d.ts.map +1 -1
  74. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.js +1 -2
  75. package/dist/field/features/horizontalrule/nodes/HorizontalRuleNode.js.map +1 -1
  76. package/dist/field/features/horizontalrule/plugin/index.d.ts.map +1 -1
  77. package/dist/field/features/horizontalrule/plugin/index.js +3 -6
  78. package/dist/field/features/horizontalrule/plugin/index.js.map +1 -1
  79. package/dist/field/features/indent/feature.client.d.ts.map +1 -1
  80. package/dist/field/features/indent/feature.client.js +1 -2
  81. package/dist/field/features/indent/feature.client.js.map +1 -1
  82. package/dist/field/features/link/feature.client.d.ts.map +1 -1
  83. package/dist/field/features/link/feature.client.js +2 -4
  84. package/dist/field/features/link/feature.client.js.map +1 -1
  85. package/dist/field/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
  86. package/dist/field/features/link/nodes/AutoLinkNode.js +1 -2
  87. package/dist/field/features/link/nodes/AutoLinkNode.js.map +1 -1
  88. package/dist/field/features/link/nodes/LinkNode.d.ts +1 -3
  89. package/dist/field/features/link/nodes/LinkNode.d.ts.map +1 -1
  90. package/dist/field/features/link/nodes/LinkNode.js +2 -4
  91. package/dist/field/features/link/nodes/LinkNode.js.map +1 -1
  92. package/dist/field/features/link/plugins/autoLink/index.d.ts.map +1 -1
  93. package/dist/field/features/link/plugins/autoLink/index.js +3 -6
  94. package/dist/field/features/link/plugins/autoLink/index.js.map +1 -1
  95. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.d.ts.map +1 -1
  96. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.js +1 -2
  97. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.js.map +1 -1
  98. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  99. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +20 -17
  100. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  101. package/dist/field/features/link/plugins/link/index.js +3 -6
  102. package/dist/field/features/link/plugins/link/index.js.map +1 -1
  103. package/dist/field/features/lists/checklist/feature.client.d.ts.map +1 -1
  104. package/dist/field/features/lists/checklist/feature.client.js +1 -2
  105. package/dist/field/features/lists/checklist/feature.client.js.map +1 -1
  106. package/dist/field/features/lists/checklist/feature.server.d.ts.map +1 -1
  107. package/dist/field/features/lists/checklist/feature.server.js +1 -2
  108. package/dist/field/features/lists/checklist/feature.server.js.map +1 -1
  109. package/dist/field/features/lists/checklist/markdownTransformers.d.ts.map +1 -1
  110. package/dist/field/features/lists/checklist/markdownTransformers.js +1 -2
  111. package/dist/field/features/lists/checklist/markdownTransformers.js.map +1 -1
  112. package/dist/field/features/lists/checklist/plugin/index.d.ts.map +1 -1
  113. package/dist/field/features/lists/checklist/plugin/index.js +1 -2
  114. package/dist/field/features/lists/checklist/plugin/index.js.map +1 -1
  115. package/dist/field/features/lists/common/markdown.d.ts.map +1 -1
  116. package/dist/field/features/lists/common/markdown.js +1 -2
  117. package/dist/field/features/lists/common/markdown.js.map +1 -1
  118. package/dist/field/features/lists/htmlConverter.d.ts.map +1 -1
  119. package/dist/field/features/lists/htmlConverter.js +1 -2
  120. package/dist/field/features/lists/htmlConverter.js.map +1 -1
  121. package/dist/field/features/lists/orderedlist/feature.client.d.ts.map +1 -1
  122. package/dist/field/features/lists/orderedlist/feature.client.js +1 -2
  123. package/dist/field/features/lists/orderedlist/feature.client.js.map +1 -1
  124. package/dist/field/features/lists/orderedlist/feature.server.d.ts.map +1 -1
  125. package/dist/field/features/lists/orderedlist/feature.server.js +1 -2
  126. package/dist/field/features/lists/orderedlist/feature.server.js.map +1 -1
  127. package/dist/field/features/lists/orderedlist/markdownTransformer.d.ts.map +1 -1
  128. package/dist/field/features/lists/orderedlist/markdownTransformer.js +1 -2
  129. package/dist/field/features/lists/orderedlist/markdownTransformer.js.map +1 -1
  130. package/dist/field/features/lists/plugin/index.d.ts.map +1 -1
  131. package/dist/field/features/lists/plugin/index.js +1 -2
  132. package/dist/field/features/lists/plugin/index.js.map +1 -1
  133. package/dist/field/features/lists/unorderedlist/feature.client.d.ts.map +1 -1
  134. package/dist/field/features/lists/unorderedlist/feature.client.js +1 -2
  135. package/dist/field/features/lists/unorderedlist/feature.client.js.map +1 -1
  136. package/dist/field/features/lists/unorderedlist/feature.server.d.ts.map +1 -1
  137. package/dist/field/features/lists/unorderedlist/feature.server.js +1 -2
  138. package/dist/field/features/lists/unorderedlist/feature.server.js.map +1 -1
  139. package/dist/field/features/lists/unorderedlist/markdownTransformer.d.ts.map +1 -1
  140. package/dist/field/features/lists/unorderedlist/markdownTransformer.js +1 -2
  141. package/dist/field/features/lists/unorderedlist/markdownTransformer.js.map +1 -1
  142. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts +1 -3
  143. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
  144. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +2 -4
  145. package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  146. package/dist/field/features/migrations/slateToLexical/converter/index.d.ts.map +1 -1
  147. package/dist/field/features/migrations/slateToLexical/converter/index.js +2 -1
  148. package/dist/field/features/migrations/slateToLexical/converter/index.js.map +1 -1
  149. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts +1 -3
  150. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
  151. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +2 -4
  152. package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  153. package/dist/field/features/paragraph/feature.client.d.ts.map +1 -1
  154. package/dist/field/features/paragraph/feature.client.js +2 -4
  155. package/dist/field/features/paragraph/feature.client.js.map +1 -1
  156. package/dist/field/features/relationship/drawer/commands.d.ts.map +1 -1
  157. package/dist/field/features/relationship/drawer/commands.js +1 -2
  158. package/dist/field/features/relationship/drawer/commands.js.map +1 -1
  159. package/dist/field/features/relationship/drawer/index.d.ts.map +1 -1
  160. package/dist/field/features/relationship/drawer/index.js +2 -4
  161. package/dist/field/features/relationship/drawer/index.js.map +1 -1
  162. package/dist/field/features/relationship/nodes/RelationshipNode.d.ts +2 -4
  163. package/dist/field/features/relationship/nodes/RelationshipNode.d.ts.map +1 -1
  164. package/dist/field/features/relationship/nodes/RelationshipNode.js +1 -2
  165. package/dist/field/features/relationship/nodes/RelationshipNode.js.map +1 -1
  166. package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
  167. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +2 -4
  168. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
  169. package/dist/field/features/relationship/plugins/index.d.ts.map +1 -1
  170. package/dist/field/features/relationship/plugins/index.js +3 -6
  171. package/dist/field/features/relationship/plugins/index.js.map +1 -1
  172. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.d.ts.map +1 -1
  173. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js +2 -4
  174. package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js.map +1 -1
  175. package/dist/field/features/upload/component/index.d.ts.map +1 -1
  176. package/dist/field/features/upload/component/index.js +52 -6
  177. package/dist/field/features/upload/component/index.js.map +1 -1
  178. package/dist/field/features/upload/drawer/commands.d.ts.map +1 -1
  179. package/dist/field/features/upload/drawer/commands.js +1 -2
  180. package/dist/field/features/upload/drawer/commands.js.map +1 -1
  181. package/dist/field/features/upload/drawer/index.d.ts.map +1 -1
  182. package/dist/field/features/upload/drawer/index.js +2 -4
  183. package/dist/field/features/upload/drawer/index.js.map +1 -1
  184. package/dist/field/features/upload/nodes/UploadNode.d.ts +1 -3
  185. package/dist/field/features/upload/nodes/UploadNode.d.ts.map +1 -1
  186. package/dist/field/features/upload/nodes/UploadNode.js +2 -8
  187. package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
  188. package/dist/field/features/upload/plugin/index.d.ts.map +1 -1
  189. package/dist/field/features/upload/plugin/index.js +3 -6
  190. package/dist/field/features/upload/plugin/index.js.map +1 -1
  191. package/dist/field/index.d.ts +1 -1
  192. package/dist/field/index.d.ts.map +1 -1
  193. package/dist/field/index.js.map +1 -1
  194. package/dist/field/lexical/LexicalEditor.d.ts.map +1 -1
  195. package/dist/field/lexical/LexicalEditor.js +5 -10
  196. package/dist/field/lexical/LexicalEditor.js.map +1 -1
  197. package/dist/field/lexical/LexicalProvider.d.ts +1 -1
  198. package/dist/field/lexical/LexicalProvider.d.ts.map +1 -1
  199. package/dist/field/lexical/LexicalProvider.js +1 -2
  200. package/dist/field/lexical/LexicalProvider.js.map +1 -1
  201. package/dist/field/lexical/config/client/default.d.ts +1 -1
  202. package/dist/field/lexical/config/client/default.d.ts.map +1 -1
  203. package/dist/field/lexical/config/client/default.js.map +1 -1
  204. package/dist/field/lexical/config/client/sanitize.d.ts +1 -1
  205. package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
  206. package/dist/field/lexical/config/client/sanitize.js.map +1 -1
  207. package/dist/field/lexical/config/server/default.d.ts +1 -1
  208. package/dist/field/lexical/config/server/default.d.ts.map +1 -1
  209. package/dist/field/lexical/config/server/default.js.map +1 -1
  210. package/dist/field/lexical/config/types.d.ts +1 -1
  211. package/dist/field/lexical/config/types.d.ts.map +1 -1
  212. package/dist/field/lexical/config/types.js.map +1 -1
  213. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.d.ts.map +1 -1
  214. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js +3 -6
  215. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js.map +1 -1
  216. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.d.ts.map +1 -1
  217. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js +3 -6
  218. package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js.map +1 -1
  219. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts.map +1 -1
  220. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js +3 -6
  221. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +1 -1
  222. package/dist/field/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
  223. package/dist/field/lexical/plugins/MarkdownShortcut/index.js +1 -2
  224. package/dist/field/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  225. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
  226. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +3 -6
  227. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  228. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
  229. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +3 -6
  230. package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  231. package/dist/field/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
  232. package/dist/field/lexical/plugins/SlashMenu/index.js +1 -2
  233. package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
  234. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.d.ts.map +1 -1
  235. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js +2 -4
  236. package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  237. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts.map +1 -1
  238. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js +1 -2
  239. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js.map +1 -1
  240. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  241. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js +2 -4
  242. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  243. package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.d.ts.map +1 -1
  244. package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.js +1 -2
  245. package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.js.map +1 -1
  246. package/dist/field/lexical/theme/EditorTheme.scss +7 -8
  247. package/dist/field/lexical/ui/ContentEditable.d.ts.map +1 -1
  248. package/dist/field/lexical/ui/ContentEditable.js +1 -2
  249. package/dist/field/lexical/ui/ContentEditable.js.map +1 -1
  250. package/dist/field/lexical/utils/getSelectedNode.d.ts.map +1 -1
  251. package/dist/field/lexical/utils/getSelectedNode.js +1 -2
  252. package/dist/field/lexical/utils/getSelectedNode.js.map +1 -1
  253. package/dist/field/lexical/utils/nodeFormat.d.ts +2 -1
  254. package/dist/field/lexical/utils/nodeFormat.d.ts.map +1 -1
  255. package/dist/field/lexical/utils/nodeFormat.js.map +1 -1
  256. package/dist/index.d.ts.map +1 -1
  257. package/dist/index.js.map +1 -1
  258. package/dist/populate/defaultValue.d.ts.map +1 -1
  259. package/dist/populate/defaultValue.js +1 -0
  260. package/dist/populate/defaultValue.js.map +1 -1
  261. package/dist/types.d.ts +3 -4
  262. package/dist/types.d.ts.map +1 -1
  263. package/dist/types.js.map +1 -1
  264. package/dist/validate/index.d.ts +1 -1
  265. package/dist/validate/index.d.ts.map +1 -1
  266. package/package.json +22 -21
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/field/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary.js'\nimport lexicalHistoryPluginImport from '@lexical/react/LexicalHistoryPlugin.js'\nconst { HistoryPlugin } = lexicalHistoryPluginImport\n\nimport lexicalOnChangePluginImport from '@lexical/react/LexicalOnChangePlugin.js'\nconst { OnChangePlugin } = lexicalOnChangePluginImport\n\nimport lexicalRichTextPluginImport from '@lexical/react/LexicalRichTextPlugin.js'\nconst { RichTextPlugin } = lexicalRichTextPluginImport\n\nimport lexicalTabIndentationPluginImport from '@lexical/react/LexicalTabIndentationPlugin.js'\nconst { TabIndentationPlugin } = lexicalTabIndentationPluginImport\n\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { FloatingSelectToolbarPlugin } from './plugins/FloatingSelectToolbar/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>> = (\n props,\n) => {\n const { editorConfig, onChange } = props\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 1025px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const ErrorBoundaryComponent = LexicalErrorBoundary.default || LexicalErrorBoundary\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'top') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n <RichTextPlugin\n //@ts-expect-error ts being dumb\n ErrorBoundary={ErrorBoundaryComponent}\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable />\n </div>\n </div>\n }\n placeholder={\n <p className=\"editor-placeholder\">Start typing, or press '/' for commands...</p>\n }\n />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) onChange(editorState, editor, tags)\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin anchorElem={floatingAnchorElem} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <FloatingSelectToolbarPlugin anchorElem={floatingAnchorElem} />\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n\n <TabIndentationPlugin />\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'normal') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'bottom') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","LexicalErrorBoundary","lexicalHistoryPluginImport","HistoryPlugin","lexicalOnChangePluginImport","OnChangePlugin","lexicalRichTextPluginImport","RichTextPlugin","lexicalTabIndentationPluginImport","TabIndentationPlugin","React","useEffect","useState","EditorPlugin","FloatingSelectToolbarPlugin","MarkdownShortcutPlugin","SlashMenuPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","LexicalContentEditable","LexicalEditor","props","editorConfig","onChange","editor","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","isSmallWidthViewport","setIsSmallWidthViewport","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","ErrorBoundaryComponent","default","Fragment","features","plugins","map","plugin","position","key","ErrorBoundary","contentEditable","div","className","ref","placeholder","p","ignoreSelectionChange","editorState","tags","has","size","isEditable","anchorElem","desktopOnly","markdownTransformers","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,OAAOE,0BAA0B,yCAAwC;AACzE,OAAOC,gCAAgC,yCAAwC;AAC/E,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,iCAAiC,0CAAyC;AACjF,MAAM,EAAEC,cAAc,EAAE,GAAGD;AAE3B,OAAOE,iCAAiC,0CAAyC;AACjF,MAAM,EAAEC,cAAc,EAAE,GAAGD;AAE3B,OAAOE,uCAAuC,gDAA+C;AAC7F,MAAM,EAAEC,oBAAoB,EAAE,GAAGD;AAEjC,YAAYE,WAAW,QAAO;AAC9B,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI3C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,OAAO,uBAAsB;AAC7B,SAASC,2BAA2B,QAAQ,2CAA0C;AACtF,SAASC,sBAAsB,QAAQ,sCAAqC;AAC5E,SAASC,eAAe,QAAQ,+BAA8B;AAC9D,SAASC,oBAAoB,QAAQ,kDAAiD;AACtF,SAASC,oBAAoB,QAAQ,kDAAiD;AACtF,SAASC,sBAAsB,QAAQ,0BAAyB;AAEhE,OAAO,MAAMC,gBAAmF,CAC9FC;IAEA,MAAM,EAAEC,YAAY,EAAEC,QAAQ,EAAE,GAAGF;IACnC,MAAM,CAACG,OAAO,GAAGxB;IAEjB,MAAM,CAACyB,oBAAoBC,sBAAsB,GAAGd,SAAgC;IACpF,MAAMe,QAAQ,CAACC;QACb,IAAIA,wBAAwB,MAAM;YAChCF,sBAAsBE;Q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C,OAAO,CAACC,GAAG,CAAC,CAACC;QAClC,IACEA,OAAOC,QAAQ,KAAK,wBACpB,CAAED,CAAAA,OAAOiB,WAAW,KAAK,QAAQhC,oBAAmB,GACpD;YACA,qBACE,oBAAChB;gBAAa+C,YAAYnC;gBAAoBqB,KAAKF,OAAOE,GAAG;gBAAEF,QAAQA;;QAE3E;IACF,IACCpB,OAAOmC,UAAU,oBAChB,oBAACjD,MAAM8B,QAAQ,sBACb,oBAAC1B;QAA4B8C,YAAYnC;sBACzC,oBAACT;QAAgB4C,YAAYnC;UAKpCD,OAAOmC,UAAU,oBAChB,oBAACjD,MAAM8B,QAAQ,sBACb,oBAACrC,sBACAmB,cAAcmB,UAAUqB,sBAAsBC,SAAS,mBAAK,oBAAChD,8CAIlE,oBAACN,6BACAa,aAAamB,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC;QAClC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;YAChC,qBAAO,oBAAChC;gBAAaiC,KAAKF,OAAOE,GAAG;gBAAEF,QAAQA;;QAChD;IACF,IACCtB,aAAamB,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC;QAClC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;YAChC,qBAAO,oBAAChC;gBAAaiC,KAAKF,OAAOE,GAAG;gBAAEF,QAAQA;;QAChD;IACF;AAGN,EAAC"}
1
+ {"version":3,"sources":["../../../src/field/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin.js'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { FloatingSelectToolbarPlugin } from './plugins/FloatingSelectToolbar/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>> = (\n props,\n) => {\n const { editorConfig, onChange } = props\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 1025px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const ErrorBoundaryComponent = LexicalErrorBoundary.default || LexicalErrorBoundary\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'top') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n <RichTextPlugin\n //@ts-expect-error ts being dumb\n ErrorBoundary={ErrorBoundaryComponent}\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable />\n </div>\n </div>\n }\n placeholder={\n <p className=\"editor-placeholder\">Start typing, or press '/' for commands...</p>\n }\n />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) onChange(editorState, editor, tags)\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin anchorElem={floatingAnchorElem} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <FloatingSelectToolbarPlugin anchorElem={floatingAnchorElem} />\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n\n <TabIndentationPlugin />\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'normal') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'bottom') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","TabIndentationPlugin","React","useEffect","useState","EditorPlugin","FloatingSelectToolbarPlugin","MarkdownShortcutPlugin","SlashMenuPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","LexicalContentEditable","LexicalEditor","props","editorConfig","onChange","editor","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","isSmallWidthViewport","setIsSmallWidthViewport","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","ErrorBoundaryComponent","default","Fragment","features","plugins","map","plugin","position","key","ErrorBoundary","contentEditable","div","className","ref","placeholder","p","ignoreSelectionChange","editorState","tags","has","size","isEditable","anchorElem","desktopOnly","markdownTransformers","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,OAAOC,0BAA0B,yCAAwC;AACzE,SAASC,aAAa,QAAQ,yCAAwC;AACtE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,YAAYC,WAAW,QAAO;AAC9B,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI3C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,OAAO,uBAAsB;AAC7B,SAASC,2BAA2B,QAAQ,2CAA0C;AACtF,SAASC,sBAAsB,QAAQ,sCAAqC;AAC5E,SAASC,eAAe,QAAQ,+BAA8B;AAC9D,SAASC,oBAAoB,QAAQ,kDAAiD;AACtF,SAASC,oBAAoB,QAAQ,kDAAiD;AACtF,SAASC,sBAAsB,QAAQ,0BAAyB;AAEhE,OAAO,MAAMC,gBAAmF,CAC9FC;IAEA,MAAM,EAAEC,YAAY,EAAEC,QAAQ,EAAE,GAAGF;IACnC,MAAM,CAACG,OAAO,GAAGpB;IAEjB,MAAM,CAACqB,oBAAoBC,sBAAsB,GAAGd,SAAgC;IACpF,MAAM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C;sBAClC,oBAACR;QAAqB2C,YAAYnC;SAGrCH,aAAamB,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC;QAClC,IACEA,OAAOC,QAAQ,KAAK,wBACpB,CAAED,CAAAA,OAAOiB,WAAW,KAAK,QAAQhC,oBAAmB,GACpD;YACA,qBACE,oBAAChB;gBAAa+C,YAAYnC;gBAAoBqB,KAAKF,OAAOE,GAAG;gBAAEF,QAAQA;;QAE3E;IACF,IACCpB,OAAOmC,UAAU,oBAChB,oBAACjD,MAAM8B,QAAQ,sBACb,oBAAC1B;QAA4B8C,YAAYnC;sBACzC,oBAACT;QAAgB4C,YAAYnC;UAKpCD,OAAOmC,UAAU,oBAChB,oBAACjD,MAAM8B,QAAQ,sBACb,oBAAClC,sBACAgB,cAAcmB,UAAUqB,sBAAsBC,SAAS,mBAAK,oBAAChD,8CAIlE,oBAACN,6BACAa,aAAamB,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC;QAClC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;YAChC,qBAAO,oBAAChC;gBAAaiC,KAAKF,OAAOE,GAAG;gBAAEF,QAAQA;;QAChD;IACF,IACCtB,aAAamB,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC;QAClC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;YAChC,qBAAO,oBAAChC;gBAAaiC,KAAKF,OAAOE,GAAG;gBAAEF,QAAQA;;QAChD;IACF;AAGN,EAAC"}
@@ -1,6 +1,6 @@
1
+ import type { FormFieldBase } from '@payloadcms/ui/fields/shared';
1
2
  import type { EditorState, SerializedEditorState } from 'lexical';
2
3
  import type { LexicalEditor } from 'lexical';
3
- import type { FormFieldBase } from '@payloadcms/ui/fields/shared';
4
4
  import * as React from 'react';
5
5
  import type { SanitizedClientEditorConfig } from './config/types.js';
6
6
  export type LexicalProviderProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalProvider.d.ts","sourceRoot":"","sources":["../../../src/field/lexical/LexicalProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAEjE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAMpE,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,2BAA2B,CAAA;IACzC,UAAU,EAAE,aAAa,GAAG;QAC1B,YAAY,EAAE,2BAA2B,CAAA;QACzC,IAAI,EAAE,MAAM,CAAA;QACZ,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;KACnD,CAAA;IACD,QAAQ,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAA;IACtF,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,qBAAqB,CAAA;CAC7B,CAAA;AACD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA2D1D,CAAA"}
1
+ {"version":3,"file":"LexicalProvider.d.ts","sourceRoot":"","sources":["../../../src/field/lexical/LexicalProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAG5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAMpE,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,2BAA2B,CAAA;IACzC,UAAU,EAAE,aAAa,GAAG;QAC1B,YAAY,EAAE,2BAA2B,CAAA;QACzC,IAAI,EAAE,MAAM,CAAA;QACZ,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;KACnD,CAAA;IACD,QAAQ,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAA;IACtF,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,qBAAqB,CAAA;CAC7B,CAAA;AACD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA2D1D,CAAA"}
@@ -1,6 +1,5 @@
1
1
  'use client';
2
- import lexicalComposerImport from '@lexical/react/LexicalComposer.js';
3
- const { LexicalComposer } = lexicalComposerImport;
2
+ import { LexicalComposer } from '@lexical/react/LexicalComposer.js';
4
3
  import * as React from 'react';
5
4
  import { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js';
6
5
  import { EditorConfigProvider } from './config/client/EditorConfigProvider.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/field/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { LexicalEditor } from 'lexical'\n\nimport lexicalComposerImport from '@lexical/react/LexicalComposer.js'\nconst { LexicalComposer } = lexicalComposerImport\n\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\n\nimport * as React from 'react'\n\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { EditorConfigProvider } from './config/client/EditorConfigProvider.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n path: string\n readOnly: boolean\n value: SerializedEditorState\n}\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const { editorConfig, fieldProps, onChange, path, readOnly } = props\n let { value } = props\n\n const [initialConfig, setInitialConfig] = React.useState<InitialConfigType | null>(null)\n\n // set lexical config in useEffect: // TODO: Is this the most performant way to do this? Prob not\n React.useEffect(() => {\n const newInitialConfig: InitialConfigType = {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: [...getEnabledNodes({ editorConfig })],\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n setInitialConfig(newInitialConfig)\n }, [editorConfig, readOnly, value])\n\n if (editorConfig?.features?.hooks?.load?.length) {\n editorConfig.features.hooks.load.forEach((hook) => {\n value = hook({ incomingEditorState: value })\n })\n }\n\n if (value && typeof value !== 'object') {\n throw new Error(\n 'The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' +\n JSON.stringify(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\n throw new Error(\n 'You have tried to pass in data from the old, Slate editor, to the new, Lexical editor. This is not supported. There is no automatic conversion from Slate to Lexical data available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (value && 'jsonContent' in value) {\n throw new Error(\n 'You have tried to pass in data from payload-plugin-lexical. This is not supported. The data structure has changed in this editor, compared to the plugin, and there is no automatic conversion available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={path}>\n <EditorConfigProvider editorConfig={editorConfig} fieldProps={fieldProps}>\n <div className=\"editor-shell\">\n <LexicalEditorComponent editorConfig={editorConfig} onChange={onChange} />\n </div>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n"],"names":["lexicalComposerImport","LexicalComposer","React","LexicalEditor","LexicalEditorComponent","EditorConfigProvider","getEnabledNodes","LexicalProvider","props","editorConfig","fieldProps","onChange","path","readOnly","value","initialConfig","setInitialConfig","useState","useEffect","newInitialConfig","editable","editorState","JSON","stringify","undefined","namespace","lexical","nodes","onError","error","theme","features","hooks","load","length","forEach","hook","incomingEditorState","Error","Array","isArray","p","key","div","className"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,OAAOA,2BAA2B,oCAAmC;AACrE,MAAM,EAAEC,eAAe,EAAE,GAAGD;AAK5B,YAAYE,WAAW,QAAO;AAI9B,SAASC,iBAAiBC,sBAAsB,QAAQ,qBAAoB;AAC5E,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,eAAe,QAAQ,mBAAkB;AAclD,OAAO,MAAMC,kBAAkD,CAACC;IAC9D,MAAM,EAAEC,YAAY,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGL;IAC/D,IAAI,EAAEM,KAAK,EAAE,GAAGN;IAEhB,MAAM,CAACO,eAAeC,iBAAiB,GAAGd,MAAMe,QAAQ,CAA2B;IAEnF,iGAAiG;IACjGf,MAAMgB,SAAS,CAAC;QACd,MAAMC,mBAAsC;YAC1CC,UAAUP,aAAa;YACvBQ,aAAaP,SAAS,OAAOQ,KAAKC,SAAS,CAACT,SAASU;YACrDC,WAAWhB,aAAaiB,OAAO,CAACD,SAAS;YACzCE,OAAO;mBAAIrB,gBAAgB;oBAAEG;gBAAa;aAAG;YAC7CmB,SAAS,CAACC;gBACR,MAAMA;YACR;YACAC,OAAOrB,aAAaiB,OAAO,CAACI,KAAK;QACnC;QACAd,iBAAiBG;IACnB,GAAG;QAACV;QAAcI;QAAUC;KAAM;IAElC,IAAIL,cAAcsB,UAAUC,OAAOC,MAAMC,QAAQ;QAC/CzB,aAAasB,QAAQ,CAACC,KAAK,CAACC,IAAI,CAACE,OAAO,CAAC,CAACC;YACxCtB,QAAQsB,KAAK;gBAAEC,qBAAqBvB;YAAM;QAC5C;IACF;IAEA,IAAIA,SAAS,OAAOA,UAAU,UAAU;QACtC,MAAM,IAAIwB,MACR,kLACEhB,KAAKC,SAAS,CAACT;IAErB;IAEA,IAAIA,SAASyB,MAAMC,OAAO,CAAC1B,UAAU,CAAE,CAAA,UAAUA,KAAI,GAAI;QACvD,MAAM,IAAIwB,MACR;IAEJ;IAEA,IAAIxB,SAAS,iBAAiBA,OAAO;QACnC,MAAM,IAAIwB,MACR;IAEJ;IAEA,IAAI,CAACvB,eAAe;QAClB,qBAAO,oBAAC0B,WAAE;IACZ;IAEA,qBACE,oBAACxC;QAAgBc,eAAeA;QAAe2B,KAAK9B;qBAClD,oBAACP;QAAqBI,cAAcA;QAAcC,YAAYA;qBAC5D,oBAACiC;QAAIC,WAAU;qBACb,oBAACxC;QAAuBK,cAAcA;QAAcE,UAAUA;;AAKxE,EAAC"}
1
+ {"version":3,"sources":["../../../src/field/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { LexicalEditor } from 'lexical'\n\nimport { LexicalComposer } from '@lexical/react/LexicalComposer.js'\nimport * as React from 'react'\n\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { EditorConfigProvider } from './config/client/EditorConfigProvider.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n path: string\n readOnly: boolean\n value: SerializedEditorState\n}\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const { editorConfig, fieldProps, onChange, path, readOnly } = props\n let { value } = props\n\n const [initialConfig, setInitialConfig] = React.useState<InitialConfigType | null>(null)\n\n // set lexical config in useEffect: // TODO: Is this the most performant way to do this? Prob not\n React.useEffect(() => {\n const newInitialConfig: InitialConfigType = {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: [...getEnabledNodes({ editorConfig })],\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n setInitialConfig(newInitialConfig)\n }, [editorConfig, readOnly, value])\n\n if (editorConfig?.features?.hooks?.load?.length) {\n editorConfig.features.hooks.load.forEach((hook) => {\n value = hook({ incomingEditorState: value })\n })\n }\n\n if (value && typeof value !== 'object') {\n throw new Error(\n 'The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' +\n JSON.stringify(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\n throw new Error(\n 'You have tried to pass in data from the old, Slate editor, to the new, Lexical editor. This is not supported. There is no automatic conversion from Slate to Lexical data available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (value && 'jsonContent' in value) {\n throw new Error(\n 'You have tried to pass in data from payload-plugin-lexical. This is not supported. The data structure has changed in this editor, compared to the plugin, and there is no automatic conversion available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={path}>\n <EditorConfigProvider editorConfig={editorConfig} fieldProps={fieldProps}>\n <div className=\"editor-shell\">\n <LexicalEditorComponent editorConfig={editorConfig} onChange={onChange} />\n </div>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n"],"names":["LexicalComposer","React","LexicalEditor","LexicalEditorComponent","EditorConfigProvider","getEnabledNodes","LexicalProvider","props","editorConfig","fieldProps","onChange","path","readOnly","value","initialConfig","setInitialConfig","useState","useEffect","newInitialConfig","editable","editorState","JSON","stringify","undefined","namespace","lexical","nodes","onError","error","theme","features","hooks","load","length","forEach","hook","incomingEditorState","Error","Array","isArray","p","key","div","className"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAMA,SAASA,eAAe,QAAQ,oCAAmC;AACnE,YAAYC,WAAW,QAAO;AAI9B,SAASC,iBAAiBC,sBAAsB,QAAQ,qBAAoB;AAC5E,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,eAAe,QAAQ,mBAAkB;AAclD,OAAO,MAAMC,kBAAkD,CAACC;IAC9D,MAAM,EAAEC,YAAY,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGL;IAC/D,IAAI,EAAEM,KAAK,EAAE,GAAGN;IAEhB,MAAM,CAACO,eAAeC,iBAAiB,GAAGd,MAAMe,QAAQ,CAA2B;IAEnF,iGAAiG;IACjGf,MAAMgB,SAAS,CAAC;QACd,MAAMC,mBAAsC;YAC1CC,UAAUP,aAAa;YACvBQ,aAAaP,SAAS,OAAOQ,KAAKC,SAAS,CAACT,SAASU;YACrDC,WAAWhB,aAAaiB,OAAO,CAACD,SAAS;YACzCE,OAAO;mBAAIrB,gBAAgB;oBAAEG;gBAAa;aAAG;YAC7CmB,SAAS,CAACC;gBACR,MAAMA;YACR;YACAC,OAAOrB,aAAaiB,OAAO,CAACI,KAAK;QACnC;QACAd,iBAAiBG;IACnB,GAAG;QAACV;QAAcI;QAAUC;KAAM;IAElC,IAAIL,cAAcsB,UAAUC,OAAOC,MAAMC,QAAQ;QAC/CzB,aAAasB,QAAQ,CAACC,KAAK,CAACC,IAAI,CAACE,OAAO,CAAC,CAACC;YACxCtB,QAAQsB,KAAK;gBAAEC,qBAAqBvB;YAAM;QAC5C;IACF;IAEA,IAAIA,SAAS,OAAOA,UAAU,UAAU;QACtC,MAAM,IAAIwB,MACR,kLACEhB,KAAKC,SAAS,CAACT;IAErB;IAEA,IAAIA,SAASyB,MAAMC,OAAO,CAAC1B,UAAU,CAAE,CAAA,UAAUA,KAAI,GAAI;QACvD,MAAM,IAAIwB,MACR;IAEJ;IAEA,IAAIxB,SAAS,iBAAiBA,OAAO;QACnC,MAAM,IAAIwB,MACR;IAEJ;IAEA,IAAI,CAACvB,eAAe;QAClB,qBAAO,oBAAC0B,WAAE;IACZ;IAEA,qBACE,oBAACxC;QAAgBc,eAAeA;QAAe2B,KAAK9B;qBAClD,oBAACP;QAAqBI,cAAcA;QAAcC,YAAYA;qBAC5D,oBAACiC;QAAIC,WAAU;qBACb,oBAACxC;QAAuBK,cAAcA;QAAcE,UAAUA;;AAKxE,EAAC"}
@@ -1,3 +1,3 @@
1
- import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js';
1
+ import type { EditorConfig as LexicalEditorConfig } from 'lexical';
2
2
  export declare const defaultEditorLexicalConfig: LexicalEditorConfig;
3
3
  //# sourceMappingURL=default.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/client/default.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAInF,eAAO,MAAM,0BAA0B,EAAE,mBAGxC,CAAA"}
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/client/default.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAIlE,eAAO,MAAM,0BAA0B,EAAE,mBAGxC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/config/client/default.ts"],"sourcesContent":["'use client'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport { LexicalEditorTheme } from '../../theme/EditorTheme.js'\n\nexport const defaultEditorLexicalConfig: LexicalEditorConfig = {\n namespace: 'lexical',\n theme: LexicalEditorTheme,\n}\n"],"names":["LexicalEditorTheme","defaultEditorLexicalConfig","namespace","theme"],"rangeMappings":";;;;;","mappings":"AAAA;AAGA,SAASA,kBAAkB,QAAQ,6BAA4B;AAE/D,OAAO,MAAMC,6BAAkD;IAC7DC,WAAW;IACXC,OAAOH;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/config/client/default.ts"],"sourcesContent":["'use client'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport { LexicalEditorTheme } from '../../theme/EditorTheme.js'\n\nexport const defaultEditorLexicalConfig: LexicalEditorConfig = {\n namespace: 'lexical',\n theme: LexicalEditorTheme,\n}\n"],"names":["LexicalEditorTheme","defaultEditorLexicalConfig","namespace","theme"],"rangeMappings":";;;;;","mappings":"AAAA;AAGA,SAASA,kBAAkB,QAAQ,6BAA4B;AAE/D,OAAO,MAAMC,6BAAkD;IAC7DC,WAAW;IACXC,OAAOH;AACT,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js';
1
+ import type { EditorConfig as LexicalEditorConfig } from 'lexical';
2
2
  import type { ResolvedClientFeatureMap, SanitizedClientFeatures } from '../../../features/types.js';
3
3
  import type { SanitizedClientEditorConfig } from '../types.js';
4
4
  export declare const sanitizeClientFeatures: (features: ResolvedClientFeatureMap) => SanitizedClientFeatures;
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnF,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,eAAO,MAAM,sBAAsB,0CAEhC,uBA4IF,CAAA;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,mBAAmB,EAC5B,wBAAwB,EAAE,wBAAwB,GACjD,2BAA2B,CAM7B"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,eAAO,MAAM,sBAAsB,0CAEhC,uBA4IF,CAAA;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,mBAAmB,EAC5B,wBAAwB,EAAE,wBAAwB,GACjD,2BAA2B,CAM7B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport type { ResolvedClientFeatureMap, SanitizedClientFeatures } from '../../../features/types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\nexport const sanitizeClientFeatures = (\n features: ResolvedClientFeatureMap,\n): SanitizedClientFeatures => {\n const sanitized: SanitizedClientFeatures = {\n enabledFeatures: [],\n floatingSelectToolbar: {\n sections: [],\n },\n hooks: {\n load: [],\n save: [],\n },\n markdownTransformers: [],\n nodes: [],\n plugins: [],\n slashMenu: {\n dynamicOptions: [],\n groupsWithOptions: [],\n },\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature.hooks) {\n if (feature.hooks?.load?.length) {\n sanitized.hooks.load = sanitized.hooks.load.concat(feature.hooks.load)\n }\n if (feature.hooks?.save?.length) {\n sanitized.hooks.save = sanitized.hooks.save.concat(feature.hooks.save)\n }\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\n }\n if (feature.plugins?.length) {\n feature.plugins.forEach((plugin, i) => {\n sanitized.plugins.push({\n Component: plugin.Component,\n key: feature.key + i,\n position: plugin.position,\n })\n })\n }\n\n if (feature.floatingSelectToolbar?.sections?.length) {\n for (const section of feature.floatingSelectToolbar.sections) {\n // 1. find the section with the same key or create new one\n let foundSection = sanitized.floatingSelectToolbar.sections.find(\n (sanitizedSection) => sanitizedSection.key === section.key,\n )\n if (!foundSection) {\n foundSection = {\n ...section,\n entries: [],\n }\n } else {\n sanitized.floatingSelectToolbar.sections =\n sanitized.floatingSelectToolbar.sections.filter(\n (sanitizedSection) => sanitizedSection.key !== section.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (section?.entries?.length) {\n foundSection.entries = foundSection.entries.concat(section.entries)\n }\n sanitized.floatingSelectToolbar?.sections.push(foundSection)\n }\n }\n\n if (feature.slashMenu?.options) {\n if (feature.slashMenu.dynamicOptions?.length) {\n sanitized.slashMenu.dynamicOptions = sanitized.slashMenu.dynamicOptions.concat(\n feature.slashMenu.dynamicOptions,\n )\n }\n\n for (const optionGroup of feature.slashMenu.options) {\n // 1. find the group with the same name or create new one\n let group = sanitized.slashMenu.groupsWithOptions.find(\n (group) => group.key === optionGroup.key,\n )\n if (!group) {\n group = {\n ...optionGroup,\n options: [],\n }\n } else {\n sanitized.slashMenu.groupsWithOptions = sanitized.slashMenu.groupsWithOptions.filter(\n (group) => group.key !== optionGroup.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (optionGroup?.options?.length) {\n group.options = group.options.concat(optionGroup.options)\n }\n sanitized.slashMenu.groupsWithOptions.push(group)\n }\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\n )\n }\n sanitized.enabledFeatures.push(feature.key)\n })\n\n // Sort sanitized.floatingSelectToolbar.sections by order property\n sanitized.floatingSelectToolbar.sections.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n\n // Sort sanitized.floatingSelectToolbar.sections.[section].entries by order property\n for (const section of sanitized.floatingSelectToolbar.sections) {\n section.entries.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n return sanitized\n}\n\nexport function sanitizeClientEditorConfig(\n lexical: LexicalEditorConfig,\n resolvedClientFeatureMap: ResolvedClientFeatureMap,\n): SanitizedClientEditorConfig {\n return {\n features: sanitizeClientFeatures(resolvedClientFeatureMap),\n lexical,\n resolvedFeatureMap: resolvedClientFeatureMap,\n }\n}\n"],"names":["sanitizeClientFeatures","features","sanitized","enabledFeatures","floatingSelectToolbar","sections","hooks","load","save","markdownTransformers","nodes","plugins","slashMenu","dynamicOptions","groupsWithOptions","size","forEach","feature","length","concat","plugin","i","push","Component","key","position","section","foundSection","find","sanitizedSection","entries","filter","options","optionGroup","group","sort","a","b","order","sanitizeClientEditorConfig","lexical","resolvedClientFeatureMap","resolvedFeatureMap"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAOA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 {"version":3,"sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type { ResolvedClientFeatureMap, SanitizedClientFeatures } from '../../../features/types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\nexport const sanitizeClientFeatures = (\n features: ResolvedClientFeatureMap,\n): SanitizedClientFeatures => {\n const sanitized: SanitizedClientFeatures = {\n enabledFeatures: [],\n floatingSelectToolbar: {\n sections: [],\n },\n hooks: {\n load: [],\n save: [],\n },\n markdownTransformers: [],\n nodes: [],\n plugins: [],\n slashMenu: {\n dynamicOptions: [],\n groupsWithOptions: [],\n },\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature.hooks) {\n if (feature.hooks?.load?.length) {\n sanitized.hooks.load = sanitized.hooks.load.concat(feature.hooks.load)\n }\n if (feature.hooks?.save?.length) {\n sanitized.hooks.save = sanitized.hooks.save.concat(feature.hooks.save)\n }\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\n }\n if (feature.plugins?.length) {\n feature.plugins.forEach((plugin, i) => {\n sanitized.plugins.push({\n Component: plugin.Component,\n key: feature.key + i,\n position: plugin.position,\n })\n })\n }\n\n if (feature.floatingSelectToolbar?.sections?.length) {\n for (const section of feature.floatingSelectToolbar.sections) {\n // 1. find the section with the same key or create new one\n let foundSection = sanitized.floatingSelectToolbar.sections.find(\n (sanitizedSection) => sanitizedSection.key === section.key,\n )\n if (!foundSection) {\n foundSection = {\n ...section,\n entries: [],\n }\n } else {\n sanitized.floatingSelectToolbar.sections =\n sanitized.floatingSelectToolbar.sections.filter(\n (sanitizedSection) => sanitizedSection.key !== section.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (section?.entries?.length) {\n foundSection.entries = foundSection.entries.concat(section.entries)\n }\n sanitized.floatingSelectToolbar?.sections.push(foundSection)\n }\n }\n\n if (feature.slashMenu?.options) {\n if (feature.slashMenu.dynamicOptions?.length) {\n sanitized.slashMenu.dynamicOptions = sanitized.slashMenu.dynamicOptions.concat(\n feature.slashMenu.dynamicOptions,\n )\n }\n\n for (const optionGroup of feature.slashMenu.options) {\n // 1. find the group with the same name or create new one\n let group = sanitized.slashMenu.groupsWithOptions.find(\n (group) => group.key === optionGroup.key,\n )\n if (!group) {\n group = {\n ...optionGroup,\n options: [],\n }\n } else {\n sanitized.slashMenu.groupsWithOptions = sanitized.slashMenu.groupsWithOptions.filter(\n (group) => group.key !== optionGroup.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (optionGroup?.options?.length) {\n group.options = group.options.concat(optionGroup.options)\n }\n sanitized.slashMenu.groupsWithOptions.push(group)\n }\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\n )\n }\n sanitized.enabledFeatures.push(feature.key)\n })\n\n // Sort sanitized.floatingSelectToolbar.sections by order property\n sanitized.floatingSelectToolbar.sections.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n\n // Sort sanitized.floatingSelectToolbar.sections.[section].entries by order property\n for (const section of sanitized.floatingSelectToolbar.sections) {\n section.entries.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n return sanitized\n}\n\nexport function sanitizeClientEditorConfig(\n lexical: LexicalEditorConfig,\n resolvedClientFeatureMap: ResolvedClientFeatureMap,\n): SanitizedClientEditorConfig {\n return {\n features: sanitizeClientFeatures(resolvedClientFeatureMap),\n lexical,\n resolvedFeatureMap: resolvedClientFeatureMap,\n }\n}\n"],"names":["sanitizeClientFeatures","features","sanitized","enabledFeatures","floatingSelectToolbar","sections","hooks","load","save","markdownTransformers","nodes","plugins","slashMenu","dynamicOptions","groupsWithOptions","size","forEach","feature","length","concat","plugin","i","push","Component","key","position","section","foundSection","find","sanitizedSection","entries","filter","options","optionGroup","group","sort","a","b","order","sanitizeClientEditorConfig","lexical","resolvedClientFeatureMap","resolvedFeatureMap"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAOA,OAAO,MAAMA,yBAAyB,CACpCC;IAEA,MAAMC,YAAqC;QACzCC,iBAAiB,EAAE;QACnBC,uBAAuB;YACrBC,UAAU,EAAE;QACd;QACAC,OAAO;YACLC,MAAM,EAAE;YACRC,MAAM,EAAE;QACV;QACAC,sBAAsB,EAAE;QACxBC,OAAO,EAAE;QACTC,SAAS,EAAE;QACXC,WAAW;YACTC,gBAAgB,EAAE;YAClBC,mBAAmB,EAAE;QACvB;IACF;IAEA,IAAI,CAACb,UAAUc,MAAM;QACnB,OAAOb;IACT;IAEAD,SAASe,OAAO,CAAC,CAACC;QAChB,IAAIA,QAAQX,KAAK,EAAE;YACjB,IAAIW,QAAQX,KAAK,EAAEC,MAAMW,QAAQ;gBAC/BhB,UAAUI,KAAK,CAACC,IAAI,GAAGL,UAAUI,KAAK,CAACC,IAAI,CAACY,MAAM,CAACF,QAAQX,KAAK,CAACC,IAAI;YACvE;YACA,IAAIU,QAAQX,KAAK,EAAEE,MAAMU,QAAQ;gBAC/BhB,UAAUI,KAAK,CAACE,IAAI,GAAGN,UAAUI,KAAK,CAACE,IAAI,CAACW,MAAM,CAACF,QAAQX,KAAK,CAACE,IAAI;YACvE;QACF;QAEA,IAAIS,QAAQP,KAAK,EAAEQ,QAAQ;YACzBhB,UAAUQ,KAAK,GAAGR,UAAUQ,KAAK,CAACS,MAAM,CAACF,QAAQP,KAAK;QACxD;QACA,IAAIO,Q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C,KAAK,EAAE;gBACtB,OAAOF,EAAEE,KAAK,GAAGD,EAAEC,KAAK;YAC1B,OAAO,IAAIF,EAAEE,KAAK,EAAE;gBAClB,OAAO,CAAC;YACV,OAAO,IAAID,EAAEC,KAAK,EAAE;gBAClB,OAAO;YACT,OAAO;gBACL,OAAO;YACT;QACF;IACF;IAEA,OAAOpC;AACT,EAAC;AAED,OAAO,SAASqC,2BACdC,OAA4B,EAC5BC,wBAAkD;IAElD,OAAO;QACLxC,UAAUD,uBAAuByC;QACjCD;QACAE,oBAAoBD;IACtB;AACF"}
@@ -1,4 +1,4 @@
1
- import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js';
1
+ import type { EditorConfig as LexicalEditorConfig } from 'lexical';
2
2
  import type { FeatureProviderServer } from '../../../features/types.js';
3
3
  import type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js';
4
4
  export declare const defaultEditorLexicalConfig: LexicalEditorConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAwBlF,eAAO,MAAM,0BAA0B,EAAE,mBAGxC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAoB1E,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,kBAGjC,CAAA;AAED,eAAO,MAAM,kCAAkC,EAAE,2BACA,CAAA"}
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAwBlF,eAAO,MAAM,0BAA0B,EAAE,mBAGxC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAoB1E,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,kBAGjC,CAAA;AAED,eAAO,MAAM,kCAAkC,EAAE,2BACA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/config/server/default.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport type { FeatureProviderServer } from '../../../features/types.js'\nimport type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js'\n\nimport { AlignFeature } from '../../../features/align/feature.server.js'\nimport { BlockQuoteFeature } from '../../../features/blockquote/feature.server.js'\nimport { BoldFeature } from '../../../features/format/bold/feature.server.js'\nimport { InlineCodeFeature } from '../../../features/format/inlinecode/feature.server.js'\nimport { ItalicFeature } from '../../../features/format/italic/feature.server.js'\nimport { StrikethroughFeature } from '../../../features/format/strikethrough/feature.server.js'\nimport { SubscriptFeature } from '../../../features/format/subscript/feature.server.js'\nimport { SuperscriptFeature } from '../../../features/format/superscript/feature.server.js'\nimport { UnderlineFeature } from '../../../features/format/underline/feature.server.js'\nimport { HeadingFeature } from '../../../features/heading/feature.server.js'\nimport { HorizontalRuleFeature } from '../../../features/horizontalrule/feature.server.js'\nimport { IndentFeature } from '../../../features/indent/feature.server.js'\nimport { LinkFeature } from '../../../features/link/feature.server.js'\nimport { CheckListFeature } from '../../../features/lists/checklist/feature.server.js'\nimport { OrderedListFeature } from '../../../features/lists/orderedlist/feature.server.js'\nimport { UnorderedListFeature } from '../../../features/lists/unorderedlist/feature.server.js'\nimport { ParagraphFeature } from '../../../features/paragraph/feature.server.js'\nimport { RelationshipFeature } from '../../../features/relationship/feature.server.js'\nimport { UploadFeature } from '../../../features/upload/feature.server.js'\nimport { LexicalEditorTheme } from '../../theme/EditorTheme.js'\nimport { sanitizeServerEditorConfig } from './sanitize.js'\n\nexport const defaultEditorLexicalConfig: LexicalEditorConfig = {\n namespace: 'lexical',\n theme: LexicalEditorTheme,\n}\n\nexport const defaultEditorFeatures: FeatureProviderServer<unknown, unknown>[] = [\n BoldFeature(),\n ItalicFeature(),\n UnderlineFeature(),\n StrikethroughFeature(),\n SubscriptFeature(),\n SuperscriptFeature(),\n InlineCodeFeature(),\n ParagraphFeature(),\n HeadingFeature(),\n AlignFeature(),\n IndentFeature(),\n UnorderedListFeature(),\n OrderedListFeature(),\n CheckListFeature(),\n LinkFeature(),\n RelationshipFeature(),\n BlockQuoteFeature(),\n UploadFeature(),\n HorizontalRuleFeature(),\n]\n\nexport const defaultEditorConfig: ServerEditorConfig = {\n features: defaultEditorFeatures,\n lexical: defaultEditorLexicalConfig,\n}\n\nexport const defaultSanitizedServerEditorConfig: SanitizedServerEditorConfig =\n sanitizeServerEditorConfig(defaultEditorConfig)\n"],"names":["AlignFeature","BlockQuoteFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","LinkFeature","CheckListFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","UploadFeature","LexicalEditorTheme","sanitizeServerEditorConfig","defaultEditorLexicalConfig","namespace","theme","defaultEditorFeatures","defaultEditorConfig","features","lexical","defaultSanitizedServerEditorConfig"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,YAAY,QAAQ,4CAA2C;AACxE,SAASC,iBAAiB,QAAQ,iDAAgD;AAClF,SAASC,WAAW,QAAQ,kDAAiD;AAC7E,SAASC,iBAAiB,QAAQ,wDAAuD;AACzF,SAASC,aAAa,QAAQ,oDAAmD;AACjF,SAASC,oBAAoB,QAAQ,2DAA0D;AAC/F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,kBAAkB,QAAQ,yDAAwD;AAC3F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,cAAc,QAAQ,8CAA6C;AAC5E,SAASC,qBAAqB,QAAQ,qDAAoD;AAC1F,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,WAAW,QAAQ,2CAA0C;AACtE,SAASC,gBAAgB,QAAQ,sDAAqD;AACtF,SAASC,kBAAkB,QAAQ,wDAAuD;AAC1F,SAASC,oBAAoB,QAAQ,0DAAyD;AAC9F,SAASC,gBAAgB,QAAQ,gDAA+C;AAChF,SAASC,mBAAmB,QAAQ,mDAAkD;AACtF,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,0BAA0B,QAAQ,gBAAe;AAE1D,OAAO,MAAMC,6BAAkD;IAC7DC,WAAW;IACXC,OAAOJ;AACT,EAAC;AAED,OAAO,MAAMK,wBAAmE;IAC9EtB;IACAE;IACAI;IACAH;IACAC;IACAC;IACAJ;IACAa;IACAP;IACAT;IACAW;IACAI;IACAD;IACAD;IACAD;IACAK;IACAhB;IACAiB;IACAR;CACD,CAAA;AAED,OAAO,MAAMe,sBAA0C;IACrDC,UAAUF;IACVG,SAASN;AACX,EAAC;AAED,OAAO,MAAMO,qCACXR,2BAA2BK,qBAAoB"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/config/server/default.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type { FeatureProviderServer } from '../../../features/types.js'\nimport type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js'\n\nimport { AlignFeature } from '../../../features/align/feature.server.js'\nimport { BlockQuoteFeature } from '../../../features/blockquote/feature.server.js'\nimport { BoldFeature } from '../../../features/format/bold/feature.server.js'\nimport { InlineCodeFeature } from '../../../features/format/inlinecode/feature.server.js'\nimport { ItalicFeature } from '../../../features/format/italic/feature.server.js'\nimport { StrikethroughFeature } from '../../../features/format/strikethrough/feature.server.js'\nimport { SubscriptFeature } from '../../../features/format/subscript/feature.server.js'\nimport { SuperscriptFeature } from '../../../features/format/superscript/feature.server.js'\nimport { UnderlineFeature } from '../../../features/format/underline/feature.server.js'\nimport { HeadingFeature } from '../../../features/heading/feature.server.js'\nimport { HorizontalRuleFeature } from '../../../features/horizontalrule/feature.server.js'\nimport { IndentFeature } from '../../../features/indent/feature.server.js'\nimport { LinkFeature } from '../../../features/link/feature.server.js'\nimport { CheckListFeature } from '../../../features/lists/checklist/feature.server.js'\nimport { OrderedListFeature } from '../../../features/lists/orderedlist/feature.server.js'\nimport { UnorderedListFeature } from '../../../features/lists/unorderedlist/feature.server.js'\nimport { ParagraphFeature } from '../../../features/paragraph/feature.server.js'\nimport { RelationshipFeature } from '../../../features/relationship/feature.server.js'\nimport { UploadFeature } from '../../../features/upload/feature.server.js'\nimport { LexicalEditorTheme } from '../../theme/EditorTheme.js'\nimport { sanitizeServerEditorConfig } from './sanitize.js'\n\nexport const defaultEditorLexicalConfig: LexicalEditorConfig = {\n namespace: 'lexical',\n theme: LexicalEditorTheme,\n}\n\nexport const defaultEditorFeatures: FeatureProviderServer<unknown, unknown>[] = [\n BoldFeature(),\n ItalicFeature(),\n UnderlineFeature(),\n StrikethroughFeature(),\n SubscriptFeature(),\n SuperscriptFeature(),\n InlineCodeFeature(),\n ParagraphFeature(),\n HeadingFeature(),\n AlignFeature(),\n IndentFeature(),\n UnorderedListFeature(),\n OrderedListFeature(),\n CheckListFeature(),\n LinkFeature(),\n RelationshipFeature(),\n BlockQuoteFeature(),\n UploadFeature(),\n HorizontalRuleFeature(),\n]\n\nexport const defaultEditorConfig: ServerEditorConfig = {\n features: defaultEditorFeatures,\n lexical: defaultEditorLexicalConfig,\n}\n\nexport const defaultSanitizedServerEditorConfig: SanitizedServerEditorConfig =\n sanitizeServerEditorConfig(defaultEditorConfig)\n"],"names":["AlignFeature","BlockQuoteFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","LinkFeature","CheckListFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","UploadFeature","LexicalEditorTheme","sanitizeServerEditorConfig","defaultEditorLexicalConfig","namespace","theme","defaultEditorFeatures","defaultEditorConfig","features","lexical","defaultSanitizedServerEditorConfig"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,YAAY,QAAQ,4CAA2C;AACxE,SAASC,iBAAiB,QAAQ,iDAAgD;AAClF,SAASC,WAAW,QAAQ,kDAAiD;AAC7E,SAASC,iBAAiB,QAAQ,wDAAuD;AACzF,SAASC,aAAa,QAAQ,oDAAmD;AACjF,SAASC,oBAAoB,QAAQ,2DAA0D;AAC/F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,kBAAkB,QAAQ,yDAAwD;AAC3F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,cAAc,QAAQ,8CAA6C;AAC5E,SAASC,qBAAqB,QAAQ,qDAAoD;AAC1F,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,WAAW,QAAQ,2CAA0C;AACtE,SAASC,gBAAgB,QAAQ,sDAAqD;AACtF,SAASC,kBAAkB,QAAQ,wDAAuD;AAC1F,SAASC,oBAAoB,QAAQ,0DAAyD;AAC9F,SAASC,gBAAgB,QAAQ,gDAA+C;AAChF,SAASC,mBAAmB,QAAQ,mDAAkD;AACtF,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,0BAA0B,QAAQ,gBAAe;AAE1D,OAAO,MAAMC,6BAAkD;IAC7DC,WAAW;IACXC,OAAOJ;AACT,EAAC;AAED,OAAO,MAAMK,wBAAmE;IAC9EtB;IACAE;IACAI;IACAH;IACAC;IACAC;IACAJ;IACAa;IACAP;IACAT;IACAW;IACAI;IACAD;IACAD;IACAD;IACAK;IACAhB;IACAiB;IACAR;CACD,CAAA;AAED,OAAO,MAAMe,sBAA0C;IACrDC,UAAUF;IACVG,SAASN;AACX,EAAC;AAED,OAAO,MAAMO,qCACXR,2BAA2BK,qBAAoB"}
@@ -1,4 +1,4 @@
1
- import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js';
1
+ import type { EditorConfig as LexicalEditorConfig } from 'lexical';
2
2
  import type { FeatureProviderClient, FeatureProviderServer, ResolvedClientFeatureMap, ResolvedServerFeatureMap, SanitizedClientFeatures, SanitizedServerFeatures } from '../../features/types.js';
3
3
  export type ServerEditorConfig = {
4
4
  features: FeatureProviderServer<unknown, unknown>[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/field/lexical/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnF,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAA;IACnD,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAA;IAC1C,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/field/lexical/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAA;IACnD,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAA;IAC1C,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/lexical/config/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport type {\n FeatureProviderClient,\n FeatureProviderServer,\n ResolvedClientFeatureMap,\n ResolvedServerFeatureMap,\n SanitizedClientFeatures,\n SanitizedServerFeatures,\n} from '../../features/types.js'\n\nexport type ServerEditorConfig = {\n features: FeatureProviderServer<unknown, unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedServerEditorConfig = {\n features: SanitizedServerFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedServerFeatureMap\n}\n\nexport type ClientEditorConfig = {\n features: FeatureProviderClient<unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedClientEditorConfig = {\n features: SanitizedClientFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedClientFeatureMap\n}\n"],"names":[],"rangeMappings":"","mappings":"AA2BA,WAIC"}
1
+ {"version":3,"sources":["../../../../src/field/lexical/config/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type {\n FeatureProviderClient,\n FeatureProviderServer,\n ResolvedClientFeatureMap,\n ResolvedServerFeatureMap,\n SanitizedClientFeatures,\n SanitizedServerFeatures,\n} from '../../features/types.js'\n\nexport type ServerEditorConfig = {\n features: FeatureProviderServer<unknown, unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedServerEditorConfig = {\n features: SanitizedServerFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedServerFeatureMap\n}\n\nexport type ClientEditorConfig = {\n features: FeatureProviderClient<unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedClientEditorConfig = {\n features: SanitizedClientFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedClientFeatureMap\n}\n"],"names":[],"rangeMappings":"","mappings":"AA2BA,WAIC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,aAAa,yBAGvB;IACD,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC3B,KAAK,EAAE,2BAA2B,CAAA;CACnC,sBA8EA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAE9D,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,aAAa,yBAGvB;IACD,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC3B,KAAK,EAAE,2BAA2B,CAAA;CACnC,sBA8EA,CAAA"}
@@ -1,10 +1,7 @@
1
1
  'use client';
2
- import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js';
3
- const { useLexicalComposerContext } = lexicalComposerContextImport;
4
- import lexicalUtilsImport from '@lexical/utils';
5
- const { mergeRegister } = lexicalUtilsImport;
6
- import lexicalImport from 'lexical';
7
- const { $getSelection } = lexicalImport;
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
+ import { mergeRegister } from '@lexical/utils';
4
+ import { $getSelection } from 'lexical';
8
5
  import React, { useCallback, useEffect, useState } from 'react';
9
6
  import './index.scss';
10
7
  const baseClass = 'floating-select-toolbar-popup__button';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalUtilsImport from '@lexical/utils'\nconst { mergeRegister } = lexicalUtilsImport\n\nimport lexicalImport from 'lexical'\nconst { $getSelection } = lexicalImport\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nimport './index.scss'\n\nconst baseClass = 'floating-select-toolbar-popup__button'\n\nexport const ToolbarButton = ({\n children,\n entry,\n}: {\n children: React.JSX.Element\n entry: FloatingToolbarSectionEntry\n}) => {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-` + entry.key : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","mergeRegister","lexicalImport","$getSelection","React","useCallback","useEffect","useState","baseClass","ToolbarButton","children","entry","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","button","onClick","onMouseDown","e","preventDefault","type"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI/D,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,OAAO,MAAMC,gBAAgB,CAAC,EAC5BC,QAAQ,EACRC,KAAK,EAIN;IACC,MAAM,CAACC,OAAO,GAAGb;IACjB,MAAM,CAACc,SAASC,WAAW,GAAGP,SAAkB;IAChD,MAAM,CAACQ,QAAQC,UAAU,GAAGT,SAAkB;IAC9C,MAAM,CAACU,WAAWC,aAAa,GAAGX,SAAiBC;IAEnD,MAAMW,eAAed,YAAY;QAC/BO,OAAOQ,cAAc,GAAGC,IAAI,CAAC;YAC3B,MAAMC,YAAYnB;YAClB,IAAIQ,MAAMY,QAAQ,EAAE;gBAClB,MAAMA,WAAWZ,MAAMY,QAAQ,CAAC;oBAAEX;oBAAQU;gBAAU;gBACpD,IAAIP,WAAWQ,UAAU;oBACvBP,UAAUO;gBACZ;YACF;YACA,IAAIZ,MAAMa,SAAS,EAAE;gBACnB,MAAMA,YAAYb,MAAMa,SAAS,CAAC;oBAAEZ;oBAAQU;gBAAU;gBACtD,IAAIT,YAAYW,WAAW;oBACzBV,WAAWU;gBACb;YACF;QACF;IACF,GAAG;QAACT;QAAQH;QAAQC;QAASF;KAAM;IAEnCL,UAAU;QACRa;IACF,GAAG;QAACA;KAAa;IAEjBb,UAAU;QACRmB,SAASC,gBAAgB,CAAC,WAAWP;QACrC,OAAO;YACLM,SAASE,mBAAmB,CAAC,WAAWR;QAC1C;IACF,GAAG;QAACA;KAAa;IAEjBb,UAAU;QACR,OAAOL,cACLW,OAAOgB,sBAAsB,CAAC;YAC5BT;QACF;IAEJ,GAAG;QAACP;QAAQO;KAAa;IAEzBb,UAAU;QACRY,aACE;YACEV;YACAK,YAAY,QAAQ,aAAa;YACjCE,SAAS,WAAW;YACpBJ,OAAOkB,MAAM,CAAC,EAAErB,UAAU,CAAC,CAAC,GAAGG,MAAMkB,GAAG,GAAG;SAC5C,CACEC,MAAM,CAACC,SACPC,IAAI,CAAC;IAEZ,GAAG;QAACnB;QAASE;QAAQE;KAAU;IAE/B,qBACE,oBAACgB;QACChB,WAAWA;QACXiB,SAAS;YACP,IAAIrB,YAAY,OAAO;gBACrBF,MAAMuB,OAAO,CAAC;oBACZtB;oBACAW,UAAUR;gBACZ;YACF;QACF;QACAoB,aAAa,CAACC;YACZ,8HAA8H;YAC9H,2JAA2J;YAC3J,sKAAsK;YACtKA,EAAEC,cAAc;QAClB;QACAC,MAAK;OAEJ5B;AAGP,EAAC"}
1
+ {"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { $getSelection } from 'lexical'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nimport './index.scss'\n\nconst baseClass = 'floating-select-toolbar-popup__button'\n\nexport const ToolbarButton = ({\n children,\n entry,\n}: {\n children: React.JSX.Element\n entry: FloatingToolbarSectionEntry\n}) => {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-` + entry.key : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","React","useCallback","useEffect","useState","baseClass","ToolbarButton","children","entry","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","button","onClick","onMouseDown","e","preventDefault","type"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,aAAa,QAAQ,UAAS;AACvC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI/D,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,OAAO,MAAMC,gBAAgB,CAAC,EAC5BC,QAAQ,EACRC,KAAK,EAIN;IACC,MAAM,CAACC,OAAO,GAAGX;IACjB,MAAM,CAACY,SAASC,WAAW,GAAGP,SAAkB;IAChD,MAAM,CAACQ,QAAQC,UAAU,GAAGT,SAAkB;IAC9C,MAAM,CAACU,WAAWC,aAAa,GAAGX,SAAiBC;IAEnD,MAAMW,eAAed,YAAY;QAC/BO,OAAOQ,cAAc,GAAGC,IAAI,CAAC;YAC3B,MAAMC,YAAYnB;YAClB,IAAIQ,MAAMY,QAAQ,EAAE;gBAClB,MAAMA,WAAWZ,MAAMY,QAAQ,CAAC;oBAAEX;oBAAQU;gBAAU;gBACpD,IAAIP,WAAWQ,UAAU;oBACvBP,UAAUO;gBACZ;YACF;YACA,IAAIZ,MAAMa,SAAS,EAAE;gBACnB,MAAMA,YAAYb,MAAMa,SAAS,CAAC;oBAAEZ;oBAAQU;gBAAU;gBACtD,IAAIT,YAAYW,WAAW;oBACzBV,WAAWU;gBACb;YACF;QACF;IACF,GAAG;QAACT;QAAQH;QAAQC;QAASF;KAAM;IAEnCL,UAAU;QACRa;IACF,GAAG;QAACA;KAAa;IAEjBb,UAAU;QACRmB,SAASC,gBAAgB,CAAC,WAAWP;QACrC,OAAO;YACLM,SAASE,mBAAmB,CAAC,WAAWR;QAC1C;IACF,GAAG;QAACA;KAAa;IAEjBb,UAAU;QACR,OAAOJ,cACLU,OAAOgB,sBAAsB,CAAC;YAC5BT;QACF;IAEJ,GAAG;QAACP;QAAQO;KAAa;IAEzBb,UAAU;QACRY,aACE;YACEV;YACAK,YAAY,QAAQ,aAAa;YACjCE,SAAS,WAAW;YACpBJ,OAAOkB,MAAM,CAAC,EAAErB,UAAU,CAAC,CAAC,GAAGG,MAAMkB,GAAG,GAAG;SAC5C,CACEC,MAAM,CAACC,SACPC,IAAI,CAAC;IAEZ,GAAG;QAACnB;QAASE;QAAQE;KAAU;IAE/B,qBACE,oBAACgB;QACChB,WAAWA;QACXiB,SAAS;YACP,IAAIrB,YAAY,OAAO;gBACrBF,MAAMuB,OAAO,CAAC;oBACZtB;oBACAW,UAAUR;gBACZ;YACF;QACF;QACAoB,aAAa,CAACC;YACZ,8HAA8H;YAC9H,2JAA2J;YAC3J,sKAAsK;YACtKA,EAAEC,cAAc;QAClB;QACAC,MAAK;OAEJ5B;AAGP,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AACzF,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAU9D,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,KAAK,EACL,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,EAAE,2BAA2B,CAAA;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,KAAK,CAAC,SAAS,CA+FlB;AA4ED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,eAAe,EACf,eAAe,EACf,QAAQ,EACR,QAAgB,EAChB,oBAAoB,GACrB,EAAE;IACD,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,GAAG,KAAK,CAAC,SAAS,CAgFlB"}
1
+ {"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAqD,MAAM,OAAO,CAAA;AACzF,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAU9D,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,KAAK,EACL,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,EAAE,2BAA2B,CAAA;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,KAAK,CAAC,SAAS,CA+FlB;AA4ED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,eAAe,EACf,eAAe,EACf,QAAQ,EACR,QAAgB,EAChB,oBAAoB,GACrB,EAAE;IACD,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,GAAG,KAAK,CAAC,SAAS,CAgFlB"}
@@ -1,10 +1,7 @@
1
1
  'use client';
2
- import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js';
3
- const { useLexicalComposerContext } = lexicalComposerContextImport;
4
- import lexicalUtilsImport from '@lexical/utils';
5
- const { mergeRegister } = lexicalUtilsImport;
6
- import lexicalImport from 'lexical';
7
- const { $getSelection } = lexicalImport;
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
+ import { mergeRegister } from '@lexical/utils';
4
+ import { $getSelection } from 'lexical';
8
5
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
9
6
  import React from 'react';
10
7
  import { createPortal } from 'react-dom';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport lexicalUtilsImport from '@lexical/utils'\nconst { mergeRegister } = lexicalUtilsImport\n\nimport lexicalImport from 'lexical'\nconst { $getSelection } = lexicalImport\n\nimport { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nconst baseClass = 'floating-select-toolbar-popup__dropdown-item'\n\ninterface DropDownContextType {\n registerItem: (ref: React.RefObject<HTMLButtonElement>) => void\n}\n\nconst DropDownContext = React.createContext<DropDownContextType | null>(null)\n\nexport function DropDownItem({\n children,\n entry,\n title,\n}: {\n children: React.ReactNode\n entry: FloatingToolbarSectionEntry\n title?: string\n}): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-${entry.key}` : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className, entry.key])\n\n const ref = useRef<HTMLButtonElement>(null)\n\n const dropDownContext = React.useContext(DropDownContext)\n\n if (dropDownContext === null) {\n throw new Error('DropDownItem must be used within a DropDown')\n }\n\n const { registerItem } = dropDownContext\n\n useEffect(() => {\n if (ref?.current != null) {\n registerItem(ref)\n }\n }, [ref, registerItem])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This is required for Firefox compatibility. Without it, the dropdown will disappear without the onClick being called.\n // This only happens in Firefox. Must be something about how Firefox handles focus events differently.\n e.preventDefault()\n }}\n ref={ref}\n title={title}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n\nfunction DropDownItems({\n children,\n dropDownRef,\n onClose,\n}: {\n children: React.ReactNode\n dropDownRef: React.Ref<HTMLDivElement>\n onClose: () => void\n}): JSX.Element {\n const [items, setItems] = useState<Array<React.RefObject<HTMLButtonElement>>>()\n const [highlightedItem, setHighlightedItem] = useState<React.RefObject<HTMLButtonElement>>()\n\n const registerItem = useCallback(\n (itemRef: React.RefObject<HTMLButtonElement>) => {\n setItems((prev) => (prev != null ? [...prev, itemRef] : [itemRef]))\n },\n [setItems],\n )\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>): void => {\n if (items == null) return\n\n const { key } = event\n\n if (['ArrowDown', 'ArrowUp', 'Escape', 'Tab'].includes(key)) {\n event.preventDefault()\n }\n\n if (key === 'Escape' || key === 'Tab') {\n onClose()\n } else if (key === 'ArrowUp') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n const index = items.indexOf(prev) - 1\n return items[index === -1 ? items.length - 1 : index]\n })\n } else if (key === 'ArrowDown') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n return items[items.indexOf(prev) + 1]\n })\n }\n }\n\n const contextValue = useMemo(\n () => ({\n registerItem,\n }),\n [registerItem],\n )\n\n useEffect(() => {\n if (items != null && highlightedItem == null) {\n setHighlightedItem(items[0])\n }\n\n if (highlightedItem?.current != null) {\n highlightedItem.current.focus()\n }\n }, [items, highlightedItem])\n\n return (\n <DropDownContext.Provider value={contextValue}>\n <div\n className=\"floating-select-toolbar-popup__dropdown-items\"\n onKeyDown={handleKeyDown}\n ref={dropDownRef}\n >\n {children}\n </div>\n </DropDownContext.Provider>\n )\n}\n\nexport function DropDown({\n Icon,\n buttonAriaLabel,\n buttonClassName,\n children,\n disabled = false,\n stopCloseOnClickSelf,\n}: {\n Icon?: React.FC\n buttonAriaLabel?: string\n buttonClassName: string\n children: ReactNode\n disabled?: boolean\n stopCloseOnClickSelf?: boolean\n}): React.ReactNode {\n const dropDownRef = useRef<HTMLDivElement>(null)\n const buttonRef = useRef<HTMLButtonElement>(null)\n const [showDropDown, setShowDropDown] = useState(false)\n\n const handleClose = (): void => {\n setShowDropDown(false)\n if (buttonRef?.current != null) {\n buttonRef.current.focus()\n }\n }\n\n useEffect(() => {\n const button = buttonRef.current\n const dropDown = dropDownRef.current\n\n if (showDropDown && button !== null && dropDown !== null) {\n const { left, top } = button.getBoundingClientRect()\n const scrollTopOffset = window.pageYOffset || document.documentElement.scrollTop\n dropDown.style.top = `${top + scrollTopOffset + button.offsetHeight + 5}px`\n dropDown.style.left = `${Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20)}px`\n }\n }, [dropDownRef, buttonRef, showDropDown])\n\n useEffect(() => {\n const button = buttonRef.current\n\n if (button !== null && showDropDown) {\n const handle = (event: MouseEvent): void => {\n const { target } = event\n if (stopCloseOnClickSelf != null) {\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (dropDownRef.current != null && dropDownRef.current.contains(target as Node)) {\n return\n }\n }\n if (!button.contains(target as Node)) {\n setShowDropDown(false)\n }\n }\n document.addEventListener('click', handle)\n\n return () => {\n document.removeEventListener('click', handle)\n }\n }\n }, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf])\n\n return (\n <React.Fragment>\n <button\n aria-label={buttonAriaLabel}\n className={buttonClassName + (showDropDown ? ' active' : '')}\n disabled={disabled}\n onClick={(event) => {\n event.preventDefault()\n setShowDropDown(!showDropDown)\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n ref={buttonRef}\n type=\"button\"\n >\n <Icon />\n <i className=\"floating-select-toolbar-popup__dropdown-caret\" />\n </button>\n\n {showDropDown &&\n createPortal(\n <DropDownItems dropDownRef={dropDownRef} onClose={handleClose}>\n {children}\n </DropDownItems>,\n document.body,\n )}\n </React.Fragment>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","mergeRegister","lexicalImport","$getSelection","useCallback","useEffect","useMemo","useRef","useState","React","createPortal","baseClass","DropDownContext","createContext","DropDownItem","children","entry","title","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","ref","dropDownContext","useContext","Error","registerItem","current","button","onClick","onMouseDown","e","preventDefault","type","DropDownItems","dropDownRef","onClose","items","setItems","highlightedItem","setHighlightedItem","itemRef","prev","handleKeyDown","event","includes","index","indexOf","length","contextValue","focus","Provider","value","div","onKeyDown","DropDown","Icon","buttonAriaLabel","buttonClassName","disabled","stopCloseOnClickSelf","buttonRef","showDropDown","setShowDropDown","handleClose","dropDown","left","top","getBoundingClientRect","scrollTopOffset","window","pageYOffset","documentElement","scrollTop","style","offsetHeight","Math","min","innerWidth","offsetWidth","handle","target","contains","Fragment","aria-label","i","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,SAAyBE,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACzF,OAAOC,WAAW,QAAO;AACzB,SAASC,YAAY,QAAQ,YAAW;AAIxC,MAAMC,YAAY;AAMlB,MAAMC,gCAAkBH,MAAMI,aAAa,CAA6B;AAExE,OAAO,SAASC,aAAa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B,2BACD,oBAAC6B;QAAE/E,WAAU;SAGdwD,8BACCrE,2BACE,oBAACyC;QAAcC,aAAaA;QAAaC,SAAS4B;OAC/ClE,WAEHgB,SAASwE,IAAI;AAIvB"}
1
+ {"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { $getSelection } from 'lexical'\nimport { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nconst baseClass = 'floating-select-toolbar-popup__dropdown-item'\n\ninterface DropDownContextType {\n registerItem: (ref: React.RefObject<HTMLButtonElement>) => void\n}\n\nconst DropDownContext = React.createContext<DropDownContextType | null>(null)\n\nexport function DropDownItem({\n children,\n entry,\n title,\n}: {\n children: React.ReactNode\n entry: FloatingToolbarSectionEntry\n title?: string\n}): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-${entry.key}` : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className, entry.key])\n\n const ref = useRef<HTMLButtonElement>(null)\n\n const dropDownContext = React.useContext(DropDownContext)\n\n if (dropDownContext === null) {\n throw new Error('DropDownItem must be used within a DropDown')\n }\n\n const { registerItem } = dropDownContext\n\n useEffect(() => {\n if (ref?.current != null) {\n registerItem(ref)\n }\n }, [ref, registerItem])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This is required for Firefox compatibility. Without it, the dropdown will disappear without the onClick being called.\n // This only happens in Firefox. Must be something about how Firefox handles focus events differently.\n e.preventDefault()\n }}\n ref={ref}\n title={title}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n\nfunction DropDownItems({\n children,\n dropDownRef,\n onClose,\n}: {\n children: React.ReactNode\n dropDownRef: React.Ref<HTMLDivElement>\n onClose: () => void\n}): JSX.Element {\n const [items, setItems] = useState<Array<React.RefObject<HTMLButtonElement>>>()\n const [highlightedItem, setHighlightedItem] = useState<React.RefObject<HTMLButtonElement>>()\n\n const registerItem = useCallback(\n (itemRef: React.RefObject<HTMLButtonElement>) => {\n setItems((prev) => (prev != null ? [...prev, itemRef] : [itemRef]))\n },\n [setItems],\n )\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>): void => {\n if (items == null) return\n\n const { key } = event\n\n if (['ArrowDown', 'ArrowUp', 'Escape', 'Tab'].includes(key)) {\n event.preventDefault()\n }\n\n if (key === 'Escape' || key === 'Tab') {\n onClose()\n } else if (key === 'ArrowUp') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n const index = items.indexOf(prev) - 1\n return items[index === -1 ? items.length - 1 : index]\n })\n } else if (key === 'ArrowDown') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n return items[items.indexOf(prev) + 1]\n })\n }\n }\n\n const contextValue = useMemo(\n () => ({\n registerItem,\n }),\n [registerItem],\n )\n\n useEffect(() => {\n if (items != null && highlightedItem == null) {\n setHighlightedItem(items[0])\n }\n\n if (highlightedItem?.current != null) {\n highlightedItem.current.focus()\n }\n }, [items, highlightedItem])\n\n return (\n <DropDownContext.Provider value={contextValue}>\n <div\n className=\"floating-select-toolbar-popup__dropdown-items\"\n onKeyDown={handleKeyDown}\n ref={dropDownRef}\n >\n {children}\n </div>\n </DropDownContext.Provider>\n )\n}\n\nexport function DropDown({\n Icon,\n buttonAriaLabel,\n buttonClassName,\n children,\n disabled = false,\n stopCloseOnClickSelf,\n}: {\n Icon?: React.FC\n buttonAriaLabel?: string\n buttonClassName: string\n children: ReactNode\n disabled?: boolean\n stopCloseOnClickSelf?: boolean\n}): React.ReactNode {\n const dropDownRef = useRef<HTMLDivElement>(null)\n const buttonRef = useRef<HTMLButtonElement>(null)\n const [showDropDown, setShowDropDown] = useState(false)\n\n const handleClose = (): void => {\n setShowDropDown(false)\n if (buttonRef?.current != null) {\n buttonRef.current.focus()\n }\n }\n\n useEffect(() => {\n const button = buttonRef.current\n const dropDown = dropDownRef.current\n\n if (showDropDown && button !== null && dropDown !== null) {\n const { left, top } = button.getBoundingClientRect()\n const scrollTopOffset = window.pageYOffset || document.documentElement.scrollTop\n dropDown.style.top = `${top + scrollTopOffset + button.offsetHeight + 5}px`\n dropDown.style.left = `${Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20)}px`\n }\n }, [dropDownRef, buttonRef, showDropDown])\n\n useEffect(() => {\n const button = buttonRef.current\n\n if (button !== null && showDropDown) {\n const handle = (event: MouseEvent): void => {\n const { target } = event\n if (stopCloseOnClickSelf != null) {\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (dropDownRef.current != null && dropDownRef.current.contains(target as Node)) {\n return\n }\n }\n if (!button.contains(target as Node)) {\n setShowDropDown(false)\n }\n }\n document.addEventListener('click', handle)\n\n return () => {\n document.removeEventListener('click', handle)\n }\n }\n }, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf])\n\n return (\n <React.Fragment>\n <button\n aria-label={buttonAriaLabel}\n className={buttonClassName + (showDropDown ? ' active' : '')}\n disabled={disabled}\n onClick={(event) => {\n event.preventDefault()\n setShowDropDown(!showDropDown)\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n ref={buttonRef}\n type=\"button\"\n >\n <Icon />\n <i className=\"floating-select-toolbar-popup__dropdown-caret\" />\n </button>\n\n {showDropDown &&\n createPortal(\n <DropDownItems dropDownRef={dropDownRef} onClose={handleClose}>\n {children}\n </DropDownItems>,\n document.body,\n )}\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","useCallback","useEffect","useMemo","useRef","useState","React","createPortal","baseClass","DropDownContext","createContext","DropDownItem","children","entry","title","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","ref","dropDownContext","useContext","Error","registerItem","current","button","onClick","onMouseDown","e","preventDefault","type","DropDownItems","dropDownRef","onClose","items","setItems","highlightedItem","setHighlightedItem","itemRef","prev","handleKeyDown","event","includes","index","indexOf","length","contextValue","focus","Provider","value","div","onKeyDown","DropDown","Icon","buttonAriaLabel","buttonClassName","disabled","stopCloseOnClickSelf","buttonRef","showDropDown","setShowDropDown","handleClose","dropDown","left","top","getBoundingClientRect","scrollTopOffset","window","pageYOffset","documentElement","scrollTop","style","offsetHeight","Math","min","innerWidth","offsetWidth","handle","target","contains","Fragment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E;oBACpE,IAAIzB,YAAYR,OAAO,IAAI,QAAQQ,YAAYR,OAAO,CAACuD,QAAQ,CAACD,SAAiB;wBAC/E;oBACF;gBACF;gBACA,IAAI,CAACrD,OAAOsD,QAAQ,CAACD,SAAiB;oBACpClB,gBAAgB;gBAClB;YACF;YACAjD,SAASC,gBAAgB,CAAC,SAASiE;YAEnC,OAAO;gBACLlE,SAASE,mBAAmB,CAAC,SAASgE;YACxC;QACF;IACF,GAAG;QAAC7C;QAAa0B;QAAWC;QAAcF;KAAqB;IAE/D,qBACE,oBAACpE,MAAM2F,QAAQ,sBACb,oBAACvD;QACCwD,cAAY3B;QACZnD,WAAWoD,kBAAmBI,CAAAA,eAAe,YAAY,EAAC;QAC1DH,UAAUA;QACV9B,SAAS,CAACe;YACRA,MAAMZ,cAAc;YACpB+B,gBAAgB,CAACD;QACnB;QACAhC,aAAa,CAACC;YACZ,8HAA8H;YAC9H,2JAA2J;YAC3J,sKAAsK;YACtKA,EAAEC,cAAc;QAClB;QACAV,KAAKuC;QACL5B,MAAK;qBAEL,oBAACuB,2BACD,oBAAC6B;QAAE/E,WAAU;SAGdwD,8BACCrE,2BACE,oBAACyC;QAAcC,aAAaA;QAAaC,SAAS4B;OAC/ClE,WAEHgB,SAASwE,IAAI;AAIvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/plugins/FloatingSelectToolbar/index.tsx"],"names":[],"mappings":";AA6BA,OAAO,cAAc,CAAA;AAoVrB,wBAAgB,2BAA2B,CAAC,EAC1C,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAGrB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/plugins/FloatingSelectToolbar/index.tsx"],"names":[],"mappings":";AAuBA,OAAO,cAAc,CAAA;AAoVrB,wBAAgB,2BAA2B,CAAC,EAC1C,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAGrB"}
@@ -1,10 +1,7 @@
1
1
  'use client';
2
- import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js';
3
- const { useLexicalComposerContext } = lexicalComposerContextImport;
4
- import lexicalUtilsImport from '@lexical/utils';
5
- const { mergeRegister } = lexicalUtilsImport;
6
- import lexicalImport from 'lexical';
7
- const { $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_LOW, SELECTION_CHANGE_COMMAND } = lexicalImport;
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
+ import { mergeRegister } from '@lexical/utils';
4
+ import { $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_LOW, SELECTION_CHANGE_COMMAND } from 'lexical';
8
5
  import { useCallback, useEffect, useRef, useState } from 'react';
9
6
  import * as React from 'react';
10
7
  import { createPortal } from 'react-dom';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/plugins/FloatingSelectToolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport lexicalUtilsImport from '@lexical/utils'\nconst { mergeRegister } = lexicalUtilsImport\n\nimport lexicalImport from 'lexical'\nconst {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n SELECTION_CHANGE_COMMAND,\n} = lexicalImport\n\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { FloatingToolbarSection, FloatingToolbarSectionEntry } from './types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { getDOMRangeRect } from '../../utils/getDOMRangeRect.js'\nimport { setFloatingElemPosition } from '../../utils/setFloatingElemPosition.js'\nimport { ToolbarButton } from './ToolbarButton/index.js'\nimport { ToolbarDropdown } from './ToolbarDropdown/index.js'\nimport './index.scss'\n\nfunction ButtonSectionEntry({\n anchorElem,\n editor,\n entry,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n entry: FloatingToolbarSectionEntry\n}): React.ReactNode {\n if (entry.Component) {\n return (\n entry?.Component && (\n <entry.Component anchorElem={anchorElem} editor={editor} entry={entry} key={entry.key} />\n )\n )\n }\n\n return (\n <ToolbarButton entry={entry} key={entry.key}>\n {entry?.ChildComponent && <entry.ChildComponent />}\n </ToolbarButton>\n )\n}\n\nfunction ToolbarSection({\n anchorElem,\n editor,\n index,\n section,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n index: number\n section: FloatingToolbarSection\n}): React.ReactNode {\n const { editorConfig } = useEditorConfigContext()\n\n const Icon =\n section?.type === 'dropdown' && section.entries.length && section.ChildComponent\n ? section.ChildComponent\n : null\n\n return (\n <div\n className={`floating-select-toolbar-popup__section floating-select-toolbar-popup__section-${section.key}`}\n key={section.key}\n >\n {section.type === 'dropdown' &&\n section.entries.length &&\n (Icon ? (\n <ToolbarDropdown\n Icon={Icon}\n anchorElem={anchorElem}\n editor={editor}\n entries={section.entries}\n sectionKey={section.key}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n entries={section.entries}\n sectionKey={section.key}\n />\n ))}\n {section.type === 'buttons' &&\n section.entries.length &&\n section.entries.map((entry) => {\n return (\n <ButtonSectionEntry\n anchorElem={anchorElem}\n editor={editor}\n entry={entry}\n key={entry.key}\n />\n )\n })}\n {index < editorConfig.features.floatingSelectToolbar?.sections.length - 1 && (\n <div className=\"divider\" />\n )}\n </div>\n )\n}\n\nfunction FloatingSelectToolbar({\n anchorElem,\n editor,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n}): React.ReactNode {\n const popupCharStylesEditorRef = useRef<HTMLDivElement | null>(null)\n const caretRef = useRef<HTMLDivElement | null>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const closeFloatingToolbar = useCallback(() => {\n if (popupCharStylesEditorRef?.current) {\n const isOpacityZero = popupCharStylesEditorRef.current.style.opacity === '0'\n const isPointerEventsNone = popupCharStylesEditorRef.current.style.pointerEvents === 'none'\n\n if (!isOpacityZero) {\n popupCharStylesEditorRef.current.style.opacity = '0'\n }\n if (!isPointerEventsNone) {\n popupCharStylesEditorRef.current.style.pointerEvents = 'none'\n }\n }\n }, [popupCharStylesEditorRef])\n\n const mouseMoveListener = useCallback(\n (e: MouseEvent) => {\n if (popupCharStylesEditorRef?.current && (e.buttons === 1 || e.buttons === 3)) {\n const isOpacityZero = popupCharStylesEditorRef.current.style.opacity === '0'\n const isPointerEventsNone = popupCharStylesEditorRef.current.style.pointerEvents === 'none'\n if (!isOpacityZero || !isPointerEventsNone) {\n // Check if the mouse is not over the popup\n const x = e.clientX\n const y = e.clientY\n const elementUnderMouse = document.elementFromPoint(x, y)\n if (!popupCharStylesEditorRef.current.contains(elementUnderMouse)) {\n // Mouse is not over the target element => not a normal click, but probably a drag\n closeFloatingToolbar()\n }\n }\n }\n },\n [closeFloatingToolbar],\n )\n\n const mouseUpListener = useCallback(() => {\n if (popupCharStylesEditorRef?.current) {\n if (popupCharStylesEditorRef.current.style.opacity !== '1') {\n popupCharStylesEditorRef.current.style.opacity = '1'\n }\n if (popupCharStylesEditorRef.current.style.pointerEvents !== 'auto') {\n popupCharStylesEditorRef.current.style.pointerEvents = 'auto'\n }\n }\n }, [popupCharStylesEditorRef])\n\n useEffect(() => {\n document.addEventListener('mousemove', mouseMoveListener)\n document.addEventListener('mouseup', mouseUpListener)\n\n return () => {\n document.removeEventListener('mousemove', mouseMoveListener)\n document.removeEventListener('mouseup', mouseUpListener)\n }\n }, [popupCharStylesEditorRef, mouseMoveListener, mouseUpListener])\n\n const updateTextFormatFloatingToolbar = useCallback(() => {\n const selection = $getSelection()\n\n const popupCharStylesEditorElem = popupCharStylesEditorRef.current\n const nativeSelection = window.getSelection()\n\n if (popupCharStylesEditorElem === null) {\n return\n }\n\n const rootElement = editor.getRootElement()\n if (\n selection !== null &&\n nativeSelection !== null &&\n !nativeSelection.isCollapsed &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n const rangeRect = getDOMRangeRect(nativeSelection, rootElement)\n\n setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElem, 'center')\n\n if (caretRef.current) {\n setFloatingElemPosition(\n rangeRect, // selection to position around\n caretRef.current, // what to position\n popupCharStylesEditorElem, // anchor elem\n 'center',\n 10,\n 5,\n true,\n )\n }\n }\n }, [editor, anchorElem])\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement\n\n const update = () => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar()\n })\n }\n\n window.addEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.addEventListener('scroll', update)\n }\n\n return () => {\n window.removeEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.removeEventListener('scroll', update)\n }\n }\n }, [editor, updateTextFormatFloatingToolbar, anchorElem])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar()\n })\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateTextFormatFloatingToolbar()\n })\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n updateTextFormatFloatingToolbar()\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateTextFormatFloatingToolbar])\n\n return (\n <div className=\"floating-select-toolbar-popup\" ref={popupCharStylesEditorRef}>\n <div className=\"caret\" ref={caretRef} />\n {editor.isEditable() && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.floatingSelectToolbar?.sections.map((section, i) => {\n return (\n <ToolbarSection\n anchorElem={anchorElem}\n editor={editor}\n index={i}\n key={section.key}\n section={section}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nfunction useFloatingTextFormatToolbar(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n): JSX.Element | null {\n const [isText, setIsText] = useState(false)\n\n const updatePopup = useCallback(() => {\n editor.getEditorState().read(() => {\n // Should not to pop up the floating toolbar when using IME input\n if (editor.isComposing()) {\n return\n }\n const selection = $getSelection()\n const nativeSelection = window.getSelection()\n const rootElement = editor.getRootElement()\n\n if (\n nativeSelection !== null &&\n (!$isRangeSelection(selection) ||\n rootElement === null ||\n !rootElement.contains(nativeSelection.anchorNode))\n ) {\n setIsText(false)\n return\n }\n\n if (!$isRangeSelection(selection)) {\n return\n }\n\n if (selection.getTextContent() !== '') {\n const nodes = selection.getNodes()\n let foundNodeWithText = false\n for (const node of nodes) {\n if ($isTextNode(node)) {\n setIsText(true)\n foundNodeWithText = true\n break\n }\n }\n if (!foundNodeWithText) {\n setIsText(false)\n }\n } else {\n setIsText(false)\n }\n\n const rawTextContent = selection.getTextContent().replace(/\\n/g, '')\n if (!selection.isCollapsed() && rawTextContent === '') {\n setIsText(false)\n return\n }\n })\n }, [editor])\n\n useEffect(() => {\n document.addEventListener('selectionchange', updatePopup)\n document.addEventListener('mouseup', updatePopup)\n return () => {\n document.removeEventListener('selectionchange', updatePopup)\n document.removeEventListener('mouseup', updatePopup)\n }\n }, [updatePopup])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updatePopup()\n }),\n editor.registerRootListener(() => {\n if (editor.getRootElement() === null) {\n setIsText(false)\n }\n }),\n )\n }, [editor, updatePopup])\n\n if (!isText) {\n return null\n }\n\n return createPortal(<FloatingSelectToolbar anchorElem={anchorElem} editor={editor} />, anchorElem)\n}\n\nexport function FloatingSelectToolbarPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n return useFloatingTextFormatToolbar(editor, anchorElem)\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","mergeRegister","lexicalImport","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","SELECTION_CHANGE_COMMAND","useCallback","useEffect","useRef","useState","React","createPortal","useEditorConfigContext","getDOMRangeRect","setFloatingElemPosition","ToolbarButton","ToolbarDropdown","ButtonSectionEntry","anchorElem","editor","entry","Component","key","ChildComponent","ToolbarSection","index","section","editorConfig","Icon","type","entries","length","div","className","sectionKey","map","features","floatingSelectToolbar","sections","FloatingSelectToolbar","popupCharStylesEditorRef","caretRef","closeFloatingToolbar","current","isOpacityZero","style","opacity","isPointerEventsNone","pointerEvents","mouseMoveListener","e","buttons","x","clientX","y","clientY","elementUnderMouse","document","elementFromPoint","contains","mouseUpListener","addEventListener","removeEventListener","updateTextFormatFloatingToolbar","selection","popupCharStylesEditorElem","nativeSelection","window","getSelection","rootElement","getRootElement","isCollapsed","anchorNode","rangeRect","scrollerElem","parentElement","update","getEditorState","read","registerUpdateListener","editorState","registerCommand","ref","isEditable","Fragment","i","useFloatingTextFormatToolbar","isText","setIsText","updatePopup","isComposing","getTextContent","nodes","getNodes","foundNodeWithText","node","rawTextContent","replace","registerRootListener","FloatingSelectToolbarPlugin","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,aAAa,EAAE,GAA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IACF,GAAG;QAACA;KAAY;IAEhBlF,UAAU;QACR,OAAOR,cACLoB,OAAO4D,sBAAsB,CAAC;YAC5BU;QACF,IACAtE,OAAO+E,oBAAoB,CAAC;YAC1B,IAAI/E,OAAOmD,cAAc,OAAO,MAAM;gBACpCkB,UAAU;YACZ;QACF;IAEJ,GAAG;QAACrE;QAAQsE;KAAY;IAExB,IAAI,CAACF,QAAQ;QACX,OAAO;IACT;IAEA,qBAAO5E,2BAAa,oBAAC4B;QAAsBrB,YAAYA;QAAYC,QAAQA;QAAYD;AACzF;AAEA,OAAO,SAASiF,4BAA4B,EAC1CjF,aAAauC,SAAS2C,IAAI,EAG3B;IACC,MAAM,CAACjF,OAAO,GAAGtB;IACjB,OAAOyF,6BAA6BnE,QAAQD;AAC9C"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/plugins/FloatingSelectToolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } 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 SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { FloatingToolbarSection, FloatingToolbarSectionEntry } from './types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { getDOMRangeRect } from '../../utils/getDOMRangeRect.js'\nimport { setFloatingElemPosition } from '../../utils/setFloatingElemPosition.js'\nimport { ToolbarButton } from './ToolbarButton/index.js'\nimport { ToolbarDropdown } from './ToolbarDropdown/index.js'\nimport './index.scss'\n\nfunction ButtonSectionEntry({\n anchorElem,\n editor,\n entry,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n entry: FloatingToolbarSectionEntry\n}): React.ReactNode {\n if (entry.Component) {\n return (\n entry?.Component && (\n <entry.Component anchorElem={anchorElem} editor={editor} entry={entry} key={entry.key} />\n )\n )\n }\n\n return (\n <ToolbarButton entry={entry} key={entry.key}>\n {entry?.ChildComponent && <entry.ChildComponent />}\n </ToolbarButton>\n )\n}\n\nfunction ToolbarSection({\n anchorElem,\n editor,\n index,\n section,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n index: number\n section: FloatingToolbarSection\n}): React.ReactNode {\n const { editorConfig } = useEditorConfigContext()\n\n const Icon =\n section?.type === 'dropdown' && section.entries.length && section.ChildComponent\n ? section.ChildComponent\n : null\n\n return (\n <div\n className={`floating-select-toolbar-popup__section floating-select-toolbar-popup__section-${section.key}`}\n key={section.key}\n >\n {section.type === 'dropdown' &&\n section.entries.length &&\n (Icon ? (\n <ToolbarDropdown\n Icon={Icon}\n anchorElem={anchorElem}\n editor={editor}\n entries={section.entries}\n sectionKey={section.key}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n entries={section.entries}\n sectionKey={section.key}\n />\n ))}\n {section.type === 'buttons' &&\n section.entries.length &&\n section.entries.map((entry) => {\n return (\n <ButtonSectionEntry\n anchorElem={anchorElem}\n editor={editor}\n entry={entry}\n key={entry.key}\n />\n )\n })}\n {index < editorConfig.features.floatingSelectToolbar?.sections.length - 1 && (\n <div className=\"divider\" />\n )}\n </div>\n )\n}\n\nfunction FloatingSelectToolbar({\n anchorElem,\n editor,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n}): React.ReactNode {\n const popupCharStylesEditorRef = useRef<HTMLDivElement | null>(null)\n const caretRef = useRef<HTMLDivElement | null>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const closeFloatingToolbar = useCallback(() => {\n if (popupCharStylesEditorRef?.current) {\n const isOpacityZero = popupCharStylesEditorRef.current.style.opacity === '0'\n const isPointerEventsNone = popupCharStylesEditorRef.current.style.pointerEvents === 'none'\n\n if (!isOpacityZero) {\n popupCharStylesEditorRef.current.style.opacity = '0'\n }\n if (!isPointerEventsNone) {\n popupCharStylesEditorRef.current.style.pointerEvents = 'none'\n }\n }\n }, [popupCharStylesEditorRef])\n\n const mouseMoveListener = useCallback(\n (e: MouseEvent) => {\n if (popupCharStylesEditorRef?.current && (e.buttons === 1 || e.buttons === 3)) {\n const isOpacityZero = popupCharStylesEditorRef.current.style.opacity === '0'\n const isPointerEventsNone = popupCharStylesEditorRef.current.style.pointerEvents === 'none'\n if (!isOpacityZero || !isPointerEventsNone) {\n // Check if the mouse is not over the popup\n const x = e.clientX\n const y = e.clientY\n const elementUnderMouse = document.elementFromPoint(x, y)\n if (!popupCharStylesEditorRef.current.contains(elementUnderMouse)) {\n // Mouse is not over the target element => not a normal click, but probably a drag\n closeFloatingToolbar()\n }\n }\n }\n },\n [closeFloatingToolbar],\n )\n\n const mouseUpListener = useCallback(() => {\n if (popupCharStylesEditorRef?.current) {\n if (popupCharStylesEditorRef.current.style.opacity !== '1') {\n popupCharStylesEditorRef.current.style.opacity = '1'\n }\n if (popupCharStylesEditorRef.current.style.pointerEvents !== 'auto') {\n popupCharStylesEditorRef.current.style.pointerEvents = 'auto'\n }\n }\n }, [popupCharStylesEditorRef])\n\n useEffect(() => {\n document.addEventListener('mousemove', mouseMoveListener)\n document.addEventListener('mouseup', mouseUpListener)\n\n return () => {\n document.removeEventListener('mousemove', mouseMoveListener)\n document.removeEventListener('mouseup', mouseUpListener)\n }\n }, [popupCharStylesEditorRef, mouseMoveListener, mouseUpListener])\n\n const updateTextFormatFloatingToolbar = useCallback(() => {\n const selection = $getSelection()\n\n const popupCharStylesEditorElem = popupCharStylesEditorRef.current\n const nativeSelection = window.getSelection()\n\n if (popupCharStylesEditorElem === null) {\n return\n }\n\n const rootElement = editor.getRootElement()\n if (\n selection !== null &&\n nativeSelection !== null &&\n !nativeSelection.isCollapsed &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n const rangeRect = getDOMRangeRect(nativeSelection, rootElement)\n\n setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElem, 'center')\n\n if (caretRef.current) {\n setFloatingElemPosition(\n rangeRect, // selection to position around\n caretRef.current, // what to position\n popupCharStylesEditorElem, // anchor elem\n 'center',\n 10,\n 5,\n true,\n )\n }\n }\n }, [editor, anchorElem])\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement\n\n const update = () => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar()\n })\n }\n\n window.addEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.addEventListener('scroll', update)\n }\n\n return () => {\n window.removeEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.removeEventListener('scroll', update)\n }\n }\n }, [editor, updateTextFormatFloatingToolbar, anchorElem])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar()\n })\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateTextFormatFloatingToolbar()\n })\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n updateTextFormatFloatingToolbar()\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateTextFormatFloatingToolbar])\n\n return (\n <div className=\"floating-select-toolbar-popup\" ref={popupCharStylesEditorRef}>\n <div className=\"caret\" ref={caretRef} />\n {editor.isEditable() && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.floatingSelectToolbar?.sections.map((section, i) => {\n return (\n <ToolbarSection\n anchorElem={anchorElem}\n editor={editor}\n index={i}\n key={section.key}\n section={section}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nfunction useFloatingTextFormatToolbar(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n): JSX.Element | null {\n const [isText, setIsText] = useState(false)\n\n const updatePopup = useCallback(() => {\n editor.getEditorState().read(() => {\n // Should not to pop up the floating toolbar when using IME input\n if (editor.isComposing()) {\n return\n }\n const selection = $getSelection()\n const nativeSelection = window.getSelection()\n const rootElement = editor.getRootElement()\n\n if (\n nativeSelection !== null &&\n (!$isRangeSelection(selection) ||\n rootElement === null ||\n !rootElement.contains(nativeSelection.anchorNode))\n ) {\n setIsText(false)\n return\n }\n\n if (!$isRangeSelection(selection)) {\n return\n }\n\n if (selection.getTextContent() !== '') {\n const nodes = selection.getNodes()\n let foundNodeWithText = false\n for (const node of nodes) {\n if ($isTextNode(node)) {\n setIsText(true)\n foundNodeWithText = true\n break\n }\n }\n if (!foundNodeWithText) {\n setIsText(false)\n }\n } else {\n setIsText(false)\n }\n\n const rawTextContent = selection.getTextContent().replace(/\\n/g, '')\n if (!selection.isCollapsed() && rawTextContent === '') {\n setIsText(false)\n return\n }\n })\n }, [editor])\n\n useEffect(() => {\n document.addEventListener('selectionchange', updatePopup)\n document.addEventListener('mouseup', updatePopup)\n return () => {\n document.removeEventListener('selectionchange', updatePopup)\n document.removeEventListener('mouseup', updatePopup)\n }\n }, [updatePopup])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updatePopup()\n }),\n editor.registerRootListener(() => {\n if (editor.getRootElement() === null) {\n setIsText(false)\n }\n }),\n )\n }, [editor, updatePopup])\n\n if (!isText) {\n return null\n }\n\n return createPortal(<FloatingSelectToolbar anchorElem={anchorElem} editor={editor} />, anchorElem)\n}\n\nexport function FloatingSelectToolbarPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n return useFloatingTextFormatToolbar(editor, anchorElem)\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","SELECTION_CHANGE_COMMAND","useCallback","useEffect","useRef","useState","React","createPortal","useEditorConfigContext","getDOMRangeRect","setFloatingElemPosition","ToolbarButton","ToolbarDropdown","ButtonSectionEntry","anchorElem","editor","entry","Component","key","ChildComponent","ToolbarSection","index","section","editorConfig","Icon","type","entries","length","div","className","sectionKey","map","features","floatingSelectToolbar","sections","FloatingSelectToolbar","popupCharStylesEditorRef","caretRef","closeFloatingToolbar","current","isOpacityZero","style","opacity","isPointerEventsNone","pointerEvents","mouseMoveListener","e","buttons","x","clientX","y","clientY","elementUnderMouse","document","elementFromPoint","contains","mouseUpListener","addEventListener","removeEventListener","updateTextFormatFloatingToolbar","selection","popupCharStylesEditorElem","nativeSelection","window","getSelection","rootElement","getRootElement","isCollapsed","anchorNode","rangeRect","scrollerElem","parentElement","update","getEditorState","read","registerUpdateListener","editorState","registerCommand","ref","isEditable","Fragment","i","useFloatingTextFormatToolbar","isText","setIsText","updatePopup","isComposing","getTextContent","nodes","getNodes","foundNodeWithText","node","rawTextContent","replace","registerRootListener","FloatingSelectToolbarPlugin","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SACEC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,oBAAoB,EACpBC,wBAAwB,QACnB,UAAS;AAChB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChE,YAAYC,WAAW,QAAO;AAC9B,SAASC,YAAY,QAAQ,YAAW;AAIxC,SAASC,sBAAsB,QAAQ,8CAA6C;AACpF,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,aAAa,QAAQ,2BAA0B;A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AI,EAG3B;IACC,MAAM,CAACjF,OAAO,GAAGpB;IACjB,OAAOuF,6BAA6BnE,QAAQD;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/plugins/MarkdownShortcut/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAI1C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/plugins/MarkdownShortcut/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAI1C,CAAA"}
@@ -1,6 +1,5 @@
1
1
  'use client';
2
- import lexicalMarkdownShortcutPluginImport from '@lexical/react/LexicalMarkdownShortcutPlugin.js';
3
- const { MarkdownShortcutPlugin: LexicalMarkdownShortcutPlugin } = lexicalMarkdownShortcutPluginImport;
2
+ import { MarkdownShortcutPlugin as LexicalMarkdownShortcutPlugin } from '@lexical/react/LexicalMarkdownShortcutPlugin.js';
4
3
  import * as React from 'react';
5
4
  import { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js';
6
5
  export const MarkdownShortcutPlugin = ()=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/plugins/MarkdownShortcut/index.tsx"],"sourcesContent":["'use client'\n\nimport lexicalMarkdownShortcutPluginImport from '@lexical/react/LexicalMarkdownShortcutPlugin.js'\nconst { MarkdownShortcutPlugin: LexicalMarkdownShortcutPlugin } =\n lexicalMarkdownShortcutPluginImport\n\nimport * as React from 'react'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\n\nexport const MarkdownShortcutPlugin: React.FC = () => {\n const { editorConfig } = useEditorConfigContext()\n\n return <LexicalMarkdownShortcutPlugin transformers={editorConfig.features.markdownTransformers} />\n}\n"],"names":["lexicalMarkdownShortcutPluginImport","MarkdownShortcutPlugin","LexicalMarkdownShortcutPlugin","React","useEditorConfigContext","editorConfig","transformers","features","markdownTransformers"],"rangeMappings":";;;;;;;;;;","mappings":"AAAA;AAEA,OAAOA,yCAAyC,kDAAiD;AACjG,MAAM,EAAEC,wBAAwBC,6BAA6B,EAAE,GAC7DF;AAEF,YAAYG,WAAW,QAAO;AAE9B,SAASC,sBAAsB,QAAQ,8CAA6C;AAEpF,OAAO,MAAMH,yBAAmC;IAC9C,MAAM,EAAEI,YAAY,EAAE,GAAGD;IAEzB,qBAAO,oBAACF;QAA8BI,cAAcD,aAAaE,QAAQ,CAACC,oBAAoB;;AAChG,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/plugins/MarkdownShortcut/index.tsx"],"sourcesContent":["'use client'\n\nimport { MarkdownShortcutPlugin as LexicalMarkdownShortcutPlugin } from '@lexical/react/LexicalMarkdownShortcutPlugin.js'\nimport * as React from 'react'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\n\nexport const MarkdownShortcutPlugin: React.FC = () => {\n const { editorConfig } = useEditorConfigContext()\n\n return <LexicalMarkdownShortcutPlugin transformers={editorConfig.features.markdownTransformers} />\n}\n"],"names":["MarkdownShortcutPlugin","LexicalMarkdownShortcutPlugin","React","useEditorConfigContext","editorConfig","transformers","features","markdownTransformers"],"rangeMappings":";;;;;;;;;","mappings":"AAAA;AAEA,SAASA,0BAA0BC,6BAA6B,QAAQ,kDAAiD;AACzH,YAAYC,WAAW,QAAO;AAE9B,SAASC,sBAAsB,QAAQ,8CAA6C;AAEpF,OAAO,MAAMH,yBAAmC;IAC9C,MAAM,EAAEI,YAAY,EAAE,GAAGD;IAEzB,qBAAO,oBAACF;QAA8BI,cAAcD,aAAaE,QAAQ,CAACC,oBAAoB;;AAChG,EAAC"}