@webiny/lexical-editor 5.44.1-beta.0 → 5.45.0-beta.0

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 (252) hide show
  1. package/README.md +6 -12
  2. package/commands/image.d.ts +2 -2
  3. package/commands/image.js +2 -8
  4. package/commands/image.js.map +1 -1
  5. package/commands/index.d.ts +5 -4
  6. package/commands/index.js +5 -49
  7. package/commands/index.js.map +1 -1
  8. package/commands/list.d.ts +1 -1
  9. package/commands/list.js +4 -10
  10. package/commands/list.js.map +1 -1
  11. package/commands/quote.d.ts +1 -1
  12. package/commands/quote.js +2 -8
  13. package/commands/quote.js.map +1 -1
  14. package/commands/toolbar.js +2 -8
  15. package/commands/toolbar.js.map +1 -1
  16. package/commands/typography.d.ts +8 -0
  17. package/commands/typography.js +4 -0
  18. package/commands/typography.js.map +1 -0
  19. package/components/Editor/EnsureHeadingTagPlugin.js +10 -16
  20. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
  21. package/components/Editor/RichTextEditor.d.ts +12 -8
  22. package/components/Editor/RichTextEditor.js +89 -102
  23. package/components/Editor/RichTextEditor.js.map +1 -1
  24. package/components/Editor/normalizeInputValue.d.ts +1 -1
  25. package/components/Editor/normalizeInputValue.js +2 -8
  26. package/components/Editor/normalizeInputValue.js.map +1 -1
  27. package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +14 -16
  28. package/components/LexicalEditorConfig/LexicalEditorConfig.js +21 -69
  29. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
  30. package/components/LexicalEditorConfig/components/Node.d.ts +1 -1
  31. package/components/LexicalEditorConfig/components/Node.js +17 -26
  32. package/components/LexicalEditorConfig/components/Node.js.map +1 -1
  33. package/components/LexicalEditorConfig/components/Plugin.js +17 -26
  34. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
  35. package/components/LexicalEditorConfig/components/ToolbarElement.js +17 -26
  36. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
  37. package/components/LexicalHtmlRenderer.d.ts +4 -7
  38. package/components/LexicalHtmlRenderer.js +35 -53
  39. package/components/LexicalHtmlRenderer.js.map +1 -1
  40. package/components/Toolbar/StaticToolbar.css +416 -0
  41. package/components/Toolbar/StaticToolbar.d.ts +3 -1
  42. package/components/Toolbar/StaticToolbar.js +19 -23
  43. package/components/Toolbar/StaticToolbar.js.map +1 -1
  44. package/components/ToolbarActions/BoldAction.js +16 -21
  45. package/components/ToolbarActions/BoldAction.js.map +1 -1
  46. package/components/ToolbarActions/BulletListAction.js +25 -31
  47. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  48. package/components/ToolbarActions/CodeHighlightAction.js +16 -21
  49. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
  50. package/components/ToolbarActions/FontColorAction.js +32 -42
  51. package/components/ToolbarActions/FontColorAction.js.map +1 -1
  52. package/components/ToolbarActions/ImageAction.js +19 -34
  53. package/components/ToolbarActions/ImageAction.js.map +1 -1
  54. package/components/ToolbarActions/ItalicAction.js +16 -21
  55. package/components/ToolbarActions/ItalicAction.js.map +1 -1
  56. package/components/ToolbarActions/LinkAction.js +19 -24
  57. package/components/ToolbarActions/LinkAction.js.map +1 -1
  58. package/components/ToolbarActions/NumberedListAction.js +25 -36
  59. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  60. package/components/ToolbarActions/QuoteAction.js +20 -25
  61. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  62. package/components/ToolbarActions/TextAlignmentAction.js +36 -45
  63. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
  64. package/components/ToolbarActions/TypographyAction.js +57 -79
  65. package/components/ToolbarActions/TypographyAction.js.map +1 -1
  66. package/components/ToolbarActions/UnderlineAction.js +16 -21
  67. package/components/ToolbarActions/UnderlineAction.js.map +1 -1
  68. package/context/FontColorActionContext.js +2 -9
  69. package/context/FontColorActionContext.js.map +1 -1
  70. package/context/RichTextEditorContext.d.ts +6 -7
  71. package/context/RichTextEditorContext.js +28 -26
  72. package/context/RichTextEditorContext.js.map +1 -1
  73. package/context/SharedHistoryContext.d.ts +2 -2
  74. package/context/SharedHistoryContext.js +12 -20
  75. package/context/SharedHistoryContext.js.map +1 -1
  76. package/context/TextAlignmentActionContextProps.d.ts +1 -1
  77. package/context/TextAlignmentActionContextProps.js +2 -9
  78. package/context/TextAlignmentActionContextProps.js.map +1 -1
  79. package/context/TypographyActionContext.d.ts +3 -2
  80. package/context/TypographyActionContext.js +2 -9
  81. package/context/TypographyActionContext.js.map +1 -1
  82. package/exports/admin/lexical.d.ts +15 -0
  83. package/exports/admin/lexical.js +23 -0
  84. package/exports/admin/lexical.js.map +1 -0
  85. package/hooks/index.d.ts +7 -8
  86. package/hooks/index.js +7 -93
  87. package/hooks/index.js.map +1 -1
  88. package/hooks/useCurrentElement.d.ts +3 -3
  89. package/hooks/useCurrentElement.js +11 -18
  90. package/hooks/useCurrentElement.js.map +1 -1
  91. package/hooks/useCurrentSelection.d.ts +2 -1
  92. package/hooks/useCurrentSelection.js +27 -40
  93. package/hooks/useCurrentSelection.js.map +1 -1
  94. package/hooks/useFontColorPicker.d.ts +1 -1
  95. package/hooks/useFontColorPicker.js +5 -11
  96. package/hooks/useFontColorPicker.js.map +1 -1
  97. package/hooks/useIsMounted.js +6 -14
  98. package/hooks/useIsMounted.js.map +1 -1
  99. package/hooks/useRichTextEditor.d.ts +1 -1
  100. package/hooks/useRichTextEditor.js +5 -11
  101. package/hooks/useRichTextEditor.js.map +1 -1
  102. package/hooks/useTextAlignmentAction.d.ts +1 -1
  103. package/hooks/useTextAlignmentAction.js +5 -11
  104. package/hooks/useTextAlignmentAction.js.map +1 -1
  105. package/hooks/useTypographyAction.d.ts +1 -1
  106. package/hooks/useTypographyAction.js +5 -11
  107. package/hooks/useTypographyAction.js.map +1 -1
  108. package/index.d.ts +33 -38
  109. package/index.js +44 -322
  110. package/index.js.map +1 -1
  111. package/package.json +18 -22
  112. package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +2 -2
  113. package/plugins/BlurEventPlugin/BlurEventPlugin.js +16 -22
  114. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
  115. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +9 -14
  116. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
  117. package/plugins/CodeHighlightPlugin/index.d.ts +1 -1
  118. package/plugins/CodeHighlightPlugin/index.js +1 -16
  119. package/plugins/CodeHighlightPlugin/index.js.map +1 -1
  120. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +10 -0
  121. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +28 -0
  122. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
  123. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +7 -0
  124. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +61 -0
  125. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
  126. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +2 -136
  127. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +4 -16
  128. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +7 -180
  129. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  130. package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -1
  131. package/plugins/FloatingLinkEditorPlugin/index.js +1 -16
  132. package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
  133. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +3 -9
  134. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
  135. package/plugins/FloatingLinkEditorPlugin/types.d.ts +10 -0
  136. package/plugins/FloatingLinkEditorPlugin/types.js +3 -0
  137. package/plugins/FloatingLinkEditorPlugin/types.js.map +1 -0
  138. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.d.ts +8 -2
  139. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +120 -88
  140. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -1
  141. package/plugins/FontColorPlugin/FontColorPlugin.js +19 -22
  142. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
  143. package/plugins/FontColorPlugin/applyColorToNode.d.ts +2 -2
  144. package/plugins/FontColorPlugin/applyColorToNode.js +4 -10
  145. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
  146. package/plugins/FontColorPlugin/applyColorToSelection.d.ts +2 -2
  147. package/plugins/FontColorPlugin/applyColorToSelection.js +28 -44
  148. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
  149. package/plugins/ImagesPlugin/ImagesPlugin.d.ts +1 -2
  150. package/plugins/ImagesPlugin/ImagesPlugin.js +58 -60
  151. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
  152. package/plugins/LinkPlugin/LinkPlugin.js +29 -37
  153. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
  154. package/plugins/ListPLugin/ListPlugin.js +52 -15
  155. package/plugins/ListPLugin/ListPlugin.js.map +1 -1
  156. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +19 -16
  157. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
  158. package/plugins/StateHandlingPlugin.d.ts +1 -1
  159. package/plugins/StateHandlingPlugin.js +32 -39
  160. package/plugins/StateHandlingPlugin.js.map +1 -1
  161. package/plugins/TypographyPlugin/TypographyPlugin.js +17 -21
  162. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
  163. package/types.d.ts +4 -4
  164. package/types.js +6 -38
  165. package/types.js.map +1 -1
  166. package/ui/ContentEditable.d.ts +0 -1
  167. package/ui/ContentEditable.js +7 -14
  168. package/ui/ContentEditable.js.map +1 -1
  169. package/ui/Divider.d.ts +0 -1
  170. package/ui/Divider.js +3 -10
  171. package/ui/Divider.js.map +1 -1
  172. package/ui/DropDown.d.ts +1 -1
  173. package/ui/DropDown.js +64 -90
  174. package/ui/DropDown.js.map +1 -1
  175. package/ui/ImageResizer.d.ts +0 -1
  176. package/ui/ImageResizer.js +78 -83
  177. package/ui/ImageResizer.js.map +1 -1
  178. package/ui/LinkPreview.d.ts +0 -1
  179. package/ui/LinkPreview.js +22 -29
  180. package/ui/LinkPreview.js.map +1 -1
  181. package/ui/Placeholder.d.ts +1 -1
  182. package/ui/Placeholder.js +10 -16
  183. package/ui/Placeholder.js.map +1 -1
  184. package/ui/TextInput.d.ts +0 -1
  185. package/ui/TextInput.js +11 -18
  186. package/ui/TextInput.js.map +1 -1
  187. package/ui/ToolbarActionDialog.js +30 -42
  188. package/ui/ToolbarActionDialog.js.map +1 -1
  189. package/utils/canUseDOM.js +1 -7
  190. package/utils/canUseDOM.js.map +1 -1
  191. package/utils/files.d.ts +6 -6
  192. package/utils/files.js +5 -32
  193. package/utils/files.js.map +1 -1
  194. package/utils/getDOMRangeRect.js +4 -10
  195. package/utils/getDOMRangeRect.js.map +1 -1
  196. package/utils/getSelectedNode.d.ts +1 -1
  197. package/utils/getSelectedNode.js +9 -16
  198. package/utils/getSelectedNode.js.map +1 -1
  199. package/utils/getTransparentImage.js +1 -7
  200. package/utils/getTransparentImage.js.map +1 -1
  201. package/utils/insertImage.d.ts +1 -1
  202. package/utils/insertImage.js +8 -14
  203. package/utils/insertImage.js.map +1 -1
  204. package/utils/isAnchorLink.js +1 -7
  205. package/utils/isAnchorLink.js.map +1 -1
  206. package/utils/isChildOfFloatingToolbar.js +3 -12
  207. package/utils/isChildOfFloatingToolbar.js.map +1 -1
  208. package/utils/isHTMLElement.js +1 -7
  209. package/utils/isHTMLElement.js.map +1 -1
  210. package/utils/isValidJSON.js +3 -9
  211. package/utils/isValidJSON.js.map +1 -1
  212. package/utils/isValidLexicalData.d.ts +3 -3
  213. package/utils/isValidLexicalData.js +6 -12
  214. package/utils/isValidLexicalData.js.map +1 -1
  215. package/utils/point.js +35 -60
  216. package/utils/point.js.map +1 -1
  217. package/utils/rect.d.ts +1 -1
  218. package/utils/rect.js +115 -149
  219. package/utils/rect.js.map +1 -1
  220. package/utils/sanitizeUrl.js +6 -13
  221. package/utils/sanitizeUrl.js.map +1 -1
  222. package/utils/setFloatingElemPosition.d.ts +1 -1
  223. package/utils/setFloatingElemPosition.js +24 -30
  224. package/utils/setFloatingElemPosition.js.map +1 -1
  225. package/components/Editor/HeadingEditor.d.ts +0 -7
  226. package/components/Editor/HeadingEditor.js +0 -30
  227. package/components/Editor/HeadingEditor.js.map +0 -1
  228. package/components/Editor/ParagraphEditor.d.ts +0 -7
  229. package/components/Editor/ParagraphEditor.js +0 -29
  230. package/components/Editor/ParagraphEditor.js.map +0 -1
  231. package/components/Toolbar/Toolbar.css +0 -643
  232. package/components/Toolbar/Toolbar.d.ts +0 -11
  233. package/components/Toolbar/Toolbar.js +0 -165
  234. package/components/Toolbar/Toolbar.js.map +0 -1
  235. package/components/ToolbarActions/FontSizeAction.d.ts +0 -14
  236. package/components/ToolbarActions/FontSizeAction.js +0 -109
  237. package/components/ToolbarActions/FontSizeAction.js.map +0 -1
  238. package/hooks/useList.d.ts +0 -2
  239. package/hooks/useList.js +0 -54
  240. package/hooks/useList.js.map +0 -1
  241. package/hooks/useQuote.d.ts +0 -2
  242. package/hooks/useQuote.js +0 -22
  243. package/hooks/useQuote.js.map +0 -1
  244. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +0 -9
  245. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +0 -118
  246. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +0 -1
  247. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +0 -9
  248. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +0 -44
  249. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +0 -1
  250. package/utils/generateInitialLexicalValue.d.ts +0 -4
  251. package/utils/generateInitialLexicalValue.js +0 -33
  252. 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._
