@webiny/lexical-editor 5.37.8 → 5.38.0-beta.1

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 (229) hide show
  1. package/commands/image.d.ts +6 -0
  2. package/commands/{insertFiles.js → image.js} +3 -1
  3. package/commands/image.js.map +1 -0
  4. package/commands/index.d.ts +3 -0
  5. package/commands/index.js +40 -0
  6. package/commands/index.js.map +1 -0
  7. package/commands/list.d.ts +7 -0
  8. package/commands/list.js +15 -0
  9. package/commands/list.js.map +1 -0
  10. package/commands/quote.d.ts +5 -0
  11. package/commands/quote.js +11 -0
  12. package/commands/quote.js.map +1 -0
  13. package/components/Editor/HeadingEditor.js +3 -1
  14. package/components/Editor/ParagraphEditor.js +3 -1
  15. package/components/Editor/RichTextEditor.d.ts +2 -2
  16. package/components/Editor/RichTextEditor.js +19 -12
  17. package/components/Editor/RichTextEditor.js.map +1 -1
  18. package/components/LexicalEditorConfig/LexicalEditorConfig.js +3 -1
  19. package/components/LexicalEditorConfig/components/Node.js +3 -1
  20. package/components/LexicalEditorConfig/components/Plugin.js +3 -1
  21. package/components/LexicalEditorConfig/components/ToolbarElement.js +3 -1
  22. package/components/LexicalHtmlRenderer.d.ts +2 -2
  23. package/components/LexicalHtmlRenderer.js +24 -17
  24. package/components/LexicalHtmlRenderer.js.map +1 -1
  25. package/components/Toolbar/StaticToolbar.d.ts +2 -2
  26. package/components/Toolbar/StaticToolbar.js +7 -78
  27. package/components/Toolbar/StaticToolbar.js.map +1 -1
  28. package/components/Toolbar/Toolbar.d.ts +1 -1
  29. package/components/Toolbar/Toolbar.js +27 -80
  30. package/components/Toolbar/Toolbar.js.map +1 -1
  31. package/components/ToolbarActions/BoldAction.js +10 -20
  32. package/components/ToolbarActions/BoldAction.js.map +1 -1
  33. package/components/ToolbarActions/BulletListAction.js +17 -23
  34. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  35. package/components/ToolbarActions/CodeHighlightAction.js +10 -20
  36. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
  37. package/components/ToolbarActions/FontColorAction.js +20 -37
  38. package/components/ToolbarActions/FontColorAction.js.map +1 -1
  39. package/components/ToolbarActions/FontSizeAction.js +11 -27
  40. package/components/ToolbarActions/FontSizeAction.js.map +1 -1
  41. package/components/ToolbarActions/ImageAction.js +6 -4
  42. package/components/ToolbarActions/ImageAction.js.map +1 -1
  43. package/components/ToolbarActions/ItalicAction.js +10 -20
  44. package/components/ToolbarActions/ItalicAction.js.map +1 -1
  45. package/components/ToolbarActions/LinkAction.js +18 -36
  46. package/components/ToolbarActions/LinkAction.js.map +1 -1
  47. package/components/ToolbarActions/NumberedListAction.js +18 -27
  48. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  49. package/components/ToolbarActions/QuoteAction.js +15 -24
  50. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  51. package/components/ToolbarActions/TextAlignmentAction.js +27 -21
  52. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
  53. package/components/ToolbarActions/TypographyAction.js +53 -60
  54. package/components/ToolbarActions/TypographyAction.js.map +1 -1
  55. package/components/ToolbarActions/UnderlineAction.js +11 -21
  56. package/components/ToolbarActions/UnderlineAction.js.map +1 -1
  57. package/context/FontColorActionContext.js +3 -1
  58. package/context/RichTextEditorContext.d.ts +2 -6
  59. package/context/RichTextEditorContext.js +20 -36
  60. package/context/RichTextEditorContext.js.map +1 -1
  61. package/context/SharedHistoryContext.js +3 -1
  62. package/context/TextAlignmentActionContextProps.js +3 -1
  63. package/context/TypographyActionContext.d.ts +1 -1
  64. package/context/TypographyActionContext.js +3 -1
  65. package/context/TypographyActionContext.js.map +1 -1
  66. package/hooks/index.d.ts +7 -0
  67. package/hooks/index.js +84 -0
  68. package/hooks/index.js.map +1 -0
  69. package/hooks/useCurrentElement.d.ts +7 -0
  70. package/hooks/useCurrentElement.js +33 -0
  71. package/hooks/useCurrentElement.js.map +1 -0
  72. package/hooks/useCurrentSelection.d.ts +12 -0
  73. package/hooks/useCurrentSelection.js +72 -0
  74. package/hooks/useCurrentSelection.js.map +1 -0
  75. package/hooks/useFontColorPicker.js +3 -1
  76. package/hooks/useIsMounted.d.ts +1 -0
  77. package/hooks/useIsMounted.js +20 -0
  78. package/hooks/useIsMounted.js.map +1 -0
  79. package/hooks/useList.js +22 -21
  80. package/hooks/useList.js.map +1 -1
  81. package/hooks/useQuote.d.ts +1 -1
  82. package/hooks/useQuote.js +9 -7
  83. package/hooks/useQuote.js.map +1 -1
  84. package/hooks/useRichTextEditor.js +3 -1
  85. package/hooks/useTextAlignmentAction.js +3 -1
  86. package/hooks/useTypographyAction.js +3 -1
  87. package/index.d.ts +4 -8
  88. package/index.js +71 -48
  89. package/index.js.map +1 -1
  90. package/package.json +16 -20
  91. package/plugins/BlurEventPlugin/BlurEventPlugin.js +3 -1
  92. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +3 -1
  93. package/plugins/CodeHighlightPlugin/index.js +3 -1
  94. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +11 -9
  95. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  96. package/plugins/FloatingLinkEditorPlugin/index.js +3 -1
  97. package/plugins/FontColorPlugin/FontColorPlugin.js +8 -7
  98. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
  99. package/plugins/ImagesPlugin/ImagesPlugin.d.ts +1 -1
  100. package/plugins/ImagesPlugin/ImagesPlugin.js +11 -9
  101. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
  102. package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.d.ts +9 -0
  103. package/plugins/LexicalUpdateStatePlugin/{LexicalUpdateStatePlugin.js → UpdateStatePlugin.js} +22 -14
  104. package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js.map +1 -0
  105. package/plugins/LexicalUpdateStatePlugin/index.d.ts +1 -1
  106. package/plugins/LexicalUpdateStatePlugin/index.js +7 -5
  107. package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -1
  108. package/plugins/LinkPlugin/LinkPlugin.d.ts +5 -0
  109. package/plugins/LinkPlugin/LinkPlugin.js +68 -0
  110. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -0
  111. package/plugins/ListPLugin/ListPlugin.js +6 -5
  112. package/plugins/ListPLugin/ListPlugin.js.map +1 -1
  113. package/plugins/TypographyPlugin/TypographyPlugin.js +7 -7
  114. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
  115. package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js +6 -4
  116. package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js.map +1 -1
  117. package/types.d.ts +1 -60
  118. package/types.js +5 -3
  119. package/types.js.map +1 -1
  120. package/ui/ContentEditable.js +3 -1
  121. package/ui/Divider.js +3 -1
  122. package/ui/DropDown.js +3 -1
  123. package/ui/ImageResizer.js +3 -1
  124. package/ui/LinkPreview.js +3 -1
  125. package/ui/Placeholder.js +3 -1
  126. package/ui/TextInput.js +3 -1
  127. package/ui/ToolbarActionDialog.js +3 -1
  128. package/utils/canUseDOM.js +3 -1
  129. package/utils/files.d.ts +1 -1
  130. package/utils/files.js +3 -1
  131. package/utils/files.js.map +1 -1
  132. package/utils/generateInitialLexicalValue.js +3 -1
  133. package/utils/getDOMRangeRect.js +3 -1
  134. package/utils/getSelectedNode.js +3 -1
  135. package/utils/getTransparentImage.js +3 -1
  136. package/utils/insertImage.d.ts +2 -0
  137. package/utils/{nodes/insertImage.js → insertImage.js} +6 -5
  138. package/utils/insertImage.js.map +1 -0
  139. package/utils/isHTMLElement.js +3 -1
  140. package/utils/isUrlLinkReference.js +3 -1
  141. package/utils/isValidJSON.js +3 -1
  142. package/utils/isValidLexicalData.js +3 -1
  143. package/utils/point.js +3 -1
  144. package/utils/rect.js +3 -1
  145. package/utils/sanitizeUrl.js +3 -1
  146. package/utils/setFloatingElemPosition.js +3 -1
  147. package/commands/insertFiles.d.ts +0 -14
  148. package/commands/insertFiles.js.map +0 -1
  149. package/commands/webiny-list.d.ts +0 -7
  150. package/commands/webiny-list.js +0 -13
  151. package/commands/webiny-list.js.map +0 -1
  152. package/commands/webiny-quote.d.ts +0 -5
  153. package/commands/webiny-quote.js +0 -9
  154. package/commands/webiny-quote.js.map +0 -1
  155. package/components/ImageComponent.d.ts +0 -23
  156. package/components/ImageComponent.js +0 -252
  157. package/components/ImageComponent.js.map +0 -1
  158. package/nodes/FontColorNode.d.ts +0 -43
  159. package/nodes/FontColorNode.js +0 -123
  160. package/nodes/FontColorNode.js.map +0 -1
  161. package/nodes/HeadingNode.d.ts +0 -34
  162. package/nodes/HeadingNode.js +0 -191
  163. package/nodes/HeadingNode.js.map +0 -1
  164. package/nodes/ImageNode.d.ts +0 -50
  165. package/nodes/ImageNode.js +0 -206
  166. package/nodes/ImageNode.js.map +0 -1
  167. package/nodes/ListItemNode.d.ts +0 -46
  168. package/nodes/ListItemNode.js +0 -447
  169. package/nodes/ListItemNode.js.map +0 -1
  170. package/nodes/ListNode/formatList.d.ts +0 -19
  171. package/nodes/ListNode/formatList.js +0 -447
  172. package/nodes/ListNode/formatList.js.map +0 -1
  173. package/nodes/ListNode.d.ts +0 -42
  174. package/nodes/ListNode.js +0 -288
  175. package/nodes/ListNode.js.map +0 -1
  176. package/nodes/ParagraphNode.d.ts +0 -32
  177. package/nodes/ParagraphNode.js +0 -218
  178. package/nodes/ParagraphNode.js.map +0 -1
  179. package/nodes/QuoteNode.d.ts +0 -34
  180. package/nodes/QuoteNode.js +0 -225
  181. package/nodes/QuoteNode.js.map +0 -1
  182. package/nodes/TypographyElementNode.d.ts +0 -42
  183. package/nodes/TypographyElementNode.js +0 -151
  184. package/nodes/TypographyElementNode.js.map +0 -1
  185. package/nodes/imageNode.css +0 -43
  186. package/nodes/link-node.d.ts +0 -19
  187. package/nodes/link-node.js +0 -120
  188. package/nodes/link-node.js.map +0 -1
  189. package/nodes/types.d.ts +0 -15
  190. package/nodes/types.js +0 -5
  191. package/nodes/types.js.map +0 -1
  192. package/nodes/webinyNodes.d.ts +0 -7
  193. package/nodes/webinyNodes.js +0 -60
  194. package/nodes/webinyNodes.js.map +0 -1
  195. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.d.ts +0 -8
  196. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +0 -1
  197. package/themes/webinyLexicalTheme.css +0 -423
  198. package/themes/webinyLexicalTheme.d.ts +0 -9
  199. package/themes/webinyLexicalTheme.js +0 -90
  200. package/themes/webinyLexicalTheme.js.map +0 -1
  201. package/utils/findTypographyStyleByHtmlTag.d.ts +0 -8
  202. package/utils/findTypographyStyleByHtmlTag.js +0 -16
  203. package/utils/findTypographyStyleByHtmlTag.js.map +0 -1
  204. package/utils/getLexicalTextSelectionState.d.ts +0 -5
  205. package/utils/getLexicalTextSelectionState.js +0 -167
  206. package/utils/getLexicalTextSelectionState.js.map +0 -1
  207. package/utils/nodes/clearNodeFormating.d.ts +0 -2
  208. package/utils/nodes/clearNodeFormating.js +0 -28
  209. package/utils/nodes/clearNodeFormating.js.map +0 -1
  210. package/utils/nodes/formatToHeading.d.ts +0 -3
  211. package/utils/nodes/formatToHeading.js +0 -25
  212. package/utils/nodes/formatToHeading.js.map +0 -1
  213. package/utils/nodes/formatToParagraph.d.ts +0 -2
  214. package/utils/nodes/formatToParagraph.js +0 -20
  215. package/utils/nodes/formatToParagraph.js.map +0 -1
  216. package/utils/nodes/formatToQuote.d.ts +0 -2
  217. package/utils/nodes/formatToQuote.js +0 -25
  218. package/utils/nodes/formatToQuote.js.map +0 -1
  219. package/utils/nodes/insertImage.d.ts +0 -2
  220. package/utils/nodes/insertImage.js.map +0 -1
  221. package/utils/nodes/listNode.d.ts +0 -11
  222. package/utils/nodes/listNode.js +0 -107
  223. package/utils/nodes/listNode.js.map +0 -1
  224. package/utils/styleObjectToString.d.ts +0 -2
  225. package/utils/styleObjectToString.js +0 -22
  226. package/utils/styleObjectToString.js.map +0 -1
  227. package/utils/toTypographyEmotionMap.d.ts +0 -3
  228. package/utils/toTypographyEmotionMap.js +0 -41
  229. package/utils/toTypographyEmotionMap.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ import { LexicalCommand, NodeKey } from "lexical";
