@webiny/lexical-editor 6.3.0 → 6.4.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 (252) hide show
  1. package/commands/image.js +2 -1
  2. package/commands/image.js.map +1 -1
  3. package/commands/index.js +0 -2
  4. package/commands/list.js +4 -3
  5. package/commands/list.js.map +1 -1
  6. package/commands/quote.js +2 -1
  7. package/commands/quote.js.map +1 -1
  8. package/commands/toolbar.js +2 -1
  9. package/commands/toolbar.js.map +1 -1
  10. package/commands/typography.js +2 -1
  11. package/commands/typography.js.map +1 -1
  12. package/components/Editor/EnsureHeadingTagPlugin.js +8 -15
  13. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
  14. package/components/Editor/RichTextEditor.js +82 -121
  15. package/components/Editor/RichTextEditor.js.map +1 -1
  16. package/components/Editor/normalizeInputValue.js +11 -13
  17. package/components/Editor/normalizeInputValue.js.map +1 -1
  18. package/components/LexicalEditorConfig/LexicalEditorConfig.js +24 -15
  19. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
  20. package/components/LexicalEditorConfig/components/Node.js +21 -26
  21. package/components/LexicalEditorConfig/components/Node.js.map +1 -1
  22. package/components/LexicalEditorConfig/components/Plugin.js +21 -26
  23. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
  24. package/components/LexicalEditorConfig/components/ToolbarElement.js +21 -26
  25. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
  26. package/components/LexicalHtmlRenderer.js +35 -40
  27. package/components/LexicalHtmlRenderer.js.map +1 -1
  28. package/components/Toolbar/StaticToolbar.js +11 -16
  29. package/components/Toolbar/StaticToolbar.js.map +1 -1
  30. package/components/ToolbarActions/BoldAction.js +16 -19
  31. package/components/ToolbarActions/BoldAction.js.map +1 -1
  32. package/components/ToolbarActions/BulletListAction.js +24 -32
  33. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  34. package/components/ToolbarActions/CodeHighlightAction.js +16 -19
  35. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
  36. package/components/ToolbarActions/FontColorAction.js +32 -38
  37. package/components/ToolbarActions/FontColorAction.js.map +1 -1
  38. package/components/ToolbarActions/ImageAction.js +28 -30
  39. package/components/ToolbarActions/ImageAction.js.map +1 -1
  40. package/components/ToolbarActions/ItalicAction.js +16 -19
  41. package/components/ToolbarActions/ItalicAction.js.map +1 -1
  42. package/components/ToolbarActions/LinkAction.js +25 -30
  43. package/components/ToolbarActions/LinkAction.js.map +1 -1
  44. package/components/ToolbarActions/NumberedListAction.js +28 -37
  45. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  46. package/components/ToolbarActions/QuoteAction.js +22 -27
  47. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  48. package/components/ToolbarActions/TextAlignmentAction.js +38 -50
  49. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
  50. package/components/ToolbarActions/TypographyAction.js +69 -99
  51. package/components/ToolbarActions/TypographyAction.js.map +1 -1
  52. package/components/ToolbarActions/UnderlineAction.js +16 -19
  53. package/components/ToolbarActions/UnderlineAction.js.map +1 -1
  54. package/context/FontColorActionContext.js +3 -2
  55. package/context/FontColorActionContext.js.map +1 -1
  56. package/context/RichTextEditorContext.js +26 -29
  57. package/context/RichTextEditorContext.js.map +1 -1
  58. package/context/SharedHistoryContext.js +11 -15
  59. package/context/SharedHistoryContext.js.map +1 -1
  60. package/context/TextAlignmentActionContextProps.js +3 -2
  61. package/context/TextAlignmentActionContextProps.js.map +1 -1
  62. package/context/TypographyActionContext.js +3 -2
  63. package/context/TypographyActionContext.js.map +1 -1
  64. package/exports/admin/lexical.js +2 -20
  65. package/hooks/index.js +0 -2
  66. package/hooks/useCurrentElement.js +18 -21
  67. package/hooks/useCurrentElement.js.map +1 -1
  68. package/hooks/useCurrentSelection.js +39 -48
  69. package/hooks/useCurrentSelection.js.map +1 -1
  70. package/hooks/useFontColorPicker.js +5 -6
  71. package/hooks/useFontColorPicker.js.map +1 -1
  72. package/hooks/useIsMounted.js +7 -8
  73. package/hooks/useIsMounted.js.map +1 -1
  74. package/hooks/useRichTextEditor.js +5 -6
  75. package/hooks/useRichTextEditor.js.map +1 -1
  76. package/hooks/useTextAlignmentAction.js +5 -6
  77. package/hooks/useTextAlignmentAction.js.map +1 -1
  78. package/hooks/useTypographyAction.js +5 -6
  79. package/hooks/useTypographyAction.js.map +1 -1
  80. package/images/icons/chat-square-quote.js +19 -0
  81. package/images/icons/chat-square-quote.js.map +1 -0
  82. package/images/icons/chevron-down.js +18 -0
  83. package/images/icons/chevron-down.js.map +1 -0
  84. package/images/icons/code.js +17 -0
  85. package/images/icons/code.js.map +1 -0
  86. package/images/icons/font-color.js +17 -0
  87. package/images/icons/font-color.js.map +1 -0
  88. package/images/icons/indent.js +18 -0
  89. package/images/icons/indent.js.map +1 -0
  90. package/images/icons/insert-image.js +20 -0
  91. package/images/icons/insert-image.js.map +1 -0
  92. package/images/icons/justify.js +19 -0
  93. package/images/icons/justify.js.map +1 -0
  94. package/images/icons/link.js +19 -0
  95. package/images/icons/link.js.map +1 -0
  96. package/images/icons/list-ol.js +20 -0
  97. package/images/icons/list-ol.js.map +1 -0
  98. package/images/icons/list-ul.js +18 -0
  99. package/images/icons/list-ul.js.map +1 -0
  100. package/images/icons/outdent.js +18 -0
  101. package/images/icons/outdent.js.map +1 -0
  102. package/images/icons/pencil-fill.js +17 -0
  103. package/images/icons/pencil-fill.js.map +1 -0
  104. package/images/icons/text-center.js +18 -0
  105. package/images/icons/text-center.js.map +1 -0
  106. package/images/icons/text-left.js +18 -0
  107. package/images/icons/text-left.js.map +1 -0
  108. package/images/icons/text-paragraph.js +18 -0
  109. package/images/icons/text-paragraph.js.map +1 -0
  110. package/images/icons/text-right.js +18 -0
  111. package/images/icons/text-right.js.map +1 -0
  112. package/images/icons/type-bold.js +17 -0
  113. package/images/icons/type-bold.js.map +1 -0
  114. package/images/icons/type-h1.js +17 -0
  115. package/images/icons/type-h1.js.map +1 -0
  116. package/images/icons/type-h2.js +17 -0
  117. package/images/icons/type-h2.js.map +1 -0
  118. package/images/icons/type-h3.js +17 -0
  119. package/images/icons/type-h3.js.map +1 -0
  120. package/images/icons/type-h4.js +17 -0
  121. package/images/icons/type-h4.js.map +1 -0
  122. package/images/icons/type-h5.js +17 -0
  123. package/images/icons/type-h5.js.map +1 -0
  124. package/images/icons/type-h6.js +17 -0
  125. package/images/icons/type-h6.js.map +1 -0
  126. package/images/icons/type-italic.js +17 -0
  127. package/images/icons/type-italic.js.map +1 -0
  128. package/images/icons/type-strikethrough.js +17 -0
  129. package/images/icons/type-strikethrough.js.map +1 -0
  130. package/images/icons/type-underline.js +17 -0
  131. package/images/icons/type-underline.js.map +1 -0
  132. package/images/icons/unlink_icon.js +27 -0
  133. package/images/icons/unlink_icon.js.map +1 -0
  134. package/index.js +5 -18
  135. package/package.json +7 -7
  136. package/plugins/BlurEventPlugin/BlurEventPlugin.js +11 -14
  137. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
  138. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +7 -8
  139. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
  140. package/plugins/CodeHighlightPlugin/index.js +0 -2
  141. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +16 -24
  142. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -1
  143. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +37 -51
  144. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -1
  145. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +6 -5
  146. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  147. package/plugins/FloatingLinkEditorPlugin/index.js +0 -2
  148. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +6 -9
  149. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
  150. package/plugins/FloatingLinkEditorPlugin/types.js +0 -3
  151. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +101 -108
  152. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -1
  153. package/plugins/FontColorPlugin/FontColorPlugin.js +14 -19
  154. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
  155. package/plugins/FontColorPlugin/applyColorToNode.js +5 -4
  156. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
  157. package/plugins/FontColorPlugin/applyColorToSelection.js +42 -60
  158. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
  159. package/plugins/ImagesPlugin/ImagesPlugin.js +79 -121
  160. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
  161. package/plugins/LinkPlugin/LinkPlugin.js +46 -52
  162. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
  163. package/plugins/ListPLugin/ListPlugin.js +44 -52
  164. package/plugins/ListPLugin/ListPlugin.js.map +1 -1
  165. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -19
  166. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
  167. package/plugins/StateHandlingPlugin.js +55 -64
  168. package/plugins/StateHandlingPlugin.js.map +1 -1
  169. package/plugins/TypographyPlugin/TypographyPlugin.js +13 -20
  170. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
  171. package/static/svg/chat-square-quote.123cfa24.svg +1 -0
  172. package/static/svg/chevron-down.d9636921.svg +1 -0
  173. package/static/svg/code.912b1f4d.svg +1 -0
  174. package/static/svg/font-color.4f0c0de5.svg +1 -0
  175. package/static/svg/indent.4d78e483.svg +3 -0
  176. package/static/svg/insert-image.354465f1.svg +4 -0
  177. package/static/svg/justify.dab42aec.svg +3 -0
  178. package/static/svg/link.b774de25.svg +1 -0
  179. package/static/svg/list-ol.d64946f3.svg +1 -0
  180. package/static/svg/list-ul.1d54da3f.svg +1 -0
  181. package/static/svg/outdent.5c13ff16.svg +3 -0
  182. package/static/svg/pencil-fill.94cb216b.svg +1 -0
  183. package/static/svg/text-center.a411e780.svg +1 -0
  184. package/static/svg/text-left.54f41f4e.svg +1 -0
  185. package/static/svg/text-paragraph.61674422.svg +1 -0
  186. package/static/svg/text-right.9288b7a2.svg +1 -0
  187. package/static/svg/type-bold.7e3e270b.svg +1 -0
  188. package/static/svg/type-h1.f292ffe1.svg +1 -0
  189. package/static/svg/type-h2.a9d1aa48.svg +1 -0
  190. package/static/svg/type-h3.4a29ff88.svg +1 -0
  191. package/static/svg/type-h4.7f48750c.svg +1 -0
  192. package/static/svg/type-h5.14b4ac56.svg +1 -0
  193. package/static/svg/type-h6.4e9dfe2d.svg +1 -0
  194. package/static/svg/type-italic.d8e45748.svg +1 -0
  195. package/static/svg/type-strikethrough.2694a816.svg +1 -0
  196. package/static/svg/type-underline.104a0ed5.svg +1 -0
  197. package/static/svg/unlink_icon.074ceed3.svg +1 -0
  198. package/types.js +0 -8
  199. package/ui/ContentEditable.js +6 -14
  200. package/ui/ContentEditable.js.map +1 -1
  201. package/ui/Divider.js +6 -5
  202. package/ui/Divider.js.map +1 -1
  203. package/ui/DropDown.js +146 -176
  204. package/ui/DropDown.js.map +1 -1
  205. package/ui/ImageResizer.js +173 -204
  206. package/ui/ImageResizer.js.map +1 -1
  207. package/ui/LinkPreview.js +61 -84
  208. package/ui/LinkPreview.js.map +1 -1
  209. package/ui/Placeholder.js +9 -20
  210. package/ui/Placeholder.js.map +1 -1
  211. package/ui/TextInput.js +17 -30
  212. package/ui/TextInput.js.map +1 -1
  213. package/ui/ToolbarActionDialog.js +64 -73
  214. package/ui/ToolbarActionDialog.js.map +1 -1
  215. package/utils/canUseDOM.js +2 -1
  216. package/utils/canUseDOM.js.map +1 -1
  217. package/utils/files.js +9 -8
  218. package/utils/files.js.map +1 -1
  219. package/utils/getDOMRangeRect.js +10 -20
  220. package/utils/getDOMRangeRect.js.map +1 -1
  221. package/utils/getSelectedNode.js +9 -20
  222. package/utils/getSelectedNode.js.map +1 -1
  223. package/utils/getTransparentImage.js +2 -3
  224. package/utils/getTransparentImage.js.map +1 -1
  225. package/utils/insertImage.js +9 -11
  226. package/utils/insertImage.js.map +1 -1
  227. package/utils/isAnchorLink.js +2 -3
  228. package/utils/isAnchorLink.js.map +1 -1
  229. package/utils/isChildOfFloatingToolbar.js +6 -9
  230. package/utils/isChildOfFloatingToolbar.js.map +1 -1
  231. package/utils/isHTMLElement.js +3 -9
  232. package/utils/isHTMLElement.js.map +1 -1
  233. package/utils/isValidJSON.js +9 -10
  234. package/utils/isValidJSON.js.map +1 -1
  235. package/utils/isValidLexicalData.js +17 -20
  236. package/utils/isValidLexicalData.js.map +1 -1
  237. package/utils/point.js +32 -45
  238. package/utils/point.js.map +1 -1
  239. package/utils/rect.js +92 -125
  240. package/utils/rect.js.map +1 -1
  241. package/utils/sanitizeUrl.js +8 -21
  242. package/utils/sanitizeUrl.js.map +1 -1
  243. package/utils/setFloatingElemPosition.js +23 -27
  244. package/utils/setFloatingElemPosition.js.map +1 -1
  245. package/commands/index.js.map +0 -1
  246. package/exports/admin/lexical.js.map +0 -1
  247. package/hooks/index.js.map +0 -1
  248. package/index.js.map +0 -1
  249. package/plugins/CodeHighlightPlugin/index.js.map +0 -1
  250. package/plugins/FloatingLinkEditorPlugin/index.js.map +0 -1
  251. package/plugins/FloatingLinkEditorPlugin/types.js.map +0 -1
  252. package/types.js.map +0 -1