@@ -1,5 +1,5 @@
1
- import { LexicalCommand, NodeKey } from "lexical";
2
- import { ImageNodeProps } from "@webiny/lexical-nodes";
1
+ import type { LexicalCommand, NodeKey } from "lexical";
2
+ import type { ImageNodeProps } from "@webiny/lexical-nodes";
3
3
  export interface ImagePayload extends ImageNodeProps {
4
4
  key?: NodeKey;
5
5
  }
package/commands/image.js CHANGED
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.INSERT_IMAGE_COMMAND = void 0;
7
- var _lexical = require("lexical");
8
- var INSERT_IMAGE_COMMAND = exports.INSERT_IMAGE_COMMAND = (0, _lexical.createCommand)("INSERT_IMAGE_COMMAND");
1
+ import { createCommand } from "lexical";
2
+ export const INSERT_IMAGE_COMMAND = createCommand("INSERT_IMAGE_COMMAND");
9
3
 
10
4
  //# sourceMappingURL=image.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_lexical","require","INSERT_IMAGE_COMMAND","exports","createCommand"],"sources":["image.ts"],"sourcesContent":["import { createCommand, LexicalCommand, NodeKey } from \"lexical\";\nimport { 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":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAOO,IAAMC,oBAAkD,GAAAC,OAAA,CAAAD,oBAAA,GAC3D,IAAAE,sBAAa,EAAC,sBAAsB,CAAC","ignoreList":[]}
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":[]}
@@ -1,4 +1,5 @@
1
- export * from "./image";
2
- export * from "./list";
3
- export * from "./quote";
4
- export * from "./toolbar";
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";
package/commands/index.js CHANGED
@@ -1,51 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _image = require("./image");
7
- Object.keys(_image).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _image[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function get() {
13
- return _image[key];
14
- }
15
- });
16
- });
17
- var _list = require("./list");
18
- Object.keys(_list).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _list[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function get() {
24
- return _list[key];
25
- }
26
- });
27
- });
28
- var _quote = require("./quote");
29
- Object.keys(_quote).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _quote[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function get() {
35
- return _quote[key];
36
- }
37
- });
38
- });
39
- var _toolbar = require("./toolbar");
40
- Object.keys(_toolbar).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _toolbar[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function get() {
46
- return _toolbar[key];
47
- }
48
- });
49
- });
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";
50
6
 