2
+ import { ImageNodeProps } from "@webiny/lexical-nodes";
3
+ export interface ImagePayload extends ImageNodeProps {
4
+ key?: NodeKey;
5
+ }
6
+ export declare const INSERT_IMAGE_COMMAND: LexicalCommand<ImagePayload>;
@@ -6,4 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.INSERT_IMAGE_COMMAND = void 0;
7
7
  var _lexical = require("lexical");
8
8
  var INSERT_IMAGE_COMMAND = (0, _lexical.createCommand)("INSERT_IMAGE_COMMAND");
9
- exports.INSERT_IMAGE_COMMAND = INSERT_IMAGE_COMMAND;
9
+ exports.INSERT_IMAGE_COMMAND = INSERT_IMAGE_COMMAND;
10
+
11
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lexical","require","INSERT_IMAGE_COMMAND","createCommand","exports"],"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,GAC3D,IAAAC,sBAAa,EAAC,sBAAsB,CAAC;AAACC,OAAA,CAAAF,oBAAA,GAAAA,oBAAA"}
@@ -0,0 +1,3 @@
1
+ export * from "./image";
2
+ export * from "./list";
3
+ export * from "./quote";
@@ -0,0 +1,40 @@
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
+
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_image","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_list","_quote"],"sources":["index.ts"],"sourcesContent":["export * from \"~/commands/image\";\nexport * from \"~/commands/list\";\nexport * from \"~/commands/quote\";\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"}
@@ -0,0 +1,7 @@
1
+ import { LexicalCommand } from "lexical";
2
+ export declare 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,15 @@
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 = (0, _lexical.createCommand)("INSERT_UNORDERED_LIST_COMMAND");
9
+ exports.INSERT_UNORDERED_LIST_COMMAND = INSERT_UNORDERED_LIST_COMMAND;
10
+ var INSERT_ORDERED_LIST_COMMAND = (0, _lexical.createCommand)("INSERT_ORDERED_LIST_COMMAND");
11
+ exports.INSERT_ORDERED_LIST_COMMAND = INSERT_ORDERED_LIST_COMMAND;
12
+ var REMOVE_LIST_COMMAND = (0, _lexical.createCommand)("REMOVE_LIST_COMMAND");
13
+ exports.REMOVE_LIST_COMMAND = REMOVE_LIST_COMMAND;
14
+
15
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lexical","require","INSERT_UNORDERED_LIST_COMMAND","createCommand","exports","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,GAAG,IAAAC,sBAAa,EAC1F,+BACJ,CAAC;AAACC,OAAA,CAAAF,6BAAA,GAAAA,6BAAA;AAEK,IAAMG,2BAA+D,GAAG,IAAAF,sBAAa,EACxF,6BACJ,CAAC;AAACC,OAAA,CAAAC,2BAAA,GAAAA,2BAAA;AAEK,IAAMC,mBAAyC,GAAG,IAAAH,sBAAa,EAAC,qBAAqB,CAAC;AAACC,OAAA,CAAAE,mBAAA,GAAAA,mBAAA"}
@@ -0,0 +1,5 @@
1
+ import { LexicalCommand } from "lexical";
2
+ export declare type QuoteCommandPayload = {
3
+ themeStyleId: string;
4
+ };
5
+ export declare const INSERT_QUOTE_COMMAND: LexicalCommand<QuoteCommandPayload>;
@@ -0,0 +1,11 @@
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 = (0, _lexical.createCommand)("INSERT_QUOTE_COMMAND");
9
+ exports.INSERT_QUOTE_COMMAND = INSERT_QUOTE_COMMAND;
10
+
11
+ //# sourceMappingURL=quote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lexical","require","INSERT_QUOTE_COMMAND","createCommand","exports"],"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,GAClE,IAAAC,sBAAa,EAAC,sBAAsB,CAAC;AAACC,OAAA,CAAAF,oBAAA,GAAAA,oBAAA"}
@@ -24,4 +24,6 @@ var HeadingEditor = function HeadingEditor(_ref) {
24
24
  }