package/commands/image.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createCommand } from "lexical";
2
- export const INSERT_IMAGE_COMMAND = createCommand("INSERT_IMAGE_COMMAND");
2
+ const INSERT_IMAGE_COMMAND = createCommand("INSERT_IMAGE_COMMAND");
3
+ export { INSERT_IMAGE_COMMAND };
3
4
 
4
5
  //# sourceMappingURL=image.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createCommand","INSERT_IMAGE_COMMAND"],"sources":["image.ts"],"sourcesContent":["import type { LexicalCommand, NodeKey } from \"lexical\";\nimport { createCommand } from \"lexical\";\nimport type { ImageNodeProps } from \"@webiny/lexical-nodes\";\n\nexport interface ImagePayload extends ImageNodeProps {\n key?: NodeKey;\n}\n\nexport const INSERT_IMAGE_COMMAND: LexicalCommand<ImagePayload> =\n createCommand(\"INSERT_IMAGE_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAOvC,OAAO,MAAMC,oBAAkD,GAC3DD,aAAa,CAAC,sBAAsB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"commands/image.js","sources":["../../src/commands/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"],"names":["INSERT_IMAGE_COMMAND","createCommand"],"mappings":";AAQO,MAAMA,uBACTC,cAAc"}
package/commands/index.js CHANGED
@@ -3,5 +3,3 @@ export * from "./image.js";
3
3
  export * from "./list.js";
4
4
  export * from "./quote.js";
5
5
  export * from "./toolbar.js";
6
-
7
- //# sourceMappingURL=index.js.map
package/commands/list.js CHANGED
@@ -1,6 +1,7 @@
1
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");
2
+ const INSERT_UNORDERED_LIST_COMMAND = createCommand("INSERT_UNORDERED_LIST_COMMAND");
3
+ const INSERT_ORDERED_LIST_COMMAND = createCommand("INSERT_ORDERED_LIST_COMMAND");
4
+ const REMOVE_LIST_COMMAND = createCommand("REMOVE_LIST_COMMAND");
5
+ export { INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND };
5
6
 