51
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_image","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_list","_quote","_toolbar"],"sources":["index.ts"],"sourcesContent":["export * from \"~/commands/image\";\nexport * from \"~/commands/list\";\nexport * from \"~/commands/quote\";\nexport * from \"~/commands/toolbar\";\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,KAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,KAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,KAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,KAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,MAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,MAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,MAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,MAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,QAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,QAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,QAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAG,QAAA,CAAAP,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
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":[]}
@@ -1,4 +1,4 @@
1
- import { LexicalCommand } from "lexical";
1
+ import type { LexicalCommand } from "lexical";
2
2
  export type ListCommandPayload = {
3
3
  themeStyleId?: string;
4
4
  };
package/commands/list.js CHANGED
@@ -1,12 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.REMOVE_LIST_COMMAND = exports.INSERT_UNORDERED_LIST_COMMAND = exports.INSERT_ORDERED_LIST_COMMAND = void 0;
7
- var _lexical = require("lexical");
8
- var INSERT_UNORDERED_LIST_COMMAND = exports.INSERT_UNORDERED_LIST_COMMAND = (0, _lexical.createCommand)("INSERT_UNORDERED_LIST_COMMAND");
9
- var INSERT_ORDERED_LIST_COMMAND = exports.INSERT_ORDERED_LIST_COMMAND = (0, _lexical.createCommand)("INSERT_ORDERED_LIST_COMMAND");
10
- var REMOVE_LIST_COMMAND = exports.REMOVE_LIST_COMMAND = (0, _lexical.createCommand)("REMOVE_LIST_COMMAND");
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");
11
5
 