25
25
  }), rest === null || rest === void 0 ? void 0 : rest.children);
26
26
  };
27
- exports.HeadingEditor = HeadingEditor;
27
+ exports.HeadingEditor = HeadingEditor;
28
+
29
+ //# sourceMappingURL=HeadingEditor.js.map
@@ -24,4 +24,6 @@ var ParagraphEditor = function ParagraphEditor(_ref) {
24
24
  }
25
25
  }), rest === null || rest === void 0 ? void 0 : rest.children);
26
26
  };
27
- exports.ParagraphEditor = ParagraphEditor;
27
+ exports.ParagraphEditor = ParagraphEditor;
28
+
29
+ //# sourceMappingURL=ParagraphEditor.js.map
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
2
  import { CSSObject } from "@emotion/react";
3
3
  import { Klass, LexicalNode } from "lexical";
4
- import { LexicalValue, ThemeEmotionMap, ToolbarActionPlugin } from "../../types";
5
- import { WebinyTheme } from "../../themes/webinyLexicalTheme";
4
+ import { LexicalValue, ToolbarActionPlugin } from "../../types";
5
+ import { WebinyTheme, ThemeEmotionMap } from "@webiny/lexical-theme";
6
6
  export interface RichTextEditorProps {
7
7
  children?: React.ReactNode | React.ReactNode[];
8
8
  classes?: string;
@@ -26,11 +26,10 @@ var _LexicalUpdateStatePlugin = require("../../plugins/LexicalUpdateStatePlugin"
26
26
  var _BlurEventPlugin = require("../../plugins/BlurEventPlugin/BlurEventPlugin");
27
27
  var _Placeholder = require("../../ui/Placeholder");
28
28
  var _generateInitialLexicalValue = require("../../utils/generateInitialLexicalValue");
29
- var _webinyLexicalTheme = require("../../themes/webinyLexicalTheme");
30
- var _webinyNodes = require("../../nodes/webinyNodes");
29
+ var _lexicalTheme = require("@webiny/lexical-theme");
30
+ var _lexicalNodes = require("@webiny/lexical-nodes");
31
31
  var _SharedHistoryContext = require("../../context/SharedHistoryContext");
32
32
  var _useRichTextEditor2 = require("../../hooks/useRichTextEditor");
33
- var _toTypographyEmotionMap = require("../../utils/toTypographyEmotionMap");
34
33
  var _LexicalEditorConfig = require("../LexicalEditorConfig/LexicalEditorConfig");
35
34
  var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
36
35
  var toolbar = _ref.toolbar,
@@ -50,6 +49,7 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
50
49
  toolbarActionPlugins = _ref.toolbarActionPlugins,
51
50
  contentEditableStyles = _ref.contentEditableStyles,
52
51
  placeholderStyles = _ref.placeholderStyles;
52
+ var editorTheme = (0, _react.useRef)((0, _lexicalTheme.createTheme)());
53
53
  var config = (0, _LexicalEditorConfig.useLexicalEditorConfig)();
54
54
  var _useSharedHistoryCont = (0, _SharedHistoryContext.useSharedHistoryContext)(),
55
55
  historyState = _useSharedHistoryCont.historyState;
@@ -91,14 +91,17 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
91
91
  key: plugin.name
92
92
  }, plugin.element);
93
93
  });
94
+ var editorValue = (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)();
94
95
  var initialConfig = {
95
- editorState: (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)(),
96
+ // We update the state via the `<LexicalUpdateStatePlugin/>`.
97
+ editorState: null,
96
98
  namespace: "webiny",
97
- onError: function onError(error) {
98
- throw error;
99
+ onError: function onError() {
100
+ // Ignore errors. We don't want to break the app because of errors caused by config/value updates.
101
+ // These are usually resolved in the next component render cycle.
99
102
  },
100
- nodes: [].concat((0, _toConsumableArray2.default)(_webinyNodes.WebinyNodes), (0, _toConsumableArray2.default)(configNodes), (0, _toConsumableArray2.default)(nodes || [])),
101
- theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _webinyLexicalTheme.webinyEditorTheme), {}, {
103
+ nodes: [].concat((0, _toConsumableArray2.default)(_lexicalNodes.allNodes), (0, _toConsumableArray2.default)(configNodes), (0, _toConsumableArray2.default)(nodes || [])),
104
+ theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, editorTheme.current), {}, {
102
105
  emotionMap: themeEmotionMap
103
106
  })
104
107
  };
@@ -123,6 +126,8 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
123
126
  initialConfig: initialConfig,
124
127
  key: initialConfig.nodes.length
125
128
  }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, staticToolbar && staticToolbar, /*#__PURE__*/_react.default.createElement("div", {
129
+ /* This className is necessary for targeting of editor container from CSS files. */
130
+ className: "editor-shell",
126
131
  ref: scrollRef,
127
132
  style: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, styles), sizeStyle), {}, {
128
133
  overflow: "auto",
@@ -130,8 +135,8 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
130
135
  })
