@webiny/lexical-editor 0.0.0-unstable.06b2ede40f

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 (308) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -0
  3. package/commands/image.d.ts +6 -0
  4. package/commands/image.js +4 -0
  5. package/commands/image.js.map +1 -0
  6. package/commands/index.d.ts +5 -0
  7. package/commands/index.js +7 -0
  8. package/commands/index.js.map +1 -0
  9. package/commands/list.d.ts +7 -0
  10. package/commands/list.js +6 -0
  11. package/commands/list.js.map +1 -0
  12. package/commands/quote.d.ts +5 -0
  13. package/commands/quote.js +4 -0
  14. package/commands/quote.js.map +1 -0
  15. package/commands/toolbar.d.ts +1 -0
  16. package/commands/toolbar.js +4 -0
  17. package/commands/toolbar.js.map +1 -0
  18. package/commands/typography.d.ts +8 -0
  19. package/commands/typography.js +4 -0
  20. package/commands/typography.js.map +1 -0
  21. package/components/Editor/EnsureHeadingTagPlugin.d.ts +6 -0
  22. package/components/Editor/EnsureHeadingTagPlugin.js +20 -0
  23. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -0
  24. package/components/Editor/HeadingEditor.d.ts +7 -0
  25. package/components/Editor/HeadingEditor.js +22 -0
  26. package/components/Editor/HeadingEditor.js.map +1 -0
  27. package/components/Editor/ParagraphEditor.d.ts +7 -0
  28. package/components/Editor/ParagraphEditor.js +22 -0
  29. package/components/Editor/ParagraphEditor.js.map +1 -0
  30. package/components/Editor/RichTextEditor.d.ts +49 -0
  31. package/components/Editor/RichTextEditor.js +133 -0
  32. package/components/Editor/RichTextEditor.js.map +1 -0
  33. package/components/Editor/normalizeInputValue.d.ts +6 -0
  34. package/components/Editor/normalizeInputValue.js +16 -0
  35. package/components/Editor/normalizeInputValue.js.map +1 -0
  36. package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +20 -0
  37. package/components/LexicalEditorConfig/LexicalEditorConfig.js +63 -0
  38. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
  39. package/components/LexicalEditorConfig/components/Node.d.ts +14 -0
  40. package/components/LexicalEditorConfig/components/Node.js +30 -0
  41. package/components/LexicalEditorConfig/components/Node.js.map +1 -0
  42. package/components/LexicalEditorConfig/components/Plugin.d.ts +13 -0
  43. package/components/LexicalEditorConfig/components/Plugin.js +30 -0
  44. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -0
  45. package/components/LexicalEditorConfig/components/ToolbarElement.d.ts +13 -0
  46. package/components/LexicalEditorConfig/components/ToolbarElement.js +30 -0
  47. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -0
  48. package/components/LexicalHtmlRenderer.d.ts +14 -0
  49. package/components/LexicalHtmlRenderer.js +55 -0
  50. package/components/LexicalHtmlRenderer.js.map +1 -0
  51. package/components/Toolbar/StaticToolbar.css +260 -0
  52. package/components/Toolbar/StaticToolbar.d.ts +5 -0
  53. package/components/Toolbar/StaticToolbar.js +22 -0
  54. package/components/Toolbar/StaticToolbar.js.map +1 -0
  55. package/components/Toolbar/Toolbar.css +643 -0
  56. package/components/Toolbar/Toolbar.d.ts +6 -0
  57. package/components/Toolbar/Toolbar.js +148 -0
  58. package/components/Toolbar/Toolbar.js.map +1 -0
  59. package/components/ToolbarActions/BoldAction.d.ts +2 -0
  60. package/components/ToolbarActions/BoldAction.js +25 -0
  61. package/components/ToolbarActions/BoldAction.js.map +1 -0
  62. package/components/ToolbarActions/BulletListAction.d.ts +2 -0
  63. package/components/ToolbarActions/BulletListAction.js +40 -0
  64. package/components/ToolbarActions/BulletListAction.js.map +1 -0
  65. package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -0
  66. package/components/ToolbarActions/CodeHighlightAction.js +25 -0
  67. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -0
  68. package/components/ToolbarActions/FontColorAction.d.ts +29 -0
  69. package/components/ToolbarActions/FontColorAction.js +50 -0
  70. package/components/ToolbarActions/FontColorAction.js.map +1 -0
  71. package/components/ToolbarActions/FontSizeAction.d.ts +14 -0
  72. package/components/ToolbarActions/FontSizeAction.js +91 -0
  73. package/components/ToolbarActions/FontSizeAction.js.map +1 -0
  74. package/components/ToolbarActions/ImageAction.d.ts +2 -0
  75. package/components/ToolbarActions/ImageAction.js +37 -0
  76. package/components/ToolbarActions/ImageAction.js.map +1 -0
  77. package/components/ToolbarActions/ItalicAction.d.ts +2 -0
  78. package/components/ToolbarActions/ItalicAction.js +25 -0
  79. package/components/ToolbarActions/ItalicAction.js.map +1 -0
  80. package/components/ToolbarActions/LinkAction.d.ts +2 -0
  81. package/components/ToolbarActions/LinkAction.js +37 -0
  82. package/components/ToolbarActions/LinkAction.js.map +1 -0
  83. package/components/ToolbarActions/NumberedListAction.d.ts +2 -0
  84. package/components/ToolbarActions/NumberedListAction.js +48 -0
  85. package/components/ToolbarActions/NumberedListAction.js.map +1 -0
  86. package/components/ToolbarActions/QuoteAction.d.ts +2 -0
  87. package/components/ToolbarActions/QuoteAction.js +33 -0
  88. package/components/ToolbarActions/QuoteAction.js.map +1 -0
  89. package/components/ToolbarActions/TextAlignmentAction.d.ts +29 -0
  90. package/components/ToolbarActions/TextAlignmentAction.js +61 -0
  91. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -0
  92. package/components/ToolbarActions/TypographyAction.d.ts +29 -0
  93. package/components/ToolbarActions/TypographyAction.js +108 -0
  94. package/components/ToolbarActions/TypographyAction.js.map +1 -0
  95. package/components/ToolbarActions/UnderlineAction.d.ts +2 -0
  96. package/components/ToolbarActions/UnderlineAction.js +24 -0
  97. package/components/ToolbarActions/UnderlineAction.js.map +1 -0
  98. package/context/FontColorActionContext.d.ts +6 -0
  99. package/context/FontColorActionContext.js +4 -0
  100. package/context/FontColorActionContext.js.map +1 -0
  101. package/context/RichTextEditorContext.d.ts +19 -0
  102. package/context/RichTextEditorContext.js +21 -0
  103. package/context/RichTextEditorContext.js.map +1 -0
  104. package/context/SharedHistoryContext.d.ts +10 -0
  105. package/context/SharedHistoryContext.js +19 -0
  106. package/context/SharedHistoryContext.js.map +1 -0
  107. package/context/TextAlignmentActionContextProps.d.ts +9 -0
  108. package/context/TextAlignmentActionContextProps.js +4 -0
  109. package/context/TextAlignmentActionContextProps.js.map +1 -0
  110. package/context/TypographyActionContext.d.ts +8 -0
  111. package/context/TypographyActionContext.js +4 -0
  112. package/context/TypographyActionContext.js.map +1 -0
  113. package/hooks/index.d.ts +8 -0
  114. package/hooks/index.js +10 -0
  115. package/hooks/index.js.map +1 -0
  116. package/hooks/useCurrentElement.d.ts +7 -0
  117. package/hooks/useCurrentElement.js +27 -0
  118. package/hooks/useCurrentElement.js.map +1 -0
  119. package/hooks/useCurrentSelection.d.ts +13 -0
  120. package/hooks/useCurrentSelection.js +57 -0
  121. package/hooks/useCurrentSelection.js.map +1 -0
  122. package/hooks/useFontColorPicker.d.ts +2 -0
  123. package/hooks/useFontColorPicker.js +11 -0
  124. package/hooks/useFontColorPicker.js.map +1 -0
  125. package/hooks/useIsMounted.d.ts +1 -0
  126. package/hooks/useIsMounted.js +12 -0
  127. package/hooks/useIsMounted.js.map +1 -0
  128. package/hooks/useList.d.ts +2 -0
  129. package/hooks/useList.js +50 -0
  130. package/hooks/useList.js.map +1 -0
  131. package/hooks/useQuote.d.ts +2 -0
  132. package/hooks/useQuote.js +17 -0
  133. package/hooks/useQuote.js.map +1 -0
  134. package/hooks/useRichTextEditor.d.ts +2 -0
  135. package/hooks/useRichTextEditor.js +11 -0
  136. package/hooks/useRichTextEditor.js.map +1 -0
  137. package/hooks/useTextAlignmentAction.d.ts +1 -0
  138. package/hooks/useTextAlignmentAction.js +11 -0
  139. package/hooks/useTextAlignmentAction.js.map +1 -0
  140. package/hooks/useTypographyAction.d.ts +1 -0
  141. package/hooks/useTypographyAction.js +11 -0
  142. package/hooks/useTypographyAction.js.map +1 -0
  143. package/images/icons/LICENSE.md +5 -0
  144. package/images/icons/chat-square-quote.svg +1 -0
  145. package/images/icons/chevron-down.svg +1 -0
  146. package/images/icons/code.svg +1 -0
  147. package/images/icons/font-color.svg +1 -0
  148. package/images/icons/indent.svg +3 -0
  149. package/images/icons/insert-image.svg +4 -0
  150. package/images/icons/justify.svg +3 -0
  151. package/images/icons/link.svg +1 -0
  152. package/images/icons/list-ol.svg +1 -0
  153. package/images/icons/list-ul.svg +1 -0
  154. package/images/icons/outdent.svg +3 -0
  155. package/images/icons/pencil-fill.svg +1 -0
  156. package/images/icons/text-center.svg +1 -0
  157. package/images/icons/text-left.svg +1 -0
  158. package/images/icons/text-paragraph.svg +1 -0
  159. package/images/icons/text-right.svg +1 -0
  160. package/images/icons/type-bold.svg +1 -0
  161. package/images/icons/type-h1.svg +1 -0
  162. package/images/icons/type-h2.svg +1 -0
  163. package/images/icons/type-h3.svg +1 -0
  164. package/images/icons/type-h4.svg +1 -0
  165. package/images/icons/type-h5.svg +1 -0
  166. package/images/icons/type-h6.svg +1 -0
  167. package/images/icons/type-italic.svg +1 -0
  168. package/images/icons/type-strikethrough.svg +1 -0
  169. package/images/icons/type-underline.svg +1 -0
  170. package/images/icons/unlink_icon.svg +1 -0
  171. package/index.d.ts +37 -0
  172. package/index.js +50 -0
  173. package/index.js.map +1 -0
  174. package/package.json +40 -0
  175. package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +7 -0
  176. package/plugins/BlurEventPlugin/BlurEventPlugin.js +20 -0
  177. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -0
  178. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.d.ts +1 -0
  179. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +14 -0
  180. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -0
  181. package/plugins/CodeHighlightPlugin/index.d.ts +1 -0
  182. package/plugins/CodeHighlightPlugin/index.js +3 -0
  183. package/plugins/CodeHighlightPlugin/index.js.map +1 -0
  184. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +16 -0
  185. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +158 -0
  186. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
  187. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +8 -0
  188. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +62 -0
  189. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
  190. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +176 -0
  191. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +7 -0
  192. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +14 -0
  193. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -0
  194. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +8 -0
  195. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +104 -0
  196. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +1 -0
  197. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +9 -0
  198. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +34 -0
  199. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +1 -0
  200. package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -0
  201. package/plugins/FloatingLinkEditorPlugin/index.js +3 -0
  202. package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
  203. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.d.ts +1 -0
  204. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +12 -0
  205. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -0
  206. package/plugins/FontColorPlugin/FontColorPlugin.d.ts +1 -0
  207. package/plugins/FontColorPlugin/FontColorPlugin.js +27 -0
  208. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
  209. package/plugins/FontColorPlugin/applyColorToNode.d.ts +3 -0
  210. package/plugins/FontColorPlugin/applyColorToNode.js +8 -0
  211. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -0
  212. package/plugins/FontColorPlugin/applyColorToSelection.d.ts +3 -0
  213. package/plugins/FontColorPlugin/applyColorToSelection.js +66 -0
  214. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -0
  215. package/plugins/ImagesPlugin/ImagesPlugin.d.ts +12 -0
  216. package/plugins/ImagesPlugin/ImagesPlugin.js +151 -0
  217. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -0
  218. package/plugins/LinkPlugin/LinkPlugin.d.ts +5 -0
  219. package/plugins/LinkPlugin/LinkPlugin.js +59 -0
  220. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -0
  221. package/plugins/ListPLugin/ListPlugin.d.ts +1 -0
  222. package/plugins/ListPLugin/ListPlugin.js +17 -0
  223. package/plugins/ListPLugin/ListPlugin.js.map +1 -0
  224. package/plugins/QuoteNodePlugin/QuoteNodePlugin.d.ts +1 -0
  225. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -0
  226. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -0
  227. package/plugins/StateHandlingPlugin.d.ts +8 -0
  228. package/plugins/StateHandlingPlugin.js +75 -0
  229. package/plugins/StateHandlingPlugin.js.map +1 -0
  230. package/plugins/TypographyPlugin/TypographyPlugin.d.ts +1 -0
  231. package/plugins/TypographyPlugin/TypographyPlugin.js +27 -0
  232. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
  233. package/types.d.ts +12 -0
  234. package/types.js +9 -0
  235. package/types.js.map +1 -0
  236. package/ui/ContentEditable.css +22 -0
  237. package/ui/ContentEditable.d.ts +12 -0
  238. package/ui/ContentEditable.js +19 -0
  239. package/ui/ContentEditable.js.map +1 -0
  240. package/ui/Divider.d.ts +2 -0
  241. package/ui/Divider.js +8 -0
  242. package/ui/Divider.js.map +1 -0
  243. package/ui/DropDown.d.ts +25 -0
  244. package/ui/DropDown.js +182 -0
  245. package/ui/DropDown.js.map +1 -0
  246. package/ui/ImageResizer.d.ts +24 -0
  247. package/ui/ImageResizer.js +211 -0
  248. package/ui/ImageResizer.js.map +1 -0
  249. package/ui/Input.css +32 -0
  250. package/ui/LinkPreview.css +69 -0
  251. package/ui/LinkPreview.d.ts +12 -0
  252. package/ui/LinkPreview.js +97 -0
  253. package/ui/LinkPreview.js.map +1 -0
  254. package/ui/Placeholder.css +20 -0
  255. package/ui/Placeholder.d.ts +15 -0
  256. package/ui/Placeholder.js +24 -0
  257. package/ui/Placeholder.js.map +1 -0
  258. package/ui/TextInput.d.ts +18 -0
  259. package/ui/TextInput.js +34 -0
  260. package/ui/TextInput.js.map +1 -0
  261. package/ui/ToolbarActionDialog.d.ts +11 -0
  262. package/ui/ToolbarActionDialog.js +77 -0
  263. package/ui/ToolbarActionDialog.js.map +1 -0
  264. package/utils/canUseDOM.d.ts +1 -0
  265. package/utils/canUseDOM.js +3 -0
  266. package/utils/canUseDOM.js.map +1 -0
  267. package/utils/files.d.ts +11 -0
  268. package/utils/files.js +21 -0
  269. package/utils/files.js.map +1 -0
  270. package/utils/getDOMRangeRect.d.ts +8 -0
  271. package/utils/getDOMRangeRect.js +23 -0
  272. package/utils/getDOMRangeRect.js.map +1 -0
  273. package/utils/getSelectedNode.d.ts +2 -0
  274. package/utils/getSelectedNode.js +25 -0
  275. package/utils/getSelectedNode.js.map +1 -0
  276. package/utils/getTransparentImage.d.ts +1 -0
  277. package/utils/getTransparentImage.js +5 -0
  278. package/utils/getTransparentImage.js.map +1 -0
  279. package/utils/insertImage.d.ts +2 -0
  280. package/utils/insertImage.js +16 -0
  281. package/utils/insertImage.js.map +1 -0
  282. package/utils/isAnchorLink.d.ts +1 -0
  283. package/utils/isAnchorLink.js +5 -0
  284. package/utils/isAnchorLink.js.map +1 -0
  285. package/utils/isChildOfFloatingToolbar.d.ts +1 -0
  286. package/utils/isChildOfFloatingToolbar.js +12 -0
  287. package/utils/isChildOfFloatingToolbar.js.map +1 -0
  288. package/utils/isHTMLElement.d.ts +8 -0
  289. package/utils/isHTMLElement.js +12 -0
  290. package/utils/isHTMLElement.js.map +1 -0
  291. package/utils/isValidJSON.d.ts +1 -0
  292. package/utils/isValidJSON.js +13 -0
  293. package/utils/isValidJSON.js.map +1 -0
  294. package/utils/isValidLexicalData.d.ts +4 -0
  295. package/utils/isValidLexicalData.js +24 -0
  296. package/utils/isValidLexicalData.js.map +1 -0
  297. package/utils/point.d.ts +21 -0
  298. package/utils/point.js +49 -0
  299. package/utils/point.js.map +1 -0
  300. package/utils/rect.d.ts +45 -0
  301. package/utils/rect.js +130 -0
  302. package/utils/rect.js.map +1 -0
  303. package/utils/sanitizeUrl.d.ts +1 -0
  304. package/utils/sanitizeUrl.js +25 -0
  305. package/utils/sanitizeUrl.js.map +1 -0
  306. package/utils/setFloatingElemPosition.d.ts +1 -0
  307. package/utils/setFloatingElemPosition.js +30 -0
  308. package/utils/setFloatingElemPosition.js.map +1 -0
