@webiny/lexical-editor 0.0.0-unstable.df6d94b531 → 0.0.0-unstable.df7a8bb475

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 (325) hide show
  1. package/README.md +6 -12
  2. package/commands/image.d.ts +6 -0
  3. package/commands/image.js +4 -0
  4. package/commands/image.js.map +1 -0
  5. package/commands/index.d.ts +5 -0
  6. package/commands/index.js +7 -0
  7. package/commands/index.js.map +1 -0
  8. package/commands/list.d.ts +7 -0
  9. package/commands/list.js +6 -0
  10. package/commands/list.js.map +1 -0
  11. package/commands/quote.d.ts +5 -0
  12. package/commands/quote.js +4 -0
  13. package/commands/quote.js.map +1 -0
  14. package/commands/toolbar.d.ts +1 -0
  15. package/commands/toolbar.js +4 -0
  16. package/commands/toolbar.js.map +1 -0
  17. package/commands/typography.d.ts +8 -0
  18. package/commands/typography.js +4 -0
  19. package/commands/typography.js.map +1 -0
  20. package/components/Editor/EnsureHeadingTagPlugin.d.ts +6 -0
  21. package/components/Editor/EnsureHeadingTagPlugin.js +20 -0
  22. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -0
  23. package/components/Editor/RichTextEditor.d.ts +44 -15
  24. package/components/Editor/RichTextEditor.js +119 -95
  25. package/components/Editor/RichTextEditor.js.map +1 -1
  26. package/components/Editor/normalizeInputValue.d.ts +6 -0
  27. package/components/Editor/normalizeInputValue.js +16 -0
  28. package/components/Editor/normalizeInputValue.js.map +1 -0
  29. package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +17 -6
  30. package/components/LexicalEditorConfig/LexicalEditorConfig.js +24 -14
  31. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
  32. package/components/LexicalEditorConfig/components/Node.d.ts +14 -0
  33. package/components/LexicalEditorConfig/components/Node.js +30 -0
  34. package/components/LexicalEditorConfig/components/Node.js.map +1 -0
  35. package/components/LexicalEditorConfig/components/Plugin.d.ts +13 -0
  36. package/components/LexicalEditorConfig/components/Plugin.js +30 -0
  37. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -0
  38. package/components/LexicalEditorConfig/components/ToolbarElement.d.ts +13 -0
  39. package/components/LexicalEditorConfig/components/ToolbarElement.js +30 -0
  40. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -0
  41. package/components/LexicalHtmlRenderer.d.ts +5 -5
  42. package/components/LexicalHtmlRenderer.js +42 -40
  43. package/components/LexicalHtmlRenderer.js.map +1 -1
  44. package/components/Toolbar/StaticToolbar.css +260 -0
  45. package/components/Toolbar/StaticToolbar.d.ts +5 -0
  46. package/components/Toolbar/StaticToolbar.js +22 -0
  47. package/components/Toolbar/StaticToolbar.js.map +1 -0
  48. package/components/Toolbar/Toolbar.css +259 -39
  49. package/components/Toolbar/Toolbar.d.ts +2 -9
  50. package/components/Toolbar/Toolbar.js +116 -129
  51. package/components/Toolbar/Toolbar.js.map +1 -1
  52. package/components/ToolbarActions/BoldAction.d.ts +2 -5
  53. package/components/ToolbarActions/BoldAction.js +20 -33
  54. package/components/ToolbarActions/BoldAction.js.map +1 -1
  55. package/components/ToolbarActions/BulletListAction.d.ts +2 -5
  56. package/components/ToolbarActions/BulletListAction.js +30 -80
  57. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  58. package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -6
  59. package/components/ToolbarActions/CodeHighlightAction.js +20 -34
  60. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
  61. package/components/ToolbarActions/FontColorAction.d.ts +22 -4
  62. package/components/ToolbarActions/FontColorAction.js +44 -78
  63. package/components/ToolbarActions/FontColorAction.js.map +1 -1
  64. package/components/ToolbarActions/ImageAction.d.ts +2 -0
  65. package/components/ToolbarActions/ImageAction.js +37 -0
  66. package/components/ToolbarActions/ImageAction.js.map +1 -0
  67. package/components/ToolbarActions/ItalicAction.d.ts +2 -5
  68. package/components/ToolbarActions/ItalicAction.js +20 -33
  69. package/components/ToolbarActions/ItalicAction.js.map +1 -1
  70. package/components/ToolbarActions/LinkAction.d.ts +2 -7
  71. package/components/ToolbarActions/LinkAction.js +27 -59
  72. package/components/ToolbarActions/LinkAction.js.map +1 -1
  73. package/components/ToolbarActions/NumberedListAction.d.ts +2 -5
  74. package/components/ToolbarActions/NumberedListAction.js +35 -80
  75. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  76. package/components/ToolbarActions/QuoteAction.d.ts +2 -4
  77. package/components/ToolbarActions/QuoteAction.js +26 -59
  78. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  79. package/components/ToolbarActions/TextAlignmentAction.d.ts +29 -0
  80. package/components/ToolbarActions/TextAlignmentAction.js +61 -0
  81. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -0
  82. package/components/ToolbarActions/TypographyAction.d.ts +29 -0
  83. package/components/ToolbarActions/TypographyAction.js +111 -0
  84. package/components/ToolbarActions/TypographyAction.js.map +1 -0
  85. package/components/ToolbarActions/UnderlineAction.d.ts +2 -5
  86. package/components/ToolbarActions/UnderlineAction.js +20 -34
  87. package/components/ToolbarActions/UnderlineAction.js.map +1 -1
  88. package/context/FontColorActionContext.js +3 -9
  89. package/context/FontColorActionContext.js.map +1 -1
  90. package/context/RichTextEditorContext.d.ts +9 -3
  91. package/context/RichTextEditorContext.js +17 -25
  92. package/context/RichTextEditorContext.js.map +1 -1
  93. package/context/SharedHistoryContext.d.ts +10 -0
  94. package/context/SharedHistoryContext.js +19 -0
  95. package/context/SharedHistoryContext.js.map +1 -0
  96. package/context/TextAlignmentActionContextProps.d.ts +9 -0
  97. package/context/TextAlignmentActionContextProps.js +4 -0
  98. package/context/TextAlignmentActionContextProps.js.map +1 -0
  99. package/context/TypographyActionContext.d.ts +8 -0
  100. package/context/TypographyActionContext.js +4 -0
  101. package/context/TypographyActionContext.js.map +1 -0
  102. package/exports/admin/lexical.d.ts +15 -0
  103. package/exports/admin/lexical.js +23 -0
  104. package/exports/admin/lexical.js.map +1 -0
  105. package/hooks/index.d.ts +7 -0
  106. package/hooks/index.js +9 -0
  107. package/hooks/index.js.map +1 -0
  108. package/hooks/useCurrentElement.d.ts +7 -0
  109. package/hooks/useCurrentElement.js +27 -0
  110. package/hooks/useCurrentElement.js.map +1 -0
  111. package/hooks/useCurrentSelection.d.ts +13 -0
  112. package/hooks/useCurrentSelection.js +57 -0
  113. package/hooks/useCurrentSelection.js.map +1 -0
  114. package/hooks/useFontColorPicker.d.ts +1 -1
  115. package/hooks/useFontColorPicker.js +8 -12
  116. package/hooks/useFontColorPicker.js.map +1 -1
  117. package/hooks/useIsMounted.d.ts +1 -0
  118. package/hooks/useIsMounted.js +12 -0
  119. package/hooks/useIsMounted.js.map +1 -0
  120. package/hooks/useRichTextEditor.d.ts +1 -1
  121. package/hooks/useRichTextEditor.js +8 -12
  122. package/hooks/useRichTextEditor.js.map +1 -1
  123. package/hooks/useTextAlignmentAction.d.ts +1 -0
  124. package/hooks/useTextAlignmentAction.js +11 -0
  125. package/hooks/useTextAlignmentAction.js.map +1 -0
  126. package/hooks/useTypographyAction.d.ts +1 -0
  127. package/hooks/useTypographyAction.js +11 -0
  128. package/hooks/useTypographyAction.js.map +1 -0
  129. package/images/icons/indent.svg +3 -0
  130. package/images/icons/insert-image.svg +4 -0
  131. package/images/icons/justify.svg +3 -0
  132. package/images/icons/outdent.svg +3 -0
  133. package/index.d.ts +34 -37
  134. package/index.js +46 -259
  135. package/index.js.map +1 -1
  136. package/package.json +19 -22
  137. package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +2 -2
  138. package/plugins/BlurEventPlugin/BlurEventPlugin.js +18 -26
  139. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
  140. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +12 -18
  141. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
  142. package/plugins/CodeHighlightPlugin/index.d.ts +1 -1
  143. package/plugins/CodeHighlightPlugin/index.js +2 -15
  144. package/plugins/CodeHighlightPlugin/index.js.map +1 -1
  145. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +16 -0
  146. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +158 -0
  147. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
  148. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +8 -0
  149. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +62 -0
  150. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
  151. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +65 -7
  152. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +4 -5
  153. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +12 -220
  154. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  155. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +8 -0
  156. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +104 -0
  157. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +1 -0
  158. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +9 -0
  159. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +34 -0
  160. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +1 -0
  161. package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -1
  162. package/plugins/FloatingLinkEditorPlugin/index.js +2 -15
  163. package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
  164. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.d.ts +1 -0
  165. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +12 -0
  166. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -0
  167. package/plugins/FontColorPlugin/FontColorPlugin.d.ts +1 -2
  168. package/plugins/FontColorPlugin/FontColorPlugin.js +21 -32
  169. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
  170. package/plugins/FontColorPlugin/applyColorToNode.d.ts +3 -0
  171. package/plugins/FontColorPlugin/applyColorToNode.js +8 -0
  172. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -0
  173. package/plugins/FontColorPlugin/applyColorToSelection.d.ts +3 -0
  174. package/plugins/FontColorPlugin/applyColorToSelection.js +66 -0
  175. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -0
  176. package/plugins/ImagesPlugin/ImagesPlugin.d.ts +11 -0
  177. package/plugins/ImagesPlugin/ImagesPlugin.js +149 -0
  178. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -0
  179. package/plugins/LinkPlugin/LinkPlugin.d.ts +5 -0
  180. package/plugins/LinkPlugin/LinkPlugin.js +59 -0
  181. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -0
  182. package/plugins/ListPLugin/ListPlugin.d.ts +1 -0
  183. package/plugins/ListPLugin/ListPlugin.js +60 -0
  184. package/plugins/ListPLugin/ListPlugin.js.map +1 -0
  185. package/plugins/QuoteNodePlugin/QuoteNodePlugin.d.ts +1 -0
  186. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +27 -0
  187. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -0
  188. package/plugins/StateHandlingPlugin.d.ts +8 -0
  189. package/plugins/StateHandlingPlugin.js +75 -0
  190. package/plugins/StateHandlingPlugin.js.map +1 -0
  191. package/plugins/TypographyPlugin/TypographyPlugin.d.ts +1 -0
  192. package/plugins/TypographyPlugin/TypographyPlugin.js +27 -0
  193. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
  194. package/types.d.ts +12 -3
  195. package/types.js +9 -12
  196. package/types.js.map +1 -1
  197. package/ui/ContentEditable.css +22 -0
  198. package/{plugins/AutoLinkPlugin/AutoLinkPlugin.d.ts → ui/ContentEditable.d.ts} +4 -4
  199. package/ui/ContentEditable.js +19 -0
  200. package/ui/ContentEditable.js.map +1 -0
  201. package/ui/Divider.d.ts +0 -1
  202. package/ui/Divider.js +6 -11
  203. package/ui/Divider.js.map +1 -1
  204. package/ui/DropDown.d.ts +2 -3
  205. package/ui/DropDown.js +104 -94
  206. package/ui/DropDown.js.map +1 -1
  207. package/ui/ImageResizer.d.ts +23 -0
  208. package/ui/ImageResizer.js +211 -0
  209. package/ui/ImageResizer.js.map +1 -0
  210. package/ui/LinkPreview.d.ts +0 -1
  211. package/ui/LinkPreview.js +32 -36
  212. package/ui/LinkPreview.js.map +1 -1
  213. package/ui/Placeholder.css +2 -5
  214. package/ui/Placeholder.d.ts +4 -2
  215. package/ui/Placeholder.js +13 -13
  216. package/ui/Placeholder.js.map +1 -1
  217. package/ui/TextInput.d.ts +1 -2
  218. package/ui/TextInput.js +14 -19
  219. package/ui/TextInput.js.map +1 -1
  220. package/ui/ToolbarActionDialog.d.ts +2 -3
  221. package/ui/ToolbarActionDialog.js +25 -55
  222. package/ui/ToolbarActionDialog.js.map +1 -1
  223. package/utils/canUseDOM.d.ts +1 -0
  224. package/utils/canUseDOM.js +3 -0
  225. package/utils/canUseDOM.js.map +1 -0
  226. package/utils/files.d.ts +11 -0
  227. package/utils/files.js +11 -0
  228. package/utils/files.js.map +1 -0
  229. package/utils/getDOMRangeRect.d.ts +0 -2
  230. package/utils/getDOMRangeRect.js +7 -11
  231. package/utils/getDOMRangeRect.js.map +1 -1
  232. package/utils/getSelectedNode.d.ts +1 -1
  233. package/utils/getSelectedNode.js +12 -17
  234. package/utils/getSelectedNode.js.map +1 -1
  235. package/utils/getTransparentImage.d.ts +1 -0
  236. package/utils/getTransparentImage.js +5 -0
  237. package/utils/getTransparentImage.js.map +1 -0
  238. package/utils/insertImage.d.ts +2 -0
  239. package/utils/insertImage.js +16 -0
  240. package/utils/insertImage.js.map +1 -0
  241. package/utils/isAnchorLink.d.ts +1 -0
  242. package/utils/isAnchorLink.js +5 -0
  243. package/utils/isAnchorLink.js.map +1 -0
  244. package/utils/isChildOfFloatingToolbar.d.ts +1 -0
  245. package/utils/isChildOfFloatingToolbar.js +12 -0
  246. package/utils/isChildOfFloatingToolbar.js.map +1 -0
  247. package/utils/isHTMLElement.d.ts +8 -0
  248. package/utils/isHTMLElement.js +12 -0
  249. package/utils/isHTMLElement.js.map +1 -0
  250. package/utils/isValidJSON.js +5 -10
  251. package/utils/isValidJSON.js.map +1 -1
  252. package/utils/isValidLexicalData.d.ts +4 -2
  253. package/utils/isValidLexicalData.js +18 -18
  254. package/utils/isValidLexicalData.js.map +1 -1
  255. package/utils/point.js +38 -66
  256. package/utils/point.js.map +1 -1
  257. package/utils/rect.d.ts +2 -4
  258. package/utils/rect.js +117 -156
  259. package/utils/rect.js.map +1 -1
  260. package/utils/sanitizeUrl.d.ts +0 -7
  261. package/utils/sanitizeUrl.js +10 -12
  262. package/utils/sanitizeUrl.js.map +1 -1
  263. package/utils/setFloatingElemPosition.d.ts +1 -3
  264. package/utils/setFloatingElemPosition.js +29 -39
  265. package/utils/setFloatingElemPosition.js.map +1 -1
  266. package/components/AddRichTextEditorNodeType.d.ts +0 -6
  267. package/components/AddRichTextEditorNodeType.js +0 -28
  268. package/components/AddRichTextEditorNodeType.js.map +0 -1
  269. package/components/AddRichTextEditorPlugin.d.ts +0 -12
  270. package/components/AddRichTextEditorPlugin.js +0 -33
  271. package/components/AddRichTextEditorPlugin.js.map +0 -1
  272. package/components/AddToolbarAction.d.ts +0 -7
  273. package/components/AddToolbarAction.js +0 -33
  274. package/components/AddToolbarAction.js.map +0 -1
  275. package/components/Editor/HeadingEditor.d.ts +0 -7
  276. package/components/Editor/HeadingEditor.js +0 -28
  277. package/components/Editor/HeadingEditor.js.map +0 -1
  278. package/components/Editor/ParagraphEditor.d.ts +0 -7
  279. package/components/Editor/ParagraphEditor.js +0 -30
  280. package/components/Editor/ParagraphEditor.js.map +0 -1
  281. package/components/Toolbar/HeadingToolbar.d.ts +0 -12
  282. package/components/Toolbar/HeadingToolbar.js +0 -23
  283. package/components/Toolbar/HeadingToolbar.js.map +0 -1
  284. package/components/Toolbar/ParagraphToolbar.d.ts +0 -12
  285. package/components/Toolbar/ParagraphToolbar.js +0 -23
  286. package/components/Toolbar/ParagraphToolbar.js.map +0 -1
  287. package/components/ToolbarActions/FontSizeAction.d.ts +0 -2
  288. package/components/ToolbarActions/FontSizeAction.js +0 -104
  289. package/components/ToolbarActions/FontSizeAction.js.map +0 -1
  290. package/components/ToolbarPresets/HeadingToolbarPreset.d.ts +0 -2
  291. package/components/ToolbarPresets/HeadingToolbarPreset.js +0 -48
  292. package/components/ToolbarPresets/HeadingToolbarPreset.js.map +0 -1
  293. package/components/ToolbarPresets/ParagraphToolbarPreset.d.ts +0 -2
  294. package/components/ToolbarPresets/ParagraphToolbarPreset.js +0 -63
  295. package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +0 -1
  296. package/nodes/FontColorNode.d.ts +0 -43
  297. package/nodes/FontColorNode.js +0 -127
  298. package/nodes/FontColorNode.js.map +0 -1
  299. package/nodes/webinyNodes.d.ts +0 -2
  300. package/nodes/webinyNodes.js +0 -16
  301. package/nodes/webinyNodes.js.map +0 -1
  302. package/plugins/AutoLinkPlugin/AutoLinkPlugin.js +0 -46
  303. package/plugins/AutoLinkPlugin/AutoLinkPlugin.js.map +0 -1
  304. package/plugins/AutoLinkPlugin/index.d.ts +0 -1
  305. package/plugins/AutoLinkPlugin/index.js +0 -16
  306. package/plugins/AutoLinkPlugin/index.js.map +0 -1
  307. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.d.ts +0 -17
  308. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js +0 -88
  309. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js.map +0 -1
  310. package/plugins/ClickableLinkPlugin/index.d.ts +0 -1
  311. package/plugins/ClickableLinkPlugin/index.js +0 -16
  312. package/plugins/ClickableLinkPlugin/index.js.map +0 -1
  313. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.d.ts +0 -8
  314. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js +0 -34
  315. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +0 -1
  316. package/plugins/LexicalUpdateStatePlugin/index.d.ts +0 -1
  317. package/plugins/LexicalUpdateStatePlugin/index.js +0 -16
  318. package/plugins/LexicalUpdateStatePlugin/index.js.map +0 -1
  319. package/themes/webinyLexicalTheme.css +0 -422
  320. package/themes/webinyLexicalTheme.d.ts +0 -7
  321. package/themes/webinyLexicalTheme.js +0 -86
  322. package/themes/webinyLexicalTheme.js.map +0 -1
  323. package/utils/generateInitialLexicalValue.d.ts +0 -5
  324. package/utils/generateInitialLexicalValue.js +0 -29
  325. package/utils/generateInitialLexicalValue.js.map +0 -1