131
136
  }, /*#__PURE__*/_react.default.createElement(_LexicalOnChangePlugin.OnChangePlugin, {
132
137
  onChange: handleOnChange
133
- }), value && /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.LexicalUpdateStatePlugin, {
134
- value: value
138
+ }), /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.UpdateStatePlugin, {
139
+ value: editorValue
135
140
  }), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null), /*#__PURE__*/_react.default.createElement(_LexicalHistoryPlugin.HistoryPlugin, {
136
141
  externalHistoryState: historyState
137
142
  }), onBlur && /*#__PURE__*/_react.default.createElement(_BlurEventPlugin.BlurEventPlugin, {
@@ -161,10 +166,12 @@ var RichTextEditor = (0, _reactComposition.makeComposable)("RichTextEditor", fun
161
166
  return /*#__PURE__*/_react.default.createElement(_LexicalEditorConfig.LexicalEditorWithConfig, null, /*#__PURE__*/_react.default.createElement(_RichTextEditorContext.RichTextEditorProvider, null, /*#__PURE__*/_react.default.createElement(_react2.ClassNames, null, function (_ref2) {
162
167
  var _props$themeEmotionMa;
163
168
  var css = _ref2.css;
164
- var themeEmotionMap = (_props$themeEmotionMa = props === null || props === void 0 ? void 0 : props.themeEmotionMap) !== null && _props$themeEmotionMa !== void 0 ? _props$themeEmotionMa : (0, _toTypographyEmotionMap.toTypographyEmotionMap)(css, props.theme, props.themeStylesTransformer);
169
+ var themeEmotionMap = (_props$themeEmotionMa = props === null || props === void 0 ? void 0 : props.themeEmotionMap) !== null && _props$themeEmotionMa !== void 0 ? _props$themeEmotionMa : (0, _lexicalTheme.toTypographyEmotionMap)(css, props.theme, props.themeStylesTransformer);
165
170
  return /*#__PURE__*/_react.default.createElement(_SharedHistoryContext.SharedHistoryContext, null, /*#__PURE__*/_react.default.createElement(BaseRichTextEditor, Object.assign({}, props, {
166
171
  themeEmotionMap: themeEmotionMap
167
172
  })));
168
173
  })));
169
174
  });
170
- exports.RichTextEditor = RichTextEditor;
175
+ exports.RichTextEditor = RichTextEditor;
176
+
177
+ //# sourceMappingURL=RichTextEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_react2","_LexicalComposer","_LexicalOnChangePlugin","_LexicalAutoFocusPlugin","_LexicalClearEditorPlugin","_LexicalRichTextPlugin","_LexicalErrorBoundary","_interopRequireDefault","_reactComposition","_LexicalHistoryPlugin","_LexicalContentEditable","_RichTextEditorContext","_isValidLexicalData","_LexicalUpdateStatePlugin","_BlurEventPlugin","_Placeholder","_generateInitialLexicalValue","_webinyLexicalTheme","_webinyNodes","_SharedHistoryContext","_useRichTextEditor2","_toTypographyEmotionMap","_LexicalEditorConfig","BaseRichTextEditor","_ref","toolbar","staticToolbar","onChange","value","nodes","placeholder","children","onBlur","focus","styles","width","height","theme","themeEmotionMap","toolbarActionPlugins","contentEditableStyles","placeholderStyles","config","useLexicalEditorConfig","_useSharedHistoryCont","useSharedHistoryContext","historyState","placeholderElem","default","createElement","Placeholder","scrollRef","useRef","_useState","useState","undefined","_useState2","_slicedToArray2","floatingAnchorElem","setFloatingAnchorElem","_useRichTextEditor","useRichTextEditor","setTheme","setThemeEmotionMap","setToolbarActionPlugins","useEffect","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","Fragment","key","name","element","initialConfig","editorState","isValidLexicalData","generateInitialLexicalValue","namespace","onError","error","concat","_toConsumableArray2","WebinyNodes","_objectSpread2","webinyEditorTheme","emotionMap","handleOnChange","editor","read","getEditorState","JSON","stringify","toJSON","LexicalComposer","length","ref","style","overflow","position","OnChangePlugin","LexicalUpdateStatePlugin","ClearEditorPlugin","HistoryPlugin","externalHistoryState","BlurEventPlugin","AutoFocusPlugin","RichTextPlugin","contentEditable","className","ContentEditable","outline","ErrorBoundary","LexicalErrorBoundary","RichTextEditor","makeComposable","props","LexicalEditorWithConfig","RichTextEditorProvider","ClassNames","_ref2","_props$themeEmotionMa","css","toTypographyEmotionMap","themeStylesTransformer","SharedHistoryContext","Object","assign","exports"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useEffect, useRef, useState } from \"react\";\nimport { ClassNames, CSSObject } from \"@emotion/react\";\nimport { Klass, LexicalEditor, LexicalNode } from \"lexical\";\nimport { EditorState } from \"lexical/LexicalEditorState\";\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 { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\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 { LexicalValue, ThemeEmotionMap, ToolbarActionPlugin } from \"~/types\";\nimport { Placeholder } from \"~/ui/Placeholder\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { webinyEditorTheme, WebinyTheme } from \"~/themes/webinyLexicalTheme\";\nimport { WebinyNodes } from \"~/nodes/webinyNodes\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\nimport { toTypographyEmotionMap } from \"~/utils/toTypographyEmotionMap\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig\";\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?: (json: LexicalValue) => void;\n placeholder?: string;\n placeholderStyles?: React.CSSProperties;\n staticToolbar?: React.ReactNode;\n styles?: React.CSSProperties;\n tag?: string;\n theme: WebinyTheme;\n themeEmotionMap?: ThemeEmotionMap;\n themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;\n toolbar?: React.ReactNode;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n value: LexicalValue | null;\n width?: number | string;\n}\n\nconst BaseRichTextEditor: React.FC<RichTextEditorProps> = ({\n toolbar,\n staticToolbar,\n onChange,\n value,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n height,\n theme,\n themeEmotionMap,\n toolbarActionPlugins,\n contentEditableStyles,\n placeholderStyles\n}: RichTextEditorProps) => {\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 const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n const { setTheme, setThemeEmotionMap, setToolbarActionPlugins } = useRichTextEditor();\n\n useEffect(() => {\n setTheme(theme);\n setThemeEmotionMap(themeEmotionMap);\n }, [themeEmotionMap, theme]);\n\n useEffect(() => {\n if (toolbarActionPlugins) {\n setToolbarActionPlugins(toolbarActionPlugins || []);\n }\n }, [toolbarActionPlugins]);\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 editorState: isValidLexicalData(value) ? value : generateInitialLexicalValue(),\n namespace: \"webiny\",\n onError: (error: Error) => {\n throw error;\n },\n nodes: [...WebinyNodes, ...configNodes, ...(nodes || [])],\n theme: { ...webinyEditorTheme, emotionMap: themeEmotionMap }\n };\n\n function handleOnChange(editorState: EditorState, editor: LexicalEditor) {\n editorState.read(() => {\n if (typeof onChange === \"function\") {\n const editorState = editor.getEditorState();\n onChange(JSON.stringify(editorState.toJSON()));\n }\n });\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 <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <>\n {staticToolbar && staticToolbar}\n <div\n ref={scrollRef}\n style={{ ...styles, ...sizeStyle, overflow: \"auto\", position: \"relative\" }}\n >\n {/* data */}\n <OnChangePlugin onChange={handleOnChange} />\n {value && <LexicalUpdateStatePlugin value={value} />}\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Events */}\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 </>\n </LexicalComposer>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeComposable<RichTextEditorProps>(\"RichTextEditor\", props => {\n return (\n <LexicalEditorWithConfig>\n <RichTextEditorProvider>\n <ClassNames>\n {({ css }) => {\n const themeEmotionMap =\n props?.themeEmotionMap ??\n toTypographyEmotionMap(css, props.theme, props.themeStylesTransformer);\n return (\n <SharedHistoryContext>\n <BaseRichTextEditor {...props} themeEmotionMap={themeEmotionMap} />\n </SharedHistoryContext>\n );\n }}\n </ClassNames>\n </RichTextEditorProvider>\n </LexicalEditorWithConfig>\n );\n});\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAGA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,uBAAA,GAAAJ,OAAA;AACA,IAAAK,yBAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,qBAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AACA,IAAAU,qBAAA,GAAAV,OAAA;AACA,IAAAW,uBAAA,GAAAX,OAAA;AACA,IAAAY,sBAAA,GAAAZ,OAAA;AACA,IAAAa,mBAAA,GAAAb,OAAA;AACA,IAAAc,yBAAA,GAAAd,OAAA;AACA,IAAAe,gBAAA,GAAAf,OAAA;AAEA,IAAAgB,YAAA,GAAAhB,OAAA;AACA,IAAAiB,4BAAA,GAAAjB,OAAA;AACA,IAAAkB,mBAAA,GAAAlB,OAAA;AACA,IAAAmB,YAAA,GAAAnB,OAAA;AACA,IAAAoB,qBAAA,GAAApB,OAAA;AACA,IAAAqB,mBAAA,GAAArB,OAAA;AACA,IAAAsB,uBAAA,GAAAtB,OAAA;AACA,IAAAuB,oBAAA,GAAAvB,OAAA;AA4BA,IAAMwB,kBAAiD,GAAG,SAApDA,kBAAiDA,CAAAC,IAAA,EAkB5B;EAAA,IAjBvBC,OAAO,GAAAD,IAAA,CAAPC,OAAO;IACPC,aAAa,GAAAF,IAAA,CAAbE,aAAa;IACbC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,KAAK,GA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,OACtB,CACP,CACW;EAAC;AAE1B,CAAC;;AAED;AACA;AACA;AACO,IAAM8F,cAAc,GAAG,IAAAC,gCAAc,EAAsB,gBAAgB,EAAE,UAAAC,KAAK,EAAI;EACzF,oBACI5H,MAAA,CAAAmD,OAAA,CAAAC,aAAA,CAAC3B,oBAAA,CAAAoG,uBAAuB,qBACpB7H,MAAA,CAAAmD,OAAA,CAAAC,aAAA,CAACtC,sBAAA,CAAAgH,sBAAsB,qBACnB9H,MAAA,CAAAmD,OAAA,CAAAC,aAAA,CAACjD,OAAA,CAAA4H,UAAU,QACN,UAAAC,KAAA,EAAa;IAAA,IAAAC,qBAAA;IAAA,IAAVC,GAAG,GAAAF,KAAA,CAAHE,GAAG;IACH,IAAMzF,eAAe,IAAAwF,qBAAA,GACjBL,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEnF,eAAe,cAAAwF,qBAAA,cAAAA,qBAAA,GACtB,IAAAE,8CAAsB,EAACD,GAAG,EAAEN,KAAK,CAACpF,KAAK,EAAEoF,KAAK,CAACQ,sBAAsB,CAAC;IAC1E,oBACIpI,MAAA,CAAAmD,OAAA,CAAAC,aAAA,CAAC9B,qBAAA,CAAA+G,oBAAoB,qBACjBrI,MAAA,CAAAmD,OAAA,CAAAC,aAAA,CAAC1B,kBAAkB,EAAA4G,MAAA,CAAAC,MAAA,KAAKX,KAAK;MAAEnF,eAAe,EAAEA;IAAgB,EAAE,CAChD,CAAC;EAE/B,CACQ,CACQ,CACH,CAAC;AAElC,CAAC,CAAC;AAAC+F,OAAA,CAAAd,cAAA,GAAAA,cAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_react2","_LexicalComposer","_LexicalOnChangePlugin","_LexicalAutoFocusPlugin","_LexicalClearEditorPlugin","_LexicalRichTextPlugin","_LexicalErrorBoundary","_interopRequireDefault","_reactComposition","_LexicalHistoryPlugin","_LexicalContentEditable","_RichTextEditorContext","_isValidLexicalData","_LexicalUpdateStatePlugin","_BlurEventPlugin","_Placeholder","_generateInitialLexicalValue","_lexicalTheme","_lexicalNodes","_SharedHistoryContext","_useRichTextEditor2","_LexicalEditorConfig","BaseRichTextEditor","_ref","toolbar","staticToolbar","onChange","value","nodes","placeholder","children","onBlur","focus","styles","width","height","theme","themeEmotionMap","toolbarActionPlugins","contentEditableStyles","placeholderStyles","editorTheme","useRef","createTheme","config","useLexicalEditorConfig","_useSharedHistoryCont","useSharedHistoryContext","historyState","placeholderElem","default","createElement","Placeholder","scrollRef","_useState","useState","undefined","_useState2","_slicedToArray2","floatingAnchorElem","setFloatingAnchorElem","_useRichTextEditor","useRichTextEditor","setTheme","setThemeEmotionMap","setToolbarActionPlugins","useEffect","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","Fragment","key","name","element","editorValue","isValidLexicalData","generateInitialLexicalValue","initialConfig","editorState","namespace","onError","concat","_toConsumableArray2","allNodes","_objectSpread2","current","emotionMap","handleOnChange","editor","read","getEditorState","JSON","stringify","toJSON","LexicalComposer","length","className","ref","style","overflow","position","OnChangePlugin","UpdateStatePlugin","ClearEditorPlugin","HistoryPlugin","externalHistoryState","BlurEventPlugin","AutoFocusPlugin","RichTextPlugin","contentEditable","ContentEditable","outline","ErrorBoundary","LexicalErrorBoundary","RichTextEditor","makeComposable","props","LexicalEditorWithConfig","RichTextEditorProvider","ClassNames","_ref2","_props$themeEmotionMa","css","toTypographyEmotionMap","themeStylesTransformer","SharedHistoryContext","Object","assign","exports"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useEffect, useRef, useState } from \"react\";\nimport { ClassNames, CSSObject } from \"@emotion/react\";\nimport { Klass, LexicalEditor, LexicalNode } from \"lexical\";\nimport { EditorState } from \"lexical/LexicalEditorState\";\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 { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { UpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin\";\nimport { LexicalValue, ToolbarActionPlugin } from \"~/types\";\nimport { Placeholder } from \"~/ui/Placeholder\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport {\n createTheme,\n WebinyTheme,\n ThemeEmotionMap,\n toTypographyEmotionMap\n} from \"@webiny/lexical-theme\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig\";\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?: (json: LexicalValue) => void;\n placeholder?: string;\n placeholderStyles?: React.CSSProperties;\n staticToolbar?: React.ReactNode;\n styles?: React.CSSProperties;\n tag?: string;\n theme: WebinyTheme;\n themeEmotionMap?: ThemeEmotionMap;\n themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;\n toolbar?: React.ReactNode;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n value: LexicalValue | null;\n width?: number | string;\n}\n\nconst BaseRichTextEditor: React.FC<RichTextEditorProps> = ({\n toolbar,\n staticToolbar,\n onChange,\n value,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n height,\n theme,\n themeEmotionMap,\n toolbarActionPlugins,\n contentEditableStyles,\n placeholderStyles\n}: RichTextEditorProps) => {\n const editorTheme = useRef(createTheme());\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 const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n const { setTheme, setThemeEmotionMap, setToolbarActionPlugins } = useRichTextEditor();\n\n useEffect(() => {\n setTheme(theme);\n setThemeEmotionMap(themeEmotionMap);\n }, [themeEmotionMap, theme]);\n\n useEffect(() => {\n if (toolbarActionPlugins) {\n setToolbarActionPlugins(toolbarActionPlugins || []);\n }\n }, [toolbarActionPlugins]);\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 editorValue = isValidLexicalData(value) ? value : generateInitialLexicalValue();\n\n const initialConfig = {\n // We update the state via the `<LexicalUpdateStatePlugin/>`.\n editorState: null,\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: { ...editorTheme.current, emotionMap: themeEmotionMap }\n };\n\n function handleOnChange(editorState: EditorState, editor: LexicalEditor) {\n editorState.read(() => {\n if (typeof onChange === \"function\") {\n const editorState = editor.getEditorState();\n onChange(JSON.stringify(editorState.toJSON()));\n }\n });\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 <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <>\n {staticToolbar && staticToolbar}\n <div\n /* This className is necessary for targeting of editor container from CSS files. */\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{ ...styles, ...sizeStyle, overflow: \"auto\", position: \"relative\" }}\n >\n {/* data */}\n <OnChangePlugin onChange={handleOnChange} />\n <UpdateStatePlugin value={editorValue} />\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Events */}\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 </>\n </LexicalComposer>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeComposable<RichTextEditorProps>(\"RichTextEditor\", props => {\n return (\n <LexicalEditorWithConfig>\n <RichTextEditorProvider>\n <ClassNames>\n {({ css }) => {\n const themeEmotionMap =\n props?.themeEmotionMap ??\n toTypographyEmotionMap(css, props.theme, props.themeStylesTransformer);\n return (\n <SharedHistoryContext>\n <BaseRichTextEditor {...props} themeEmotionMap={themeEmotionMap} />\n </SharedHistoryContext>\n );\n }}\n </ClassNames>\n </RichTextEditorProvider>\n </LexicalEditorWithConfig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EAAE,UAAAC,KAAK,EAAI;EACzF,oBACI7H,MAAA,CAAAqD,OAAA,CAAAC,aAAA,CAAC9B,oBAAA,CAAAsG,uBAAuB,qBACpB9H,MAAA,CAAAqD,OAAA,CAAAC,aAAA,CAACxC,sBAAA,CAAAiH,sBAAsB,qBACnB/H,MAAA,CAAAqD,OAAA,CAAAC,aAAA,CAACnD,OAAA,CAAA6H,UAAU,QACN,UAAAC,KAAA,EAAa;IAAA,IAAAC,qBAAA;IAAA,IAAVC,GAAG,GAAAF,KAAA,CAAHE,GAAG;IACH,IAAM3F,eAAe,IAAA0F,qBAAA,GACjBL,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAErF,eAAe,cAAA0F,qBAAA,cAAAA,qBAAA,GACtB,IAAAE,oCAAsB,EAACD,GAAG,EAAEN,KAAK,CAACtF,KAAK,EAAEsF,KAAK,CAACQ,sBAAsB,CAAC;IAC1E,oBACIrI,MAAA,CAAAqD,OAAA,CAAAC,aAAA,CAAChC,qBAAA,CAAAgH,oBAAoB,qBACjBtI,MAAA,CAAAqD,OAAA,CAAAC,aAAA,CAAC7B,kBAAkB,EAAA8G,MAAA,CAAAC,MAAA,KAAKX,KAAK;MAAErF,eAAe,EAAEA;IAAgB,EAAE,CAChD,CAAC;EAE/B,CACQ,CACQ,CACH,CAAC;AAElC,CAAC,CAAC;AAACiG,OAAA,CAAAd,cAAA,GAAAA,cAAA"}
@@ -70,4 +70,6 @@ function useLexicalEditorConfig() {
70
70
  plugins: config.plugins || [],
71
71
  nodes: config.nodes || []
72
72
  };
73
- }
73
+ }
74
+
75
+ //# sourceMappingURL=LexicalEditorConfig.js.map
@@ -35,4 +35,6 @@ var Node = function Node(_ref) {
35
35
  value: node
36
36
  }) : null);