12
6
  //# sourceMappingURL=list.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_lexical","require","INSERT_UNORDERED_LIST_COMMAND","exports","createCommand","INSERT_ORDERED_LIST_COMMAND","REMOVE_LIST_COMMAND"],"sources":["list.ts"],"sourcesContent":["import { createCommand, LexicalCommand } 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":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAMO,IAAMC,6BAAiE,GAAAC,OAAA,CAAAD,6BAAA,GAAG,IAAAE,sBAAa,EAC1F,+BACJ,CAAC;AAEM,IAAMC,2BAA+D,GAAAF,OAAA,CAAAE,2BAAA,GAAG,IAAAD,sBAAa,EACxF,6BACJ,CAAC;AAEM,IAAME,mBAAyC,GAAAH,OAAA,CAAAG,mBAAA,GAAG,IAAAF,sBAAa,EAAC,qBAAqB,CAAC","ignoreList":[]}
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":[]}
@@ -1,4 +1,4 @@
1
- import { LexicalCommand } from "lexical";
1
+ import type { LexicalCommand } from "lexical";
2
2
  export type QuoteCommandPayload = {
3
3
  themeStyleId: string;
4
4
  };
package/commands/quote.js CHANGED
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.INSERT_QUOTE_COMMAND = void 0;
7
- var _lexical = require("lexical");
8
- var INSERT_QUOTE_COMMAND = exports.INSERT_QUOTE_COMMAND = (0, _lexical.createCommand)("INSERT_QUOTE_COMMAND");
1
+ import { createCommand } from "lexical";
2
+ export const INSERT_QUOTE_COMMAND = createCommand("INSERT_QUOTE_COMMAND");
9
3
 
