@webiny/lexical-editor 0.0.0-unstable.e3f4727c56 → 0.0.0-unstable.eb196ccd2f

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 (320) hide show
  1. package/commands/image.d.ts +6 -0
  2. package/commands/image.js +4 -0
  3. package/commands/image.js.map +1 -0
  4. package/commands/index.d.ts +5 -0
  5. package/commands/index.js +7 -0
  6. package/commands/index.js.map +1 -0
  7. package/commands/list.d.ts +7 -0
  8. package/commands/list.js +6 -0
  9. package/commands/list.js.map +1 -0
  10. package/commands/quote.d.ts +5 -0
  11. package/commands/quote.js +4 -0
  12. package/commands/quote.js.map +1 -0
  13. package/commands/toolbar.d.ts +1 -0
  14. package/commands/toolbar.js +4 -0
  15. package/commands/toolbar.js.map +1 -0
  16. package/commands/typography.d.ts +8 -0
  17. package/commands/typography.js +4 -0
  18. package/commands/typography.js.map +1 -0
  19. package/components/Editor/EnsureHeadingTagPlugin.d.ts +6 -0
  20. package/components/Editor/EnsureHeadingTagPlugin.js +20 -0
  21. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -0
  22. package/components/Editor/HeadingEditor.d.ts +2 -2
  23. package/components/Editor/HeadingEditor.js +21 -27
  24. package/components/Editor/HeadingEditor.js.map +1 -1
  25. package/components/Editor/ParagraphEditor.d.ts +2 -2
  26. package/components/Editor/ParagraphEditor.js +21 -29
  27. package/components/Editor/ParagraphEditor.js.map +1 -1
  28. package/components/Editor/RichTextEditor.d.ts +39 -13
  29. package/components/Editor/RichTextEditor.js +116 -90
  30. package/components/Editor/RichTextEditor.js.map +1 -1
  31. package/components/Editor/normalizeInputValue.d.ts +6 -0
  32. package/components/Editor/normalizeInputValue.js +16 -0
  33. package/components/Editor/normalizeInputValue.js.map +1 -0
  34. package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +20 -0
  35. package/components/LexicalEditorConfig/LexicalEditorConfig.js +63 -0
  36. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
  37. package/components/LexicalEditorConfig/components/Node.d.ts +14 -0
  38. package/components/LexicalEditorConfig/components/Node.js +30 -0
  39. package/components/LexicalEditorConfig/components/Node.js.map +1 -0
  40. package/components/LexicalEditorConfig/components/Plugin.d.ts +13 -0
  41. package/components/LexicalEditorConfig/components/Plugin.js +30 -0
  42. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -0
  43. package/components/LexicalEditorConfig/components/ToolbarElement.d.ts +13 -0
  44. package/components/LexicalEditorConfig/components/ToolbarElement.js +30 -0
  45. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -0
  46. package/components/LexicalHtmlRenderer.d.ts +8 -3
  47. package/components/LexicalHtmlRenderer.js +47 -36
  48. package/components/LexicalHtmlRenderer.js.map +1 -1
  49. package/components/Toolbar/StaticToolbar.css +260 -0
  50. package/components/Toolbar/StaticToolbar.d.ts +5 -0
  51. package/components/Toolbar/StaticToolbar.js +22 -0
  52. package/components/Toolbar/StaticToolbar.js.map +1 -0
  53. package/components/Toolbar/Toolbar.css +265 -36
  54. package/components/Toolbar/Toolbar.d.ts +2 -9
  55. package/components/Toolbar/Toolbar.js +116 -129
  56. package/components/Toolbar/Toolbar.js.map +1 -1
  57. package/components/ToolbarActions/BoldAction.d.ts +2 -5
  58. package/components/ToolbarActions/BoldAction.js +20 -33
  59. package/components/ToolbarActions/BoldAction.js.map +1 -1
  60. package/components/ToolbarActions/BulletListAction.d.ts +2 -5
  61. package/components/ToolbarActions/BulletListAction.js +31 -80
  62. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  63. package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -6
  64. package/components/ToolbarActions/CodeHighlightAction.js +20 -34
  65. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
  66. package/components/ToolbarActions/FontColorAction.d.ts +29 -0
  67. package/components/ToolbarActions/FontColorAction.js +50 -0
  68. package/components/ToolbarActions/FontColorAction.js.map +1 -0
  69. package/components/ToolbarActions/FontSizeAction.d.ts +14 -2
  70. package/components/ToolbarActions/FontSizeAction.js +70 -83
  71. package/components/ToolbarActions/FontSizeAction.js.map +1 -1
  72. package/components/ToolbarActions/ImageAction.d.ts +2 -0
  73. package/components/ToolbarActions/ImageAction.js +37 -0
  74. package/components/ToolbarActions/ImageAction.js.map +1 -0
  75. package/components/ToolbarActions/ItalicAction.d.ts +2 -5
  76. package/components/ToolbarActions/ItalicAction.js +20 -33
  77. package/components/ToolbarActions/ItalicAction.js.map +1 -1
  78. package/components/ToolbarActions/LinkAction.d.ts +2 -7
  79. package/components/ToolbarActions/LinkAction.js +27 -59
  80. package/components/ToolbarActions/LinkAction.js.map +1 -1
  81. package/components/ToolbarActions/NumberedListAction.d.ts +2 -5
  82. package/components/ToolbarActions/NumberedListAction.js +39 -80
  83. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  84. package/components/ToolbarActions/QuoteAction.d.ts +2 -4
  85. package/components/ToolbarActions/QuoteAction.js +26 -59
  86. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  87. package/components/ToolbarActions/TextAlignmentAction.d.ts +29 -0
  88. package/components/ToolbarActions/TextAlignmentAction.js +61 -0
  89. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -0
  90. package/components/ToolbarActions/TypographyAction.d.ts +29 -0
  91. package/components/ToolbarActions/TypographyAction.js +108 -0
  92. package/components/ToolbarActions/TypographyAction.js.map +1 -0
  93. package/components/ToolbarActions/UnderlineAction.d.ts +2 -5
  94. package/components/ToolbarActions/UnderlineAction.js +20 -34
  95. package/components/ToolbarActions/UnderlineAction.js.map +1 -1
  96. package/context/FontColorActionContext.d.ts +6 -0
  97. package/context/FontColorActionContext.js +4 -0
  98. package/context/FontColorActionContext.js.map +1 -0
  99. package/context/RichTextEditorContext.d.ts +11 -3
  100. package/context/RichTextEditorContext.js +17 -25
  101. package/context/RichTextEditorContext.js.map +1 -1
  102. package/context/SharedHistoryContext.d.ts +10 -0
  103. package/context/SharedHistoryContext.js +19 -0
  104. package/context/SharedHistoryContext.js.map +1 -0
  105. package/context/TextAlignmentActionContextProps.d.ts +9 -0
  106. package/context/TextAlignmentActionContextProps.js +4 -0
  107. package/context/TextAlignmentActionContextProps.js.map +1 -0
  108. package/context/TypographyActionContext.d.ts +8 -0
  109. package/context/TypographyActionContext.js +4 -0
  110. package/context/TypographyActionContext.js.map +1 -0
  111. package/hooks/index.d.ts +8 -0
  112. package/hooks/index.js +10 -0
  113. package/hooks/index.js.map +1 -0
  114. package/hooks/useCurrentElement.d.ts +7 -0
  115. package/hooks/useCurrentElement.js +27 -0
  116. package/hooks/useCurrentElement.js.map +1 -0
  117. package/hooks/useCurrentSelection.d.ts +13 -0
  118. package/hooks/useCurrentSelection.js +57 -0
  119. package/hooks/useCurrentSelection.js.map +1 -0
  120. package/hooks/useFontColorPicker.d.ts +2 -0
  121. package/hooks/useFontColorPicker.js +11 -0
  122. package/hooks/useFontColorPicker.js.map +1 -0
  123. package/hooks/useIsMounted.d.ts +1 -0
  124. package/hooks/useIsMounted.js +12 -0
  125. package/hooks/useIsMounted.js.map +1 -0
  126. package/hooks/useList.d.ts +2 -0
  127. package/hooks/useList.js +50 -0
  128. package/hooks/useList.js.map +1 -0
  129. package/hooks/useQuote.d.ts +2 -0
  130. package/hooks/useQuote.js +17 -0
  131. package/hooks/useQuote.js.map +1 -0
  132. package/hooks/useRichTextEditor.js +8 -12
  133. package/hooks/useRichTextEditor.js.map +1 -1
  134. package/hooks/useTextAlignmentAction.d.ts +1 -0
  135. package/hooks/useTextAlignmentAction.js +11 -0
  136. package/hooks/useTextAlignmentAction.js.map +1 -0
  137. package/hooks/useTypographyAction.d.ts +1 -0
  138. package/hooks/useTypographyAction.js +11 -0
  139. package/hooks/useTypographyAction.js.map +1 -0
  140. package/images/icons/font-color.svg +1 -0
  141. package/images/icons/indent.svg +3 -0
  142. package/images/icons/insert-image.svg +4 -0
  143. package/images/icons/justify.svg +3 -0
  144. package/images/icons/outdent.svg +3 -0
  145. package/index.d.ts +15 -12
  146. package/index.js +49 -238
  147. package/index.js.map +1 -1
  148. package/package.json +22 -20
  149. package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +2 -2
  150. package/plugins/BlurEventPlugin/BlurEventPlugin.js +18 -26
  151. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
  152. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +12 -18
  153. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
  154. package/plugins/CodeHighlightPlugin/index.js +2 -15
  155. package/plugins/CodeHighlightPlugin/index.js.map +1 -1
  156. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +16 -0
  157. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +158 -0
  158. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
  159. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +8 -0
  160. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +62 -0
  161. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
  162. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +65 -7
  163. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +4 -4
  164. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +12 -220
  165. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  166. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +8 -0
  167. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +104 -0
  168. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +1 -0
  169. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +9 -0
  170. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +34 -0
  171. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +1 -0
  172. package/plugins/FloatingLinkEditorPlugin/index.js +2 -15
  173. package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
  174. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.d.ts +1 -0
  175. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +12 -0
  176. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -0
  177. package/plugins/FontColorPlugin/FontColorPlugin.d.ts +1 -0
  178. package/plugins/FontColorPlugin/FontColorPlugin.js +27 -0
  179. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
  180. package/plugins/FontColorPlugin/applyColorToNode.d.ts +3 -0
  181. package/plugins/FontColorPlugin/applyColorToNode.js +8 -0
  182. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -0
  183. package/plugins/FontColorPlugin/applyColorToSelection.d.ts +3 -0
  184. package/plugins/FontColorPlugin/applyColorToSelection.js +66 -0
  185. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -0
  186. package/plugins/ImagesPlugin/ImagesPlugin.d.ts +12 -0
  187. package/plugins/ImagesPlugin/ImagesPlugin.js +151 -0
  188. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -0
  189. package/plugins/LinkPlugin/LinkPlugin.d.ts +5 -0
  190. package/plugins/LinkPlugin/LinkPlugin.js +59 -0
  191. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -0
  192. package/plugins/ListPLugin/ListPlugin.d.ts +1 -0
  193. package/plugins/ListPLugin/ListPlugin.js +17 -0
  194. package/plugins/ListPLugin/ListPlugin.js.map +1 -0
  195. package/plugins/QuoteNodePlugin/QuoteNodePlugin.d.ts +1 -0
  196. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -0
  197. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -0
  198. package/plugins/StateHandlingPlugin.d.ts +8 -0
  199. package/plugins/StateHandlingPlugin.js +75 -0
  200. package/plugins/StateHandlingPlugin.js.map +1 -0
  201. package/plugins/TypographyPlugin/TypographyPlugin.d.ts +1 -0
  202. package/plugins/TypographyPlugin/TypographyPlugin.js +27 -0
  203. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
  204. package/types.d.ts +12 -2
  205. package/types.js +8 -4
  206. package/types.js.map +1 -1
  207. package/ui/ContentEditable.css +22 -0
  208. package/{plugins/AutoLinkPlugin/AutoLinkPlugin.d.ts → ui/ContentEditable.d.ts} +5 -4
  209. package/ui/ContentEditable.js +19 -0
  210. package/ui/ContentEditable.js.map +1 -0
  211. package/ui/Divider.js +6 -11
  212. package/ui/Divider.js.map +1 -1
  213. package/ui/DropDown.d.ts +4 -4
  214. package/ui/DropDown.js +102 -88
  215. package/ui/DropDown.js.map +1 -1
  216. package/ui/ImageResizer.d.ts +24 -0
  217. package/ui/ImageResizer.js +211 -0
  218. package/ui/ImageResizer.js.map +1 -0
  219. package/ui/LinkPreview.js +32 -36
  220. package/ui/LinkPreview.js.map +1 -1
  221. package/ui/Placeholder.css +2 -5
  222. package/ui/Placeholder.d.ts +4 -2
  223. package/ui/Placeholder.js +13 -13
  224. package/ui/Placeholder.js.map +1 -1
  225. package/ui/TextInput.d.ts +1 -1
  226. package/ui/TextInput.js +14 -19
  227. package/ui/TextInput.js.map +1 -1
  228. package/ui/ToolbarActionDialog.d.ts +11 -0
  229. package/ui/ToolbarActionDialog.js +77 -0
  230. package/ui/ToolbarActionDialog.js.map +1 -0
  231. package/utils/canUseDOM.d.ts +1 -0
  232. package/utils/canUseDOM.js +3 -0
  233. package/utils/canUseDOM.js.map +1 -0
  234. package/utils/files.d.ts +11 -0
  235. package/utils/files.js +21 -0
  236. package/utils/files.js.map +1 -0
  237. package/utils/getDOMRangeRect.d.ts +0 -2
  238. package/utils/getDOMRangeRect.js +7 -11
  239. package/utils/getDOMRangeRect.js.map +1 -1
  240. package/utils/getSelectedNode.d.ts +1 -1
  241. package/utils/getSelectedNode.js +12 -17
  242. package/utils/getSelectedNode.js.map +1 -1
  243. package/utils/getTransparentImage.d.ts +1 -0
  244. package/utils/getTransparentImage.js +5 -0
  245. package/utils/getTransparentImage.js.map +1 -0
  246. package/utils/insertImage.d.ts +2 -0
  247. package/utils/insertImage.js +16 -0
  248. package/utils/insertImage.js.map +1 -0
  249. package/utils/isAnchorLink.d.ts +1 -0
  250. package/utils/isAnchorLink.js +5 -0
  251. package/utils/isAnchorLink.js.map +1 -0
  252. package/utils/isChildOfFloatingToolbar.d.ts +1 -0
  253. package/utils/isChildOfFloatingToolbar.js +12 -0
  254. package/utils/isChildOfFloatingToolbar.js.map +1 -0
  255. package/{themes/webinyLexicalTheme.d.ts → utils/isHTMLElement.d.ts} +1 -3
  256. package/utils/isHTMLElement.js +12 -0
  257. package/utils/isHTMLElement.js.map +1 -0
  258. package/utils/isValidJSON.js +5 -10
  259. package/utils/isValidJSON.js.map +1 -1
  260. package/utils/isValidLexicalData.d.ts +4 -2
  261. package/utils/isValidLexicalData.js +18 -18
  262. package/utils/isValidLexicalData.js.map +1 -1
  263. package/utils/point.js +38 -66
  264. package/utils/point.js.map +1 -1
  265. package/utils/rect.d.ts +2 -4
  266. package/utils/rect.js +117 -156
  267. package/utils/rect.js.map +1 -1
  268. package/utils/sanitizeUrl.d.ts +0 -7
  269. package/utils/sanitizeUrl.js +10 -12
  270. package/utils/sanitizeUrl.js.map +1 -1
  271. package/utils/setFloatingElemPosition.d.ts +1 -3
  272. package/utils/setFloatingElemPosition.js +29 -39
  273. package/utils/setFloatingElemPosition.js.map +1 -1
  274. package/components/AddRichTextEditorNodeType.d.ts +0 -6
  275. package/components/AddRichTextEditorNodeType.js +0 -28
  276. package/components/AddRichTextEditorNodeType.js.map +0 -1
  277. package/components/AddRichTextEditorPlugin.d.ts +0 -10
  278. package/components/AddRichTextEditorPlugin.js +0 -31
  279. package/components/AddRichTextEditorPlugin.js.map +0 -1
  280. package/components/AddToolbarAction.d.ts +0 -7
  281. package/components/AddToolbarAction.js +0 -33
  282. package/components/AddToolbarAction.js.map +0 -1
  283. package/components/Toolbar/HeadingToolbar.d.ts +0 -12
  284. package/components/Toolbar/HeadingToolbar.js +0 -23
  285. package/components/Toolbar/HeadingToolbar.js.map +0 -1
  286. package/components/Toolbar/ParagraphToolbar.d.ts +0 -12
  287. package/components/Toolbar/ParagraphToolbar.js +0 -23
  288. package/components/Toolbar/ParagraphToolbar.js.map +0 -1
  289. package/components/ToolbarPresets/HeadingToolbarPreset.d.ts +0 -2
  290. package/components/ToolbarPresets/HeadingToolbarPreset.js +0 -44
  291. package/components/ToolbarPresets/HeadingToolbarPreset.js.map +0 -1
  292. package/components/ToolbarPresets/ParagraphToolbarPreset.d.ts +0 -2
  293. package/components/ToolbarPresets/ParagraphToolbarPreset.js +0 -59
  294. package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +0 -1
  295. package/nodes/webinyNodes.d.ts +0 -2
  296. package/nodes/webinyNodes.js +0 -15
  297. package/nodes/webinyNodes.js.map +0 -1
  298. package/plugins/AutoLinkPlugin/AutoLinkPlugin.js +0 -46
  299. package/plugins/AutoLinkPlugin/AutoLinkPlugin.js.map +0 -1
  300. package/plugins/AutoLinkPlugin/index.d.ts +0 -1
  301. package/plugins/AutoLinkPlugin/index.js +0 -16
  302. package/plugins/AutoLinkPlugin/index.js.map +0 -1
  303. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.d.ts +0 -17
  304. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js +0 -88
  305. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js.map +0 -1
  306. package/plugins/ClickableLinkPlugin/index.d.ts +0 -1
  307. package/plugins/ClickableLinkPlugin/index.js +0 -16
  308. package/plugins/ClickableLinkPlugin/index.js.map +0 -1
  309. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.d.ts +0 -8
  310. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js +0 -34
  311. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +0 -1
  312. package/plugins/LexicalUpdateStatePlugin/index.d.ts +0 -1
  313. package/plugins/LexicalUpdateStatePlugin/index.js +0 -16
  314. package/plugins/LexicalUpdateStatePlugin/index.js.map +0 -1
  315. package/themes/webinyLexicalTheme.css +0 -422
  316. package/themes/webinyLexicalTheme.js +0 -107
  317. package/themes/webinyLexicalTheme.js.map +0 -1
  318. package/utils/generateInitialLexicalValue.d.ts +0 -5
  319. package/utils/generateInitialLexicalValue.js +0 -29
  320. package/utils/generateInitialLexicalValue.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ import type { LexicalCommand, NodeKey } from "lexical";