37
37
  };
38
- exports.Node = Node;
38
+ exports.Node = Node;
39
+
40
+ //# sourceMappingURL=Node.js.map
@@ -35,4 +35,6 @@ var Plugin = function Plugin(_ref) {
35
35
  value: element
36
36
  }) : null);
37
37
  };
38
- exports.Plugin = Plugin;
38
+ exports.Plugin = Plugin;
39
+
40
+ //# sourceMappingURL=Plugin.js.map
@@ -35,4 +35,6 @@ var ToolbarElement = function ToolbarElement(_ref) {
35
35
  value: element
36
36
  }) : null);
37
37
  };
38
- exports.ToolbarElement = ToolbarElement;
38
+ exports.ToolbarElement = ToolbarElement;
39
+
40
+ //# sourceMappingURL=ToolbarElement.js.map
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
- import { LexicalValue, ThemeEmotionMap } from "../types";
3
2
  import { Klass, LexicalNode } from "lexical";
4
- import { WebinyTheme } from "../themes/webinyLexicalTheme";
5
3
  import { CSSObject } from "@emotion/react";
4
+ import { WebinyTheme, ThemeEmotionMap } from "@webiny/lexical-theme";
5
+ import { LexicalValue } from "../types";
6
6
  interface LexicalHtmlRendererProps {
7
7
  nodes?: Klass<LexicalNode>[];
8
8
  value: LexicalValue | null;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
3
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
@@ -7,46 +8,50 @@ Object.defineProperty(exports, "__esModule", {
7
8
  exports.LexicalHtmlRenderer = exports.BaseLexicalHtmlRenderer = void 0;
8
9
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
- var _react = _interopRequireDefault(require("react"));
11
- var _isValidLexicalData = require("../utils/isValidLexicalData");
12
- var _generateInitialLexicalValue = require("../utils/generateInitialLexicalValue");
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _react2 = require("@emotion/react");
13
13
  var _LexicalComposer = require("@lexical/react/LexicalComposer");
14
14
  var _LexicalRichTextPlugin = require("@lexical/react/LexicalRichTextPlugin");
15
15
  var _LexicalContentEditable = require("@lexical/react/LexicalContentEditable");
16
16
  var _LexicalErrorBoundary = _interopRequireDefault(require("@lexical/react/LexicalErrorBoundary"));
17
+ var _lexicalNodes = require("@webiny/lexical-nodes");
18
+ var _lexicalTheme = require("@webiny/lexical-theme");
19
+ var _isValidLexicalData = require("../utils/isValidLexicalData");
20
+ var _generateInitialLexicalValue = require("../utils/generateInitialLexicalValue");
17
21
  var _LexicalUpdateStatePlugin = require("../plugins/LexicalUpdateStatePlugin");
18
- var _webinyNodes = require("../nodes/webinyNodes");
19
- var _webinyLexicalTheme = require("../themes/webinyLexicalTheme");
20
- var _react2 = require("@emotion/react");
21
- var _toTypographyEmotionMap = require("../utils/toTypographyEmotionMap");
22
22
  var BaseLexicalHtmlRenderer = function BaseLexicalHtmlRenderer(_ref) {
23
23
  var nodes = _ref.nodes,
24
24
  value = _ref.value,
25
25
  theme = _ref.theme,
26
26
  themeEmotionMap = _ref.themeEmotionMap;
27
+ var editorTheme = (0, _react.useRef)((0, _lexicalTheme.createTheme)());
28
+ var editorValue = (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)();
27
29
  var initialConfig = {
28
- editorState: (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)(),
30
+ // We update the state via the `<LexicalUpdateStatePlugin/>`.
31
+ editorState: null,
29
32
  namespace: "webiny",
30
- onError: function onError(error) {
31
- throw error;
33
+ onError: function onError() {
34
+ // Ignore errors. We don't want to break the app because of errors caused by config/value updates.
35
+ // These are usually resolved in the next component render cycle.
32
36
  },
33
37
  editable: false,
34
- nodes: [].concat((0, _toConsumableArray2.default)(_webinyNodes.WebinyNodes), (0, _toConsumableArray2.default)(nodes || [])),
35
- theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _webinyLexicalTheme.webinyEditorTheme), {}, {
38
+ nodes: [].concat((0, _toConsumableArray2.default)(_lexicalNodes.allNodes), (0, _toConsumableArray2.default)(nodes || [])),
39
+ theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, editorTheme.current), {}, {
36
40
  emotionMap: themeEmotionMap,
37
41
  styles: theme.styles
38
42
  })
39
43
  };
40
44
  return /*#__PURE__*/_react.default.createElement(_LexicalComposer.LexicalComposer, {
41
- initialConfig: initialConfig
45
+ initialConfig: initialConfig,
46
+ key: initialConfig.nodes.length
42
47
  }, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
43
48
  contentEditable: /*#__PURE__*/_react.default.createElement("div", {
44
49
  className: "editor"
45
50
  }, /*#__PURE__*/_react.default.createElement(_LexicalContentEditable.ContentEditable, null)),
46
51
  ErrorBoundary: _LexicalErrorBoundary.default,
47
52
  placeholder: null
48
- }), /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.LexicalUpdateStatePlugin, {
49
- value: value
53
+ }), /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.UpdateStatePlugin, {
54
+ value: editorValue
50
55
  }));