10
4
  //# sourceMappingURL=quote.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_lexical","require","INSERT_QUOTE_COMMAND","exports","createCommand"],"sources":["quote.ts"],"sourcesContent":["import { createCommand, LexicalCommand } 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":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAMO,IAAMC,oBAAyD,GAAAC,OAAA,CAAAD,oBAAA,GAClE,IAAAE,sBAAa,EAAC,sBAAsB,CAAC","ignoreList":[]}
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":[]}
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.HIDE_FLOATING_TOOLBAR = void 0;
7
- var _lexical = require("lexical");
8
- var HIDE_FLOATING_TOOLBAR = exports.HIDE_FLOATING_TOOLBAR = (0, _lexical.createCommand)("HIDE_FLOATING_TOOLBAR_COMMAND");
1
+ import { createCommand } from "lexical";
2
+ export const HIDE_FLOATING_TOOLBAR = createCommand("HIDE_FLOATING_TOOLBAR_COMMAND");
9
3
 
10
4
  //# sourceMappingURL=toolbar.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_lexical","require","HIDE_FLOATING_TOOLBAR","exports","createCommand"],"sources":["toolbar.ts"],"sourcesContent":["import { createCommand } from \"lexical\";\n\nexport const HIDE_FLOATING_TOOLBAR = createCommand(\"HIDE_FLOATING_TOOLBAR_COMMAND\");\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEO,IAAMC,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,IAAAE,sBAAa,EAAC,+BAA+B,CAAC","ignoreList":[]}
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":[]}
@@ -1,25 +1,19 @@
1
- "use strict";
1
+ import { useEffect } from "react";
2
+ import { ParagraphNode, $createHeadingNode } from "@webiny/lexical-nodes";
3
+ import { useRichTextEditor } from "../../hooks/index.js";
2
4
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.EnsureHeadingTagPlugin = void 0;
7
- var _react = require("react");
8
- var _lexicalNodes = require("@webiny/lexical-nodes");
9
- var _hooks = require("../../hooks");
10
5
  /**
11
6
  * In the "Heading" editor, we only want to support heading tags.
12
7
  * However, when the editor is empty, and you start typing, Lexical automatically creates an empty "paragraph" node.
13
8
  * This ensures that any paragraph node is automatically converted to a heading node.
14
9
  */