2
+ import type { ImageNodeProps } from "@webiny/lexical-nodes";
3
+ export interface ImagePayload extends ImageNodeProps {
4
+ key?: NodeKey;
5
+ }
6
+ export declare const INSERT_IMAGE_COMMAND: LexicalCommand<ImagePayload>;
@@ -0,0 +1,4 @@
1
+ import { createCommand } from "lexical";
2
+ export const INSERT_IMAGE_COMMAND = createCommand("INSERT_IMAGE_COMMAND");
3
+
4
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommand","INSERT_IMAGE_COMMAND"],"sources":["image.ts"],"sourcesContent":["import type { LexicalCommand, NodeKey } from \"lexical\";\nimport { createCommand } from \"lexical\";\nimport type { ImageNodeProps } from \"@webiny/lexical-nodes\";\n\nexport interface ImagePayload extends ImageNodeProps {\n key?: NodeKey;\n}\n\nexport const INSERT_IMAGE_COMMAND: LexicalCommand<ImagePayload> =\n createCommand(\"INSERT_IMAGE_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAOvC,OAAO,MAAMC,oBAAkD,GAC3DD,aAAa,CAAC,sBAAsB,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ export * from "./typography";
2
+ export * from "./image";
3
+ export * from "./list";
4
+ export * from "./quote";
5
+ export * from "./toolbar";
@@ -0,0 +1,7 @@
1
+ export * from "./typography";
2
+ export * from "./image";
3
+ export * from "./list";
4
+ export * from "./quote";
5
+ export * from "./toolbar";
6
+
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"~/commands/typography\";\nexport * from \"~/commands/image\";\nexport * from \"~/commands/list\";\nexport * from \"~/commands/quote\";\nexport * from \"~/commands/toolbar\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import type { LexicalCommand } from "lexical";
2
+ export type ListCommandPayload = {
3
+ themeStyleId?: string;
4
+ };
5
+ export declare const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload>;
6
+ export declare const INSERT_ORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload>;
7
+ export declare const REMOVE_LIST_COMMAND: LexicalCommand<void>;
@@ -0,0 +1,6 @@
1
+ import { createCommand } from "lexical";
2
+ export const INSERT_UNORDERED_LIST_COMMAND = createCommand("INSERT_UNORDERED_LIST_COMMAND");
3
+ export const INSERT_ORDERED_LIST_COMMAND = createCommand("INSERT_ORDERED_LIST_COMMAND");
4
+ export const REMOVE_LIST_COMMAND = createCommand("REMOVE_LIST_COMMAND");
5
+
6
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommand","INSERT_UNORDERED_LIST_COMMAND","INSERT_ORDERED_LIST_COMMAND","REMOVE_LIST_COMMAND"],"sources":["list.ts"],"sourcesContent":["import type { LexicalCommand } from \"lexical\";\nimport { createCommand } from \"lexical\";\n\nexport type ListCommandPayload = {\n themeStyleId?: string;\n};\n\nexport const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload> = createCommand(\n \"INSERT_UNORDERED_LIST_COMMAND\"\n);\n\nexport const INSERT_ORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload> = createCommand(\n \"INSERT_ORDERED_LIST_COMMAND\"\n);\n\nexport const REMOVE_LIST_COMMAND: LexicalCommand<void> = createCommand(\"REMOVE_LIST_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAMvC,OAAO,MAAMC,6BAAiE,GAAGD,aAAa,CAC1F,+BACJ,CAAC;AAED,OAAO,MAAME,2BAA+D,GAAGF,aAAa,CACxF,6BACJ,CAAC;AAED,OAAO,MAAMG,mBAAyC,GAAGH,aAAa,CAAC,qBAAqB,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ import type { LexicalCommand } from "lexical";
2
+ export type QuoteCommandPayload = {
3
+ themeStyleId: string;
4
+ };
5
+ export declare const INSERT_QUOTE_COMMAND: LexicalCommand<QuoteCommandPayload>;
@@ -0,0 +1,4 @@
1
+ import { createCommand } from "lexical";
2
+ export const INSERT_QUOTE_COMMAND = createCommand("INSERT_QUOTE_COMMAND");
3
+
4
+ //# sourceMappingURL=quote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommand","INSERT_QUOTE_COMMAND"],"sources":["quote.ts"],"sourcesContent":["import type { LexicalCommand } from \"lexical\";\nimport { createCommand } from \"lexical\";\n\nexport type QuoteCommandPayload = {\n themeStyleId: string;\n};\n\nexport const INSERT_QUOTE_COMMAND: LexicalCommand<QuoteCommandPayload> =\n createCommand(\"INSERT_QUOTE_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAMvC,OAAO,MAAMC,oBAAyD,GAClED,aAAa,CAAC,sBAAsB,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export declare const HIDE_FLOATING_TOOLBAR: import("lexical").LexicalCommand<unknown>;
@@ -0,0 +1,4 @@
1
+ import { createCommand } from "lexical";
2
+ export const HIDE_FLOATING_TOOLBAR = createCommand("HIDE_FLOATING_TOOLBAR_COMMAND");
3
+
4
+ //# sourceMappingURL=toolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommand","HIDE_FLOATING_TOOLBAR"],"sources":["toolbar.ts"],"sourcesContent":["import { createCommand } from \"lexical\";\n\nexport const HIDE_FLOATING_TOOLBAR = createCommand(\"HIDE_FLOATING_TOOLBAR_COMMAND\");\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,SAAS;AAEvC,OAAO,MAAMC,qBAAqB,GAAGD,aAAa,CAAC,+BAA+B,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import type { LexicalCommand, LexicalEditor, NodeKey } from "lexical";
2
+ import type { TypographyValue } from "@webiny/lexical-theme";
3
+ export declare const ADD_TYPOGRAPHY_COMMAND: LexicalCommand<TypographyPayload>;
4
+ export interface TypographyPayload {
5
+ value: TypographyValue;
6
+ caption?: LexicalEditor;
7
+ key?: NodeKey;
8
+ }
@@ -0,0 +1,4 @@
1
+ import { createCommand } from "lexical";
2
+ export const ADD_TYPOGRAPHY_COMMAND = createCommand("ADD_TYPOGRAPHY_COMMAND");
3
+
4
+ //# sourceMappingURL=typography.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommand","ADD_TYPOGRAPHY_COMMAND"],"sources":["typography.ts"],"sourcesContent":["import type { LexicalCommand, LexicalEditor, NodeKey } from \"lexical\";\nimport { createCommand } from \"lexical\";\nimport type { TypographyValue } from \"@webiny/lexical-theme\";\n\nexport const ADD_TYPOGRAPHY_COMMAND: LexicalCommand<TypographyPayload> =\n createCommand(\"ADD_TYPOGRAPHY_COMMAND\");\n\nexport interface TypographyPayload {\n value: TypographyValue;\n caption?: LexicalEditor;\n key?: NodeKey;\n}\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAGvC,OAAO,MAAMC,sBAAyD,GAClED,aAAa,CAAC,wBAAwB,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * In the "Heading" editor, we only want to support heading tags.
3
+ * However, when the editor is empty, and you start typing, Lexical automatically creates an empty "paragraph" node.
4
+ * This ensures that any paragraph node is automatically converted to a heading node.
5
+ */
6
+ export declare const EnsureHeadingTagPlugin: () => null;
@@ -0,0 +1,20 @@
1
+ import { useEffect } from "react";
2
+ import { ParagraphNode, $createHeadingNode } from "@webiny/lexical-nodes";
3
+ import { useRichTextEditor } from "../../hooks";
4
+
5
+ /**
6
+ * In the "Heading" editor, we only want to support heading tags.
7
+ * However, when the editor is empty, and you start typing, Lexical automatically creates an empty "paragraph" node.
8
+ * This ensures that any paragraph node is automatically converted to a heading node.
9
+ */
10
+ export const EnsureHeadingTagPlugin = () => {
11
+ const {
12
+ editor
13
+ } = useRichTextEditor();
14
+ useEffect(() => editor.registerNodeTransform(ParagraphNode, node => {
15
+ node.replace($createHeadingNode("h1"), true);
16
+ }), []);
17
+ return null;
18
+ };
19
+
20
+ //# sourceMappingURL=EnsureHeadingTagPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","ParagraphNode","$createHeadingNode","useRichTextEditor","EnsureHeadingTagPlugin","editor","registerNodeTransform","node","replace"],"sources":["EnsureHeadingTagPlugin.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { ParagraphNode, $createHeadingNode } from \"@webiny/lexical-nodes\";\nimport { useRichTextEditor } from \"~/hooks\";\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,7 +1,7 @@
1
1
  import React from "react";