6
7
  //# sourceMappingURL=list.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createCommand","INSERT_UNORDERED_LIST_COMMAND","INSERT_ORDERED_LIST_COMMAND","REMOVE_LIST_COMMAND"],"sources":["list.ts"],"sourcesContent":["import type { LexicalCommand } from \"lexical\";\nimport { createCommand } from \"lexical\";\n\nexport type ListCommandPayload = {\n themeStyleId?: string;\n};\n\nexport const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload> = createCommand(\n \"INSERT_UNORDERED_LIST_COMMAND\"\n);\n\nexport const INSERT_ORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload> = createCommand(\n \"INSERT_ORDERED_LIST_COMMAND\"\n);\n\nexport const REMOVE_LIST_COMMAND: LexicalCommand<void> = createCommand(\"REMOVE_LIST_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAMvC,OAAO,MAAMC,6BAAiE,GAAGD,aAAa,CAC1F,+BACJ,CAAC;AAED,OAAO,MAAME,2BAA+D,GAAGF,aAAa,CACxF,6BACJ,CAAC;AAED,OAAO,MAAMG,mBAAyC,GAAGH,aAAa,CAAC,qBAAqB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"commands/list.js","sources":["../../src/commands/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"],"names":["INSERT_UNORDERED_LIST_COMMAND","createCommand","INSERT_ORDERED_LIST_COMMAND","REMOVE_LIST_COMMAND"],"mappings":";AAOO,MAAMA,gCAAoEC,cAC7E;AAGG,MAAMC,8BAAkED,cAC3E;AAGG,MAAME,sBAA4CF,cAAc"}
package/commands/quote.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createCommand } from "lexical";
2
- export const INSERT_QUOTE_COMMAND = createCommand("INSERT_QUOTE_COMMAND");
2
+ const INSERT_QUOTE_COMMAND = createCommand("INSERT_QUOTE_COMMAND");
3
+ export { INSERT_QUOTE_COMMAND };
3
4
 
4
5
  //# sourceMappingURL=quote.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createCommand","INSERT_QUOTE_COMMAND"],"sources":["quote.ts"],"sourcesContent":["import type { LexicalCommand } from \"lexical\";\nimport { createCommand } from \"lexical\";\n\nexport type QuoteCommandPayload = {\n themeStyleId: string;\n};\n\nexport const INSERT_QUOTE_COMMAND: LexicalCommand<QuoteCommandPayload> =\n createCommand(\"INSERT_QUOTE_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAMvC,OAAO,MAAMC,oBAAyD,GAClED,aAAa,CAAC,sBAAsB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"commands/quote.js","sources":["../../src/commands/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"],"names":["INSERT_QUOTE_COMMAND","createCommand"],"mappings":";AAOO,MAAMA,uBACTC,cAAc"}
@@ -1,4 +1,5 @@
1
1
  import { createCommand } from "lexical";
2
- export const HIDE_FLOATING_TOOLBAR = createCommand("HIDE_FLOATING_TOOLBAR_COMMAND");
2
+ const HIDE_FLOATING_TOOLBAR = createCommand("HIDE_FLOATING_TOOLBAR_COMMAND");
3
+ export { HIDE_FLOATING_TOOLBAR };
3
4
 
4
5
  //# sourceMappingURL=toolbar.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createCommand","HIDE_FLOATING_TOOLBAR"],"sources":["toolbar.ts"],"sourcesContent":["import { createCommand } from \"lexical\";\n\nexport const HIDE_FLOATING_TOOLBAR = createCommand(\"HIDE_FLOATING_TOOLBAR_COMMAND\");\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,SAAS;AAEvC,OAAO,MAAMC,qBAAqB,GAAGD,aAAa,CAAC,+BAA+B,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"commands/toolbar.js","sources":["../../src/commands/toolbar.ts"],"sourcesContent":["import { createCommand } from \"lexical\";\n\nexport const HIDE_FLOATING_TOOLBAR = createCommand(\"HIDE_FLOATING_TOOLBAR_COMMAND\");\n"],"names":["HIDE_FLOATING_TOOLBAR","createCommand"],"mappings":";AAEO,MAAMA,wBAAwBC,cAAc"}
@@ -1,4 +1,5 @@
1
1
  import { createCommand } from "lexical";
2
- export const ADD_TYPOGRAPHY_COMMAND = createCommand("ADD_TYPOGRAPHY_COMMAND");
2
+ const ADD_TYPOGRAPHY_COMMAND = createCommand("ADD_TYPOGRAPHY_COMMAND");
3
+ export { ADD_TYPOGRAPHY_COMMAND };
3
4
 
4
5
  //# sourceMappingURL=typography.js.map
@@ -1 +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
+ {"version":3,"file":"commands/typography.js","sources":["../../src/commands/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"],"names":["ADD_TYPOGRAPHY_COMMAND","createCommand"],"mappings":";AAIO,MAAMA,yBACTC,cAAc"}
@@ -1,20 +1,13 @@
1
1
  import { useEffect } from "react";
2
- import { ParagraphNode, $createHeadingNode } from "@webiny/lexical-nodes";
2
+ import { $createHeadingNode, ParagraphNode } from "@webiny/lexical-nodes";
3
3
  import { useRichTextEditor } from "../../hooks/index.js";