51
56
  };
52
57
 
@@ -58,10 +63,12 @@ var LexicalHtmlRenderer = function LexicalHtmlRenderer(props) {
58
63
  return /*#__PURE__*/_react.default.createElement(_react2.ClassNames, null, function (_ref2) {
59
64
  var _props$themeEmotionMa;
60
65
  var css = _ref2.css;
61
- var themeEmotionMap = (_props$themeEmotionMa = props === null || props === void 0 ? void 0 : props.themeEmotionMap) !== null && _props$themeEmotionMa !== void 0 ? _props$themeEmotionMa : (0, _toTypographyEmotionMap.toTypographyEmotionMap)(css, props.theme, props.themeStylesTransformer);
66
+ var themeEmotionMap = (_props$themeEmotionMa = props === null || props === void 0 ? void 0 : props.themeEmotionMap) !== null && _props$themeEmotionMa !== void 0 ? _props$themeEmotionMa : (0, _lexicalTheme.toTypographyEmotionMap)(css, props.theme, props.themeStylesTransformer);
62
67
  return /*#__PURE__*/_react.default.createElement(BaseLexicalHtmlRenderer, Object.assign({}, props, {
63
68
  themeEmotionMap: themeEmotionMap
64
69
  }));
65
70
  });
66
71
  };