package/README.md CHANGED
@@ -1,17 +1,11 @@
1
1
  # @webiny/lexical-editor
2
- [![](https://img.shields.io/npm/dw/@webiny/app-page-builder.svg)](https://www.npmjs.com/package/@webiny/lexical-editor)
3
- [![](https://img.shields.io/npm/v/@webiny/app-page-builder.svg)](https://www.npmjs.com/package/@webiny/lexical-editor)
4
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
2
 
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
7
6
 
8
- ## About
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
9
8
 
10
- This package provides a web text editor with rich text editing features. It's built on top of the Lexical framework.
9
+ ---
11
10
 
12
-
13
- To find more about the Lexical framework go to their website [lexical.dev](https://lexical.dev/)
14
-
15
- ## Where is it used?
16
-
17
- Currently, this packaged is used in [@webiny/app-pagebuilder](../app-page-builder).
11
+ _This README file is automatically generated during the publish process._
@@ -0,0 +1,6 @@
1
+ import type { LexicalCommand, NodeKey } from "lexical";
2
+ import type { ImageNodeProps } from "@webiny/lexical-nodes";
3
+ export interface ImagePayload extends ImageNodeProps {
4
+ key?: NodeKey;
5
+ }
6
+ export declare const INSERT_IMAGE_COMMAND: LexicalCommand<ImagePayload>;
@@ -0,0 +1,4 @@
1
+ import { createCommand } from "lexical";
2
+ export const INSERT_IMAGE_COMMAND = createCommand("INSERT_IMAGE_COMMAND");
3
+
4
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommand","INSERT_IMAGE_COMMAND"],"sources":["image.ts"],"sourcesContent":["import type { LexicalCommand, NodeKey } from \"lexical\";\nimport { createCommand } from \"lexical\";\nimport type { ImageNodeProps } from \"@webiny/lexical-nodes\";\n\nexport interface ImagePayload extends ImageNodeProps {\n key?: NodeKey;\n}\n\nexport const INSERT_IMAGE_COMMAND: LexicalCommand<ImagePayload> =\n createCommand(\"INSERT_IMAGE_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAOvC,OAAO,MAAMC,oBAAkD,GAC3DD,aAAa,CAAC,sBAAsB,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ export * from "../commands/typography.js";
2
+ export * from "../commands/image.js";
3
+ export * from "../commands/list.js";
4
+ export * from "../commands/quote.js";
5
+ export * from "../commands/toolbar.js";
@@ -0,0 +1,7 @@
1
+ export * from "./typography.js";
2
+ export * from "./image.js";
3
+ export * from "./list.js";
4
+ export * from "./quote.js";
5
+ export * from "./toolbar.js";
6
+
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"~/commands/typography.js\";\nexport * from \"~/commands/image.js\";\nexport * from \"~/commands/list.js\";\nexport * from \"~/commands/quote.js\";\nexport * from \"~/commands/toolbar.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import type { LexicalCommand } from "lexical";
2
+ export type ListCommandPayload = {
3
+ themeStyleId?: string;
4
+ };
5
+ export declare const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload>;
6
+ export declare const INSERT_ORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload>;
7
+ export declare const REMOVE_LIST_COMMAND: LexicalCommand<void>;
@@ -0,0 +1,6 @@
1
+ import { createCommand } from "lexical";
2
+ export const INSERT_UNORDERED_LIST_COMMAND = createCommand("INSERT_UNORDERED_LIST_COMMAND");
3
+ export const INSERT_ORDERED_LIST_COMMAND = createCommand("INSERT_ORDERED_LIST_COMMAND");
4
+ export const REMOVE_LIST_COMMAND = createCommand("REMOVE_LIST_COMMAND");
5
+
6
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommand","INSERT_UNORDERED_LIST_COMMAND","INSERT_ORDERED_LIST_COMMAND","REMOVE_LIST_COMMAND"],"sources":["list.ts"],"sourcesContent":["import type { LexicalCommand } from \"lexical\";\nimport { createCommand } from \"lexical\";\n\nexport type ListCommandPayload = {\n themeStyleId?: string;\n};\n\nexport const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload> = createCommand(\n \"INSERT_UNORDERED_LIST_COMMAND\"\n);\n\nexport const INSERT_ORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload> = createCommand(\n \"INSERT_ORDERED_LIST_COMMAND\"\n);\n\nexport const REMOVE_LIST_COMMAND: LexicalCommand<void> = createCommand(\"REMOVE_LIST_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAMvC,OAAO,MAAMC,6BAAiE,GAAGD,aAAa,CAC1F,+BACJ,CAAC;AAED,OAAO,MAAME,2BAA+D,GAAGF,aAAa,CACxF,6BACJ,CAAC;AAED,OAAO,MAAMG,mBAAyC,GAAGH,aAAa,CAAC,qBAAqB,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ import type { LexicalCommand } from "lexical";
2
+ export type QuoteCommandPayload = {
3
+ themeStyleId: string;
4
+ };
5
+ export declare const INSERT_QUOTE_COMMAND: LexicalCommand<QuoteCommandPayload>;
@@ -0,0 +1,4 @@
1
+ import { createCommand } from "lexical";
2
+ export const INSERT_QUOTE_COMMAND = createCommand("INSERT_QUOTE_COMMAND");
3
+
4
+ //# sourceMappingURL=quote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommand","INSERT_QUOTE_COMMAND"],"sources":["quote.ts"],"sourcesContent":["import type { LexicalCommand } from \"lexical\";\nimport { createCommand } from \"lexical\";\n\nexport type QuoteCommandPayload = {\n themeStyleId: string;\n};\n\nexport const INSERT_QUOTE_COMMAND: LexicalCommand<QuoteCommandPayload> =\n createCommand(\"INSERT_QUOTE_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAMvC,OAAO,MAAMC,oBAAyD,GAClED,aAAa,CAAC,sBAAsB,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export declare const HIDE_FLOATING_TOOLBAR: import("lexical").LexicalCommand<unknown>;
@@ -0,0 +1,4 @@
1
+ import { createCommand } from "lexical";
2
+ export const HIDE_FLOATING_TOOLBAR = createCommand("HIDE_FLOATING_TOOLBAR_COMMAND");
3
+
4
+ //# sourceMappingURL=toolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommand","HIDE_FLOATING_TOOLBAR"],"sources":["toolbar.ts"],"sourcesContent":["import { createCommand } from \"lexical\";\n\nexport const HIDE_FLOATING_TOOLBAR = createCommand(\"HIDE_FLOATING_TOOLBAR_COMMAND\");\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,SAAS;AAEvC,OAAO,MAAMC,qBAAqB,GAAGD,aAAa,CAAC,+BAA+B,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import type { LexicalCommand, LexicalEditor, NodeKey } from "lexical";
2
+ import type { TypographyValue } from "@webiny/lexical-theme";
3
+ export declare const ADD_TYPOGRAPHY_COMMAND: LexicalCommand<TypographyPayload>;
4
+ export interface TypographyPayload {
5
+ value: TypographyValue;
6
+ caption?: LexicalEditor;
7
+ key?: NodeKey;
8
+ }
@@ -0,0 +1,4 @@
1
+ import { createCommand } from "lexical";
2
+ export const ADD_TYPOGRAPHY_COMMAND = createCommand("ADD_TYPOGRAPHY_COMMAND");
3
+
4
+ //# sourceMappingURL=typography.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommand","ADD_TYPOGRAPHY_COMMAND"],"sources":["typography.ts"],"sourcesContent":["import type { LexicalCommand, LexicalEditor, NodeKey } from \"lexical\";\nimport { createCommand } from \"lexical\";\nimport type { TypographyValue } from \"@webiny/lexical-theme\";\n\nexport const ADD_TYPOGRAPHY_COMMAND: LexicalCommand<TypographyPayload> =\n createCommand(\"ADD_TYPOGRAPHY_COMMAND\");\n\nexport interface TypographyPayload {\n value: TypographyValue;\n caption?: LexicalEditor;\n key?: NodeKey;\n}\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAGvC,OAAO,MAAMC,sBAAyD,GAClED,aAAa,CAAC,wBAAwB,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * In the "Heading" editor, we only want to support heading tags.
3
+ * However, when the editor is empty, and you start typing, Lexical automatically creates an empty "paragraph" node.
4
+ * This ensures that any paragraph node is automatically converted to a heading node.
5
+ */
6
+ export declare const EnsureHeadingTagPlugin: () => null;
@@ -0,0 +1,20 @@
1
+ import { useEffect } from "react";
2
+ import { ParagraphNode, $createHeadingNode } from "@webiny/lexical-nodes";
3
+ import { useRichTextEditor } from "../../hooks/index.js";
4
+
5
+ /**
6
+ * In the "Heading" editor, we only want to support heading tags.
7
+ * However, when the editor is empty, and you start typing, Lexical automatically creates an empty "paragraph" node.
8
+ * This ensures that any paragraph node is automatically converted to a heading node.
9
+ */
10
+ export const EnsureHeadingTagPlugin = () => {
11
+ const {
12
+ editor
13
+ } = useRichTextEditor();
14
+ useEffect(() => editor.registerNodeTransform(ParagraphNode, node => {
15
+ node.replace($createHeadingNode("h1"), true);
16
+ }), []);
17
+ return null;
18
+ };
19
+
20
+ //# sourceMappingURL=EnsureHeadingTagPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","ParagraphNode","$createHeadingNode","useRichTextEditor","EnsureHeadingTagPlugin","editor","registerNodeTransform","node","replace"],"sources":["EnsureHeadingTagPlugin.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { ParagraphNode, $createHeadingNode } from \"@webiny/lexical-nodes\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\n\n/**\n * In the \"Heading\" editor, we only want to support heading tags.\n * However, when the editor is empty, and you start typing, Lexical automatically creates an empty \"paragraph\" node.\n * This ensures that any paragraph node is automatically converted to a heading node.\n */\nexport const EnsureHeadingTagPlugin = () => {\n const { editor } = useRichTextEditor();\n\n useEffect(\n () =>\n editor.registerNodeTransform(ParagraphNode, node => {\n node.replace($createHeadingNode(\"h1\"), true);\n }),\n []\n );\n return null;\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,uBAAuB;AACzE,SAASC,iBAAiB;;AAE1B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAO,CAAC,GAAGF,iBAAiB,CAAC,CAAC;EAEtCH,SAAS,CACL,MACIK,MAAM,CAACC,qBAAqB,CAACL,aAAa,EAAEM,IAAI,IAAI;IAChDA,IAAI,CAACC,OAAO,CAACN,kBAAkB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;EAChD,CAAC,CAAC,EACN,EACJ,CAAC;EACD,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
@@ -1,25 +1,54 @@
1
1
  import React from "react";
2
- import { LexicalValue } from "../../types";
3
- import { Klass, LexicalNode } from "lexical";
4
- import { WebinyTheme } from "../../themes/webinyLexicalTheme";
2
+ import type { Klass, LexicalNode } from "lexical";
3
+ import { LexicalComposer } from "@lexical/react/LexicalComposer";
4
+ import type { EditorTheme } from "@webiny/lexical-theme";
5
+ import type { LexicalValue, ToolbarActionPlugin } from "../../types.js";
6
+ export type InitialEditorConfig = React.ComponentProps<typeof LexicalComposer>["initialConfig"] & {
7
+ editorId: string;
8
+ };
5
9
  export interface RichTextEditorProps {
6
- toolbar?: React.ReactNode;
7
- tag?: string;
8
- onChange?: (json: LexicalValue) => void;
9
- value: LexicalValue | null;
10
+ children?: React.ReactNode | React.ReactNode[];
11
+ classes?: string;
12
+ contentEditableStyles?: React.CSSProperties;
10
13
  focus?: boolean;
11
- placeholder?: string;
14
+ height?: number | string;
12
15
  nodes?: Klass<LexicalNode>[];
13
- /**
14
- * @description Lexical plugins
15
- */
16
- children?: React.ReactNode | React.ReactNode[];
17
16
  onBlur?: (editorState: LexicalValue) => void;
18
- height?: number | string;
17
+ onChange?: (value: LexicalValue) => void;
18
+ placeholder?: string;
19
+ placeholderStyles?: React.CSSProperties;
20
+ staticToolbar?: React.ReactNode;
21
+ styles?: React.CSSProperties;
22
+ tag?: string;
23
+ theme: EditorTheme;
24
+ toolbarActionPlugins?: ToolbarActionPlugin[];
25
+ toolbar?: React.ReactNode;
26
+ value: LexicalValue | null | undefined;
27
+ configRef?: React.MutableRefObject<InitialEditorConfig | undefined>;
19
28
  width?: number | string;
20
- theme: WebinyTheme;
21
29
  }
22
30
  /**
23
31
  * @description Main editor container
24
32
  */
25
- export declare const RichTextEditor: import("@webiny/react-composition").ComposableFC<RichTextEditorProps>;
33
+ export declare const RichTextEditor: ((props: RichTextEditorProps) => React.JSX.Element) & {
34
+ original: (props: RichTextEditorProps) => React.JSX.Element;
35
+ originalName: string;
36
+ displayName: string;
37
+ } & {
38
+ original: ((props: RichTextEditorProps) => React.JSX.Element) & {
39
+ original: (props: RichTextEditorProps) => React.JSX.Element;
40
+ originalName: string;
41
+ displayName: string;
42
+ };
43
+ originalName: string;
44
+ displayName: string;
45
+ } & {
46
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<((props: RichTextEditorProps) => React.JSX.Element) & {
47
+ original: (props: RichTextEditorProps) => React.JSX.Element;
48
+ originalName: string;
49
+ displayName: string;
50
+ }>) => (props: unknown) => React.JSX.Element;
51
+ };
52
+ export declare namespace RichTextEditor {
53
+ type InitialConfig = InitialEditorConfig;
54
+ }
@@ -1,112 +1,136 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.RichTextEditor = void 0;
9
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _react = _interopRequireWildcard(require("react"));
13
- var _Placeholder = require("../../ui/Placeholder");
14
- var _generateInitialLexicalValue = require("../../utils/generateInitialLexicalValue");
15
- var _LexicalComposer = require("@lexical/react/LexicalComposer");
16
- var _LexicalOnChangePlugin = require("@lexical/react/LexicalOnChangePlugin");
17
- var _LexicalAutoFocusPlugin = require("@lexical/react/LexicalAutoFocusPlugin");
18
- var _LexicalClearEditorPlugin = require("@lexical/react/LexicalClearEditorPlugin");
19
- var _LexicalRichTextPlugin = require("@lexical/react/LexicalRichTextPlugin");
20
- var _LexicalErrorBoundary = _interopRequireDefault(require("@lexical/react/LexicalErrorBoundary"));
21
- var _reactComposition = require("@webiny/react-composition");
22
- var _LexicalContentEditable = require("@lexical/react/LexicalContentEditable");
23
- var _RichTextEditorContext = require("../../context/RichTextEditorContext");
24
- var _isValidLexicalData = require("../../utils/isValidLexicalData");
25
- var _LexicalUpdateStatePlugin = require("../../plugins/LexicalUpdateStatePlugin");
26
- var _BlurEventPlugin = require("../../plugins/BlurEventPlugin/BlurEventPlugin");
27
- var _FontColorPlugin = require("../../plugins/FontColorPlugin/FontColorPlugin");
28
- var _webinyLexicalTheme = require("../../themes/webinyLexicalTheme");
29
- var _webinyNodes = require("../../nodes/webinyNodes");
30
- var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
31
- var toolbar = _ref.toolbar,
32
- onChange = _ref.onChange,
33
- value = _ref.value,
34
- nodes = _ref.nodes,
35
- placeholder = _ref.placeholder,
36
- children = _ref.children,
37
- onBlur = _ref.onBlur,
38
- focus = _ref.focus,
39
- width = _ref.width,
40
- height = _ref.height,
41
- theme = _ref.theme;
42
- var placeholderElem = /*#__PURE__*/_react.default.createElement(_Placeholder.Placeholder, null, placeholder || "Enter text...");
43
- var scrollRef = (0, _react.useRef)(null);
44
- var _useState = (0, _react.useState)(undefined),
45
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
46
- floatingAnchorElem = _useState2[0],
47
- setFloatingAnchorElem = _useState2[1];
48
- var onRef = function onRef(_floatingAnchorElem) {
1
+ import React, { Fragment, useId, useRef, useState } from "react";
2
+ import { LexicalComposer } from "@lexical/react/LexicalComposer";
3
+ import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
4
+ import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
5
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
6
+ import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
7
+ import { makeDecoratable } from "@webiny/react-composition";
8
+ import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
9
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
10
+ import { allNodes } from "@webiny/lexical-nodes";
11
+ import { RichTextEditorProvider } from "../../context/RichTextEditorContext.js";
12
+ import { BlurEventPlugin } from "../../plugins/BlurEventPlugin/BlurEventPlugin.js";
13
+ import { Placeholder } from "../../ui/Placeholder.js";
14
+ import { SharedHistoryContext, useSharedHistoryContext } from "../../context/SharedHistoryContext.js";
15
+ import { LexicalEditorWithConfig, useLexicalEditorConfig } from "../LexicalEditorConfig/LexicalEditorConfig.js";
16
+ import { StateHandlingPlugin } from "../../plugins/StateHandlingPlugin.js";
17
+ const BaseRichTextEditor = ({
18
+ onChange,
19
+ toolbar,
20
+ staticToolbar,
21
+ nodes,
22
+ placeholder,
23
+ children,
24
+ onBlur,
25
+ focus,
26
+ styles,
27
+ width,
28
+ height,
29
+ contentEditableStyles,
30
+ placeholderStyles,
31
+ ...props
32
+ }) => {
33
+ const editorTheme = useRef(props.theme);
34
+ const config = useLexicalEditorConfig();
35
+ const {
36
+ historyState
37
+ } = useSharedHistoryContext();
38
+ const placeholderElem = /*#__PURE__*/React.createElement(Placeholder, {
39
+ styles: placeholderStyles
40
+ }, placeholder || "Enter text...");
41
+ const scrollRef = useRef(null);
42
+ const [floatingAnchorElem, setFloatingAnchorElem] = useState(undefined);
43
+ const onRef = _floatingAnchorElem => {
49
44
  if (_floatingAnchorElem !== null) {
50
45
  setFloatingAnchorElem(_floatingAnchorElem);
51
46
  }
52
47
  };
53
- var sizeStyle = {
48
+ const sizeStyle = {
54
49
  height: height || "",
55
50
  width: width || ""
56
51
  };
57
- var initialConfig = {
58
- editorState: (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)(),
52
+ const configNodes = config.nodes.map(node => node.node);
53
+ const configPlugins = config.plugins.map(plugin => /*#__PURE__*/React.createElement(Fragment, {
54
+ key: plugin.name
55
+ }, plugin.element));
56
+ const initialConfig = {
57
+ editorId: useId(),
59
58
  namespace: "webiny",
60
- onError: function onError(error) {
61
- throw error;
59
+ onError: () => {
60
+ // Ignore errors. We don't want to break the app because of errors caused by config/value updates.
61
+ // These are usually resolved in the next component render cycle.
62
62
  },
63
- nodes: [].concat((0, _toConsumableArray2.default)(_webinyNodes.WebinyNodes), (0, _toConsumableArray2.default)(nodes || [])),
64
- theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _webinyLexicalTheme.webinyEditorTheme), {}, {
65
- styles: theme === null || theme === void 0 ? void 0 : theme.styles
66
- })
63
+ nodes: [...allNodes, ...configNodes, ...(nodes || [])],
64
+ theme: {
65
+ ...editorTheme.current.tokens,
66
+ // I'm not aware of a better way to pass custom data to nodes.
67
+ // For now, we're using Lexical's theme to pass colors and typography.
68
+ $colors: editorTheme.current.colors,
69
+ $typography: editorTheme.current.typography,
70
+ $cacheKey: JSON.stringify(editorTheme.current)
71
+ }
67
72
  };
68
- function handleOnChange(editorState, editor) {
69
- editorState.read(function () {
70
- if (typeof onChange === "function") {
71
- var _editorState = editor.getEditorState();
72
- //TODO: send plain JSON object
73
- onChange(JSON.stringify(_editorState.toJSON()));
74
- }
75
- });
73
+ if (props.configRef) {
74
+ props.configRef.current = initialConfig;
76
75
  }
77
- return /*#__PURE__*/_react.default.createElement(_LexicalComposer.LexicalComposer, {
78
- initialConfig: initialConfig
79
- }, /*#__PURE__*/_react.default.createElement("div", {
80
- ref: scrollRef,
81
- style: (0, _objectSpread2.default)({}, sizeStyle)
82
- }, /*#__PURE__*/_react.default.createElement(_LexicalOnChangePlugin.OnChangePlugin, {
83
- onChange: handleOnChange
84
- }), value && /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.LexicalUpdateStatePlugin, {
85
- value: value
86
- }), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null), /*#__PURE__*/_react.default.createElement(_FontColorPlugin.FontColorPlugin, null), onBlur && /*#__PURE__*/_react.default.createElement(_BlurEventPlugin.BlurEventPlugin, {
87
- onBlur: onBlur
88
- }), focus && /*#__PURE__*/_react.default.createElement(_LexicalAutoFocusPlugin.AutoFocusPlugin, null), children, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
89
- contentEditable: /*#__PURE__*/_react.default.createElement("div", {
90
- className: "editor-scroller",
91
- style: (0, _objectSpread2.default)({}, sizeStyle)
92
- }, /*#__PURE__*/_react.default.createElement("div", {
93
- className: "editor",
94
- ref: onRef,
95
- style: (0, _objectSpread2.default)({}, sizeStyle)
96
- }, /*#__PURE__*/_react.default.createElement(_LexicalContentEditable.ContentEditable, {
97
- style: (0, _objectSpread2.default)({
98
- outline: 0
99
- }, sizeStyle)
100
- }))),
101
- placeholder: placeholderElem,
102
- ErrorBoundary: _LexicalErrorBoundary.default
103
- }), floatingAnchorElem && toolbar));
76
+ return (
77
+ /*#__PURE__*/
78
+ /**
79
+ * Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future
80
+ * updates to the config will be ignored. This is a problem because we pull in Nodes from our config,
81
+ * and initially, there can be multiple re-renders, while the config object is settled.
82
+ *
83
+ * To bypass this issue, we generate a naive `key` based on the number of Nodes.
84
+ */
85
+ React.createElement(SharedHistoryContext, null, /*#__PURE__*/React.createElement(LexicalComposer, {
86
+ initialConfig: initialConfig,
87
+ key: initialConfig.nodes.length
88
+ }, /*#__PURE__*/React.createElement(RichTextEditorProvider, {
89
+ theme: props.theme,
90
+ toolbarActionPlugins: props.toolbarActionPlugins
91
+ }, staticToolbar ? staticToolbar : null, /*#__PURE__*/React.createElement("div", {
92
+ /* This className is necessary for targeting of editor container from CSS files. */
93
+ className: "editor-shell",
94
+ ref: scrollRef,
95
+ style: {
96
+ ...styles,
97
+ ...sizeStyle,
98
+ overflow: "auto",
99
+ position: "relative"
100
+ }
101
+ }, /*#__PURE__*/React.createElement(StateHandlingPlugin, {
102
+ value: props.value,
103
+ onChange: onChange
104
+ }), /*#__PURE__*/React.createElement(ClearEditorPlugin, null), /*#__PURE__*/React.createElement(HistoryPlugin, {
105
+ externalHistoryState: historyState
106
+ }), onBlur && /*#__PURE__*/React.createElement(BlurEventPlugin, {
107
+ onBlur: onBlur
108
+ }), focus && /*#__PURE__*/React.createElement(AutoFocusPlugin, null), configPlugins, children, /*#__PURE__*/React.createElement(RichTextPlugin, {
109
+ contentEditable: /*#__PURE__*/React.createElement("div", {
110
+ className: "editor-scroller",
111
+ style: {
112
+ ...sizeStyle
113
+ }
114
+ }, /*#__PURE__*/React.createElement("div", {
115
+ className: "editor",
116
+ ref: onRef
117
+ }, /*#__PURE__*/React.createElement(ContentEditable, {
118
+ style: {
119
+ outline: 0,
120
+ ...contentEditableStyles
121
+ }
122
+ }))),
123
+ placeholder: placeholderElem,
124
+ ErrorBoundary: LexicalErrorBoundary
125
+ }), floatingAnchorElem && toolbar))))
126
+ );
104
127
  };
105
128
 
106
129
  /**
107
130
  * @description Main editor container
108
131
  */
109
- var RichTextEditor = (0, _reactComposition.makeComposable)("RichTextEditor", function (props) {
110
- return /*#__PURE__*/_react.default.createElement(_RichTextEditorContext.RichTextEditorProvider, null, /*#__PURE__*/_react.default.createElement(BaseRichTextEditor, props));
132
+ export const RichTextEditor = makeDecoratable("RichTextEditor", props => {
133
+ return /*#__PURE__*/React.createElement(LexicalEditorWithConfig, null, /*#__PURE__*/React.createElement(BaseRichTextEditor, props));
111
134
  });
112
- exports.RichTextEditor = RichTextEditor;
135
+
136
+ //# sourceMappingURL=RichTextEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BaseRichTextEditor","toolbar","onChange","value","nodes","placeholder","children","onBlur","focus","width","height","theme","placeholderElem","scrollRef","useRef","useState","undefined","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","sizeStyle","initialConfig","editorState","isValidLexicalData","generateInitialLexicalValue","namespace","onError","error","WebinyNodes","webinyEditorTheme","styles","handleOnChange","editor","read","getEditorState","JSON","stringify","toJSON","outline","LexicalErrorBoundary","RichTextEditor","makeComposable","props"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\";\nimport { LexicalValue } from \"~/types\";\nimport { Placeholder } from \"~/ui/Placeholder\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { EditorState } from \"lexical/LexicalEditorState\";\nimport { Klass, LexicalEditor, LexicalNode } from \"lexical\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { OnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\nimport { AutoFocusPlugin } from \"@lexical/react/LexicalAutoFocusPlugin\";\nimport { ClearEditorPlugin } from \"@lexical/react/LexicalClearEditorPlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport LexicalErrorBoundary from \"@lexical/react/LexicalErrorBoundary\";\nimport { makeComposable } from \"@webiny/react-composition\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { LexicalUpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin\";\nimport { FontColorPlugin } from \"~/plugins/FontColorPlugin/FontColorPlugin\";\nimport { webinyEditorTheme, WebinyTheme } from \"~/themes/webinyLexicalTheme\";\nimport { WebinyNodes } from \"~/nodes/webinyNodes\";\n\nexport interface RichTextEditorProps {\n toolbar?: React.ReactNode;\n tag?: string;\n onChange?: (json: LexicalValue) => void;\n value: LexicalValue | null;\n focus?: boolean;\n placeholder?: string;\n nodes?: Klass<LexicalNode>[];\n /**\n * @description Lexical plugins\n */\n children?: React.ReactNode | React.ReactNode[];\n onBlur?: (editorState: LexicalValue) => void;\n height?: number | string;\n width?: number | string;\n /*\n * @description Theme to be injected into lexical editor\n */\n theme: WebinyTheme;\n}\n\nconst BaseRichTextEditor: React.FC<RichTextEditorProps> = ({\n toolbar,\n onChange,\n value,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n width,\n height,\n theme\n}: RichTextEditorProps) => {\n const placeholderElem = <Placeholder>{placeholder || \"Enter text...\"}</Placeholder>;\n const scrollRef = useRef(null);\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem);\n }\n };\n\n const sizeStyle = {\n height: height || \"\",\n width: width || \"\"\n };\n\n const initialConfig = {\n editorState: isValidLexicalData(value) ? value : generateInitialLexicalValue(),\n namespace: \"webiny\",\n onError: (error: Error) => {\n throw error;\n },\n nodes: [...WebinyNodes, ...(nodes || [])],\n theme: { ...webinyEditorTheme, styles: theme?.styles }\n };\n\n function handleOnChange(editorState: EditorState, editor: LexicalEditor) {\n editorState.read(() => {\n if (typeof onChange === \"function\") {\n const editorState = editor.getEditorState();\n //TODO: send plain JSON object\n onChange(JSON.stringify(editorState.toJSON()));\n }\n });\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig}>\n <div ref={scrollRef} style={{ ...sizeStyle }}>\n {/* data */}\n <OnChangePlugin onChange={handleOnChange} />\n {value && <LexicalUpdateStatePlugin value={value} />}\n <ClearEditorPlugin />\n <FontColorPlugin />\n {/* Events */}\n {onBlur && <BlurEventPlugin onBlur={onBlur} />}\n {focus && <AutoFocusPlugin />}\n {/* External plugins and components */}\n {children}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\" style={{ ...sizeStyle }}>\n <div className=\"editor\" ref={onRef} style={{ ...sizeStyle }}>\n <ContentEditable style={{ outline: 0, ...sizeStyle }} />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar */}\n {floatingAnchorElem && toolbar}\n </div>\n </LexicalComposer>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeComposable<RichTextEditorProps>(\"RichTextEditor\", props => {\n return (\n <RichTextEditorProvider>\n <BaseRichTextEditor {...props} />\n </RichTextEditorProvider>\n );\n});\n"],"mappings":";;;;;;;;;;;AAAA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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B,6BAAC,kBAAkB,EAAKA,KAAK,CAAI,CACZ;AAEjC,CAAC,CAAC;AAAC"}
1
+ {"version":3,"names":["React","Fragment","useId","useRef","useState","LexicalComposer","AutoFocusPlugin","ClearEditorPlugin","RichTextPlugin","LexicalErrorBoundary","makeDecoratable","HistoryPlugin","ContentEditable","allNodes","RichTextEditorProvider","BlurEventPlugin","Placeholder","SharedHistoryContext","useSharedHistoryContext","LexicalEditorWithConfig","useLexicalEditorConfig","StateHandlingPlugin","BaseRichTextEditor","onChange","toolbar","staticToolbar","nodes","placeholder","children","onBlur","focus","styles","width","height","contentEditableStyles","placeholderStyles","props","editorTheme","theme","config","historyState","placeholderElem","createElement","scrollRef","floatingAnchorElem","setFloatingAnchorElem","undefined","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","key","name","element","initialConfig","editorId","namespace","onError","current","tokens","$colors","colors","$typography","typography","$cacheKey","JSON","stringify","configRef","length","toolbarActionPlugins","className","ref","style","overflow","position","value","externalHistoryState","contentEditable","outline","ErrorBoundary","RichTextEditor"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useId, useRef, useState } from \"react\";\nimport type { Klass, LexicalNode } from \"lexical\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { AutoFocusPlugin } from \"@lexical/react/LexicalAutoFocusPlugin\";\nimport { ClearEditorPlugin } from \"@lexical/react/LexicalClearEditorPlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport type { EditorTheme } from \"@webiny/lexical-theme\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext.js\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin.js\";\nimport type { LexicalValue, ToolbarActionPlugin } from \"~/types.js\";\nimport { Placeholder } from \"~/ui/Placeholder.js\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext.js\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig.js\";\nimport { StateHandlingPlugin } from \"~/plugins/StateHandlingPlugin.js\";\n\nexport type InitialEditorConfig = React.ComponentProps<typeof LexicalComposer>[\"initialConfig\"] & {\n editorId: string;\n};\n\nexport interface RichTextEditorProps {\n children?: React.ReactNode | React.ReactNode[];\n classes?: string;\n contentEditableStyles?: React.CSSProperties;\n focus?: boolean;\n height?: number | string;\n nodes?: Klass<LexicalNode>[];\n onBlur?: (editorState: LexicalValue) => void;\n onChange?: (value: LexicalValue) => void;\n placeholder?: string;\n placeholderStyles?: React.CSSProperties;\n staticToolbar?: React.ReactNode;\n styles?: React.CSSProperties;\n tag?: string;\n theme: EditorTheme;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n toolbar?: React.ReactNode;\n value: LexicalValue | null | undefined;\n configRef?: React.MutableRefObject<InitialEditorConfig | undefined>;\n width?: number | string;\n}\n\nconst BaseRichTextEditor = ({\n onChange,\n toolbar,\n staticToolbar,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n height,\n contentEditableStyles,\n placeholderStyles,\n ...props\n}: RichTextEditorProps) => {\n const editorTheme = useRef(props.theme);\n const config = useLexicalEditorConfig();\n const { historyState } = useSharedHistoryContext();\n const placeholderElem = (\n <Placeholder styles={placeholderStyles}>{placeholder || \"Enter text...\"}</Placeholder>\n );\n const scrollRef = useRef(null);\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem);\n }\n };\n\n const sizeStyle = {\n height: height || \"\",\n width: width || \"\"\n };\n\n const configNodes = config.nodes.map(node => node.node);\n const configPlugins = config.plugins.map(plugin => (\n <Fragment key={plugin.name}>{plugin.element}</Fragment>\n ));\n\n const initialConfig = {\n editorId: useId(),\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n nodes: [...allNodes, ...configNodes, ...(nodes || [])],\n theme: {\n ...editorTheme.current.tokens,\n // I'm not aware of a better way to pass custom data to nodes.\n // For now, we're using Lexical's theme to pass colors and typography.\n $colors: editorTheme.current.colors,\n $typography: editorTheme.current.typography,\n $cacheKey: JSON.stringify(editorTheme.current)\n }\n };\n\n if (props.configRef) {\n props.configRef.current = initialConfig;\n }\n\n return (\n /**\n * Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future\n * updates to the config will be ignored. This is a problem because we pull in Nodes from our config,\n * and initially, there can be multiple re-renders, while the config object is settled.\n *\n * To bypass this issue, we generate a naive `key` based on the number of Nodes.\n */\n <SharedHistoryContext>\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider\n theme={props.theme}\n toolbarActionPlugins={props.toolbarActionPlugins}\n >\n {staticToolbar ? staticToolbar : null}\n <div\n /* This className is necessary for targeting of editor container from CSS files. */\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{\n ...styles,\n ...sizeStyle,\n overflow: \"auto\",\n position: \"relative\"\n }}\n >\n {/* State plugins. */}\n <StateHandlingPlugin value={props.value} onChange={onChange} />\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Event plugins. */}\n {onBlur && <BlurEventPlugin onBlur={onBlur} />}\n {focus && <AutoFocusPlugin />}\n {/* External plugins and components. */}\n {configPlugins}\n {children}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\" style={{ ...sizeStyle }}>\n <div className=\"editor\" ref={onRef}>\n <ContentEditable\n style={{ outline: 0, ...contentEditableStyles }}\n />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar. */}\n {floatingAnchorElem && toolbar}\n </div>\n </RichTextEditorProvider>\n </LexicalComposer>\n </SharedHistoryContext>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeDecoratable(\"RichTextEditor\", (props: RichTextEditorProps) => {\n return (\n <LexicalEditorWithConfig>\n <BaseRichTextEditor {...props} />\n </LexicalEditorWithConfig>\n );\n});\n\nexport namespace RichTextEditor {\n export type InitialConfig = InitialEditorConfig;\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEhE,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,iBAAiB,QAAQ,yCAAyC;AAC3E,SAASC,cAAc,QAAQ,sCAAsC;AACrE,SAASC,oBAAoB,QAAQ,qCAAqC;AAC1E,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,aAAa,QAAQ,qCAAqC;AACnE,SAASC,eAAe,QAAQ,uCAAuC;AAEvE,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,sBAAsB;AAC/B,SAASC,eAAe;AAExB,SAASC,WAAW;AACpB,SAASC,oBAAoB,EAAEC,uBAAuB;AACtD,SACIC,uBAAuB,EACvBC,sBAAsB;AAE1B,SAASC,mBAAmB;AA4B5B,MAAMC,kBAAkB,GAAGA,CAAC;EACxBC,QAAQ;EACRC,OAAO;EACPC,aAAa;EACbC,KAAK;EACLC,WAAW;EACXC,QAAQ;EACRC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC,qBAAqB;EACrBC,iBAAiB;EACjB,GAAGC;AACc,CAAC,KAAK;EACvB,MAAMC,WAAW,GAAGl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,aAAA,CAAC3B,eAAe;MAACc,MAAM,EAAEA;IAAO,CAAE,CAAC,EAC7CC,KAAK,iBAAI9B,KAAA,CAAA0C,aAAA,CAACpC,eAAe,MAAE,CAAC,EAE5B+C,aAAa,EACbzB,QAAQ,eACT5B,KAAA,CAAA0C,aAAA,CAAClC,cAAc;MACX0E,eAAe,eACXlF,KAAA,CAAA0C,aAAA;QAAKiC,SAAS,EAAC,iBAAiB;QAACE,KAAK,EAAE;UAAE,GAAG5B;QAAU;MAAE,gBACrDjD,KAAA,CAAA0C,aAAA;QAAKiC,SAAS,EAAC,QAAQ;QAACC,GAAG,EAAE7B;MAAM,gBAC/B/C,KAAA,CAAA0C,aAAA,CAAC9B,eAAe;QACZiE,KAAK,EAAE;UAAEM,OAAO,EAAE,CAAC;UAAE,GAAGjD;QAAsB;MAAE,CACnD,CACA,CACJ,CACR;MACDP,WAAW,EAAEc,eAAgB;MAC7B2C,aAAa,EAAE3E;IAAqB,CACvC,CAAC,EAEDmC,kBAAkB,IAAIpB,OACtB,CACe,CACX,CACC;EAAC;AAE/B,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAM6D,cAAc,GAAG3E,eAAe,CAAC,gBAAgB,EAAG0B,KAA0B,IAAK;EAC5F,oBACIpC,KAAA,CAAA0C,aAAA,CAACvB,uBAAuB,qBACpBnB,KAAA,CAAA0C,aAAA,CAACpB,kBAAkB,EAAKc,KAAQ,CACX,CAAC;AAElC,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { LexicalValue, NormalizedInputValue } from "../../types.js";
2
+ /**
3
+ * Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes
4
+ * of input into a value that is either a `null` or a `LexicalValue`.
5
+ */
6
+ export declare function normalizeInputValue(value: LexicalValue | null | undefined): NormalizedInputValue;
@@ -0,0 +1,16 @@
1
+ const isValueEmpty = value => {
2
+ return [undefined, null, "", '""', "null"].includes(value);
3
+ };
4
+
5
+ /**
6
+ * Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes
7
+ * of input into a value that is either a `null` or a `LexicalValue`.
8
+ */
9
+ export function normalizeInputValue(value) {
10
+ if (isValueEmpty(value)) {
11
+ return null;
12
+ }
13
+ return value;
14
+ }
15
+
16
+ //# sourceMappingURL=normalizeInputValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isValueEmpty","value","undefined","includes","normalizeInputValue"],"sources":["normalizeInputValue.ts"],"sourcesContent":["import type { LexicalValue, NormalizedInputValue } from \"~/types.js\";\n\nconst isValueEmpty = (value: any) => {\n return [undefined, null, \"\", '\"\"', \"null\"].includes(value);\n};\n\n/**\n * Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes\n * of input into a value that is either a `null` or a `LexicalValue`.\n */\nexport function normalizeInputValue(value: LexicalValue | null | undefined) {\n if (isValueEmpty(value)) {\n return null;\n }\n\n return value as NormalizedInputValue;\n}\n"],"mappings":"AAEA,MAAMA,YAAY,GAAIC,KAAU,IAAK;EACjC,OAAO,CAACC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAACC,QAAQ,CAACF,KAAK,CAAC;AAC9D,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,SAASG,mBAAmBA,CAACH,KAAsC,EAAE;EACxE,IAAID,YAAY,CAACC,KAAK,CAAC,EAAE;IACrB,OAAO,IAAI;EACf;EAEA,OAAOA,KAAK;AAChB","ignoreList":[]}
@@ -1,7 +1,18 @@
1
- import React from "react";
2
- import { FontColorAction } from "../ToolbarActions/FontColorAction";
3
- interface LexicalEditorConfig extends React.FC<unknown> {
4
- FontColorAction: typeof FontColorAction;
1
+ import type { ToolbarElementConfig } from "./components/ToolbarElement.js";
2
+ import type { PluginConfig } from "./components/Plugin.js";
3
+ import type { NodeConfig } from "./components/Node.js";
4
+ export type { ToolbarElementConfig } from "./components/ToolbarElement.js";
5
+ export type { PluginConfig } from "./components/Plugin.js";
6
+ export type { NodeConfig } from "./components/Node.js";
7
+ export declare const LexicalEditorConfig: (({ priority, children }: import("@webiny/react-properties").ConfigProps) => React.JSX.Element) & {
8
+ ToolbarElement: ({ name, element, after, before, remove }: import("./components/ToolbarElement.js").ToolbarElementProps) => import("react").JSX.Element;
9
+ Plugin: ({ name, element, after, before, remove }: import("./components/Plugin.js").PluginProps) => import("react").JSX.Element;
10
+ Node: ({ name, node, after, before, remove }: import("./components/Node.js").NodeProps) => import("react").JSX.Element;
11
+ };
12
+ export declare const LexicalEditorWithConfig: ({ onProperties, children }: import("@webiny/react-properties").WithConfigProps) => React.JSX.Element;
13
+ interface LexicalEditorConfigData {
14
+ toolbarElements: ToolbarElementConfig[];
15
+ plugins: PluginConfig[];
16
+ nodes: NodeConfig[];
5
17
  }
6
- export declare const LexicalEditorConfig: LexicalEditorConfig;
7
- export {};
18
+ export declare function useLexicalEditorConfig(): LexicalEditorConfigData;