4
-
5
- /**
6
- * In the "Heading" editor, we only want to support heading tags.
7
- * However, when the editor is empty, and you start typing, Lexical automatically creates an empty "paragraph" node.
8
- * This ensures that any paragraph node is automatically converted to a heading node.
9
- */
10
- export const EnsureHeadingTagPlugin = () => {
11
- const {
12
- editor
13
- } = useRichTextEditor();
14
- useEffect(() => editor.registerNodeTransform(ParagraphNode, node => {
15
- node.replace($createHeadingNode("h1"), true);
16
- }), []);
17
- return null;
4
+ const EnsureHeadingTagPlugin = ()=>{
5
+ const { editor } = useRichTextEditor();
6
+ useEffect(()=>editor.registerNodeTransform(ParagraphNode, (node)=>{
7
+ node.replace($createHeadingNode("h1"), true);
8
+ }), []);
9
+ return null;
18
10
  };
11
+ export { EnsureHeadingTagPlugin };
19
12
 
20
13
  //# sourceMappingURL=EnsureHeadingTagPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","ParagraphNode","$createHeadingNode","useRichTextEditor","EnsureHeadingTagPlugin","editor","registerNodeTransform","node","replace"],"sources":["EnsureHeadingTagPlugin.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { ParagraphNode, $createHeadingNode } from \"@webiny/lexical-nodes\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\n\n/**\n * In the \"Heading\" editor, we only want to support heading tags.\n * However, when the editor is empty, and you start typing, Lexical automatically creates an empty \"paragraph\" node.\n * This ensures that any paragraph node is automatically converted to a heading node.\n */\nexport const EnsureHeadingTagPlugin = () => {\n const { editor } = useRichTextEditor();\n\n useEffect(\n () =>\n editor.registerNodeTransform(ParagraphNode, node => {\n node.replace($createHeadingNode(\"h1\"), true);\n }),\n []\n );\n return null;\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,uBAAuB;AACzE,SAASC,iBAAiB;;AAE1B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAO,CAAC,GAAGF,iBAAiB,CAAC,CAAC;EAEtCH,SAAS,CACL,MACIK,MAAM,CAACC,qBAAqB,CAACL,aAAa,EAAEM,IAAI,IAAI;IAChDA,IAAI,CAACC,OAAO,CAACN,kBAAkB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;EAChD,CAAC,CAAC,EACN,EACJ,CAAC;EACD,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"components/Editor/EnsureHeadingTagPlugin.js","sources":["../../../src/components/Editor/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"],"names":["EnsureHeadingTagPlugin","editor","useRichTextEditor","useEffect","ParagraphNode","node","$createHeadingNode"],"mappings":";;;AASO,MAAMA,yBAAyB;IAClC,MAAM,EAAEC,MAAM,EAAE,GAAGC;IAEnBC,UACI,IACIF,OAAO,qBAAqB,CAACG,eAAeC,CAAAA;YACxCA,KAAK,OAAO,CAACC,mBAAmB,OAAO;QAC3C,IACJ,EAAE;IAEN,OAAO;AACX"}
@@ -1,4 +1,4 @@
1
- import React, { Fragment, useId, useRef, useState } from "react";
1
+ import react, { Fragment, useId, useRef, useState } from "react";
2
2
  import { LexicalComposer } from "@lexical/react/LexicalComposer";
3
3
  import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
4
4
  import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
@@ -14,129 +14,90 @@ import { Placeholder } from "../../ui/Placeholder.js";
14
14
  import { SharedHistoryContext, useSharedHistoryContext } from "../../context/SharedHistoryContext.js";
15
15
  import { LexicalEditorWithConfig, useLexicalEditorConfig } from "../LexicalEditorConfig/LexicalEditorConfig.js";
16
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
- disabled = false,
29
- height,
30
- contentEditableStyles,
31
- placeholderStyles,
32
- ...props
33
- }) => {
34
- const editorTheme = useRef(props.theme);
35
- const config = useLexicalEditorConfig();
36
- const {
37
- historyState
38
- } = useSharedHistoryContext();
39
- const placeholderElem = /*#__PURE__*/React.createElement(Placeholder, {
40
- styles: placeholderStyles
41
- }, placeholder || "Enter text...");
42
- const scrollRef = useRef(null);
43
- const [floatingAnchorElem, setFloatingAnchorElem] = useState(undefined);
44
- const onRef = _floatingAnchorElem => {
45
- if (_floatingAnchorElem !== null) {
46
- setFloatingAnchorElem(_floatingAnchorElem);
47
- }
48
- };
49
- const sizeStyle = {
50
- height: height || "",
51
- width: width || ""
52
- };
53
- const configNodes = config.nodes.map(node => node.node);
54
- const configPlugins = config.plugins.map(plugin => /*#__PURE__*/React.createElement(Fragment, {
55
- key: plugin.name
56
- }, plugin.element));
57
- const initialConfig = {
58
- editorId: useId(),
59
- editable: !disabled,
60
- namespace: "webiny",
61
- onError: () => {
62
- // Ignore errors. We don't want to break the app because of errors caused by config/value updates.
63
- // These are usually resolved in the next component render cycle.
64
- },
65
- nodes: [...allNodes, ...configNodes, ...(nodes || [])],
66
- theme: {
67
- ...editorTheme.current.tokens,
68
- // I'm not aware of a better way to pass custom data to nodes.
69
- // For now, we're using Lexical's theme to pass colors and typography.
70
- $colors: editorTheme.current.colors,
71
- $typography: editorTheme.current.typography,
72
- $cacheKey: JSON.stringify(editorTheme.current)
73
- }
74
- };
75
- if (props.configRef) {
76
- props.configRef.current = initialConfig;
77
- }
78
- return (
79
- /*#__PURE__*/
80
- /**
81
- * Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future
82
- * updates to the config will be ignored. This is a problem because we pull in Nodes from our config,
83
- * and initially, there can be multiple re-renders, while the config object is settled.
84
- *
85
- * To bypass this issue, we generate a naive `key` based on the number of Nodes.
86
- */
87
- React.createElement(SharedHistoryContext, null, /*#__PURE__*/React.createElement(LexicalComposer, {
88
- initialConfig: initialConfig,
89
- key: initialConfig.nodes.length
90
- }, /*#__PURE__*/React.createElement(RichTextEditorProvider, {
91
- theme: props.theme,
92
- toolbarActionPlugins: props.toolbarActionPlugins
93
- }, staticToolbar && !disabled ? staticToolbar : null, /*#__PURE__*/React.createElement("div", {
94
- "data-role": "overlays",
95
- className: "relative"
96
- }), /*#__PURE__*/React.createElement("div", {
97
- /* This className is necessary for targeting of editor container from CSS files. */
98
- className: "editor-shell",
99
- ref: scrollRef,
100
- style: {
101
- ...styles,
102
- ...sizeStyle,
103
- overflow: "auto",
104
- position: "relative"
105
- }
106
- }, /*#__PURE__*/React.createElement(StateHandlingPlugin, {
107
- value: props.value,
108
- onChange: disabled ? undefined : onChange
109
- }), /*#__PURE__*/React.createElement(ClearEditorPlugin, null), /*#__PURE__*/React.createElement(HistoryPlugin, {
110
- externalHistoryState: historyState
111
- }), onBlur && /*#__PURE__*/React.createElement(BlurEventPlugin, {
112
- onBlur: onBlur
113
- }), focus && /*#__PURE__*/React.createElement(AutoFocusPlugin, null), configPlugins, children, /*#__PURE__*/React.createElement(RichTextPlugin, {
114
- contentEditable: /*#__PURE__*/React.createElement("div", {
115
- className: "editor-scroller",
116
- style: {
117
- ...sizeStyle
17
+ const BaseRichTextEditor = ({ onChange, toolbar, staticToolbar, nodes, placeholder, children, onBlur, focus, styles, width, disabled = false, height, contentEditableStyles, placeholderStyles, ...props })=>{
18
+ const editorTheme = useRef(props.theme);
19
+ const config = useLexicalEditorConfig();
20
+ const { historyState } = useSharedHistoryContext();
21
+ const placeholderElem = /*#__PURE__*/ react.createElement(Placeholder, {
22
+ styles: placeholderStyles
23
+ }, placeholder || "Enter text...");
24
+ const scrollRef = useRef(null);
25
+ const [floatingAnchorElem, setFloatingAnchorElem] = useState(void 0);
26
+ const onRef = (_floatingAnchorElem)=>{
27
+ if (null !== _floatingAnchorElem) setFloatingAnchorElem(_floatingAnchorElem);
28
+ };
29
+ const sizeStyle = {
30
+ height: height || "",
31
+ width: width || ""
32
+ };
33
+ const configNodes = config.nodes.map((node)=>node.node);
34
+ const configPlugins = config.plugins.map((plugin)=>/*#__PURE__*/ react.createElement(Fragment, {
35
+ key: plugin.name
36
+ }, plugin.element));
37
+ const initialConfig = {
38
+ editorId: useId(),
39
+ editable: !disabled,
40
+ namespace: "webiny",
41
+ onError: ()=>{},
42
+ nodes: [
43
+ ...allNodes,
44
+ ...configNodes,
45
+ ...nodes || []
46
+ ],
47
+ theme: {
48
+ ...editorTheme.current.tokens,
49
+ $colors: editorTheme.current.colors,
50
+ $typography: editorTheme.current.typography,
51
+ $cacheKey: JSON.stringify(editorTheme.current)
118
52
  }
119
- }, /*#__PURE__*/React.createElement("div", {
120
- className: "editor",
121
- ref: onRef
122
- }, /*#__PURE__*/React.createElement(ContentEditable, {
123
- disabled: disabled,
53
+ };
54
+ if (props.configRef) props.configRef.current = initialConfig;
55
+ return /*#__PURE__*/ react.createElement(SharedHistoryContext, null, /*#__PURE__*/ react.createElement(LexicalComposer, {
56
+ initialConfig: initialConfig,
57
+ key: initialConfig.nodes.length
58
+ }, /*#__PURE__*/ react.createElement(RichTextEditorProvider, {
59
+ theme: props.theme,
60
+ toolbarActionPlugins: props.toolbarActionPlugins
61
+ }, staticToolbar && !disabled ? staticToolbar : null, /*#__PURE__*/ react.createElement("div", {
62
+ "data-role": "overlays",
63
+ className: "relative"
64
+ }), /*#__PURE__*/ react.createElement("div", {
65
+ className: "editor-shell",
66
+ ref: scrollRef,
124
67
  style: {
125
- outline: 0,
126
- ...contentEditableStyles
68
+ ...styles,
69
+ ...sizeStyle,
70
+ overflow: "auto",
71
+ position: "relative"
127
72
  }
128
- }))),
129
- placeholder: placeholderElem,
130
- ErrorBoundary: LexicalErrorBoundary
131
- }), disabled ? null : floatingAnchorElem && toolbar))))
132
- );
73
+ }, /*#__PURE__*/ react.createElement(StateHandlingPlugin, {
74
+ value: props.value,
75
+ onChange: disabled ? void 0 : onChange
76
+ }), /*#__PURE__*/ react.createElement(ClearEditorPlugin, null), /*#__PURE__*/ react.createElement(HistoryPlugin, {
77
+ externalHistoryState: historyState
78
+ }), onBlur && /*#__PURE__*/ react.createElement(BlurEventPlugin, {
79
+ onBlur: onBlur
80
+ }), focus && /*#__PURE__*/ react.createElement(AutoFocusPlugin, null), configPlugins, children, /*#__PURE__*/ react.createElement(RichTextPlugin, {
81
+ contentEditable: /*#__PURE__*/ react.createElement("div", {
82
+ className: "editor-scroller",
83
+ style: {
84
+ ...sizeStyle
85
+ }
86
+ }, /*#__PURE__*/ react.createElement("div", {
87
+ className: "editor",
88
+ ref: onRef
89
+ }, /*#__PURE__*/ react.createElement(ContentEditable, {
90
+ disabled: disabled,
91
+ style: {
92
+ outline: 0,
93
+ ...contentEditableStyles
94
+ }
95
+ }))),
96
+ placeholder: placeholderElem,
97
+ ErrorBoundary: LexicalErrorBoundary
98
+ }), disabled ? null : floatingAnchorElem && toolbar))));
133
99
  };
134
-
135
- /**
136
- * @description Main editor container
137
- */
138
- export const RichTextEditor = makeDecoratable("RichTextEditor", props => {
139
- return /*#__PURE__*/React.createElement(LexicalEditorWithConfig, null, /*#__PURE__*/React.createElement(BaseRichTextEditor, props));
140
- });
100
+ const RichTextEditor = makeDecoratable("RichTextEditor", (props)=>/*#__PURE__*/ react.createElement(LexicalEditorWithConfig, null, /*#__PURE__*/ react.createElement(BaseRichTextEditor, props)));
101
+ export { RichTextEditor };
141
102
 
142
103
  //# sourceMappingURL=RichTextEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","Fragment","useId","useRef","useState","LexicalComposer","AutoFocusPlugin","ClearEditorPlugin","RichTextPlugin","LexicalErrorBoundary","makeDecoratable","HistoryPlugin","ContentEditable","allNodes","RichTextEditorProvider","BlurEventPlugin","Placeholder","SharedHistoryContext","useSharedHistoryContext","LexicalEditorWithConfig","useLexicalEditorConfig","StateHandlingPlugin","BaseRichTextEditor","onChange","toolbar","staticToolbar","nodes","placeholder","children","onBlur","focus","styles","width","disabled","height","contentEditableStyles","placeholderStyles","props","editorTheme","theme","config","historyState","placeholderElem","createElement","scrollRef","floatingAnchorElem","setFloatingAnchorElem","undefined","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","key","name","element","initialConfig","editorId","editable","namespace","onError","current","tokens","$colors","colors","$typography","typography","$cacheKey","JSON","stringify","configRef","length","toolbarActionPlugins","className","ref","style","overflow","position","value","externalHistoryState","contentEditable","outline","ErrorBoundary","RichTextEditor"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useId, useRef, useState } from \"react\";\nimport type { Klass, LexicalNode } from \"lexical\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { AutoFocusPlugin } from \"@lexical/react/LexicalAutoFocusPlugin\";\nimport { ClearEditorPlugin } from \"@lexical/react/LexicalClearEditorPlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport type { EditorTheme } from \"@webiny/lexical-theme\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext.js\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin.js\";\nimport type { LexicalValue, ToolbarActionPlugin } from \"~/types.js\";\nimport { Placeholder } from \"~/ui/Placeholder.js\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext.js\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig.js\";\nimport { StateHandlingPlugin } from \"~/plugins/StateHandlingPlugin.js\";\n\nexport type InitialEditorConfig = React.ComponentProps<typeof LexicalComposer>[\"initialConfig\"] & {\n editorId: string;\n};\n\nexport interface RichTextEditorProps {\n children?: React.ReactNode | React.ReactNode[];\n classes?: string;\n disabled?: boolean;\n contentEditableStyles?: React.CSSProperties;\n focus?: boolean;\n height?: number | string;\n nodes?: Klass<LexicalNode>[];\n onBlur?: (editorState: LexicalValue) => void;\n onChange?: (value: LexicalValue) => void;\n placeholder?: string;\n placeholderStyles?: React.CSSProperties;\n staticToolbar?: React.ReactNode;\n styles?: React.CSSProperties;\n tag?: string;\n theme: EditorTheme;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n toolbar?: React.ReactNode;\n value: LexicalValue | null | undefined;\n configRef?: React.MutableRefObject<InitialEditorConfig | undefined>;\n width?: number | string;\n}\n\nconst BaseRichTextEditor = ({\n onChange,\n toolbar,\n staticToolbar,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n disabled = false,\n height,\n contentEditableStyles,\n placeholderStyles,\n ...props\n}: RichTextEditorProps) => {\n const editorTheme = useRef(props.theme);\n const config = useLexicalEditorConfig();\n const { historyState } = useSharedHistoryContext();\n const placeholderElem = (\n <Placeholder styles={placeholderStyles}>{placeholder || \"Enter text...\"}</Placeholder>\n );\n const scrollRef = useRef(null);\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem);\n }\n };\n\n const sizeStyle = {\n height: height || \"\",\n width: width || \"\"\n };\n\n const configNodes = config.nodes.map(node => node.node);\n const configPlugins = config.plugins.map(plugin => (\n <Fragment key={plugin.name}>{plugin.element}</Fragment>\n ));\n\n const initialConfig = {\n editorId: useId(),\n editable: !disabled,\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n nodes: [...allNodes, ...configNodes, ...(nodes || [])],\n theme: {\n ...editorTheme.current.tokens,\n // I'm not aware of a better way to pass custom data to nodes.\n // For now, we're using Lexical's theme to pass colors and typography.\n $colors: editorTheme.current.colors,\n $typography: editorTheme.current.typography,\n $cacheKey: JSON.stringify(editorTheme.current)\n }\n };\n\n if (props.configRef) {\n props.configRef.current = initialConfig;\n }\n\n return (\n /**\n * Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future\n * updates to the config will be ignored. This is a problem because we pull in Nodes from our config,\n * and initially, there can be multiple re-renders, while the config object is settled.\n *\n * To bypass this issue, we generate a naive `key` based on the number of Nodes.\n */\n <SharedHistoryContext>\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider\n theme={props.theme}\n toolbarActionPlugins={props.toolbarActionPlugins}\n >\n {staticToolbar && !disabled ? staticToolbar : null}\n <div data-role={\"overlays\"} className={\"relative\"}></div>\n <div\n /* This className is necessary for targeting of editor container from CSS files. */\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{\n ...styles,\n ...sizeStyle,\n overflow: \"auto\",\n position: \"relative\"\n }}\n >\n {/* State plugins. */}\n <StateHandlingPlugin\n value={props.value}\n onChange={disabled ? undefined : onChange}\n />\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Event plugins. */}\n {onBlur && <BlurEventPlugin onBlur={onBlur} />}\n {focus && <AutoFocusPlugin />}\n {/* External plugins and components. */}\n {configPlugins}\n {children}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\" style={{ ...sizeStyle }}>\n <div className=\"editor\" ref={onRef}>\n <ContentEditable\n disabled={disabled}\n style={{ outline: 0, ...contentEditableStyles }}\n />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar. */}\n {disabled ? null : floatingAnchorElem && toolbar}\n </div>\n </RichTextEditorProvider>\n </LexicalComposer>\n </SharedHistoryContext>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeDecoratable(\"RichTextEditor\", (props: RichTextEditorProps) => {\n return (\n <LexicalEditorWithConfig>\n <BaseRichTextEditor {...props} />\n </LexicalEditorWithConfig>\n );\n});\n\nexport namespace RichTextEditor {\n export type InitialConfig = InitialEditorConfig;\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEhE,SAASC,eAAe,Q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CAAA2C,aAAA;QAAKkC,SAAS,EAAC,QAAQ;QAACC,GAAG,EAAE9B;MAAM,gBAC/BhD,KAAA,CAAA2C,aAAA,CAAC/B,eAAe;QACZqB,QAAQ,EAAEA,QAAS;QACnB8C,KAAK,EAAE;UAAEM,OAAO,EAAE,CAAC;UAAE,GAAGlD;QAAsB;MAAE,CACnD,CACA,CACJ,CACR;MACDR,WAAW,EAAEe,eAAgB;MAC7B4C,aAAa,EAAE7E;IAAqB,CACvC,CAAC,EAEDwB,QAAQ,GAAG,IAAI,GAAGY,kBAAkB,IAAIrB,OACxC,CACe,CACX,CACC;EAAC;AAE/B,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAM+D,cAAc,GAAG7E,eAAe,CAAC,gBAAgB,EAAG2B,KAA0B,IAAK;EAC5F,oBACIrC,KAAA,CAAA2C,aAAA,CAACxB,uBAAuB,qBACpBnB,KAAA,CAAA2C,aAAA,CAACrB,kBAAkB,EAAKe,KAAQ,CACX,CAAC;AAElC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"components/Editor/RichTextEditor.js","sources":["../../../src/components/Editor/RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useId, useRef, useState } from \"react\";\nimport type { Klass, LexicalNode } from \"lexical\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { AutoFocusPlugin } from \"@lexical/react/LexicalAutoFocusPlugin\";\nimport { ClearEditorPlugin } from \"@lexical/react/LexicalClearEditorPlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport type { EditorTheme } from \"@webiny/lexical-theme\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext.js\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin.js\";\nimport type { LexicalValue, ToolbarActionPlugin } from \"~/types.js\";\nimport { Placeholder } from \"~/ui/Placeholder.js\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext.js\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig.js\";\nimport { StateHandlingPlugin } from \"~/plugins/StateHandlingPlugin.js\";\n\nexport type InitialEditorConfig = React.ComponentProps<typeof LexicalComposer>[\"initialConfig\"] & {\n editorId: string;\n};\n\nexport interface RichTextEditorProps {\n children?: React.ReactNode | React.ReactNode[];\n classes?: string;\n disabled?: boolean;\n contentEditableStyles?: React.CSSProperties;\n focus?: boolean;\n height?: number | string;\n nodes?: Klass<LexicalNode>[];\n onBlur?: (editorState: LexicalValue) => void;\n onChange?: (value: LexicalValue) => void;\n placeholder?: string;\n placeholderStyles?: React.CSSProperties;\n staticToolbar?: React.ReactNode;\n styles?: React.CSSProperties;\n tag?: string;\n theme: EditorTheme;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n toolbar?: React.ReactNode;\n value: LexicalValue | null | undefined;\n configRef?: React.MutableRefObject<InitialEditorConfig | undefined>;\n width?: number | string;\n}\n\nconst BaseRichTextEditor = ({\n onChange,\n toolbar,\n staticToolbar,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n disabled = false,\n height,\n contentEditableStyles,\n placeholderStyles,\n ...props\n}: RichTextEditorProps) => {\n const editorTheme = useRef(props.theme);\n const config = useLexicalEditorConfig();\n const { historyState } = useSharedHistoryContext();\n const placeholderElem = (\n <Placeholder styles={placeholderStyles}>{placeholder || \"Enter text...\"}</Placeholder>\n );\n const scrollRef = useRef(null);\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem);\n }\n };\n\n const sizeStyle = {\n height: height || \"\",\n width: width || \"\"\n };\n\n const configNodes = config.nodes.map(node => node.node);\n const configPlugins = config.plugins.map(plugin => (\n <Fragment key={plugin.name}>{plugin.element}</Fragment>\n ));\n\n const initialConfig = {\n editorId: useId(),\n editable: !disabled,\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n nodes: [...allNodes, ...configNodes, ...(nodes || [])],\n theme: {\n ...editorTheme.current.tokens,\n // I'm not aware of a better way to pass custom data to nodes.\n // For now, we're using Lexical's theme to pass colors and typography.\n $colors: editorTheme.current.colors,\n $typography: editorTheme.current.typography,\n $cacheKey: JSON.stringify(editorTheme.current)\n }\n };\n\n if (props.configRef) {\n props.configRef.current = initialConfig;\n }\n\n return (\n /**\n * Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future\n * updates to the config will be ignored. This is a problem because we pull in Nodes from our config,\n * and initially, there can be multiple re-renders, while the config object is settled.\n *\n * To bypass this issue, we generate a naive `key` based on the number of Nodes.\n */\n <SharedHistoryContext>\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider\n theme={props.theme}\n toolbarActionPlugins={props.toolbarActionPlugins}\n >\n {staticToolbar && !disabled ? staticToolbar : null}\n <div data-role={\"overlays\"} className={\"relative\"}></div>\n <div\n /* This className is necessary for targeting of editor container from CSS files. */\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{\n ...styles,\n ...sizeStyle,\n overflow: \"auto\",\n position: \"relative\"\n }}\n >\n {/* State plugins. */}\n <StateHandlingPlugin\n value={props.value}\n onChange={disabled ? undefined : onChange}\n />\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Event plugins. */}\n {onBlur && <BlurEventPlugin onBlur={onBlur} />}\n {focus && <AutoFocusPlugin />}\n {/* External plugins and components. */}\n {configPlugins}\n {children}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\" style={{ ...sizeStyle }}>\n <div className=\"editor\" ref={onRef}>\n <ContentEditable\n disabled={disabled}\n style={{ outline: 0, ...contentEditableStyles }}\n />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar. */}\n {disabled ? null : floatingAnchorElem && toolbar}\n </div>\n </RichTextEditorProvider>\n </LexicalComposer>\n </SharedHistoryContext>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeDecoratable(\"RichTextEditor\", (props: RichTextEditorProps) => {\n return (\n <LexicalEditorWithConfig>\n <BaseRichTextEditor {...props} />\n </LexicalEditorWithConfig>\n );\n});\n\nexport namespace RichTextEditor {\n export type InitialConfig = InitialEditorConfig;\n}\n"],"names":["BaseRichTextEditor","onChange","toolbar","staticToolbar","nodes","placeholder","children","onBlur","focus","styles","width","disabled","height","contentEditableStyles","placeholderStyles","props","editorTheme","useRef","config","useLexicalEditorConfig","historyState","useSharedHistoryContext","placeholderElem","Placeholder","scrollRef","floatingAnchorElem","setFloatingAnchorElem","useState","undefined","onRef","_floatingAnchorElem","sizeStyle","configNodes","node","configPlugins","plugin","Fragment","initialConfig","useId","allNodes","JSON","SharedHistoryContext","LexicalComposer","RichTextEditorProvider","StateHandlingPlugin","ClearEditorPlugin","HistoryPlugin","BlurEventPlugin","AutoFocusPlugin","RichTextPlugin","ContentEditable","LexicalErrorBoundary","RichTextEditor","makeDecoratable","LexicalEditorWithConfig"],"mappings":";;;;;;;;;;;;;;;;AAkDA,MAAMA,qBAAqB,CAAC,EACxBC,QAAQ,EACRC,OAAO,EACPC,aAAa,EACbC,KAAK,EACLC,WAAW,EACXC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,KAAK,EACLC,WAAW,KAAK,EAChBC,MAAM,EACNC,qBAAqB,EACrBC,iBAAiB,E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AAiB,CAACQ,WAAWR,gBAAgB,oBAC9C,oBAAC;QAAI,aAAW;QAAY,WAAW;sBACvC,oBAAC;QAEG,WAAW;QACX,KAAKqB;QACL,OAAO;YACH,GAAGf,MAAM;YACT,GAAGsB,SAAS;YACZ,UAAU;YACV,UAAU;QACd;qBAGA,oBAACa,qBAAmBA;QAChB,OAAO7B,MAAM,KAAK;QAClB,UAAUJ,WAAWiB,SAAY3B;sBAErC,oBAAC4C,mBAAiBA,OAAAA,WAAAA,GAClB,oBAACC,eAAaA;QAAC,sBAAsB1B;QAEpCb,UAAU,WAAVA,GAAU,oBAACwC,iBAAeA;QAAC,QAAQxC;QACnCC,SAAS,WAATA,GAAS,oBAACwC,iBAAeA,OAEzBd,eACA5B,UAAAA,WAAAA,GACD,oBAAC2C,gBAAcA;QACX,+BACI,oBAAC;YAAI,WAAU;YAAkB,OAAO;gBAAE,GAAGlB,SAAS;YAAC;yBACnD,oBAAC;YAAI,WAAU;YAAS,KAAKF;yBACzB,oBAACqB,iBAAeA;YACZ,UAAUvC;YACV,OAAO;gBAAE,SAAS;gBAAG,GAAGE,qBAAqB;YAAC;;QAK9D,aAAaS;QACb,eAAe6B;QAGlBxC,WAAW,OAAOc,sBAAsBvB;AAMjE;AAKO,MAAMkD,iBAAiBC,gBAAgB,kBAAkB,CAACtC,QACtD,WAAP,GACI,oBAACuC,yBAAuBA,MAAAA,WAAAA,GACpB,oBAACtD,oBAAuBe"}
@@ -1,16 +1,14 @@
1
- const isValueEmpty = value => {
2
- return [undefined, null, "", '""', "null"].includes(value);
3
- };
4
-
5
- /**
6
- * Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes
7
- * of input into a value that is either a `null` or a `LexicalValue`.
8
- */
9
- export function normalizeInputValue(value) {
10
- if (isValueEmpty(value)) {
11
- return null;
12
- }
13
- return value;
1
+ const isValueEmpty = (value)=>[
2
+ void 0,
3
+ null,
4
+ "",
5
+ '""',
6
+ "null"
7
+ ].includes(value);
8
+ function normalizeInputValue(value) {
9
+ if (isValueEmpty(value)) return null;
10
+ return value;
14
11
  }
12
+ export { normalizeInputValue };
15
13
 
16
14
  //# sourceMappingURL=normalizeInputValue.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isValueEmpty","value","undefined","includes","normalizeInputValue"],"sources":["normalizeInputValue.ts"],"sourcesContent":["import type { LexicalValue, NormalizedInputValue } from \"~/types.js\";\n\nconst isValueEmpty = (value: any) => {\n return [undefined, null, \"\", '\"\"', \"null\"].includes(value);\n};\n\n/**\n * Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes\n * of input into a value that is either a `null` or a `LexicalValue`.\n */\nexport function normalizeInputValue(value: LexicalValue | null | undefined) {\n if (isValueEmpty(value)) {\n return null;\n }\n\n return value as NormalizedInputValue;\n}\n"],"mappings":"AAEA,MAAMA,YAAY,GAAIC,KAAU,IAAK;EACjC,OAAO,CAACC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAACC,QAAQ,CAACF,KAAK,CAAC;AAC9D,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,SAASG,mBAAmBA,CAACH,KAAsC,EAAE;EACxE,IAAID,YAAY,CAACC,KAAK,CAAC,EAAE;IACrB,OAAO,IAAI;EACf;EAEA,OAAOA,KAAK;AAChB","ignoreList":[]}
1
+ {"version":3,"file":"components/Editor/normalizeInputValue.js","sources":["../../../src/components/Editor/normalizeInputValue.ts"],"sourcesContent":["import type { LexicalValue, NormalizedInputValue } from \"~/types.js\";\n\nconst isValueEmpty = (value: any) => {\n return [undefined, null, \"\", '\"\"', \"null\"].includes(value);\n};\n\n/**\n * Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes\n * of input into a value that is either a `null` or a `LexicalValue`.\n */\nexport function normalizeInputValue(value: LexicalValue | null | undefined) {\n if (isValueEmpty(value)) {\n return null;\n }\n\n return value as NormalizedInputValue;\n}\n"],"names":["isValueEmpty","value","undefined","normalizeInputValue"],"mappings":"AAEA,MAAMA,eAAe,CAACC,QACX;QAACC;QAAW;QAAM;QAAI;QAAM;KAAO,CAAC,QAAQ,CAACD;AAOjD,SAASE,oBAAoBF,KAAsC;IACtE,IAAID,aAAaC,QACb,OAAO;IAGX,OAAOA;AACX"}
@@ -4,22 +4,31 @@ import { ToolbarElement } from "./components/ToolbarElement.js";
4
4
  import { Plugin } from "./components/Plugin.js";
5
5
  import { Node } from "./components/Node.js";
6
6
  const base = createConfigurableComponent("LexicalEditor");
7
- export const LexicalEditorConfig = Object.assign(base.Config, {
8
- ToolbarElement,
9
- Plugin,
10
- Node
7
+ const LexicalEditorConfig = Object.assign(base.Config, {
8
+ ToolbarElement: ToolbarElement,
9
+ Plugin: Plugin,
10
+ Node: Node
11
11
  });
12
- export const LexicalEditorWithConfig = base.WithConfig;
13
- export function useLexicalEditorConfig() {
14
- const config = base.useConfig();
15
- const toolbarElements = config.toolbarElements || [];
16
- const plugins = config.plugins || [];
17
- const nodes = config.nodes || [];
18
- return useMemo(() => ({
19
- toolbarElements: [...toolbarElements],
20
- plugins: [...plugins],
21
- nodes: [...nodes]
22
- }), [config]);
12
+ const LexicalEditorWithConfig = base.WithConfig;
13
+ function useLexicalEditorConfig() {
14
+ const config = base.useConfig();
15
+ const toolbarElements = config.toolbarElements || [];
16
+ const plugins = config.plugins || [];
17
+ const nodes = config.nodes || [];
18
+ return useMemo(()=>({
19
+ toolbarElements: [
20
+ ...toolbarElements
21
+ ],
22
+ plugins: [
23
+ ...plugins
24
+ ],
25
+ nodes: [
26
+ ...nodes
27
+ ]
28
+ }), [
29
+ config
30
+ ]);
23
31
  }
32
+ export { LexicalEditorConfig, LexicalEditorWithConfig, useLexicalEditorConfig };
24
33
 
25
34
  //# sourceMappingURL=LexicalEditorConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","createConfigurableComponent","ToolbarElement","Plugin","Node","base","LexicalEditorConfig","Object","assign","Config","LexicalEditorWithConfig","WithConfig","useLexicalEditorConfig","config","useConfig","toolbarElements","plugins","nodes"],"sources":["LexicalEditorConfig.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { createConfigurableComponent } from \"@webiny/react-properties\";\nimport type { ToolbarElementConfig } from \"./components/ToolbarElement.js\";\nimport { ToolbarElement } from \"./components/ToolbarElement.js\";\nimport type { PluginConfig } from \"./components/Plugin.js\";\nimport { Plugin } from \"./components/Plugin.js\";\nimport type { NodeConfig } from \"./components/Node.js\";\nimport { Node } from \"./components/Node.js\";\n\nexport type { ToolbarElementConfig } from \"./components/ToolbarElement.js\";\nexport type { PluginConfig } from \"./components/Plugin.js\";\nexport type { NodeConfig } from \"./components/Node.js\";\n\nconst base = createConfigurableComponent<LexicalEditorConfigData>(\"LexicalEditor\");\n\nexport const LexicalEditorConfig = Object.assign(base.Config, {\n ToolbarElement,\n Plugin,\n Node\n});\n\nexport const LexicalEditorWithConfig = base.WithConfig;\n\ninterface LexicalEditorConfigData {\n toolbarElements: ToolbarElementConfig[];\n plugins: PluginConfig[];\n nodes: NodeConfig[];\n}\n\nexport function useLexicalEditorConfig(): LexicalEditorConfigData {\n const config = base.useConfig();\n const toolbarElements = config.toolbarElements || [];\n const plugins = config.plugins || [];\n const nodes = config.nodes || [];\n\n return useMemo(\n () => ({\n toolbarElements: [...toolbarElements],\n plugins: [...plugins],\n nodes: [...nodes]\n }),\n [config]\n );\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,2BAA2B,QAAQ,0BAA0B;AAEtE,SAASC,cAAc;AAEvB,SAASC,MAAM;AAEf,SAASC,IAAI;AAMb,MAAMC,IAAI,GAAGJ,2BAA2B,CAA0B,eAAe,CAAC;AAElF,OAAO,MAAMK,mBAAmB,GAAGC,MAAM,CAACC,MAAM,CAACH,IAAI,CAACI,MAAM,EAAE;EAC1DP,cAAc;EACdC,MAAM;EACNC;AACJ,CAAC,CAAC;AAEF,OAAO,MAAMM,uBAAuB,GAAGL,IAAI,CAACM,UAAU;AAQtD,OAAO,SAASC,sBAAsBA,CAAA,EAA4B;EAC9D,MAAMC,MAAM,GAAGR,IAAI,CAACS,SAAS,CAAC,CAAC;EAC/B,MAAMC,eAAe,GAAGF,MAAM,CAACE,eAAe,IAAI,EAAE;EACpD,MAAMC,OAAO,GAAGH,MAAM,CAACG,OAAO,IAAI,EAAE;EACpC,MAAMC,KAAK,GAAGJ,MAAM,CAACI,KAAK,IAAI,EAAE;EAEhC,OAAOjB,OAAO,CACV,OAAO;IACHe,eAAe,EAAE,CAAC,GAAGA,eAAe,CAAC;IACrCC,OAAO,EAAE,CAAC,GAAGA,OAAO,CAAC;IACrBC,KAAK,EAAE,CAAC,GAAGA,KAAK;EACpB,CAAC,CAAC,EACF,CAACJ,MAAM,CACX,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"file":"components/LexicalEditorConfig/LexicalEditorConfig.js","sources":["../../../src/components/LexicalEditorConfig/LexicalEditorConfig.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { createConfigurableComponent } from \"@webiny/react-properties\";\nimport type { ToolbarElementConfig } from \"./components/ToolbarElement.js\";\nimport { ToolbarElement } from \"./components/ToolbarElement.js\";\nimport type { PluginConfig } from \"./components/Plugin.js\";\nimport { Plugin } from \"./components/Plugin.js\";\nimport type { NodeConfig } from \"./components/Node.js\";\nimport { Node } from \"./components/Node.js\";\n\nexport type { ToolbarElementConfig } from \"./components/ToolbarElement.js\";\nexport type { PluginConfig } from \"./components/Plugin.js\";\nexport type { NodeConfig } from \"./components/Node.js\";\n\nconst base = createConfigurableComponent<LexicalEditorConfigData>(\"LexicalEditor\");\n\nexport const LexicalEditorConfig = Object.assign(base.Config, {\n ToolbarElement,\n Plugin,\n Node\n});\n\nexport const LexicalEditorWithConfig = base.WithConfig;\n\ninterface LexicalEditorConfigData {\n toolbarElements: ToolbarElementConfig[];\n plugins: PluginConfig[];\n nodes: NodeConfig[];\n}\n\nexport function useLexicalEditorConfig(): LexicalEditorConfigData {\n const config = base.useConfig();\n const toolbarElements = config.toolbarElements || [];\n const plugins = config.plugins || [];\n const nodes = config.nodes || [];\n\n return useMemo(\n () => ({\n toolbarElements: [...toolbarElements],\n plugins: [...plugins],\n nodes: [...nodes]\n }),\n [config]\n );\n}\n"],"names":["base","createConfigurableComponent","LexicalEditorConfig","Object","ToolbarElement","Plugin","Node","LexicalEditorWithConfig","useLexicalEditorConfig","config","toolbarElements","plugins","nodes","useMemo"],"mappings":";;;;;AAaA,MAAMA,OAAOC,4BAAqD;AAE3D,MAAMC,sBAAsBC,OAAO,MAAM,CAACH,KAAK,MAAM,EAAE;IAC1DI,gBAAcA;IACdC,QAAMA;IACNC,MAAIA;AACR;AAEO,MAAMC,0BAA0BP,KAAK,UAAU;AAQ/C,SAASQ;IACZ,MAAMC,SAAST,KAAK,SAAS;IAC7B,MAAMU,kBAAkBD,OAAO,eAAe,IAAI,EAAE;IACpD,MAAME,UAAUF,OAAO,OAAO,IAAI,EAAE;IACpC,MAAMG,QAAQH,OAAO,KAAK,IAAI,EAAE;IAEhC,OAAOI,QACH,IAAO;YACH,iBAAiB;mBAAIH;aAAgB;YACrC,SAAS;mBAAIC;aAAQ;YACrB,OAAO;mBAAIC;aAAM;QACrB,IACA;QAACH;KAAO;AAEhB"}
@@ -1,30 +1,25 @@
1
- import React from "react";
1
+ import react from "react";
2
2
  import { Property } from "@webiny/react-properties";
3
- export const Node = ({
4
- name,
5
- node,
6
- after = undefined,
7
- before = undefined,
8
- remove = false
9
- }) => {
10
- const placeBefore = before !== undefined ? `node:${before}` : undefined;
11
- const placeAfter = after !== undefined ? `node:${after}` : undefined;
12
- return /*#__PURE__*/React.createElement(Property, {
13
- id: `nodes:${name}`,
14
- name: "nodes",
15
- array: true,
16
- before: placeBefore,
17
- after: placeAfter,
18
- remove: remove
19
- }, /*#__PURE__*/React.createElement(Property, {
20
- id: `node:${name}:name`,
21
- name: "name",
22
- value: name
23
- }), node ? /*#__PURE__*/React.createElement(Property, {
24
- id: `node:${name}:node`,
25
- name: "node",
26
- value: node
27
- }) : null);
3
+ const Node = ({ name, node, after, before, remove = false })=>{
4
+ const placeBefore = void 0 !== before ? `node:${before}` : void 0;
5
+ const placeAfter = void 0 !== after ? `node:${after}` : void 0;
6
+ return /*#__PURE__*/ react.createElement(Property, {
7
+ id: `nodes:${name}`,
8
+ name: "nodes",
9
+ array: true,
10
+ before: placeBefore,
11
+ after: placeAfter,
12
+ remove: remove
13
+ }, /*#__PURE__*/ react.createElement(Property, {
14
+ id: `node:${name}:name`,
15
+ name: "name",
16
+ value: name
17
+ }), node ? /*#__PURE__*/ react.createElement(Property, {
18
+ id: `node:${name}:node`,
19
+ name: "node",
20
+ value: node
21
+ }) : null);
28
22
  };
23
+ export { Node };
29
24
 
30
25
  //# sourceMappingURL=Node.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","Property","Node","name","node","after","undefined","before","remove","placeBefore","placeAfter","createElement","id","array","value"],"sources":["Node.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property } from \"@webiny/react-properties\";\nimport type { Klass, LexicalNode } from \"lexical\";\n\nexport interface NodeConfig {\n name: string;\n node: Klass<LexicalNode>;\n}\n\nexport interface NodeProps {\n name: string;\n node?: Klass<LexicalNode>;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport const Node = ({\n name,\n node,\n after = undefined,\n before = undefined,\n remove = false\n}: NodeProps) => {\n const placeBefore = before !== undefined ? `node:${before}` : undefined;\n const placeAfter = after !== undefined ? `node:${after}` : undefined;\n\n return (\n <Property\n id={`nodes:${name}`}\n name={\"nodes\"}\n array={true}\n before={placeBefore}\n after={placeAfter}\n remove={remove}\n >\n <Property id={`node:${name}:name`} name={\"name\"} value={name} />\n {node ? <Property id={`node:${name}:node`} name={\"node\"} value={node} /> : null}\n </Property>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,0BAA0B;AAgBnD,OAAO,MAAMC,IAAI,GAAGA,CAAC;EACjBC,IAAI;EACJC,IAAI;EACJC,KAAK,GAAGC,SAAS;EACjBC,MAAM,GAAGD,SAAS;EAClBE,MAAM,GAAG;AACF,CAAC,KAAK;EACb,MAAMC,WAAW,GAAGF,MAAM,KAAKD,SAAS,GAAG,QAAQC,MAAM,EAAE,GAAGD,SAAS;EACvE,MAAMI,UAAU,GAAGL,KAAK,KAAKC,SAAS,GAAG,QAAQD,KAAK,EAAE,GAAGC,SAAS;EAEpE,oBACIN,KAAA,CAAAW,aAAA,CAACV,QAAQ;IACLW,EAAE,EAAE,SAAST,IAAI,EAAG;IACpBA,IAAI,EAAE,OAAQ;IACdU,KAAK,EAAE,IAAK;IACZN,MAAM,EAAEE,WAAY;IACpBJ,KAAK,EAAEK,UAAW;IAClBF,MAAM,EAAEA;EAAO,gBAEfR,KAAA,CAAAW,aAAA,CAACV,QAAQ;IAACW,EAAE,EAAE,QAAQT,IAAI,OAAQ;IAACA,IAAI,EAAE,MAAO;IAACW,KAAK,EAAEX;EAAK,CAAE,CAAC,EAC/DC,IAAI,gBAAGJ,KAAA,CAAAW,aAAA,CAACV,QAAQ;IAACW,EAAE,EAAE,QAAQT,IAAI,OAAQ;IAACA,IAAI,EAAE,MAAO;IAACW,KAAK,EAAEV;EAAK,CAAE,CAAC,GAAG,IACrE,CAAC;AAEnB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"components/LexicalEditorConfig/components/Node.js","sources":["../../../../src/components/LexicalEditorConfig/components/Node.tsx"],"sourcesContent":["import React from \"react\";\nimport { Property } from \"@webiny/react-properties\";\nimport type { Klass, LexicalNode } from \"lexical\";\n\nexport interface NodeConfig {\n name: string;\n node: Klass<LexicalNode>;\n}\n\nexport interface NodeProps {\n name: string;\n node?: Klass<LexicalNode>;\n remove?: boolean;\n before?: string;\n after?: string;\n}\n\nexport const Node = ({\n name,\n node,\n after = undefined,\n before = undefined,\n remove = false\n}: NodeProps) => {\n const placeBefore = before !== undefined ? `node:${before}` : undefined;\n const placeAfter = after !== undefined ? `node:${after}` : undefined;\n\n return (\n <Property\n id={`nodes:${name}`}\n name={\"nodes\"}\n array={true}\n before={placeBefore}\n after={placeAfter}\n remove={remove}\n >\n <Property id={`node:${name}:name`} name={\"name\"} value={name} />\n {node ? <Property id={`node:${name}:node`} name={\"node\"} value={node} /> : null}\n </Property>\n );\n};\n"],"names":["Node","name","node","after","before","remove","placeBefore","undefined","placeAfter","Property"],"mappings":";;AAiBO,MAAMA,OAAO,CAAC,EACjBC,IAAI,EACJC,IAAI,EACJC,KAAiB,EACjBC,MAAkB,EAClBC,SAAS,KAAK,EACN;IACR,MAAMC,cAAcF,AAAWG,WAAXH,SAAuB,CAAC,KAAK,EAAEA,QAAQ,GAAGG;IAC9D,MAAMC,aAAaL,AAAUI,WAAVJ,QAAsB,CAAC,KAAK,EAAEA,OAAO,GAAGI;IAE3D,OAAO,WAAP,GACI,oBAACE,UAAQA;QACL,IAAI,CAAC,MAAM,EAAER,MAAM;QACnB,MAAM;QACN,OAAO;QACP,QAAQK;QACR,OAAOE;QACP,QAAQH;qBAER,oBAACI,UAAQA;QAAC,IAAI,CAAC,KAAK,EAAER,KAAK,KAAK,CAAC;QAAE,MAAM;QAAQ,OAAOA;QACvDC,OAAO,WAAPA,GAAO,oBAACO,UAAQA;QAAC,IAAI,CAAC,KAAK,EAAER,KAAK,KAAK,CAAC;QAAE,MAAM;QAAQ,OAAOC;SAAW;AAGvF"}