2
- import { RichTextEditorProps } from "./RichTextEditor";
2
+ import type { RichTextEditorProps } from "./RichTextEditor";
3
3
  interface HeadingEditorProps extends RichTextEditorProps {
4
4
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
5
5
  }
6
- export declare const HeadingEditor: React.FC<HeadingEditorProps>;
6
+ export declare const HeadingEditor: ({ tag, placeholder, ...rest }: HeadingEditorProps) => React.JSX.Element;
7
7
  export {};
@@ -1,28 +1,22 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.HeadingEditor = void 0;
8
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
- var _react = _interopRequireDefault(require("react"));
10
- var _LexicalLinkPlugin = require("@lexical/react/LexicalLinkPlugin");
11
- var _ClickableLinkPlugin = require("../../plugins/ClickableLinkPlugin/ClickableLinkPlugin");
12
- var _FloatingLinkEditorPlugin = require("../../plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin");
13
- var _HeadingToolbar = require("../Toolbar/HeadingToolbar");
14
- var _RichTextEditor = require("./RichTextEditor");
15
- var _excluded = ["tag", "placeholder"];
16
- var HeadingEditor = function HeadingEditor(_ref) {
17
- var tag = _ref.tag,
18
- placeholder = _ref.placeholder,
19
- rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
20
- return /*#__PURE__*/_react.default.createElement(_RichTextEditor.RichTextEditor, Object.assign({
21
- toolbar: /*#__PURE__*/_react.default.createElement(_HeadingToolbar.HeadingToolbar, null),
22
- tag: tag !== null && tag !== void 0 ? tag : "h1",
23
- placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Enter your heading text here..."
24
- }, rest), /*#__PURE__*/_react.default.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/_react.default.createElement(_ClickableLinkPlugin.ClickableLinkPlugin, null), /*#__PURE__*/_react.default.createElement(_FloatingLinkEditorPlugin.FloatingLinkEditorPlugin, {
25
- anchorElem: document.body
26
- }));
1
+ import React from "react";
2
+ import { RichTextEditor } from "./RichTextEditor";
3
+ import { Toolbar } from "../Toolbar/Toolbar";
4
+ import { EnsureHeadingTagPlugin } from "./EnsureHeadingTagPlugin";
5
+ const styles = {
6
+ padding: 5
7
+ };
8
+ export const HeadingEditor = ({
9
+ tag,
10
+ placeholder,
11
+ ...rest
12
+ }) => {
13
+ return /*#__PURE__*/React.createElement(RichTextEditor, Object.assign({
14
+ toolbar: /*#__PURE__*/React.createElement(Toolbar, null),
15
+ tag: tag ?? "h1",
16
+ placeholder: placeholder ?? "Enter your heading text here..."
17
+ }, rest, {
18
+ styles: styles
19
+ }), /*#__PURE__*/React.createElement(EnsureHeadingTagPlugin, null), rest?.children);
27
20
  };
28
- exports.HeadingEditor = HeadingEditor;
21
+
22
+ //# sourceMappingURL=HeadingEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_LexicalLinkPlugin","_ClickableLinkPlugin","_FloatingLinkEditorPlugin","_HeadingToolbar","_RichTextEditor","_excluded","HeadingEditor","_ref","tag","placeholder","rest","_objectWithoutProperties2","default","createElement","RichTextEditor","Object","assign","toolbar","HeadingToolbar","LinkPlugin","ClickableLinkPlugin","FloatingLinkEditorPlugin","anchorElem","document","body","exports"],"sources":["HeadingEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { LinkPlugin } from \"@lexical/react/LexicalLinkPlugin\";\nimport { ClickableLinkPlugin } from \"~/plugins/ClickableLinkPlugin/ClickableLinkPlugin\";\nimport { FloatingLinkEditorPlugin } from \"~/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin\";\nimport { HeadingToolbar } from \"~/components/Toolbar/HeadingToolbar\";\nimport { RichTextEditor, RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\n\ninterface HeadingEditorProps extends RichTextEditorProps {\n tag?: \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n}\n\nexport const HeadingEditor: React.FC<HeadingEditorProps> = ({ tag, placeholder, ...rest }) => {\n return (\n <RichTextEditor\n toolbar={<HeadingToolbar />}\n tag={tag ?? \"h1\"}\n placeholder={placeholder ?? \"Enter your heading text here...\"}\n {...rest}\n >\n <LinkPlugin />\n <ClickableLinkPlugin />\n <FloatingLinkEditorPlugin anchorElem={document.body} />\n </RichTextEditor>\n );\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,yBAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AAAyF,IAAAM,SAAA;AAMlF,IAAMC,aAA2C,GAAG,SAA9CA,aAA2CA,CAAAC,IAAA,EAAsC;EAAA,IAAhCC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IAAKC,IAAI,OAAAC,yBAAA,CAAAC,OAAA,EAAAL,IAAA,EAAAF,SAAA;EACnF,oBACIR,MAAA,CAAAe,OAAA,CAAAC,aAAA,CAACT,eAAA,CAAAU,cAAc,EAAAC,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAEpB,MAAA,CAAAe,OAAA,CAAAC,aAAA,CAACV,eAAA,CAAAe,cAAc,OAAI;IAC5BV,GAAG,EAAEA,GAAG,aAAHA,GAAG,cAAHA,GAAG,GAAI,IAAK;IACjBC,WAAW,EAAEA,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAI;EAAkC,GAC1DC,IAAI,gBAERb,MAAA,CAAAe,OAAA,CAAAC,aAAA,CAACb,kBAAA,CAAAmB,UAAU,OAAG,eACdtB,MAAA,CAAAe,OAAA,CAAAC,aAAA,CAACZ,oBAAA,CAAAmB,mBAAmB,OAAG,eACvBvB,MAAA,CAAAe,OAAA,CAAAC,aAAA,CAACX,yBAAA,CAAAmB,wBAAwB;IAACC,UAAU,EAAEC,QAAQ,CAACC;EAAK,EAAG,CAC1C;AAEzB,CAAC;AAACC,OAAA,CAAAnB,aAAA,GAAAA,aAAA"}
1
+ {"version":3,"names":["React","RichTextEditor","Toolbar","EnsureHeadingTagPlugin","styles","padding","HeadingEditor","tag","placeholder","rest","createElement","Object","assign","toolbar","children"],"sources":["HeadingEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport type { RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\nimport { RichTextEditor } from \"~/components/Editor/RichTextEditor\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\nimport { EnsureHeadingTagPlugin } from \"~/components/Editor/EnsureHeadingTagPlugin\";\n\ninterface HeadingEditorProps extends RichTextEditorProps {\n tag?: \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n}\n\nconst styles = { padding: 5 };\n\nexport const HeadingEditor = ({ tag, placeholder, ...rest }: HeadingEditorProps) => {\n return (\n <RichTextEditor\n toolbar={<Toolbar />}\n tag={tag ?? \"h1\"}\n placeholder={placeholder ?? \"Enter your heading text here...\"}\n {...rest}\n styles={styles}\n >\n <EnsureHeadingTagPlugin />\n {rest?.children}\n </RichTextEditor>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,cAAc;AACvB,SAASC,OAAO;AAChB,SAASC,sBAAsB;AAM/B,MAAMC,MAAM,GAAG;EAAEC,OAAO,EAAE;AAAE,CAAC;AAE7B,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEC,GAAG;EAAEC,WAAW;EAAE,GAAGC;AAAyB,CAAC,KAAK;EAChF,oBACIT,KAAA,CAAAU,aAAA,CAACT,cAAc,EAAAU,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAEb,KAAA,CAAAU,aAAA,CAACR,OAAO,MAAE,CAAE;IACrBK,GAAG,EAAEA,GAAG,IAAI,IAAK;IACjBC,WAAW,EAAEA,WAAW,IAAI;EAAkC,GAC1DC,IAAI;IACRL,MAAM,EAAEA;EAAO,iBAEfJ,KAAA,CAAAU,aAAA,CAACP,sBAAsB,MAAE,CAAC,EACzBM,IAAI,EAAEK,QACK,CAAC;AAEzB,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
- import { RichTextEditorProps } from "./RichTextEditor";
2
+ import type { RichTextEditorProps } from "./RichTextEditor";
3
3
  interface ParagraphLexicalEditorProps extends RichTextEditorProps {
4
4
  tag?: "p";
5
5
  }
6
- declare const ParagraphEditor: React.FC<ParagraphLexicalEditorProps>;
6
+ declare const ParagraphEditor: ({ placeholder, tag, ...rest }: ParagraphLexicalEditorProps) => React.JSX.Element;
7
7
  export { ParagraphEditor };
@@ -1,30 +1,22 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.ParagraphEditor = void 0;
8
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
- var _react = _interopRequireDefault(require("react"));
10
- var _LexicalListPlugin = require("@lexical/react/LexicalListPlugin");
11
- var _CodeHighlightPlugin = require("../../plugins/CodeHighlightPlugin/CodeHighlightPlugin");
12
- var _LexicalLinkPlugin = require("@lexical/react/LexicalLinkPlugin");
13
- var _FloatingLinkEditorPlugin = require("../../plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin");
14
- var _ClickableLinkPlugin = require("../../plugins/ClickableLinkPlugin/ClickableLinkPlugin");
15
- var _ParagraphToolbar = require("../Toolbar/ParagraphToolbar");
16
- var _RichTextEditor = require("./RichTextEditor");
17
- var _excluded = ["placeholder", "tag"];
18
- var ParagraphEditor = function ParagraphEditor(_ref) {
19
- var placeholder = _ref.placeholder,
20
- tag = _ref.tag,
21
- rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
22
- return /*#__PURE__*/_react.default.createElement(_RichTextEditor.RichTextEditor, Object.assign({
23
- toolbar: /*#__PURE__*/_react.default.createElement(_ParagraphToolbar.ParagraphToolbar, null),
24
- tag: tag !== null && tag !== void 0 ? tag : "p",
25
- placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Enter your text here..."
26
- }, rest), /*#__PURE__*/_react.default.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/_react.default.createElement(_CodeHighlightPlugin.CodeHighlightPlugin, null), /*#__PURE__*/_react.default.createElement(_ClickableLinkPlugin.ClickableLinkPlugin, null), /*#__PURE__*/_react.default.createElement(_FloatingLinkEditorPlugin.FloatingLinkEditorPlugin, {
27
- anchorElem: document.body
28
- }), /*#__PURE__*/_react.default.createElement(_LexicalListPlugin.ListPlugin, null));
1
+ import React from "react";
2
+ import { RichTextEditor } from "./RichTextEditor";
3
+ import { Toolbar } from "../Toolbar/Toolbar";
4
+ const styles = {
5
+ padding: 5
6
+ };
7
+ const ParagraphEditor = ({
8
+ placeholder,
9
+ tag,
10
+ ...rest
11
+ }) => {
12
+ return /*#__PURE__*/React.createElement(RichTextEditor, Object.assign({
13
+ toolbar: /*#__PURE__*/React.createElement(Toolbar, null),
14
+ tag: tag ?? "p",
15
+ placeholder: placeholder ?? "Enter your text here..."
16
+ }, rest, {
17
+ styles: styles
18
+ }), rest?.children);
29
19
  };
30
- exports.ParagraphEditor = ParagraphEditor;
20
+ export { ParagraphEditor };
21
+
22
+ //# sourceMappingURL=ParagraphEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_LexicalListPlugin","_CodeHighlightPlugin","_LexicalLinkPlugin","_FloatingLinkEditorPlugin","_ClickableLinkPlugin","_ParagraphToolbar","_RichTextEditor","_excluded","ParagraphEditor","_ref","placeholder","tag","rest","_objectWithoutProperties2","default","createElement","RichTextEditor","Object","assign","toolbar","ParagraphToolbar","LinkPlugin","CodeHighlightPlugin","ClickableLinkPlugin","FloatingLinkEditorPlugin","anchorElem","document","body","ListPlugin","exports"],"sources":["ParagraphEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { ListPlugin } from \"@lexical/react/LexicalListPlugin\";\nimport { CodeHighlightPlugin } from \"~/plugins/CodeHighlightPlugin/CodeHighlightPlugin\";\nimport { LinkPlugin } from \"@lexical/react/LexicalLinkPlugin\";\nimport { FloatingLinkEditorPlugin } from \"~/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin\";\nimport { ClickableLinkPlugin } from \"~/plugins/ClickableLinkPlugin/ClickableLinkPlugin\";\nimport { ParagraphToolbar } from \"~/components/Toolbar/ParagraphToolbar\";\nimport { RichTextEditor, RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\n\ninterface ParagraphLexicalEditorProps extends RichTextEditorProps {\n tag?: \"p\";\n}\n\nconst ParagraphEditor: React.FC<ParagraphLexicalEditorProps> = ({ placeholder, tag, ...rest }) => {\n return (\n <RichTextEditor\n toolbar={<ParagraphToolbar />}\n tag={tag ?? \"p\"}\n placeholder={placeholder ?? \"Enter your text here...\"}\n {...rest}\n >\n <LinkPlugin />\n <CodeHighlightPlugin />\n <ClickableLinkPlugin />\n <FloatingLinkEditorPlugin anchorElem={document.body} />\n <ListPlugin />\n </RichTextEditor>\n );\n};\n\nexport { ParagraphEditor };\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,yBAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AAAyF,IAAAQ,SAAA;AAMzF,IAAMC,eAAsD,GAAG,SAAzDA,eAAsDA,CAAAC,IAAA,EAAsC;EAAA,IAAhCC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IAAEC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IAAKC,IAAI,OAAAC,yBAAA,CAAAC,OAAA,EAAAL,IAAA,EAAAF,SAAA;EACvF,oBACIV,MAAA,CAAAiB,OAAA,CAAAC,aAAA,CAACT,eAAA,CAAAU,cAAc,EAAAC,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAEtB,MAAA,CAAAiB,OAAA,CAAAC,aAAA,CAACV,iBAAA,CAAAe,gBAAgB,OAAI;IAC9BT,GAAG,EAAEA,GAAG,aAAHA,GAAG,cAAHA,GAAG,GAAI,GAAI;IAChBD,WAAW,EAAEA,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAI;EAA0B,GAClDE,IAAI,gBAERf,MAAA,CAAAiB,OAAA,CAAAC,aAAA,CAACb,kBAAA,CAAAmB,UAAU,OAAG,eACdxB,MAAA,CAAAiB,OAAA,CAAAC,aAAA,CAACd,oBAAA,CAAAqB,mBAAmB,OAAG,eACvBzB,MAAA,CAAAiB,OAAA,CAAAC,aAAA,CAACX,oBAAA,CAAAmB,mBAAmB,OAAG,eACvB1B,MAAA,CAAAiB,OAAA,CAAAC,aAAA,CAACZ,yBAAA,CAAAqB,wBAAwB;IAACC,UAAU,EAAEC,QAAQ,CAACC;EAAK,EAAG,eACvD9B,MAAA,CAAAiB,OAAA,CAAAC,aAAA,CAACf,kBAAA,CAAA4B,UAAU,OAAG,CACD;AAEzB,CAAC;AAACC,OAAA,CAAArB,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"names":["React","RichTextEditor","Toolbar","styles","padding","ParagraphEditor","placeholder","tag","rest","createElement","Object","assign","toolbar","children"],"sources":["ParagraphEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport type { RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\nimport { RichTextEditor } from \"~/components/Editor/RichTextEditor\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\n\ninterface ParagraphLexicalEditorProps extends RichTextEditorProps {\n tag?: \"p\";\n}\n\nconst styles = { padding: 5 };\n\nconst ParagraphEditor = ({ placeholder, tag, ...rest }: ParagraphLexicalEditorProps) => {\n return (\n <RichTextEditor\n toolbar={<Toolbar />}\n tag={tag ?? \"p\"}\n placeholder={placeholder ?? \"Enter your text here...\"}\n {...rest}\n styles={styles}\n >\n {rest?.children}\n </RichTextEditor>\n );\n};\n\nexport { ParagraphEditor };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,cAAc;AACvB,SAASC,OAAO;AAMhB,MAAMC,MAAM,GAAG;EAAEC,OAAO,EAAE;AAAE,CAAC;AAE7B,MAAMC,eAAe,GAAGA,CAAC;EAAEC,WAAW;EAAEC,GAAG;EAAE,GAAGC;AAAkC,CAAC,KAAK;EACpF,oBACIR,KAAA,CAAAS,aAAA,CAACR,cAAc,EAAAS,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAEZ,KAAA,CAAAS,aAAA,CAACP,OAAO,MAAE,CAAE;IACrBK,GAAG,EAAEA,GAAG,IAAI,GAAI;IAChBD,WAAW,EAAEA,WAAW,IAAI;EAA0B,GAClDE,IAAI;IACRL,MAAM,EAAEA;EAAO,IAEdK,IAAI,EAAEK,QACK,CAAC;AAEzB,CAAC;AAED,SAASR,eAAe","ignoreList":[]}
@@ -1,23 +1,49 @@
1
1
  import React from "react";
2
- import { LexicalValue } from "../../types";
3
- import { Klass, LexicalNode } from "lexical";
2
+ import type { CSSObject } from "@emotion/react";
3
+ import type { Klass, LexicalNode } from "lexical";
4
+ import type { EditorTheme, ThemeEmotionMap } from "@webiny/lexical-theme";
5
+ import type { LexicalValue, ToolbarActionPlugin } from "../../types";
4
6
  export interface RichTextEditorProps {
5
- toolbar?: React.ReactNode;
6
- tag?: string;
7
- onChange?: (json: LexicalValue) => void;
8
- value: LexicalValue | null;
7
+ children?: React.ReactNode | React.ReactNode[];
8
+ classes?: string;
9
+ contentEditableStyles?: React.CSSProperties;
9
10
  focus?: boolean;
10
- placeholder?: string;
11
+ height?: number | string;
11
12
  nodes?: Klass<LexicalNode>[];
12
- /**
13
- * @description Lexical plugins
14
- */
15
- children?: React.ReactNode | React.ReactNode[];
16
13
  onBlur?: (editorState: LexicalValue) => void;
17
- height?: number | string;
14
+ onChange?: (json: LexicalValue) => void;
15
+ placeholder?: string;
16
+ placeholderStyles?: React.CSSProperties;
17
+ staticToolbar?: React.ReactNode;
18
+ styles?: React.CSSProperties;
19
+ tag?: string;
20
+ theme: EditorTheme;
21
+ themeEmotionMap?: ThemeEmotionMap;
22
+ toolbarActionPlugins?: ToolbarActionPlugin[];
23
+ themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;
24
+ toolbar?: React.ReactNode;
25
+ value: LexicalValue | null | undefined;
18
26
  width?: number | string;
19
27
  }
20
28
  /**
21
29
  * @description Main editor container
22
30
  */
23
- export declare const RichTextEditor: import("@webiny/react-composition").ComposableFC<RichTextEditorProps>;
31
+ export declare const RichTextEditor: ((props: RichTextEditorProps) => React.JSX.Element) & {
32
+ original: (props: RichTextEditorProps) => React.JSX.Element;
33
+ originalName: string;
34
+ displayName: string;
35
+ } & {
36
+ original: ((props: RichTextEditorProps) => React.JSX.Element) & {
37
+ original: (props: RichTextEditorProps) => React.JSX.Element;
38
+ originalName: string;
39
+ displayName: string;
40
+ };
41
+ originalName: string;
42
+ displayName: string;
43
+ } & {
44
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<((props: RichTextEditorProps) => React.JSX.Element) & {
45
+ original: (props: RichTextEditorProps) => React.JSX.Element;
46
+ originalName: string;
47
+ displayName: string;
48
+ }>) => (props: unknown) => React.JSX.Element;
49
+ };
@@ -1,107 +1,133 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.RichTextEditor = void 0;
9
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _react = _interopRequireWildcard(require("react"));
13
- var _Placeholder = require("../../ui/Placeholder");
14
- var _generateInitialLexicalValue = require("../../utils/generateInitialLexicalValue");
15
- var _webinyNodes = require("../../nodes/webinyNodes");
16
- var _webinyLexicalTheme = require("../../themes/webinyLexicalTheme");
17
- var _LexicalComposer = require("@lexical/react/LexicalComposer");
18
- var _LexicalOnChangePlugin = require("@lexical/react/LexicalOnChangePlugin");
19
- var _LexicalAutoFocusPlugin = require("@lexical/react/LexicalAutoFocusPlugin");
20
- var _LexicalClearEditorPlugin = require("@lexical/react/LexicalClearEditorPlugin");
21
- var _LexicalRichTextPlugin = require("@lexical/react/LexicalRichTextPlugin");
22
- var _LexicalErrorBoundary = _interopRequireDefault(require("@lexical/react/LexicalErrorBoundary"));
23
- var _reactComposition = require("@webiny/react-composition");
24
- var _LexicalContentEditable = require("@lexical/react/LexicalContentEditable");
25
- var _RichTextEditorContext = require("../../context/RichTextEditorContext");
26
- var _isValidLexicalData = require("../../utils/isValidLexicalData");
27
- var _LexicalUpdateStatePlugin = require("../../plugins/LexicalUpdateStatePlugin");
28
- var _BlurEventPlugin = require("../../plugins/BlurEventPlugin/BlurEventPlugin");
29
- var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
30
- var toolbar = _ref.toolbar,
31
- onChange = _ref.onChange,
32
- value = _ref.value,
33
- nodes = _ref.nodes,
34
- placeholder = _ref.placeholder,
35
- children = _ref.children,
36
- onBlur = _ref.onBlur,
37
- focus = _ref.focus,
38
- width = _ref.width,
39
- height = _ref.height;
40
- var placeholderElem = /*#__PURE__*/_react.default.createElement(_Placeholder.Placeholder, null, placeholder || "Enter text...");
41
- var scrollRef = (0, _react.useRef)(null);
42
- var _useState = (0, _react.useState)(undefined),
43
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
44
- floatingAnchorElem = _useState2[0],
45
- setFloatingAnchorElem = _useState2[1];
46
- var onRef = function onRef(_floatingAnchorElem) {
1
+ import React, { Fragment, useRef, useState } from "react";
2
+ import { css } from "emotion";
3
+ import { LexicalComposer } from "@lexical/react/LexicalComposer";
4
+ import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
5
+ import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
6
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
7
+ import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
8
+ import { makeDecoratable } from "@webiny/react-composition";
9
+ import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
10
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
11
+ import { createTheme, toTypographyEmotionMap } from "@webiny/lexical-theme";
12
+ import { allNodes } from "@webiny/lexical-nodes";
13
+ import { RichTextEditorProvider } from "../../context/RichTextEditorContext";
14
+ import { BlurEventPlugin } from "../../plugins/BlurEventPlugin/BlurEventPlugin";
15
+ import { Placeholder } from "../../ui/Placeholder";
16
+ import { SharedHistoryContext, useSharedHistoryContext } from "../../context/SharedHistoryContext";
17
+ import { LexicalEditorWithConfig, useLexicalEditorConfig } from "../LexicalEditorConfig/LexicalEditorConfig";
18
+ import { StateHandlingPlugin } from "../../plugins/StateHandlingPlugin";
19
+ const BaseRichTextEditor = ({
20
+ toolbar,
21
+ staticToolbar,
22
+ onChange,
23
+ nodes,
24
+ placeholder,
25
+ children,
26
+ onBlur,
27
+ focus,
28
+ styles,
29
+ width,
30
+ height,
31
+ contentEditableStyles,
32
+ placeholderStyles,
33
+ ...props
34
+ }) => {
35
+ const themeEmotionMap = props.themeEmotionMap ?? toTypographyEmotionMap(css, props.theme, props.themeStylesTransformer);
36
+ const editorTheme = useRef(createTheme(props.theme));
37
+ const config = useLexicalEditorConfig();
38
+ const {
39
+ historyState
40
+ } = useSharedHistoryContext();
41
+ const placeholderElem = /*#__PURE__*/React.createElement(Placeholder, {
42
+ styles: placeholderStyles
43
+ }, placeholder || "Enter text...");
44
+ const scrollRef = useRef(null);
45
+ const [floatingAnchorElem, setFloatingAnchorElem] = useState(undefined);
46
+ const onRef = _floatingAnchorElem => {
47
47
  if (_floatingAnchorElem !== null) {
48
48
  setFloatingAnchorElem(_floatingAnchorElem);
49
49
  }
50
50
  };
51
- var sizeStyle = {
51
+ const sizeStyle = {
52
52
  height: height || "",
53
53
  width: width || ""
54
54
  };
55
- var initialConfig = {
56
- editorState: (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)(),
55
+ const configNodes = config.nodes.map(node => node.node);
56
+ const configPlugins = config.plugins.map(plugin => /*#__PURE__*/React.createElement(Fragment, {
57
+ key: plugin.name
58
+ }, plugin.element));
59
+ const initialConfig = {
60
+ editorState: null,
57
61
  namespace: "webiny",
58
- onError: function onError(error) {
59
- throw error;
62
+ onError: () => {
63
+ // Ignore errors. We don't want to break the app because of errors caused by config/value updates.
64
+ // These are usually resolved in the next component render cycle.
60
65
  },
61
- nodes: [].concat((0, _toConsumableArray2.default)(_webinyNodes.WebinyNodes), (0, _toConsumableArray2.default)(nodes || [])),
62
- theme: _webinyLexicalTheme.theme
66
+ nodes: [...allNodes, ...configNodes, ...(nodes || [])],
67
+ theme: {
68
+ ...editorTheme.current,
69
+ emotionMap: themeEmotionMap
70
+ }
63
71
  };
64
- function handleOnChange(editorState, editor) {
65
- editorState.read(function () {
66
- if (typeof onChange === "function") {
67
- var _editorState = editor.getEditorState();
68
- onChange(JSON.stringify(_editorState.toJSON()));
72
+ return (
73
+ /*#__PURE__*/
74
+ /**
75
+ * Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future
76
+ * updates to the config will be ignored. This is a problem because we pull in Nodes from our config,
77
+ * and initially, there can be multiple re-renders, while the config object is settled.
78
+ *
79
+ * To bypass this issue, we generate a naive `key` based on the number of Nodes.
80
+ */
81
+ React.createElement(SharedHistoryContext, null, /*#__PURE__*/React.createElement(LexicalComposer, {
82
+ initialConfig: initialConfig,
83
+ key: initialConfig.nodes.length
84
+ }, /*#__PURE__*/React.createElement(RichTextEditorProvider, {
85
+ theme: props.theme,
86
+ themeEmotionMap: themeEmotionMap,
87
+ toolbarActionPlugins: props.toolbarActionPlugins
88
+ }, staticToolbar ? staticToolbar : null, /*#__PURE__*/React.createElement("div", {
89
+ /* This className is necessary for targeting of editor container from CSS files. */
90
+ className: "editor-shell",
91
+ ref: scrollRef,
92
+ style: {
93
+ ...styles,
94
+ ...sizeStyle,
95
+ overflow: "auto",
96
+ position: "relative"
69
97
  }
70
- });
71
- }
72
- return /*#__PURE__*/_react.default.createElement(_LexicalComposer.LexicalComposer, {
73
- initialConfig: initialConfig
74
- }, /*#__PURE__*/_react.default.createElement("div", {
75
- ref: scrollRef,
76
- style: (0, _objectSpread2.default)({}, sizeStyle)
77
- }, /*#__PURE__*/_react.default.createElement(_LexicalOnChangePlugin.OnChangePlugin, {
78
- onChange: handleOnChange
79
- }), value && /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.LexicalUpdateStatePlugin, {
80
- value: value
81
- }), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null), onBlur && /*#__PURE__*/_react.default.createElement(_BlurEventPlugin.BlurEventPlugin, {
82
- onBlur: onBlur
83
- }), focus && /*#__PURE__*/_react.default.createElement(_LexicalAutoFocusPlugin.AutoFocusPlugin, null), children, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
84
- contentEditable: /*#__PURE__*/_react.default.createElement("div", {
85
- className: "editor-scroller",
86
- style: (0, _objectSpread2.default)({}, sizeStyle)
87
- }, /*#__PURE__*/_react.default.createElement("div", {
88
- className: "editor",
89
- ref: onRef,
90
- style: (0, _objectSpread2.default)({}, sizeStyle)
91
- }, /*#__PURE__*/_react.default.createElement(_LexicalContentEditable.ContentEditable, {
92
- style: (0, _objectSpread2.default)({
93
- outline: 0
94
- }, sizeStyle)
95
- }))),
96
- placeholder: placeholderElem,
97
- ErrorBoundary: _LexicalErrorBoundary.default
98
- }), floatingAnchorElem && toolbar));
98
+ }, /*#__PURE__*/React.createElement(StateHandlingPlugin, {
99
+ value: props.value,
100
+ onChange: onChange
101
+ }), /*#__PURE__*/React.createElement(ClearEditorPlugin, null), /*#__PURE__*/React.createElement(HistoryPlugin, {
102
+ externalHistoryState: historyState
103
+ }), onBlur && /*#__PURE__*/React.createElement(BlurEventPlugin, {
104
+ onBlur: onBlur
105
+ }), focus && /*#__PURE__*/React.createElement(AutoFocusPlugin, null), configPlugins, children, /*#__PURE__*/React.createElement(RichTextPlugin, {
106
+ contentEditable: /*#__PURE__*/React.createElement("div", {
107
+ className: "editor-scroller",
108
+ style: {
109
+ ...sizeStyle
110
+ }
111
+ }, /*#__PURE__*/React.createElement("div", {
112
+ className: "editor",
113
+ ref: onRef
114
+ }, /*#__PURE__*/React.createElement(ContentEditable, {
115
+ style: {
116
+ outline: 0,
117
+ ...contentEditableStyles
118
+ }
119
+ }))),
120
+ placeholder: placeholderElem,
121
+ ErrorBoundary: LexicalErrorBoundary
122
+ }), floatingAnchorElem && toolbar))))
123
+ );
99
124
  };
100
125
 
101
126
  /**
102
127
  * @description Main editor container
103
128
  */
104
- var RichTextEditor = (0, _reactComposition.makeComposable)("RichTextEditor", function (props) {
105
- return /*#__PURE__*/_react.default.createElement(_RichTextEditorContext.RichTextEditorProvider, null, /*#__PURE__*/_react.default.createElement(BaseRichTextEditor, props));
129
+ export const RichTextEditor = makeDecoratable("RichTextEditor", props => {
130
+ return /*#__PURE__*/React.createElement(LexicalEditorWithConfig, null, /*#__PURE__*/React.createElement(BaseRichTextEditor, props));
106
131
  });
107
- exports.RichTextEditor = RichTextEditor;
132
+
133
+ //# sourceMappingURL=RichTextEditor.js.map