@@ -0,0 +1,37 @@
1
+ import React, { useCallback } from "react";
2
+ import { $isLinkNode, TOGGLE_LINK_COMMAND } from "@webiny/lexical-nodes";
3
+ import { getNodeFromSelection } from "../../hooks/useCurrentElement";
4
+ import { useDeriveValueFromSelection } from "../../hooks/useCurrentSelection";
5
+ import { useRichTextEditor } from "../../hooks";
6
+ export const LinkAction = () => {
7
+ const {
8
+ editor
9
+ } = useRichTextEditor();
10
+ const isLink = useDeriveValueFromSelection(({
11
+ rangeSelection
12
+ }) => {
13
+ if (!rangeSelection) {
14
+ return false;
15
+ }
16
+ const node = getNodeFromSelection(rangeSelection);
17
+ return node ? $isLinkNode(node) || $isLinkNode(node.getParent()) : false;
18
+ });
19
+ const insertLink = useCallback(() => {
20
+ if (!isLink) {
21
+ editor.dispatchCommand(TOGGLE_LINK_COMMAND, {
22
+ url: "https://"
23
+ });
24
+ } else {
25
+ editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
26
+ }
27
+ }, [editor, isLink]);
28
+ return /*#__PURE__*/React.createElement("button", {
29
+ onClick: insertLink,
30
+ className: "popup-item spaced " + (isLink ? "active" : ""),
31
+ "aria-label": "Insert link"
32
+ }, /*#__PURE__*/React.createElement("i", {
33
+ className: "format link"
34
+ }));
35
+ };
36
+
37
+ //# sourceMappingURL=LinkAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","$isLinkNode","TOGGLE_LINK_COMMAND","getNodeFromSelection","useDeriveValueFromSelection","useRichTextEditor","LinkAction","editor","isLink","rangeSelection","node","getParent","insertLink","dispatchCommand","url","createElement","onClick","className"],"sources":["LinkAction.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { $isLinkNode, TOGGLE_LINK_COMMAND } from \"@webiny/lexical-nodes\";\nimport { getNodeFromSelection } from \"~/hooks/useCurrentElement\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection\";\nimport { useRichTextEditor } from \"~/hooks\";\n\nexport const LinkAction = () => {\n const { editor } = useRichTextEditor();\n const isLink = useDeriveValueFromSelection(({ rangeSelection }) => {\n if (!rangeSelection) {\n return false;\n }\n const node = getNodeFromSelection(rangeSelection);\n return node ? $isLinkNode(node) || $isLinkNode(node.getParent()) : false;\n });\n\n const insertLink = useCallback(() => {\n if (!isLink) {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, { url: \"https://\" });\n } else {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);\n }\n }, [editor, isLink]);\n\n return (\n <button\n onClick={insertLink}\n className={\"popup-item spaced \" + (isLink ? \"active\" : \"\")}\n aria-label=\"Insert link\"\n >\n <i className=\"format link\" />\n </button>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,uBAAuB;AACxE,SAASC,oBAAoB;AAC7B,SAASC,2BAA2B;AACpC,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,UAAU,GAAGA,CAAA,KAAM;EAC5B,MAAM;IAAEC;EAAO,CAAC,GAAGF,iBAAiB,CAAC,CAAC;EACtC,MAAMG,MAAM,GAAGJ,2BAA2B,CAAC,CAAC;IAAEK;EAAe,CAAC,KAAK;IAC/D,IAAI,CAACA,cAAc,EAAE;MACjB,OAAO,KAAK;IAChB;IACA,MAAMC,IAAI,GAAGP,oBAAoB,CAACM,cAAc,CAAC;IACjD,OAAOC,IAAI,GAAGT,WAAW,CAACS,IAAI,CAAC,IAAIT,WAAW,CAACS,IAAI,CAACC,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK;EAC5E,CAAC,CAAC;EAEF,MAAMC,UAAU,GAAGZ,WAAW,CAAC,MAAM;IACjC,IAAI,CAACQ,MAAM,EAAE;MACTD,MAAM,CAACM,eAAe,CAACX,mBAAmB,EAAE;QAAEY,GAAG,EAAE;MAAW,CAAC,CAAC;IACpE,CAAC,MAAM;MACHP,MAAM,CAACM,eAAe,CAACX,mBAAmB,EAAE,IAAI,CAAC;IACrD;EACJ,CAAC,EAAE,CAACK,MAAM,EAAEC,MAAM,CAAC,CAAC;EAEpB,oBACIT,KAAA,CAAAgB,aAAA;IACIC,OAAO,EAAEJ,UAAW;IACpBK,SAAS,EAAE,oBAAoB,IAAIT,MAAM,GAAG,QAAQ,GAAG,EAAE,CAAE;IAC3D,cAAW;EAAa,gBAExBT,KAAA,CAAAgB,aAAA;IAAGE,SAAS,EAAC;EAAa,CAAE,CACxB,CAAC;AAEjB,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const NumberedListAction: () => React.JSX.Element;
@@ -0,0 +1,48 @@
1
+ import React from "react";
2
+ import { $isListNode } from "@webiny/lexical-nodes";
3
+ import { findTypographyStyleByHtmlTag } from "@webiny/lexical-theme";
4
+ import { INSERT_ORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND } from "../../commands";
5
+ import { useRichTextEditor } from "../../hooks/useRichTextEditor";
6
+ import { useCurrentElement } from "../../hooks/useCurrentElement";
7
+ export const NumberedListAction = () => {
8
+ const {
9
+ element
10
+ } = useCurrentElement();
11
+ const {
12
+ editor,
13
+ themeEmotionMap
14
+ } = useRichTextEditor();
15
+ const isList = $isListNode(element);
16
+ const isNumbered = isList && element.getListType() === "number";
17
+ const getStyleId = () => {
18
+ if (!themeEmotionMap) {
19
+ return undefined;
20
+ }
21
+ // check default style for numbered list
22
+ const id = findTypographyStyleByHtmlTag("ol", themeEmotionMap)?.id;
23
+ if (id) {
24
+ return id;
25
+ }
26
+ // fallback to ul list styles
27
+ return findTypographyStyleByHtmlTag("ul", themeEmotionMap)?.id;
28
+ };
29
+ const formatNumberedList = () => {
30
+ if (!isNumbered) {
31
+ const styleId = themeEmotionMap ? getStyleId() : undefined;
32
+ editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, {
33
+ themeStyleId: styleId
34
+ });
35
+ } else {
36
+ editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
37
+ }
38
+ };
39
+ return /*#__PURE__*/React.createElement("button", {
40
+ onClick: () => formatNumberedList(),
41
+ className: "popup-item spaced " + (isNumbered ? "active" : ""),
42
+ "aria-label": "Format text as numbered list"
43
+ }, /*#__PURE__*/React.createElement("i", {
44
+ className: "icon numbered-list"
45
+ }));
46
+ };
47
+
48
+ //# sourceMappingURL=NumberedListAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","$isListNode","findTypographyStyleByHtmlTag","INSERT_ORDERED_LIST_COMMAND","REMOVE_LIST_COMMAND","useRichTextEditor","useCurrentElement","NumberedListAction","element","editor","themeEmotionMap","isList","isNumbered","getListType","getStyleId","undefined","id","formatNumberedList","styleId","dispatchCommand","themeStyleId","createElement","onClick","className"],"sources":["NumberedListAction.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ListNode } from \"@webiny/lexical-nodes\";\nimport { $isListNode } from \"@webiny/lexical-nodes\";\nimport { findTypographyStyleByHtmlTag } from \"@webiny/lexical-theme\";\nimport { INSERT_ORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND } from \"~/commands\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\nimport { useCurrentElement } from \"~/hooks/useCurrentElement\";\n\nexport const NumberedListAction = () => {\n const { element } = useCurrentElement();\n const { editor, themeEmotionMap } = useRichTextEditor();\n const isList = $isListNode(element);\n const isNumbered = isList && (element as ListNode).getListType() === \"number\";\n\n const getStyleId = (): string | undefined => {\n if (!themeEmotionMap) {\n return undefined;\n }\n // check default style for numbered list\n const id = findTypographyStyleByHtmlTag(\"ol\", themeEmotionMap)?.id;\n if (id) {\n return id;\n }\n // fallback to ul list styles\n return findTypographyStyleByHtmlTag(\"ul\", themeEmotionMap)?.id;\n };\n\n const formatNumberedList = () => {\n if (!isNumbered) {\n const styleId = themeEmotionMap ? getStyleId() : undefined;\n editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, { themeStyleId: styleId });\n } else {\n editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);\n }\n };\n\n return (\n <button\n onClick={() => formatNumberedList()}\n className={\"popup-item spaced \" + (isNumbered ? \"active\" : \"\")}\n aria-label=\"Format text as numbered list\"\n >\n <i className=\"icon numbered-list\" />\n </button>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,4BAA4B,QAAQ,uBAAuB;AACpE,SAASC,2BAA2B,EAAEC,mBAAmB;AACzD,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,kBAAkB,GAAGA,CAAA,KAAM;EACpC,MAAM;IAAEC;EAAQ,CAAC,GAAGF,iBAAiB,CAAC,CAAC;EACvC,MAAM;IAAEG,MAAM;IAAEC;EAAgB,CAAC,GAAGL,iBAAiB,CAAC,CAAC;EACvD,MAAMM,MAAM,GAAGV,WAAW,CAACO,OAAO,CAAC;EACnC,MAAMI,UAAU,GAAGD,MAAM,IAAKH,OAAO,CAAcK,WAAW,CAAC,CAAC,KAAK,QAAQ;EAE7E,MAAMC,UAAU,GAAGA,CAAA,KAA0B;IACzC,IAAI,CAACJ,eAAe,EAAE;MAClB,OAAOK,SAAS;IACpB;IACA;IACA,MAAMC,EAAE,GAAGd,4BAA4B,CAAC,IAAI,EAAEQ,eAAe,CAAC,EAAEM,EAAE;IAClE,IAAIA,EAAE,EAAE;MACJ,OAAOA,EAAE;IACb;IACA;IACA,OAAOd,4BAA4B,CAAC,IAAI,EAAEQ,eAAe,CAAC,EAAEM,EAAE;EAClE,CAAC;EAED,MAAMC,kBAAkB,GAAGA,CAAA,KAAM;IAC7B,IAAI,CAACL,UAAU,EAAE;MACb,MAAMM,OAAO,GAAGR,eAAe,GAAGI,UAAU,CAAC,CAAC,GAAGC,SAAS;MAC1DN,MAAM,CAACU,eAAe,CAAChB,2BAA2B,EAAE;QAAEiB,YAAY,EAAEF;MAAQ,CAAC,CAAC;IAClF,CAAC,MAAM;MACHT,MAAM,CAACU,eAAe,CAACf,mBAAmB,EAAEW,SAAS,CAAC;IAC1D;EACJ,CAAC;EAED,oBACIf,KAAA,CAAAqB,aAAA;IACIC,OAAO,EAAEA,CAAA,KAAML,kBAAkB,CAAC,CAAE;IACpCM,SAAS,EAAE,oBAAoB,IAAIX,UAAU,GAAG,QAAQ,GAAG,EAAE,CAAE;IAC/D,cAAW;EAA8B,gBAEzCZ,KAAA,CAAAqB,aAAA;IAAGE,SAAS,EAAC;EAAoB,CAAE,CAC/B,CAAC;AAEjB,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const QuoteAction: () => React.JSX.Element;
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+ import { $isQuoteNode, formatToQuote, formatToParagraph } from "@webiny/lexical-nodes";
3
+ import { useRichTextEditor } from "../../hooks/useRichTextEditor";
4
+ import { useCurrentElement } from "../../hooks/useCurrentElement";
5
+ export const QuoteAction = () => {
6
+ const {
7
+ editor,
8
+ themeEmotionMap
9
+ } = useRichTextEditor();
10
+ const {
11
+ element
12
+ } = useCurrentElement();
13
+ const isQuote = $isQuoteNode(element);
14
+ const formatText = () => {
15
+ if (!isQuote) {
16
+ // Try to set default quote style, when the action button is clicked for first time
17
+ const DEFAULT_QUOTE_ID = "quote";
18
+ const hasQuoteStyles = themeEmotionMap && themeEmotionMap[DEFAULT_QUOTE_ID];
19
+ formatToQuote(editor, hasQuoteStyles ? DEFAULT_QUOTE_ID : undefined);
20
+ return;
21
+ }
22
+ formatToParagraph(editor);
23
+ };
24
+ return /*#__PURE__*/React.createElement("button", {
25
+ onClick: formatText,
26
+ className: "popup-item " + (isQuote ? "active" : ""),
27
+ "aria-label": "Format text as quote"
28
+ }, /*#__PURE__*/React.createElement("i", {
29
+ className: "icon quote"
30
+ }));
31
+ };
32
+
33
+ //# sourceMappingURL=QuoteAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","$isQuoteNode","formatToQuote","formatToParagraph","useRichTextEditor","useCurrentElement","QuoteAction","editor","themeEmotionMap","element","isQuote","formatText","DEFAULT_QUOTE_ID","hasQuoteStyles","undefined","createElement","onClick","className"],"sources":["QuoteAction.tsx"],"sourcesContent":["import React from \"react\";\nimport { $isQuoteNode, formatToQuote, formatToParagraph } from \"@webiny/lexical-nodes\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\nimport { useCurrentElement } from \"~/hooks/useCurrentElement\";\n\nexport const QuoteAction = () => {\n const { editor, themeEmotionMap } = useRichTextEditor();\n const { element } = useCurrentElement();\n const isQuote = $isQuoteNode(element);\n\n const formatText = () => {\n if (!isQuote) {\n // Try to set default quote style, when the action button is clicked for first time\n const DEFAULT_QUOTE_ID = \"quote\";\n const hasQuoteStyles = themeEmotionMap && themeEmotionMap[DEFAULT_QUOTE_ID];\n formatToQuote(editor, hasQuoteStyles ? DEFAULT_QUOTE_ID : undefined);\n return;\n }\n formatToParagraph(editor);\n };\n\n return (\n <button\n onClick={formatText}\n className={\"popup-item \" + (isQuote ? \"active\" : \"\")}\n aria-label=\"Format text as quote\"\n >\n <i className=\"icon quote\" />\n </button>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,EAAEC,aAAa,EAAEC,iBAAiB,QAAQ,uBAAuB;AACtF,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,WAAW,GAAGA,CAAA,KAAM;EAC7B,MAAM;IAAEC,MAAM;IAAEC;EAAgB,CAAC,GAAGJ,iBAAiB,CAAC,CAAC;EACvD,MAAM;IAAEK;EAAQ,CAAC,GAAGJ,iBAAiB,CAAC,CAAC;EACvC,MAAMK,OAAO,GAAGT,YAAY,CAACQ,OAAO,CAAC;EAErC,MAAME,UAAU,GAAGA,CAAA,KAAM;IACrB,IAAI,CAACD,OAAO,EAAE;MACV;MACA,MAAME,gBAAgB,GAAG,OAAO;MAChC,MAAMC,cAAc,GAAGL,eAAe,IAAIA,eAAe,CAACI,gBAAgB,CAAC;MAC3EV,aAAa,CAACK,MAAM,EAAEM,cAAc,GAAGD,gBAAgB,GAAGE,SAAS,CAAC;MACpE;IACJ;IACAX,iBAAiB,CAACI,MAAM,CAAC;EAC7B,CAAC;EAED,oBACIP,KAAA,CAAAe,aAAA;IACIC,OAAO,EAAEL,UAAW;IACpBM,SAAS,EAAE,aAAa,IAAIP,OAAO,GAAG,QAAQ,GAAG,EAAE,CAAE;IACrD,cAAW;EAAsB,gBAEjCV,KAAA,CAAAe,aAAA;IAAGE,SAAS,EAAC;EAAY,CAAE,CACvB,CAAC;AAEjB,CAAC","ignoreList":[]}
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ export declare const BaseTextAlignmentDropDown: (() => JSX.Element | null) & {
3
+ original: () => JSX.Element | null;
4
+ originalName: string;
5
+ displayName: string;
6
+ } & {
7
+ original: (() => JSX.Element | null) & {
8
+ original: () => JSX.Element | null;
9
+ originalName: string;
10
+ displayName: string;
11
+ };
12
+ originalName: string;
13
+ displayName: string;
14
+ } & {
15
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(() => JSX.Element | null) & {
16
+ original: () => JSX.Element | null;
17
+ originalName: string;
18
+ displayName: string;
19
+ }>) => (props: unknown) => React.JSX.Element;
20
+ };
21
+ interface TextAlignmentActionDropdownProps {
22
+ element: JSX.Element;
23
+ }
24
+ declare const TextAlignmentActionDropDown: ({ element }: TextAlignmentActionDropdownProps) => JSX.Element;
25
+ export type TextAlignmentAction = React.ComponentType<unknown> & {
26
+ TextAlignmentDropDown: typeof TextAlignmentActionDropDown;
27
+ };
28
+ export declare const TextAlignmentAction: TextAlignmentAction;
29
+ export {};
@@ -0,0 +1,61 @@
1
+ import React, { useEffect, useMemo } from "react";
2
+ import { FORMAT_ELEMENT_COMMAND, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND } from "lexical";
3
+ import { Compose, makeDecoratable } from "@webiny/react-composition";
4
+ import { TextAlignmentActionContext } from "../../context/TextAlignmentActionContextProps";
5
+ import { useDeriveValueFromSelection } from "../../hooks/useCurrentSelection";
6
+ import { getSelectedNode } from "../../utils/getSelectedNode";
7
+ import { useRichTextEditor } from "../../hooks";
8
+
9
+ /*
10
+ * Base text alignment dropdown composable component.
11
+ * Note: To add a custom dropdown component use @see LexicalEditorConfig API.
12
+ */
13
+ export const BaseTextAlignmentDropDown = makeDecoratable("BaseTextAlignmentDropDown", () => {
14
+ useEffect(() => {
15
+ console.log("Default BaseTextAlignmentDropDown, please add your own component");
16
+ }, []);
17
+ return null;
18
+ });
19
+ const TextAlignmentActionDropDown = ({
20
+ element
21
+ }) => {
22
+ return /*#__PURE__*/React.createElement(Compose, {
23
+ component: BaseTextAlignmentDropDown,
24
+ with: () => () => element
25
+ });
26
+ };
27
+ export const TextAlignmentAction = () => {
28
+ const {
29
+ editor
30
+ } = useRichTextEditor();
31
+ const alignmentValue = useDeriveValueFromSelection(({
32
+ rangeSelection
33
+ }) => {
34
+ const node = rangeSelection ? getSelectedNode(rangeSelection) : null;
35
+ if (node) {
36
+ return node.getParent()?.getFormatType() || "";
37
+ }
38
+ return "";
39
+ });
40
+ const applyTextAlignment = value => {
41
+ editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, value);
42
+ };
43
+ const outdentText = () => {
44
+ editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined);
45
+ };
46
+ const indentText = () => {
47
+ editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined);
48
+ };
49
+ const context = useMemo(() => ({
50
+ value: alignmentValue,
51
+ applyTextAlignment,
52
+ outdentText,
53
+ indentText
54
+ }), [alignmentValue]);
55
+ return /*#__PURE__*/React.createElement(TextAlignmentActionContext.Provider, {
56
+ value: context
57
+ }, /*#__PURE__*/React.createElement(BaseTextAlignmentDropDown, null));
58
+ };
59
+ TextAlignmentAction.TextAlignmentDropDown = TextAlignmentActionDropDown;
60
+
61
+ //# sourceMappingURL=TextAlignmentAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","useMemo","FORMAT_ELEMENT_COMMAND","INDENT_CONTENT_COMMAND","OUTDENT_CONTENT_COMMAND","Compose","makeDecoratable","TextAlignmentActionContext","useDeriveValueFromSelection","getSelectedNode","useRichTextEditor","BaseTextAlignmentDropDown","console","log","TextAlignmentActionDropDown","element","createElement","component","with","TextAlignmentAction","editor","alignmentValue","rangeSelection","node","getParent","getFormatType","applyTextAlignment","value","dispatchCommand","outdentText","undefined","indentText","context","Provider","TextAlignmentDropDown"],"sources":["TextAlignmentAction.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport type { ElementFormatType } from \"lexical\";\nimport { FORMAT_ELEMENT_COMMAND, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND } from \"lexical\";\nimport { Compose, makeDecoratable } from \"@webiny/react-composition\";\nimport { TextAlignmentActionContext } from \"~/context/TextAlignmentActionContextProps\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection\";\nimport { getSelectedNode } from \"~/utils/getSelectedNode\";\nimport { useRichTextEditor } from \"~/hooks\";\n\n/*\n * Base text alignment dropdown composable component.\n * Note: To add a custom dropdown component use @see LexicalEditorConfig API.\n */\nexport const BaseTextAlignmentDropDown = makeDecoratable(\n \"BaseTextAlignmentDropDown\",\n (): JSX.Element | null => {\n useEffect(() => {\n console.log(\"Default BaseTextAlignmentDropDown, please add your own component\");\n }, []);\n return null;\n }\n);\n\ninterface TextAlignmentActionDropdownProps {\n element: JSX.Element;\n}\n\nconst TextAlignmentActionDropDown = ({\n element\n}: TextAlignmentActionDropdownProps): JSX.Element => {\n return <Compose component={BaseTextAlignmentDropDown} with={() => () => element} />;\n};\n\nexport type TextAlignmentAction = React.ComponentType<unknown> & {\n TextAlignmentDropDown: typeof TextAlignmentActionDropDown;\n};\n\nexport const TextAlignmentAction: TextAlignmentAction = () => {\n const { editor } = useRichTextEditor();\n const alignmentValue: ElementFormatType = useDeriveValueFromSelection(({ rangeSelection }) => {\n const node = rangeSelection ? getSelectedNode(rangeSelection) : null;\n if (node) {\n return node.getParent()?.getFormatType() || \"\";\n }\n return \"\";\n });\n\n const applyTextAlignment = (value: ElementFormatType) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, value);\n };\n\n const outdentText = () => {\n editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined);\n };\n\n const indentText = () => {\n editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined);\n };\n\n const context = useMemo(\n () => ({\n value: alignmentValue,\n applyTextAlignment,\n outdentText,\n indentText\n }),\n [alignmentValue]\n );\n\n return (\n <TextAlignmentActionContext.Provider value={context}>\n <BaseTextAlignmentDropDown />\n </TextAlignmentActionContext.Provider>\n );\n};\n\nTextAlignmentAction.TextAlignmentDropDown = TextAlignmentActionDropDown;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAEjD,SAASC,sBAAsB,EAAEC,sBAAsB,EAAEC,uBAAuB,QAAQ,SAAS;AACjG,SAASC,OAAO,EAAEC,eAAe,QAAQ,2BAA2B;AACpE,SAASC,0BAA0B;AACnC,SAASC,2BAA2B;AACpC,SAASC,eAAe;AACxB,SAASC,iBAAiB;;AAE1B;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAGL,eAAe,CACpD,2BAA2B,EAC3B,MAA0B;EACtBN,SAAS,CAAC,MAAM;IACZY,OAAO,CAACC,GAAG,CAAC,kEAAkE,CAAC;EACnF,CAAC,EAAE,EAAE,CAAC;EACN,OAAO,IAAI;AACf,CACJ,CAAC;AAMD,MAAMC,2BAA2B,GAAGA,CAAC;EACjCC;AAC8B,CAAC,KAAkB;EACjD,oBAAOhB,KAAA,CAAAiB,aAAA,CAACX,OAAO;IAACY,SAAS,EAAEN,yBAA0B;IAACO,IAAI,EAAEA,CAAA,KAAM,MAAMH;EAAQ,CAAE,CAAC;AACvF,CAAC;AAMD,OAAO,MAAMI,mBAAwC,GAAGA,CAAA,KAAM;EAC1D,MAAM;IAAEC;EAAO,CAAC,GAAGV,iBAAiB,CAAC,CAAC;EACtC,MAAMW,cAAiC,GAAGb,2BAA2B,CAAC,CAAC;IAAEc;EAAe,CAAC,KAAK;IAC1F,MAAMC,IAAI,GAAGD,cAAc,GAAGb,eAAe,CAACa,cAAc,CAAC,GAAG,IAAI;IACpE,IAAIC,IAAI,EAAE;MACN,OAAOA,IAAI,CAACC,SAAS,CAAC,CAAC,EAAEC,aAAa,CAAC,CAAC,IAAI,EAAE;IAClD;IACA,OAAO,EAAE;EACb,CAAC,CAAC;EAEF,MAAMC,kBAAkB,GAAIC,KAAwB,IAAK;IACrDP,MAAM,CAACQ,eAAe,CAAC1B,sBAAsB,EAAEyB,KAAK,CAAC;EACzD,CAAC;EAED,MAAME,WAAW,GAAGA,CAAA,KAAM;IACtBT,MAAM,CAACQ,eAAe,CAACxB,uBAAuB,EAAE0B,SAAS,CAAC;EAC9D,CAAC;EAED,MAAMC,UAAU,GAAGA,CAAA,KAAM;IACrBX,MAAM,CAACQ,eAAe,CAACzB,sBAAsB,EAAE2B,SAAS,CAAC;EAC7D,CAAC;EAED,MAAME,OAAO,GAAG/B,OAAO,CACnB,OAAO;IACH0B,KAAK,EAAEN,cAAc;IACrBK,kBAAkB;IAClBG,WAAW;IACXE;EACJ,CAAC,CAAC,EACF,CAACV,cAAc,CACnB,CAAC;EAED,oBACItB,KAAA,CAAAiB,aAAA,CAACT,0BAA0B,CAAC0B,QAAQ;IAACN,KAAK,EAAEK;EAAQ,gBAChDjC,KAAA,CAAAiB,aAAA,CAACL,yBAAyB,MAAE,CACK,CAAC;AAE9C,CAAC;AAEDQ,mBAAmB,CAACe,qBAAqB,GAAGpB,2BAA2B","ignoreList":[]}
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ export declare const BaseTypographyActionDropDown: (() => JSX.Element | null) & {
3
+ original: () => JSX.Element | null;
4
+ originalName: string;
5
+ displayName: string;
6
+ } & {
7
+ original: (() => JSX.Element | null) & {
8
+ original: () => JSX.Element | null;
9
+ originalName: string;
10
+ displayName: string;
11
+ };
12
+ originalName: string;
13
+ displayName: string;
14
+ } & {
15
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(() => JSX.Element | null) & {
16
+ original: () => JSX.Element | null;
17
+ originalName: string;
18
+ displayName: string;
19
+ }>) => (props: unknown) => React.JSX.Element;
20
+ };
21
+ interface TypographyActionDropdownProps {
22
+ element: JSX.Element;
23
+ }
24
+ declare const TypographyActionDropDown: ({ element }: TypographyActionDropdownProps) => JSX.Element;
25
+ export type TypographyAction = React.ComponentType<unknown> & {
26
+ TypographyDropDown: typeof TypographyActionDropDown;
27
+ };
28
+ export declare const TypographyAction: TypographyAction;
29
+ export {};
@@ -0,0 +1,108 @@
1
+ import React, { useCallback, useEffect, useState } from "react";
2
+ import { Compose, makeDecoratable } from "@webiny/react-composition";
3
+ import { TypographyActionContext } from "../../context/TypographyActionContext";
4
+ import { $isHeadingNode, $isListNode, $isParagraphNode, $isQuoteNode } from "@webiny/lexical-nodes";
5
+ import { useRichTextEditor } from "../../hooks/useRichTextEditor";
6
+ import { INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, INSERT_QUOTE_COMMAND, ADD_TYPOGRAPHY_COMMAND } from "../../commands";
7
+ import { useCurrentElement } from "../../hooks/useCurrentElement";
8
+
9
+ // Unfortunately, for some time in v5 we had `quoteblock` in our theme, so let's not break it.
10
+ const quoteTagNames = ["blockquote", "quoteblock"];
11
+
12
+ /*
13
+ * Base composable action component that is mounted on toolbar action as a placeholder for the custom toolbar action.
14
+ * Note: Toa add custom component access trough @see LexicalEditorConfig API
15
+ * */
16
+ export const BaseTypographyActionDropDown = makeDecoratable("BaseTypographyActionDropDown", () => {
17
+ useEffect(() => {
18
+ console.log("Default BaseTypographyActionDropDown, please add your own component");
19
+ }, []);
20
+ return null;
21
+ });
22
+ const TypographyActionDropDown = ({
23
+ element
24
+ }) => {
25
+ return /*#__PURE__*/React.createElement(Compose, {
26
+ component: BaseTypographyActionDropDown,
27
+ with: () => () => element
28
+ });
29
+ };
30
+ export const TypographyAction = () => {
31
+ const [typography, setTypography] = useState();
32
+ const {
33
+ editor,
34
+ themeEmotionMap
35
+ } = useRichTextEditor();
36
+ const {
37
+ element
38
+ } = useCurrentElement();
39
+ const isParagraphSelected = $isParagraphNode(element);
40
+ const isHeadingSelected = $isHeadingNode(element);
41
+ const isQuoteSelected = $isQuoteNode(element);
42
+ const onTypographySelect = useCallback(value => {
43
+ setTypography(value);
44
+ if (value.tag.includes("h") || value.tag.includes("p")) {
45
+ editor.dispatchCommand(ADD_TYPOGRAPHY_COMMAND, {
46
+ value
47
+ });
48
+ }
49
+ if (value.tag === "ol") {
50
+ editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, {
51
+ themeStyleId: value.id
52
+ });
53
+ }
54
+ if (value.tag === "ul") {
55
+ editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, {
56
+ themeStyleId: value.id
57
+ });
58
+ }
59
+ if (quoteTagNames.includes(value.tag)) {
60
+ editor.dispatchCommand(INSERT_QUOTE_COMMAND, {
61
+ themeStyleId: value.id
62
+ });
63
+ }
64
+ }, []);
65
+ useEffect(() => {
66
+ if (!element || !themeEmotionMap) {
67
+ return;
68
+ }
69
+ if (isParagraphSelected || isHeadingSelected || isQuoteSelected) {
70
+ const styleId = element.getStyleId();
71
+ if (!styleId) {
72
+ return;
73
+ }
74
+ const style = themeEmotionMap[styleId];
75
+ if (style) {
76
+ setTypography({
77
+ id: style.id,
78
+ name: style.name
79
+ });
80
+ }
81
+ return;
82
+ }
83
+
84
+ // list and quote element
85
+ if (themeEmotionMap && $isListNode(element)) {
86
+ const styleId = element.getStyleId();
87
+ if (!styleId) {
88
+ return;
89
+ }
90
+ const style = themeEmotionMap[styleId];
91
+ if (style) {
92
+ setTypography({
93
+ id: style.id,
94
+ name: style.name
95
+ });
96
+ }
97
+ }
98
+ }, [element, isQuoteSelected, isParagraphSelected, isHeadingSelected]);
99
+ return /*#__PURE__*/React.createElement(TypographyActionContext.Provider, {
100
+ value: {
101
+ value: typography,
102
+ applyTypography: onTypographySelect
103
+ }
104
+ }, /*#__PURE__*/React.createElement(BaseTypographyActionDropDown, null));
105
+ };
106
+ TypographyAction.TypographyDropDown = TypographyActionDropDown;
107
+
108
+ //# sourceMappingURL=TypographyAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useEffect","useState","Compose","makeDecoratable","TypographyActionContext","$isHeadingNode","$isListNode","$isParagraphNode","$isQuoteNode","useRichTextEditor","INSERT_ORDERED_LIST_COMMAND","INSERT_UNORDERED_LIST_COMMAND","INSERT_QUOTE_COMMAND","ADD_TYPOGRAPHY_COMMAND","useCurrentElement","quoteTagNames","BaseTypographyActionDropDown","console","log","TypographyActionDropDown","element","createElement","component","with","TypographyAction","typography","setTypography","editor","themeEmotionMap","isParagraphSelected","isHeadingSelected","isQuoteSelected","onTypographySelect","value","tag","includes","dispatchCommand","themeStyleId","id","styleId","getStyleId","style","name","Provider","applyTypography","TypographyDropDown"],"sources":["TypographyAction.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\nimport type { LexicalCommand } from \"lexical\";\nimport { Compose, makeDecoratable } from \"@webiny/react-composition\";\nimport type { TypographyValue } from \"@webiny/lexical-theme\";\nimport type { ActiveTypography } from \"~/context/TypographyActionContext\";\nimport { TypographyActionContext } from \"~/context/TypographyActionContext\";\nimport { $isHeadingNode, $isListNode, $isParagraphNode, $isQuoteNode } from \"@webiny/lexical-nodes\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\nimport type { ListCommandPayload, QuoteCommandPayload, TypographyPayload } from \"~/commands\";\nimport {\n INSERT_ORDERED_LIST_COMMAND,\n INSERT_UNORDERED_LIST_COMMAND,\n INSERT_QUOTE_COMMAND,\n ADD_TYPOGRAPHY_COMMAND\n} from \"~/commands\";\nimport { useCurrentElement } from \"~/hooks/useCurrentElement\";\n\n// Unfortunately, for some time in v5 we had `quoteblock` in our theme, so let's not break it.\nconst quoteTagNames = [\"blockquote\", \"quoteblock\"];\n\n/*\n * Base composable action component that is mounted on toolbar action as a placeholder for the custom toolbar action.\n * Note: Toa add custom component access trough @see LexicalEditorConfig API\n * */\nexport const BaseTypographyActionDropDown = makeDecoratable(\n \"BaseTypographyActionDropDown\",\n (): JSX.Element | null => {\n useEffect(() => {\n console.log(\"Default BaseTypographyActionDropDown, please add your own component\");\n }, []);\n return null;\n }\n);\n\ninterface TypographyActionDropdownProps {\n element: JSX.Element;\n}\n\nconst TypographyActionDropDown = ({ element }: TypographyActionDropdownProps): JSX.Element => {\n return <Compose component={BaseTypographyActionDropDown} with={() => () => element} />;\n};\n\nexport type TypographyAction = React.ComponentType<unknown> & {\n TypographyDropDown: typeof TypographyActionDropDown;\n};\n\nexport const TypographyAction: TypographyAction = () => {\n const [typography, setTypography] = useState<ActiveTypography>();\n const { editor, themeEmotionMap } = useRichTextEditor();\n const { element } = useCurrentElement();\n const isParagraphSelected = $isParagraphNode(element);\n const isHeadingSelected = $isHeadingNode(element);\n const isQuoteSelected = $isQuoteNode(element);\n\n const onTypographySelect = useCallback((value: TypographyValue) => {\n setTypography(value);\n\n if (value.tag.includes(\"h\") || value.tag.includes(\"p\")) {\n editor.dispatchCommand<LexicalCommand<TypographyPayload>>(ADD_TYPOGRAPHY_COMMAND, {\n value\n });\n }\n\n if (value.tag === \"ol\") {\n editor.dispatchCommand<LexicalCommand<ListCommandPayload>>(\n INSERT_ORDERED_LIST_COMMAND,\n {\n themeStyleId: value.id\n }\n );\n }\n\n if (value.tag === \"ul\") {\n editor.dispatchCommand<LexicalCommand<ListCommandPayload>>(\n INSERT_UNORDERED_LIST_COMMAND,\n {\n themeStyleId: value.id\n }\n );\n }\n\n if (quoteTagNames.includes(value.tag)) {\n editor.dispatchCommand<LexicalCommand<QuoteCommandPayload>>(INSERT_QUOTE_COMMAND, {\n themeStyleId: value.id\n });\n }\n }, []);\n\n useEffect(() => {\n if (!element || !themeEmotionMap) {\n return;\n }\n\n if (isParagraphSelected || isHeadingSelected || isQuoteSelected) {\n const styleId = element.getStyleId();\n if (!styleId) {\n return;\n }\n\n const style = themeEmotionMap[styleId];\n if (style) {\n setTypography({\n id: style.id,\n name: style.name\n });\n }\n return;\n }\n\n // list and quote element\n if (themeEmotionMap && $isListNode(element)) {\n const styleId = element.getStyleId();\n if (!styleId) {\n return;\n }\n\n const style = themeEmotionMap[styleId];\n if (style) {\n setTypography({\n id: style.id,\n name: style.name\n });\n }\n }\n }, [element, isQuoteSelected, isParagraphSelected, isHeadingSelected]);\n\n return (\n <TypographyActionContext.Provider\n value={{\n value: typography,\n applyTypography: onTypographySelect\n }}\n >\n <BaseTypographyActionDropDown />\n </TypographyActionContext.Provider>\n );\n};\n\nTypographyAction.TypographyDropDown = TypographyActionDropDown;\n"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const UnderlineAction: () => React.JSX.Element;
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import { FORMAT_TEXT_COMMAND } from "lexical";
3
+ import { useCurrentSelection, useRichTextEditor } from "../../hooks";
4
+ export const UnderlineAction = () => {
5
+ const {
6
+ editor
7
+ } = useRichTextEditor();
8
+ const {
9
+ rangeSelection
10
+ } = useCurrentSelection();
11
+ const isUnderlineSelected = rangeSelection ? rangeSelection.hasFormat("underline") : false;
12
+ const handleClick = () => {
13
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, "underline");
14
+ };
15
+ return /*#__PURE__*/React.createElement("button", {
16
+ onClick: handleClick,
17
+ className: "popup-item spaced " + (isUnderlineSelected ? "active" : ""),
18
+ "aria-label": "Underline text"
19
+ }, /*#__PURE__*/React.createElement("i", {
20
+ className: "format underline"
21
+ }));
22
+ };
23
+
24
+ //# sourceMappingURL=UnderlineAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","FORMAT_TEXT_COMMAND","useCurrentSelection","useRichTextEditor","UnderlineAction","editor","rangeSelection","isUnderlineSelected","hasFormat","handleClick","dispatchCommand","createElement","onClick","className"],"sources":["UnderlineAction.tsx"],"sourcesContent":["import React from \"react\";\nimport { FORMAT_TEXT_COMMAND } from \"lexical\";\nimport { useCurrentSelection, useRichTextEditor } from \"~/hooks\";\n\nexport const UnderlineAction = () => {\n const { editor } = useRichTextEditor();\n const { rangeSelection } = useCurrentSelection();\n const isUnderlineSelected = rangeSelection ? rangeSelection.hasFormat(\"underline\") : false;\n\n const handleClick = () => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, \"underline\");\n };\n\n return (\n <button\n onClick={handleClick}\n className={\"popup-item spaced \" + (isUnderlineSelected ? \"active\" : \"\")}\n aria-label=\"Underline text\"\n >\n <i className=\"format underline\" />\n </button>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,mBAAmB,QAAQ,SAAS;AAC7C,SAASC,mBAAmB,EAAEC,iBAAiB;AAE/C,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAM;EACjC,MAAM;IAAEC;EAAO,CAAC,GAAGF,iBAAiB,CAAC,CAAC;EACtC,MAAM;IAAEG;EAAe,CAAC,GAAGJ,mBAAmB,CAAC,CAAC;EAChD,MAAMK,mBAAmB,GAAGD,cAAc,GAAGA,cAAc,CAACE,SAAS,CAAC,WAAW,CAAC,GAAG,KAAK;EAE1F,MAAMC,WAAW,GAAGA,CAAA,KAAM;IACtBJ,MAAM,CAACK,eAAe,CAACT,mBAAmB,EAAE,WAAW,CAAC;EAC5D,CAAC;EAED,oBACID,KAAA,CAAAW,aAAA;IACIC,OAAO,EAAEH,WAAY;IACrBI,SAAS,EAAE,oBAAoB,IAAIN,mBAAmB,GAAG,QAAQ,GAAG,EAAE,CAAE;IACxE,cAAW;EAAgB,gBAE3BP,KAAA,CAAAW,aAAA;IAAGE,SAAS,EAAC;EAAkB,CAAE,CAC7B,CAAC;AAEjB,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ export interface FontColorActionContext {
3
+ value: string;
4
+ applyColor: (value: string, themeColorName: string | undefined) => void;
5
+ }
6
+ export declare const FontColorActionContext: React.Context<FontColorActionContext | undefined>;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ export const FontColorActionContext = /*#__PURE__*/React.createContext(undefined);
3
+
4
+ //# sourceMappingURL=FontColorActionContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","FontColorActionContext","createContext","undefined"],"sources":["FontColorActionContext.tsx"],"sourcesContent":["import React from \"react\";\n\nexport interface FontColorActionContext {\n /*\n * @desc Current selected color value\n * */\n value: string;\n\n /*\n * @desc Apply color to selected text.\n * @params: value\n */\n applyColor: (value: string, themeColorName: string | undefined) => void;\n}\n\nexport const FontColorActionContext = React.createContext<FontColorActionContext | undefined>(\n undefined\n);\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAezB,OAAO,MAAMC,sBAAsB,gBAAGD,KAAK,CAACE,aAAa,CACrDC,SACJ,CAAC","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import type { LexicalEditor } from "lexical";
3
+ import type { ThemeEmotionMap, EditorTheme } from "@webiny/lexical-theme";
4
+ import type { ToolbarActionPlugin } from "../types";
5
+ export interface RichTextEditorContext {
6
+ editor: LexicalEditor;
7
+ theme?: EditorTheme;
8
+ themeEmotionMap?: ThemeEmotionMap;
9
+ toolbarActionPlugins: ToolbarActionPlugin[];
10
+ }
11
+ export declare const RichTextEditorContext: React.Context<RichTextEditorContext | undefined>;
12
+ interface RichTextEditorProviderProps {
13
+ theme: EditorTheme;
14
+ themeEmotionMap?: ThemeEmotionMap;
15
+ toolbarActionPlugins?: ToolbarActionPlugin[];
16
+ children?: React.ReactNode | React.ReactNode[];
17
+ }
18
+ export declare const RichTextEditorProvider: ({ themeEmotionMap, theme, toolbarActionPlugins, children }: RichTextEditorProviderProps) => React.JSX.Element;
19
+ export {};
@@ -0,0 +1,21 @@
1
+ import React, { createContext } from "react";
2
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
3
+ export const RichTextEditorContext = /*#__PURE__*/createContext(undefined);
4
+ export const RichTextEditorProvider = ({
5
+ themeEmotionMap,
6
+ theme,
7
+ toolbarActionPlugins = [],
8
+ children
9
+ }) => {
10
+ const [editor] = useLexicalComposerContext();
11
+ return /*#__PURE__*/React.createElement(RichTextEditorContext.Provider, {
12
+ value: {
13
+ editor,
14
+ theme,
15
+ themeEmotionMap,
16
+ toolbarActionPlugins
17
+ }
18
+ }, children);
19
+ };
20
+
21
+ //# sourceMappingURL=RichTextEditorContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","createContext","useLexicalComposerContext","RichTextEditorContext","undefined","RichTextEditorProvider","themeEmotionMap","theme","toolbarActionPlugins","children","editor","createElement","Provider","value"],"sources":["RichTextEditorContext.tsx"],"sourcesContent":["import React, { createContext } from \"react\";\nimport type { LexicalEditor } from \"lexical\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { ThemeEmotionMap, EditorTheme } from \"@webiny/lexical-theme\";\nimport type { ToolbarActionPlugin } from \"~/types\";\n\nexport interface RichTextEditorContext {\n editor: LexicalEditor;\n theme?: EditorTheme;\n themeEmotionMap?: ThemeEmotionMap;\n toolbarActionPlugins: ToolbarActionPlugin[];\n}\n\nexport const RichTextEditorContext = createContext<RichTextEditorContext | undefined>(undefined);\n\ninterface RichTextEditorProviderProps {\n theme: EditorTheme;\n themeEmotionMap?: ThemeEmotionMap;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n children?: React.ReactNode | React.ReactNode[];\n}\n\nexport const RichTextEditorProvider = ({\n themeEmotionMap,\n theme,\n toolbarActionPlugins = [],\n children\n}: RichTextEditorProviderProps) => {\n const [editor] = useLexicalComposerContext();\n\n return (\n <RichTextEditorContext.Provider\n value={{\n editor,\n theme,\n themeEmotionMap,\n toolbarActionPlugins\n }}\n >\n {children}\n </RichTextEditorContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,QAAQ,OAAO;AAE5C,SAASC,yBAAyB,QAAQ,uCAAuC;AAWjF,OAAO,MAAMC,qBAAqB,gBAAGF,aAAa,CAAoCG,SAAS,CAAC;AAShG,OAAO,MAAMC,sBAAsB,GAAGA,CAAC;EACnCC,eAAe;EACfC,KAAK;EACLC,oBAAoB,GAAG,EAAE;EACzBC;AACyB,CAAC,KAAK;EAC/B,MAAM,CAACC,MAAM,CAAC,GAAGR,yBAAyB,CAAC,CAAC;EAE5C,oBACIF,KAAA,CAAAW,aAAA,CAACR,qBAAqB,CAACS,QAAQ;IAC3BC,KAAK,EAAE;MACHH,MAAM;MACNH,KAAK;MACLD,eAAe;MACfE;IACJ;EAAE,GAEDC,QAC2B,CAAC;AAEzC,CAAC","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from "react";
2
+ import type { HistoryState } from "@lexical/history";
3
+ type ContextShape = {
4
+ historyState?: HistoryState;
5
+ };
6
+ export declare const SharedHistoryContext: ({ children }: {
7
+ children: ReactNode;
8
+ }) => JSX.Element;
9
+ export declare const useSharedHistoryContext: () => ContextShape;
10
+ export {};
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ import { createContext, useContext, useMemo } from "react";
3
+ import { createEmptyHistoryState } from "@lexical/history";
4
+ const Context = /*#__PURE__*/createContext({});
5
+ export const SharedHistoryContext = ({
6
+ children
7
+ }) => {
8
+ const historyContext = useMemo(() => ({
9
+ historyState: createEmptyHistoryState()
10
+ }), []);
11
+ return /*#__PURE__*/React.createElement(Context.Provider, {
12
+ value: historyContext
13
+ }, children);
14
+ };
15
+ export const useSharedHistoryContext = () => {
16
+ return useContext(Context);
17
+ };
18
+
19
+ //# sourceMappingURL=SharedHistoryContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","createContext","useContext","useMemo","createEmptyHistoryState","Context","SharedHistoryContext","children","historyContext","historyState","createElement","Provider","value","useSharedHistoryContext"],"sources":["SharedHistoryContext.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createContext, useContext, useMemo } from \"react\";\nimport type { HistoryState } from \"@lexical/history\";\nimport { createEmptyHistoryState } from \"@lexical/history\";\n\ntype ContextShape = {\n historyState?: HistoryState;\n};\n\nconst Context: React.Context<ContextShape> = createContext({});\n\nexport const SharedHistoryContext = ({ children }: { children: ReactNode }): JSX.Element => {\n const historyContext = useMemo(() => ({ historyState: createEmptyHistoryState() }), []);\n return <Context.Provider value={historyContext}>{children}</Context.Provider>;\n};\n\nexport const useSharedHistoryContext = (): ContextShape => {\n return useContext(Context);\n};\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAE1D,SAASC,uBAAuB,QAAQ,kBAAkB;AAM1D,MAAMC,OAAoC,gBAAGJ,aAAa,CAAC,CAAC,CAAC,CAAC;AAE9D,OAAO,MAAMK,oBAAoB,GAAGA,CAAC;EAAEC;AAAkC,CAAC,KAAkB;EACxF,MAAMC,cAAc,GAAGL,OAAO,CAAC,OAAO;IAAEM,YAAY,EAAEL,uBAAuB,CAAC;EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;EACvF,oBAAOJ,KAAA,CAAAU,aAAA,CAACL,OAAO,CAACM,QAAQ;IAACC,KAAK,EAAEJ;EAAe,GAAED,QAA2B,CAAC;AACjF,CAAC;AAED,OAAO,MAAMM,uBAAuB,GAAGA,CAAA,KAAoB;EACvD,OAAOX,UAAU,CAACG,OAAO,CAAC;AAC9B,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import type { ElementFormatType } from "lexical";
3
+ export interface TextAlignmentActionContextProps {
4
+ value: ElementFormatType;
5
+ applyTextAlignment: (value: ElementFormatType) => void;
6
+ outdentText: () => void;
7
+ indentText: () => void;
8
+ }
9
+ export declare const TextAlignmentActionContext: React.Context<TextAlignmentActionContextProps | undefined>;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ export const TextAlignmentActionContext = /*#__PURE__*/React.createContext(undefined);
3
+
4
+ //# sourceMappingURL=TextAlignmentActionContextProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","TextAlignmentActionContext","createContext","undefined"],"sources":["TextAlignmentActionContextProps.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ElementFormatType } from \"lexical\";\n\nexport interface TextAlignmentActionContextProps {\n /*\n * Selected text alignment value\n * */\n value: ElementFormatType;\n\n /*\n * Apply text alignment to selected text\n */\n applyTextAlignment: (value: ElementFormatType) => void;\n\n outdentText: () => void;\n\n indentText: () => void;\n}\n\nexport const TextAlignmentActionContext = React.createContext<\n TextAlignmentActionContextProps | undefined\n>(undefined);\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAmBzB,OAAO,MAAMC,0BAA0B,gBAAGD,KAAK,CAACE,aAAa,CAE3DC,SAAS,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import type { TypographyValue } from "@webiny/lexical-theme";
3
+ export type ActiveTypography = Pick<TypographyValue, "id" | "name">;
4
+ export interface TypographyActionContextProps {
5
+ value: ActiveTypography | undefined;
6
+ applyTypography: (value: TypographyValue) => void;
7
+ }
8
+ export declare const TypographyActionContext: React.Context<TypographyActionContextProps | undefined>;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ export const TypographyActionContext = /*#__PURE__*/React.createContext(undefined);
3
+
4
+ //# sourceMappingURL=TypographyActionContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","TypographyActionContext","createContext","undefined"],"sources":["TypographyActionContext.tsx"],"sourcesContent":["import React from \"react\";\nimport type { TypographyValue } from \"@webiny/lexical-theme\";\n\nexport type ActiveTypography = Pick<TypographyValue, \"id\" | \"name\">;\n\nexport interface TypographyActionContextProps {\n /*\n * @desc Current selected typography\n * */\n value: ActiveTypography | undefined;\n\n /*\n * @desc Apply font family to selected text.\n * @params: value\n */\n applyTypography: (value: TypographyValue) => void;\n}\n\nexport const TypographyActionContext = React.createContext<\n TypographyActionContextProps | undefined\n>(undefined);\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAkBzB,OAAO,MAAMC,uBAAuB,gBAAGD,KAAK,CAACE,aAAa,CAExDC,SAAS,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ export * from "./useRichTextEditor";
2
+ export * from "./useFontColorPicker";
3
+ export * from "./useTypographyAction";
4
+ export * from "./useTextAlignmentAction";
5
+ export * from "./useCurrentSelection";
6
+ export * from "./useCurrentElement";
7
+ export * from "./useList";
8
+ export * from "./useIsMounted";
package/hooks/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export * from "./useRichTextEditor";
2
+ export * from "./useFontColorPicker";
3
+ export * from "./useTypographyAction";
4
+ export * from "./useTextAlignmentAction";
5
+ export * from "./useCurrentSelection";
6
+ export * from "./useCurrentElement";
7
+ export * from "./useList";
8
+ export * from "./useIsMounted";
9
+
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./useRichTextEditor\";\nexport * from \"./useFontColorPicker\";\nexport * from \"./useTypographyAction\";\nexport * from \"./useTextAlignmentAction\";\nexport * from \"./useCurrentSelection\";\nexport * from \"./useCurrentElement\";\nexport * from \"./useList\";\nexport * from \"./useIsMounted\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}