15
- var EnsureHeadingTagPlugin = exports.EnsureHeadingTagPlugin = function EnsureHeadingTagPlugin() {
16
- var _useRichTextEditor = (0, _hooks.useRichTextEditor)(),
17
- editor = _useRichTextEditor.editor;
18
- (0, _react.useEffect)(function () {
19
- return editor.registerNodeTransform(_lexicalNodes.ParagraphNode, function (node) {
20
- node.replace((0, _lexicalNodes.$createHeadingNode)("h1"), true);
21
- });
22
- }, []);
10
+ export const EnsureHeadingTagPlugin = () => {
11
+ const {
12
+ editor
13
+ } = useRichTextEditor();
14
+ useEffect(() => editor.registerNodeTransform(ParagraphNode, node => {
15
+ node.replace($createHeadingNode("h1"), true);
16
+ }), []);
23
17
  return null;
24
18
  };
25
19
 
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_lexicalNodes","_hooks","EnsureHeadingTagPlugin","exports","_useRichTextEditor","useRichTextEditor","editor","useEffect","registerNodeTransform","ParagraphNode","node","replace","$createHeadingNode"],"sources":["EnsureHeadingTagPlugin.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { ParagraphNode, $createHeadingNode } from \"@webiny/lexical-nodes\";\nimport { useRichTextEditor } from \"~/hooks\";\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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACO,IAAMG,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,SAAzBA,sBAAsBA,CAAA,EAAS;EACxC,IAAAE,kBAAA,GAAmB,IAAAC,wBAAiB,EAAC,CAAC;IAA9BC,MAAM,GAAAF,kBAAA,CAANE,MAAM;EAEd,IAAAC,gBAAS,EACL;IAAA,OACID,MAAM,CAACE,qBAAqB,CAACC,2BAAa,EAAE,UAAAC,IAAI,EAAI;MAChDA,IAAI,CAACC,OAAO,CAAC,IAAAC,gCAAkB,EAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IAChD,CAAC,CAAC;EAAA,GACN,EACJ,CAAC;EACD,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
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,8 +1,11 @@
1
1
  import React from "react";
2
- import { CSSObject } from "@emotion/react";
3
- import { Klass, LexicalNode } from "lexical";
4
- import { EditorTheme, ThemeEmotionMap } from "@webiny/lexical-theme";
5
- import { LexicalValue, ToolbarActionPlugin } from "../../types";
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
+ };
6
9
  export interface RichTextEditorProps {
7
10
  children?: React.ReactNode | React.ReactNode[];
8
11
  classes?: string;
@@ -11,20 +14,18 @@ export interface RichTextEditorProps {
11
14
  height?: number | string;
12
15
  nodes?: Klass<LexicalNode>[];
13
16
  onBlur?: (editorState: LexicalValue) => void;
14
- onChange?: (json: LexicalValue) => void;
17
+ onChange?: (value: LexicalValue) => void;
15
18
  placeholder?: string;
16
19
  placeholderStyles?: React.CSSProperties;
17
20
  staticToolbar?: React.ReactNode;
18
21
  styles?: React.CSSProperties;
19
22
  tag?: string;
20
23
  theme: EditorTheme;
21
- themeEmotionMap?: ThemeEmotionMap;
22
24
  toolbarActionPlugins?: ToolbarActionPlugin[];
23
- themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;
24
25
  toolbar?: React.ReactNode;
25
26
  value: LexicalValue | null | undefined;
27
+ configRef?: React.MutableRefObject<InitialEditorConfig | undefined>;
26
28
  width?: number | string;
27
- generateInitialValue?: () => LexicalValue;
28
29
  }
29
30
  /**
30
31
  * @description Main editor container
@@ -48,3 +49,6 @@ export declare const RichTextEditor: ((props: RichTextEditorProps) => React.JSX.
48
49
  displayName: string;
49
50
  }>) => (props: unknown) => React.JSX.Element;
50
51
  };
52
+ export declare namespace RichTextEditor {
53
+ type InitialConfig = InitialEditorConfig;
54
+ }
@@ -1,98 +1,78 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").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 _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
- var _react = _interopRequireWildcard(require("react"));
14
- var _emotion = require("emotion");
15
- var _LexicalComposer = require("@lexical/react/LexicalComposer");
16
- var _LexicalAutoFocusPlugin = require("@lexical/react/LexicalAutoFocusPlugin");
17
- var _LexicalClearEditorPlugin = require("@lexical/react/LexicalClearEditorPlugin");
18
- var _LexicalRichTextPlugin = require("@lexical/react/LexicalRichTextPlugin");
19
- var _LexicalErrorBoundary = require("@lexical/react/LexicalErrorBoundary");
20
- var _reactComposition = require("@webiny/react-composition");
21
- var _LexicalHistoryPlugin = require("@lexical/react/LexicalHistoryPlugin");
22
- var _LexicalContentEditable = require("@lexical/react/LexicalContentEditable");
23
- var _lexicalTheme = require("@webiny/lexical-theme");
24
- var _lexicalNodes = require("@webiny/lexical-nodes");
25
- var _RichTextEditorContext = require("../../context/RichTextEditorContext");
26
- var _isValidLexicalData = require("../../utils/isValidLexicalData");
27
- var _BlurEventPlugin = require("../../plugins/BlurEventPlugin/BlurEventPlugin");
28
- var _Placeholder = require("../../ui/Placeholder");
29
- var _generateInitialLexicalValue = require("../../utils/generateInitialLexicalValue");
30
- var _SharedHistoryContext = require("../../context/SharedHistoryContext");
31
- var _LexicalEditorConfig = require("../LexicalEditorConfig/LexicalEditorConfig");
32
- var _normalizeInputValue = require("./normalizeInputValue");
33
- var _StateHandlingPlugin = require("../../plugins/StateHandlingPlugin");
34
- var _excluded = ["toolbar", "staticToolbar", "onChange", "nodes", "placeholder", "children", "onBlur", "focus", "styles", "width", "height", "contentEditableStyles", "placeholderStyles", "generateInitialValue"];
35
- var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
36
- var toolbar = _ref.toolbar,
37
- staticToolbar = _ref.staticToolbar,
38
- onChange = _ref.onChange,
39
- nodes = _ref.nodes,
40
- placeholder = _ref.placeholder,
41
- children = _ref.children,
42
- onBlur = _ref.onBlur,
43
- focus = _ref.focus,
44
- styles = _ref.styles,
45
- width = _ref.width,
46
- height = _ref.height,
47
- contentEditableStyles = _ref.contentEditableStyles,
48
- placeholderStyles = _ref.placeholderStyles,
49
- _ref$generateInitialV = _ref.generateInitialValue,
50
- generateInitialValue = _ref$generateInitialV === void 0 ? _generateInitialLexicalValue.generateInitialLexicalValue : _ref$generateInitialV,
51
- props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
52
- var themeEmotionMap = props.themeEmotionMap ?? (0, _lexicalTheme.toTypographyEmotionMap)(_emotion.css, props.theme, props.themeStylesTransformer);
53
- var editorTheme = (0, _react.useRef)((0, _lexicalTheme.createTheme)(props.theme));
54
- var config = (0, _LexicalEditorConfig.useLexicalEditorConfig)();
55
- var _useSharedHistoryCont = (0, _SharedHistoryContext.useSharedHistoryContext)(),
56
- historyState = _useSharedHistoryCont.historyState;
57
- var placeholderElem = /*#__PURE__*/_react.default.createElement(_Placeholder.Placeholder, {
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, {
58
39
  styles: placeholderStyles
59
40
  }, placeholder || "Enter text...");
60
- var scrollRef = (0, _react.useRef)(null);
61
- var _useState = (0, _react.useState)(undefined),
62
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
63
- floatingAnchorElem = _useState2[0],
64
- setFloatingAnchorElem = _useState2[1];
65
- var onRef = function onRef(_floatingAnchorElem) {
41
+ const scrollRef = useRef(null);
42
+ const [floatingAnchorElem, setFloatingAnchorElem] = useState(undefined);
43
+ const onRef = _floatingAnchorElem => {
66
44
  if (_floatingAnchorElem !== null) {
67
45
  setFloatingAnchorElem(_floatingAnchorElem);
68
46
  }
69
47
  };
70
- var sizeStyle = {
48
+ const sizeStyle = {
71
49
  height: height || "",
72
50
  width: width || ""
73
51
  };
74
- var configNodes = config.nodes.map(function (node) {
75
- return node.node;
76
- });
77
- var configPlugins = config.plugins.map(function (plugin) {
78
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
79
- key: plugin.name
80
- }, plugin.element);
81
- });
82
- var value = (0, _normalizeInputValue.normalizeInputValue)(props.value);
83
- var editorValue = (0, _isValidLexicalData.isValidLexicalData)(value) ? value : generateInitialValue();
84
- var initialConfig = {
85
- editorState: null,
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(),
86
58
  namespace: "webiny",
87
- onError: function onError() {
59
+ onError: () => {
88
60
  // Ignore errors. We don't want to break the app because of errors caused by config/value updates.
89
61
  // These are usually resolved in the next component render cycle.
90
62
  },
91
- nodes: [].concat((0, _toConsumableArray2.default)(_lexicalNodes.allNodes), (0, _toConsumableArray2.default)(configNodes), (0, _toConsumableArray2.default)(nodes || [])),
92
- theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, editorTheme.current), {}, {
93
- emotionMap: themeEmotionMap
94
- })
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
+ }
95
72
  };