67
- exports.LexicalHtmlRenderer = LexicalHtmlRenderer;
72
+ exports.LexicalHtmlRenderer = LexicalHtmlRenderer;
73
+
74
+ //# sourceMappingURL=LexicalHtmlRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_isValidLexicalData","_generateInitialLexicalValue","_LexicalComposer","_LexicalRichTextPlugin","_LexicalContentEditable","_LexicalErrorBoundary","_LexicalUpdateStatePlugin","_webinyNodes","_webinyLexicalTheme","_react2","_toTypographyEmotionMap","BaseLexicalHtmlRenderer","_ref","nodes","value","theme","themeEmotionMap","initialConfig","editorState","isValidLexicalData","generateInitialLexicalValue","namespace","onError","error","editable","concat","_toConsumableArray2","default","WebinyNodes","_objectSpread2","webinyEditorTheme","emotionMap","styles","createElement","LexicalComposer","RichTextPlugin","contentEditable","className","ContentEditable","ErrorBoundary","LexicalErrorBoundary","placeholder","LexicalUpdateStatePlugin","exports","LexicalHtmlRenderer","props","ClassNames","_ref2","_props$themeEmotionMa","css","toTypographyEmotionMap","themeStylesTransformer","Object","assign"],"sources":["LexicalHtmlRenderer.tsx"],"sourcesContent":["import React from \"react\";\nimport { LexicalValue, ThemeEmotionMap } from \"~/types\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport LexicalErrorBoundary from \"@lexical/react/LexicalErrorBoundary\";\nimport { LexicalUpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { Klass, LexicalNode } from \"lexical\";\nimport { WebinyNodes } from \"~/nodes/webinyNodes\";\nimport { webinyEditorTheme, WebinyTheme } from \"~/themes/webinyLexicalTheme\";\nimport { ClassNames, CSSObject } from \"@emotion/react\";\nimport { toTypographyEmotionMap } from \"~/utils/toTypographyEmotionMap\";\n\ninterface LexicalHtmlRendererProps {\n nodes?: Klass<LexicalNode>[];\n value: LexicalValue | null;\n /*\n * @description Theme to be injected into lexical editor\n */\n theme: WebinyTheme;\n themeEmotionMap?: ThemeEmotionMap;\n themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;\n}\n\nexport const BaseLexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps> = ({\n nodes,\n value,\n theme,\n themeEmotionMap\n}) => {\n const initialConfig = {\n editorState: isValidLexicalData(value) ? value : generateInitialLexicalValue(),\n namespace: \"webiny\",\n onError: (error: Error) => {\n throw error;\n },\n editable: false,\n nodes: [...WebinyNodes, ...(nodes || [])],\n theme: { ...webinyEditorTheme, emotionMap: themeEmotionMap, styles: theme.styles }\n };\n\n return (\n <LexicalComposer initialConfig={initialConfig}>\n <RichTextPlugin\n contentEditable={\n <div className=\"editor\">\n <ContentEditable />\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={null}\n />\n <LexicalUpdateStatePlugin value={value} />\n </LexicalComposer>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const LexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps> = props => {\n return (\n <ClassNames>\n {({ css }) => {\n const themeEmotionMap =\n props?.themeEmotionMap ??\n toTypographyEmotionMap(css, props.theme, props.themeStylesTransformer);\n return <BaseLexicalHtmlRenderer {...props} themeEmotionMap={themeEmotionMap} />;\n }}\n </ClassNames>\n );\n};\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,4BAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,yBAAA,GAAAP,OAAA;AAEA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,CACR;IACDC,aAAa,EAAEC,6BAAqB;IACpCC,WAAW,EAAE;EAAK,CACrB,CAAC,eACF5C,MAAA,CAAA8B,OAAA,CAAAM,aAAA,CAAC3B,yBAAA,CAAAoC,wBAAwB;IAAC5B,KAAK,EAAEA;EAAM,CAAE,CAC5B,CAAC;AAE1B,CAAC;;AAED;AACA;AACA;AAFA6B,OAAA,CAAAhC,uBAAA,GAAAA,uBAAA;AAGO,IAAMiC,mBAAuD,GAAG,SAA1DA,mBAAuDA,CAAGC,KAAK,EAAI;EAC5E,oBACIhD,MAAA,CAAA8B,OAAA,CAAAM,aAAA,CAACxB,OAAA,CAAAqC,UAAU,QACN,UAAAC,KAAA,EAAa;IAAA,IAAAC,qBAAA;IAAA,IAAVC,GAAG,GAAAF,KAAA,CAAHE,GAAG;IACH,IAAMjC,eAAe,IAAAgC,qBAAA,GACjBH,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAE7B,eAAe,cAAAgC,qBAAA,cAAAA,qBAAA,GACtB,IAAAE,8CAAsB,EAACD,GAAG,EAAEJ,KAAK,CAAC9B,KAAK,EAAE8B,KAAK,CAACM,sBAAsB,CAAC;IAC1E,oBAAOtD,MAAA,CAAA8B,OAAA,CAAAM,aAAA,CAACtB,uBAAuB,EAAAyC,MAAA,CAAAC,MAAA,KAAKR,KAAK;MAAE7B,eAAe,EAAEA;IAAgB,EAAE,CAAC;EACnF,CACQ,CAAC;AAErB,CAAC;AAAC2B,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_react2","_LexicalComposer","_LexicalRichTextPlugin","_LexicalContentEditable","_LexicalErrorBoundary","_interopRequireDefault","_lexicalNodes","_lexicalTheme","_isValidLexicalData","_generateInitialLexicalValue","_LexicalUpdateStatePlugin","BaseLexicalHtmlRenderer","_ref","nodes","value","theme","themeEmotionMap","editorTheme","useRef","createTheme","editorValue","isValidLexicalData","generateInitialLexicalValue","initialConfig","editorState","namespace","onError","editable","concat","_toConsumableArray2","default","allNodes","_objectSpread2","current","emotionMap","styles","createElement","LexicalComposer","key","length","RichTextPlugin","contentEditable","className","ContentEditable","ErrorBoundary","LexicalErrorBoundary","placeholder","UpdateStatePlugin","exports","LexicalHtmlRenderer","props","ClassNames","_ref2","_props$themeEmotionMa","css","toTypographyEmotionMap","themeStylesTransformer","Object","assign"],"sources":["LexicalHtmlRenderer.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport { Klass, LexicalNode } from \"lexical\";\nimport { ClassNames, CSSObject } from \"@emotion/react\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport LexicalErrorBoundary from \"@lexical/react/LexicalErrorBoundary\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport {\n createTheme,\n WebinyTheme,\n ThemeEmotionMap,\n toTypographyEmotionMap\n} from \"@webiny/lexical-theme\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { LexicalValue } from \"~/types\";\nimport { UpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\n\ninterface LexicalHtmlRendererProps {\n nodes?: Klass<LexicalNode>[];\n value: LexicalValue | null;\n theme: WebinyTheme;\n themeEmotionMap?: ThemeEmotionMap;\n themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;\n}\n\nexport const BaseLexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps> = ({\n nodes,\n value,\n theme,\n themeEmotionMap\n}) => {\n const editorTheme = useRef(createTheme());\n const editorValue = isValidLexicalData(value) ? value : generateInitialLexicalValue();\n\n const initialConfig = {\n // We update the state via the `<LexicalUpdateStatePlugin/>`.\n editorState: null,\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 editable: false,\n nodes: [...allNodes, ...(nodes || [])],\n theme: { ...editorTheme.current, emotionMap: themeEmotionMap, styles: theme.styles }\n };\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextPlugin\n contentEditable={\n <div className=\"editor\">\n <ContentEditable />\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={null}\n />\n <UpdateStatePlugin value={editorValue} />\n </LexicalComposer>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const LexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps> = props => {\n return (\n <ClassNames>\n {({ css }) => {\n const themeEmotionMap =\n props?.themeEmotionMap ??\n toTypographyEmotionMap(css, props.theme, props.themeStylesTransformer);\n return <BaseLexicalHtmlRenderer {...props} themeEmotionMap={themeEmotionMap} />;\n }}\n </ClassNames>\n );\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,uBAAA,GAAAJ,OAAA;AACA,IAAAK,qBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AAMA,IAAAS,mBAAA,GAAAT,OAAA;AACA,IAAAU,4BAAA,GAAAV,OAAA;AAEA,IAAAW,yBAAA,GAAAX,OAAA;AAUO,IAAMY,uBAA2D,GAAG,SAA9DA,uBAA2DA,CAAAC,IAAA,EAKlE;EAAA,IAJFC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,eAAe,GAAAJ,IAAA,CAAfI,eAAe;EAEf,IAAMC,WAAW,GAAG,IAAAC,aAAM,EAAC,IAAAC,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AAA,GAAAA,uBAAA;AAGO,IAAMsC,mBAAuD,GAAG,SAA1DA,mBAAuDA,CAAGC,KAAK,EAAI;EAC5E,oBACIrD,MAAA,CAAAiC,OAAA,CAAAM,aAAA,CAACpC,OAAA,CAAAmD,UAAU,QACN,UAAAC,KAAA,EAAa;IAAA,IAAAC,qBAAA;IAAA,IAAVC,GAAG,GAAAF,KAAA,CAAHE,GAAG;IACH,IAAMtC,eAAe,IAAAqC,qBAAA,GACjBH,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAElC,eAAe,cAAAqC,qBAAA,cAAAA,qBAAA,GACtB,IAAAE,oCAAsB,EAACD,GAAG,EAAEJ,KAAK,CAACnC,KAAK,EAAEmC,KAAK,CAACM,sBAAsB,CAAC;IAC1E,oBAAO3D,MAAA,CAAAiC,OAAA,CAAAM,aAAA,CAACzB,uBAAuB,EAAA8C,MAAA,CAAAC,MAAA,KAAKR,KAAK;MAAElC,eAAe,EAAEA;IAAgB,EAAE,CAAC;EACnF,CACQ,CAAC;AAErB,CAAC;AAACgC,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}
@@ -1,3 +1,3 @@
1
- import React from "react";
1
+ /// <reference types="react" />
2
2
  import "./StaticToolbar.css";
3
- export declare const StaticToolbar: () => React.ReactElement<any, any> | null;
3
+ export declare const StaticToolbar: () => JSX.Element;
@@ -8,80 +8,15 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.StaticToolbar = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
- var _lexical = require("lexical");
12
- var _useRichTextEditor2 = require("../../hooks/useRichTextEditor");
13
- var _utils = require("@lexical/utils");
14
11
  var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
15
12
  require("./StaticToolbar.css");
16
- var _getLexicalTextSelectionState = require("../../utils/getLexicalTextSelectionState");
17
13
  var _LexicalEditorConfig = require("../LexicalEditorConfig/LexicalEditorConfig");
18
- var useStaticToolbar = function useStaticToolbar(_ref) {
19
- var editor = _ref.editor;
20
- var _useRichTextEditor = (0, _useRichTextEditor2.useRichTextEditor)(),
21
- setNodeIsText = _useRichTextEditor.setNodeIsText,
22
- setTextBlockSelection = _useRichTextEditor.setTextBlockSelection,
23
- setActiveEditor = _useRichTextEditor.setActiveEditor;
24
- var _useState = (0, _react.useState)(editor),
25
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
26
- toolbarActiveEditor = _useState2[0],
27
- setToolbarActiveEditor = _useState2[1];
14
+ var StaticToolbar = function StaticToolbar() {
15
+ var _useLexicalComposerCo = (0, _LexicalComposerContext.useLexicalComposerContext)(),
16
+ _useLexicalComposerCo2 = (0, _slicedToArray2.default)(_useLexicalComposerCo, 1),
17
+ editor = _useLexicalComposerCo2[0];
28
18
  var _useLexicalEditorConf = (0, _LexicalEditorConfig.useLexicalEditorConfig)(),
29
19
  toolbarElements = _useLexicalEditorConf.toolbarElements;
30
- var updateToolbar = (0, _react.useCallback)(function () {
31
- editor.getEditorState().read(function () {
32
- // Should not to pop up the floating toolbar when using IME input
33
- if (editor.isComposing()) {
34
- return;
35
- }
36
- var selection = (0, _lexical.$getSelection)();
37
- if ((0, _lexical.$isRangeSelection)(selection)) {
38
- var selectionState = (0, _getLexicalTextSelectionState.getLexicalTextSelectionState)(toolbarActiveEditor, selection);
39
- if (selectionState) {
40
- var _selectionState$state;
41
- setTextBlockSelection(selectionState);
42
- if (selectionState.selectedText !== "" && !((_selectionState$state = selectionState.state) !== null && _selectionState$state !== void 0 && _selectionState$state.link.isSelected)) {
43
- setNodeIsText(true);
44
- } else {
45
- setNodeIsText(false);
46
- }
47
- }
48
- }
49
- if (!(0, _lexical.$isRangeSelection)(selection)) {
50
- setNodeIsText(false);
51
- return;
52
- }
53
- });
54
- }, [toolbarActiveEditor]);
55
- (0, _react.useEffect)(function () {
56
- document.addEventListener("selectionchange", updateToolbar);
57
- return function () {
58
- document.removeEventListener("selectionchange", updateToolbar);
59
- };
60
- }, [updateToolbar]);
61
- (0, _react.useEffect)(function () {
62
- return editor.registerCommand(_lexical.SELECTION_CHANGE_COMMAND, function (_payload, newEditor) {
63
- updateToolbar();
64
- setToolbarActiveEditor(newEditor);
65
- setActiveEditor(newEditor);
66
- return false;
67
- }, _lexical.COMMAND_PRIORITY_CRITICAL);
68
- }, [editor, updateToolbar]);
69
- (0, _react.useEffect)(function () {
70
- return (0, _utils.mergeRegister)(toolbarActiveEditor.registerUpdateListener(function (_ref2) {
71
- var editorState = _ref2.editorState;
72
- editorState.read(function () {
73
- updateToolbar();
74
- });
75
- }), editor.registerRootListener(function () {
76
- if (editor.getRootElement() === null) {
77
- setNodeIsText(false);
78
- }
79
- }), editor.registerRootListener(function () {
80
- if (editor.getRootElement() === null) {
81
- setNodeIsText(false);
82
- }
83
- }));
84
- }, [updateToolbar, editor, toolbarActiveEditor]);
85
20
  return /*#__PURE__*/_react.default.createElement("div", {
86
21
  className: "static-toolbar"
87
22
  }, editor.isEditable() && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toolbarElements.map(function (action) {
@@ -90,12 +25,6 @@ var useStaticToolbar = function useStaticToolbar(_ref) {
90
25
  }, action.element);
91
26
  })));
92
27
  };
93
- var StaticToolbar = function StaticToolbar() {
94
- var _useLexicalComposerCo = (0, _LexicalComposerContext.useLexicalComposerContext)(),
95
- _useLexicalComposerCo2 = (0, _slicedToArray2.default)(_useLexicalComposerCo, 1),
96
- editor = _useLexicalComposerCo2[0];
97
- return useStaticToolbar({
98
- editor: editor
99
- });
100
- };
101
- exports.StaticToolbar = StaticToolbar;
28
+ exports.StaticToolbar = StaticToolbar;
29
+
30
+ //# sourceMappingURL=StaticToolbar.js.map