73
+ if (props.configRef) {
74
+ props.configRef.current = initialConfig;
75
+ }
96
76
  return (
97
77
  /*#__PURE__*/
98
78
  /**
@@ -102,42 +82,49 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
102
82
  *
103
83
  * To bypass this issue, we generate a naive `key` based on the number of Nodes.
104
84
  */
105
- _react.default.createElement(_SharedHistoryContext.SharedHistoryContext, null, /*#__PURE__*/_react.default.createElement(_LexicalComposer.LexicalComposer, {
85
+ React.createElement(SharedHistoryContext, null, /*#__PURE__*/React.createElement(LexicalComposer, {
106
86
  initialConfig: initialConfig,
107
87
  key: initialConfig.nodes.length
108
- }, /*#__PURE__*/_react.default.createElement(_RichTextEditorContext.RichTextEditorProvider, {
88
+ }, /*#__PURE__*/React.createElement(RichTextEditorProvider, {
109
89
  theme: props.theme,
110
- themeEmotionMap: themeEmotionMap,
111
90
  toolbarActionPlugins: props.toolbarActionPlugins
112
- }, staticToolbar ? staticToolbar : null, /*#__PURE__*/_react.default.createElement("div", {
91
+ }, staticToolbar ? staticToolbar : null, /*#__PURE__*/React.createElement("div", {
92
+ "data-role": "overlays",
93
+ className: "relative"
94
+ }), /*#__PURE__*/React.createElement("div", {
113
95
  /* This className is necessary for targeting of editor container from CSS files. */
114
96
  className: "editor-shell",
115
97
  ref: scrollRef,
116
- style: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, styles), sizeStyle), {}, {
98
+ style: {
99
+ ...styles,
100
+ ...sizeStyle,
117
101
  overflow: "auto",
118
102
  position: "relative"
119
- })
120
- }, /*#__PURE__*/_react.default.createElement(_StateHandlingPlugin.StateHandlingPlugin, {
121
- value: editorValue,
103
+ }
104
+ }, /*#__PURE__*/React.createElement(StateHandlingPlugin, {
105
+ value: props.value,
122
106
  onChange: onChange
123
- }), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null), /*#__PURE__*/_react.default.createElement(_LexicalHistoryPlugin.HistoryPlugin, {
107
+ }), /*#__PURE__*/React.createElement(ClearEditorPlugin, null), /*#__PURE__*/React.createElement(HistoryPlugin, {
124
108
  externalHistoryState: historyState
125
- }), onBlur && /*#__PURE__*/_react.default.createElement(_BlurEventPlugin.BlurEventPlugin, {
109
+ }), onBlur && /*#__PURE__*/React.createElement(BlurEventPlugin, {
126
110
  onBlur: onBlur
127
- }), focus && /*#__PURE__*/_react.default.createElement(_LexicalAutoFocusPlugin.AutoFocusPlugin, null), configPlugins, children, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
128
- contentEditable: /*#__PURE__*/_react.default.createElement("div", {
111
+ }), focus && /*#__PURE__*/React.createElement(AutoFocusPlugin, null), configPlugins, children, /*#__PURE__*/React.createElement(RichTextPlugin, {
112
+ contentEditable: /*#__PURE__*/React.createElement("div", {
129
113
  className: "editor-scroller",
130
- style: (0, _objectSpread2.default)({}, sizeStyle)
131
- }, /*#__PURE__*/_react.default.createElement("div", {
114
+ style: {
115
+ ...sizeStyle
116
+ }
117
+ }, /*#__PURE__*/React.createElement("div", {
132
118
  className: "editor",
133
119
  ref: onRef
134
- }, /*#__PURE__*/_react.default.createElement(_LexicalContentEditable.ContentEditable, {
135
- style: (0, _objectSpread2.default)({
136
- outline: 0
137
- }, contentEditableStyles)
120
+ }, /*#__PURE__*/React.createElement(ContentEditable, {
121
+ style: {
122
+ outline: 0,
123
+ ...contentEditableStyles
124
+ }
138
125
  }))),
139
126
  placeholder: placeholderElem,
140
- ErrorBoundary: _LexicalErrorBoundary.LexicalErrorBoundary
127
+ ErrorBoundary: LexicalErrorBoundary
141
128
  }), floatingAnchorElem && toolbar))))
142
129
  );
143
130
  };
@@ -145,8 +132,8 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
145
132
  /**
146
133
  * @description Main editor container
147
134
  */
148
- var RichTextEditor = exports.RichTextEditor = (0, _reactComposition.makeDecoratable)("RichTextEditor", function (props) {
149
- return /*#__PURE__*/_react.default.createElement(_LexicalEditorConfig.LexicalEditorWithConfig, null, /*#__PURE__*/_react.default.createElement(BaseRichTextEditor, props));
135
+ export const RichTextEditor = makeDecoratable("RichTextEditor", props => {
136
+ return /*#__PURE__*/React.createElement(LexicalEditorWithConfig, null, /*#__PURE__*/React.createElement(BaseRichTextEditor, props));
150
137
  });
151
138
 
152
139
  //# sourceMappingURL=RichTextEditor.js.map