@webiny/lexical-editor 6.3.0 → 6.4.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/commands/image.js +2 -1
  2. package/commands/image.js.map +1 -1
  3. package/commands/index.js +0 -2
  4. package/commands/list.js +4 -3
  5. package/commands/list.js.map +1 -1
  6. package/commands/quote.js +2 -1
  7. package/commands/quote.js.map +1 -1
  8. package/commands/toolbar.js +2 -1
  9. package/commands/toolbar.js.map +1 -1
  10. package/commands/typography.js +2 -1
  11. package/commands/typography.js.map +1 -1
  12. package/components/Editor/EnsureHeadingTagPlugin.js +8 -15
  13. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
  14. package/components/Editor/RichTextEditor.js +82 -121
  15. package/components/Editor/RichTextEditor.js.map +1 -1
  16. package/components/Editor/normalizeInputValue.js +11 -13
  17. package/components/Editor/normalizeInputValue.js.map +1 -1
  18. package/components/LexicalEditorConfig/LexicalEditorConfig.js +24 -15
  19. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
  20. package/components/LexicalEditorConfig/components/Node.js +21 -26
  21. package/components/LexicalEditorConfig/components/Node.js.map +1 -1
  22. package/components/LexicalEditorConfig/components/Plugin.js +21 -26
  23. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
  24. package/components/LexicalEditorConfig/components/ToolbarElement.js +21 -26
  25. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
  26. package/components/LexicalHtmlRenderer.js +35 -40
  27. package/components/LexicalHtmlRenderer.js.map +1 -1
  28. package/components/Toolbar/StaticToolbar.js +11 -16
  29. package/components/Toolbar/StaticToolbar.js.map +1 -1
  30. package/components/ToolbarActions/BoldAction.js +16 -19
  31. package/components/ToolbarActions/BoldAction.js.map +1 -1
  32. package/components/ToolbarActions/BulletListAction.js +24 -32
  33. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  34. package/components/ToolbarActions/CodeHighlightAction.js +16 -19
  35. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
  36. package/components/ToolbarActions/FontColorAction.js +32 -38
  37. package/components/ToolbarActions/FontColorAction.js.map +1 -1
  38. package/components/ToolbarActions/ImageAction.js +28 -30
  39. package/components/ToolbarActions/ImageAction.js.map +1 -1
  40. package/components/ToolbarActions/ItalicAction.js +16 -19
  41. package/components/ToolbarActions/ItalicAction.js.map +1 -1
  42. package/components/ToolbarActions/LinkAction.js +25 -30
  43. package/components/ToolbarActions/LinkAction.js.map +1 -1
  44. package/components/ToolbarActions/NumberedListAction.js +28 -37
  45. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  46. package/components/ToolbarActions/QuoteAction.js +22 -27
  47. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  48. package/components/ToolbarActions/TextAlignmentAction.js +38 -50
  49. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
  50. package/components/ToolbarActions/TypographyAction.js +69 -99
  51. package/components/ToolbarActions/TypographyAction.js.map +1 -1
  52. package/components/ToolbarActions/UnderlineAction.js +16 -19
  53. package/components/ToolbarActions/UnderlineAction.js.map +1 -1
  54. package/context/FontColorActionContext.js +3 -2
  55. package/context/FontColorActionContext.js.map +1 -1
  56. package/context/RichTextEditorContext.js +26 -29
  57. package/context/RichTextEditorContext.js.map +1 -1
  58. package/context/SharedHistoryContext.js +11 -15
  59. package/context/SharedHistoryContext.js.map +1 -1
  60. package/context/TextAlignmentActionContextProps.js +3 -2
  61. package/context/TextAlignmentActionContextProps.js.map +1 -1
  62. package/context/TypographyActionContext.js +3 -2
  63. package/context/TypographyActionContext.js.map +1 -1
  64. package/exports/admin/lexical.js +2 -20
  65. package/hooks/index.js +0 -2
  66. package/hooks/useCurrentElement.js +18 -21
  67. package/hooks/useCurrentElement.js.map +1 -1
  68. package/hooks/useCurrentSelection.js +39 -48
  69. package/hooks/useCurrentSelection.js.map +1 -1
  70. package/hooks/useFontColorPicker.js +5 -6
  71. package/hooks/useFontColorPicker.js.map +1 -1
  72. package/hooks/useIsMounted.js +7 -8
  73. package/hooks/useIsMounted.js.map +1 -1
  74. package/hooks/useRichTextEditor.js +5 -6
  75. package/hooks/useRichTextEditor.js.map +1 -1
  76. package/hooks/useTextAlignmentAction.js +5 -6
  77. package/hooks/useTextAlignmentAction.js.map +1 -1
  78. package/hooks/useTypographyAction.js +5 -6
  79. package/hooks/useTypographyAction.js.map +1 -1
  80. package/images/icons/chat-square-quote.js +19 -0
  81. package/images/icons/chat-square-quote.js.map +1 -0
  82. package/images/icons/chevron-down.js +18 -0
  83. package/images/icons/chevron-down.js.map +1 -0
  84. package/images/icons/code.js +17 -0
  85. package/images/icons/code.js.map +1 -0
  86. package/images/icons/font-color.js +17 -0
  87. package/images/icons/font-color.js.map +1 -0
  88. package/images/icons/indent.js +18 -0
  89. package/images/icons/indent.js.map +1 -0
  90. package/images/icons/insert-image.js +20 -0
  91. package/images/icons/insert-image.js.map +1 -0
  92. package/images/icons/justify.js +19 -0
  93. package/images/icons/justify.js.map +1 -0
  94. package/images/icons/link.js +19 -0
  95. package/images/icons/link.js.map +1 -0
  96. package/images/icons/list-ol.js +20 -0
  97. package/images/icons/list-ol.js.map +1 -0
  98. package/images/icons/list-ul.js +18 -0
  99. package/images/icons/list-ul.js.map +1 -0
  100. package/images/icons/outdent.js +18 -0
  101. package/images/icons/outdent.js.map +1 -0
  102. package/images/icons/pencil-fill.js +17 -0
  103. package/images/icons/pencil-fill.js.map +1 -0
  104. package/images/icons/text-center.js +18 -0
  105. package/images/icons/text-center.js.map +1 -0
  106. package/images/icons/text-left.js +18 -0
  107. package/images/icons/text-left.js.map +1 -0
  108. package/images/icons/text-paragraph.js +18 -0
  109. package/images/icons/text-paragraph.js.map +1 -0
  110. package/images/icons/text-right.js +18 -0
  111. package/images/icons/text-right.js.map +1 -0
  112. package/images/icons/type-bold.js +17 -0
  113. package/images/icons/type-bold.js.map +1 -0
  114. package/images/icons/type-h1.js +17 -0
  115. package/images/icons/type-h1.js.map +1 -0
  116. package/images/icons/type-h2.js +17 -0
  117. package/images/icons/type-h2.js.map +1 -0
  118. package/images/icons/type-h3.js +17 -0
  119. package/images/icons/type-h3.js.map +1 -0
  120. package/images/icons/type-h4.js +17 -0
  121. package/images/icons/type-h4.js.map +1 -0
  122. package/images/icons/type-h5.js +17 -0
  123. package/images/icons/type-h5.js.map +1 -0
  124. package/images/icons/type-h6.js +17 -0
  125. package/images/icons/type-h6.js.map +1 -0
  126. package/images/icons/type-italic.js +17 -0
  127. package/images/icons/type-italic.js.map +1 -0
  128. package/images/icons/type-strikethrough.js +17 -0
  129. package/images/icons/type-strikethrough.js.map +1 -0
  130. package/images/icons/type-underline.js +17 -0
  131. package/images/icons/type-underline.js.map +1 -0
  132. package/images/icons/unlink_icon.js +27 -0
  133. package/images/icons/unlink_icon.js.map +1 -0
  134. package/index.js +5 -18
  135. package/package.json +7 -7
  136. package/plugins/BlurEventPlugin/BlurEventPlugin.js +11 -14
  137. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
  138. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +7 -8
  139. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
  140. package/plugins/CodeHighlightPlugin/index.js +0 -2
  141. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +16 -24
  142. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -1
  143. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +37 -51
  144. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -1
  145. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +6 -5
  146. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  147. package/plugins/FloatingLinkEditorPlugin/index.js +0 -2
  148. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +6 -9
  149. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
  150. package/plugins/FloatingLinkEditorPlugin/types.js +0 -3
  151. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +101 -108
  152. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -1
  153. package/plugins/FontColorPlugin/FontColorPlugin.js +14 -19
  154. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
  155. package/plugins/FontColorPlugin/applyColorToNode.js +5 -4
  156. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
  157. package/plugins/FontColorPlugin/applyColorToSelection.js +42 -60
  158. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
  159. package/plugins/ImagesPlugin/ImagesPlugin.js +79 -121
  160. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
  161. package/plugins/LinkPlugin/LinkPlugin.js +46 -52
  162. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
  163. package/plugins/ListPLugin/ListPlugin.js +44 -52
  164. package/plugins/ListPLugin/ListPlugin.js.map +1 -1
  165. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -19
  166. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
  167. package/plugins/StateHandlingPlugin.js +55 -64
  168. package/plugins/StateHandlingPlugin.js.map +1 -1
  169. package/plugins/TypographyPlugin/TypographyPlugin.js +13 -20
  170. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
  171. package/static/svg/chat-square-quote.123cfa24.svg +1 -0
  172. package/static/svg/chevron-down.d9636921.svg +1 -0
  173. package/static/svg/code.912b1f4d.svg +1 -0
  174. package/static/svg/font-color.4f0c0de5.svg +1 -0
  175. package/static/svg/indent.4d78e483.svg +3 -0
  176. package/static/svg/insert-image.354465f1.svg +4 -0
  177. package/static/svg/justify.dab42aec.svg +3 -0
  178. package/static/svg/link.b774de25.svg +1 -0
  179. package/static/svg/list-ol.d64946f3.svg +1 -0
  180. package/static/svg/list-ul.1d54da3f.svg +1 -0
  181. package/static/svg/outdent.5c13ff16.svg +3 -0
  182. package/static/svg/pencil-fill.94cb216b.svg +1 -0
  183. package/static/svg/text-center.a411e780.svg +1 -0
  184. package/static/svg/text-left.54f41f4e.svg +1 -0
  185. package/static/svg/text-paragraph.61674422.svg +1 -0
  186. package/static/svg/text-right.9288b7a2.svg +1 -0
  187. package/static/svg/type-bold.7e3e270b.svg +1 -0
  188. package/static/svg/type-h1.f292ffe1.svg +1 -0
  189. package/static/svg/type-h2.a9d1aa48.svg +1 -0
  190. package/static/svg/type-h3.4a29ff88.svg +1 -0
  191. package/static/svg/type-h4.7f48750c.svg +1 -0
  192. package/static/svg/type-h5.14b4ac56.svg +1 -0
  193. package/static/svg/type-h6.4e9dfe2d.svg +1 -0
  194. package/static/svg/type-italic.d8e45748.svg +1 -0
  195. package/static/svg/type-strikethrough.2694a816.svg +1 -0
  196. package/static/svg/type-underline.104a0ed5.svg +1 -0
  197. package/static/svg/unlink_icon.074ceed3.svg +1 -0
  198. package/types.js +0 -8
  199. package/ui/ContentEditable.js +6 -14
  200. package/ui/ContentEditable.js.map +1 -1
  201. package/ui/Divider.js +6 -5
  202. package/ui/Divider.js.map +1 -1
  203. package/ui/DropDown.js +146 -176
  204. package/ui/DropDown.js.map +1 -1
  205. package/ui/ImageResizer.js +173 -204
  206. package/ui/ImageResizer.js.map +1 -1
  207. package/ui/LinkPreview.js +61 -84
  208. package/ui/LinkPreview.js.map +1 -1
  209. package/ui/Placeholder.js +9 -20
  210. package/ui/Placeholder.js.map +1 -1
  211. package/ui/TextInput.js +17 -30
  212. package/ui/TextInput.js.map +1 -1
  213. package/ui/ToolbarActionDialog.js +64 -73
  214. package/ui/ToolbarActionDialog.js.map +1 -1
  215. package/utils/canUseDOM.js +2 -1
  216. package/utils/canUseDOM.js.map +1 -1
  217. package/utils/files.js +9 -8
  218. package/utils/files.js.map +1 -1
  219. package/utils/getDOMRangeRect.js +10 -20
  220. package/utils/getDOMRangeRect.js.map +1 -1
  221. package/utils/getSelectedNode.js +9 -20
  222. package/utils/getSelectedNode.js.map +1 -1
  223. package/utils/getTransparentImage.js +2 -3
  224. package/utils/getTransparentImage.js.map +1 -1
  225. package/utils/insertImage.js +9 -11
  226. package/utils/insertImage.js.map +1 -1
  227. package/utils/isAnchorLink.js +2 -3
  228. package/utils/isAnchorLink.js.map +1 -1
  229. package/utils/isChildOfFloatingToolbar.js +6 -9
  230. package/utils/isChildOfFloatingToolbar.js.map +1 -1
  231. package/utils/isHTMLElement.js +3 -9
  232. package/utils/isHTMLElement.js.map +1 -1
  233. package/utils/isValidJSON.js +9 -10
  234. package/utils/isValidJSON.js.map +1 -1
  235. package/utils/isValidLexicalData.js +17 -20
  236. package/utils/isValidLexicalData.js.map +1 -1
  237. package/utils/point.js +32 -45
  238. package/utils/point.js.map +1 -1
  239. package/utils/rect.js +92 -125
  240. package/utils/rect.js.map +1 -1
  241. package/utils/sanitizeUrl.js +8 -21
  242. package/utils/sanitizeUrl.js.map +1 -1
  243. package/utils/setFloatingElemPosition.js +23 -27
  244. package/utils/setFloatingElemPosition.js.map +1 -1
  245. package/commands/index.js.map +0 -1
  246. package/exports/admin/lexical.js.map +0 -1
  247. package/hooks/index.js.map +0 -1
  248. package/index.js.map +0 -1
  249. package/plugins/CodeHighlightPlugin/index.js.map +0 -1
  250. package/plugins/FloatingLinkEditorPlugin/index.js.map +0 -1
  251. package/plugins/FloatingLinkEditorPlugin/types.js.map +0 -1
  252. package/types.js.map +0 -1
@@ -1,111 +1,81 @@
1
- import React, { useCallback, useEffect, useState } from "react";
1
+ import react, { useCallback, useEffect, useState } from "react";
2
2
  import { Compose, makeDecoratable } from "@webiny/react-composition";
3
3
  import { TypographyActionContext } from "../../context/TypographyActionContext.js";
4
4
  import { $isHeadingNode, $isListNode, $isParagraphNode, $isQuoteNode } from "@webiny/lexical-nodes";
5
5
  import { useRichTextEditor } from "../../hooks/useRichTextEditor.js";
6
- import { INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, INSERT_QUOTE_COMMAND, ADD_TYPOGRAPHY_COMMAND } from "../../commands/index.js";
6
+ import { ADD_TYPOGRAPHY_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_QUOTE_COMMAND, INSERT_UNORDERED_LIST_COMMAND } from "../../commands/index.js";
7
7
  import { useCurrentElement } from "../../hooks/useCurrentElement.js";
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;
8
+ const quoteTagNames = [
9
+ "blockquote",
10
+ "quoteblock"
11
+ ];
12
+ const BaseTypographyActionDropDown = makeDecoratable("BaseTypographyActionDropDown", ()=>{
13
+ useEffect(()=>{
14
+ console.log("Default BaseTypographyActionDropDown, please add your own component");
15
+ }, []);
16
+ return null;
21
17
  });
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
- theme
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
- return;
49
- }
50
- if (value.tag === "ol") {
51
- editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, {
52
- themeStyleId: value.id
53
- });
54
- return;
55
- }
56
- if (value.tag === "ul") {
57
- editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, {
58
- themeStyleId: value.id
59
- });
60
- return;
61
- }
62
- if (quoteTagNames.includes(value.tag)) {
63
- editor.dispatchCommand(INSERT_QUOTE_COMMAND, {
64
- themeStyleId: value.id
65
- });
66
- }
67
- }, []);
68
- useEffect(() => {
69
- if (!element) {
70
- return;
71
- }
72
- if (isParagraphSelected || isHeadingSelected || isQuoteSelected) {
73
- const styleId = element.getStyleId();
74
- if (!styleId) {
75
- return;
76
- }
77
- const style = theme.getTypographyById(styleId);
78
- if (style) {
79
- setTypography({
80
- id: style.id,
81
- label: style.label
18
+ const TypographyActionDropDown = ({ element })=>/*#__PURE__*/ react.createElement(Compose, {
19
+ component: BaseTypographyActionDropDown,
20
+ with: ()=>()=>element
21
+ });
22
+ const TypographyAction = ()=>{
23
+ const [typography, setTypography] = useState();
24
+ const { editor, theme } = useRichTextEditor();
25
+ const { element } = useCurrentElement();
26
+ const isParagraphSelected = $isParagraphNode(element);
27
+ const isHeadingSelected = $isHeadingNode(element);
28
+ const isQuoteSelected = $isQuoteNode(element);
29
+ const onTypographySelect = useCallback((value)=>{
30
+ setTypography(value);
31
+ if (value.tag.includes("h") || value.tag.includes("p")) return void editor.dispatchCommand(ADD_TYPOGRAPHY_COMMAND, {
32
+ value
82
33
  });
83
- }
84
- return;
85
- }
86
-
87
- // list and quote element
88
- if ($isListNode(element)) {
89
- const styleId = element.getStyleId();
90
- if (!styleId) {
91
- return;
92
- }
93
- const style = theme.getTypographyById(styleId);
94
- if (style) {
95
- setTypography({
96
- id: style.id,
97
- label: style.label
34
+ if ("ol" === value.tag) return void editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, {
35
+ themeStyleId: value.id
36
+ });
37
+ if ("ul" === value.tag) return void editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, {
38
+ themeStyleId: value.id
39
+ });
40
+ if (quoteTagNames.includes(value.tag)) editor.dispatchCommand(INSERT_QUOTE_COMMAND, {
41
+ themeStyleId: value.id
98
42
  });
99
- }
100
- }
101
- }, [element, isQuoteSelected, isParagraphSelected, isHeadingSelected]);
102
- return /*#__PURE__*/React.createElement(TypographyActionContext.Provider, {
103
- value: {
104
- value: typography,
105
- applyTypography: onTypographySelect
106
- }
107
- }, /*#__PURE__*/React.createElement(BaseTypographyActionDropDown, null));
43
+ }, []);
44
+ useEffect(()=>{
45
+ if (!element) return;
46
+ if (isParagraphSelected || isHeadingSelected || isQuoteSelected) {
47
+ const styleId = element.getStyleId();
48
+ if (!styleId) return;
49
+ const style = theme.getTypographyById(styleId);
50
+ if (style) setTypography({
51
+ id: style.id,
52
+ label: style.label
53
+ });
54
+ return;
55
+ }
56
+ if ($isListNode(element)) {
57
+ const styleId = element.getStyleId();
58
+ if (!styleId) return;
59
+ const style = theme.getTypographyById(styleId);
60
+ if (style) setTypography({
61
+ id: style.id,
62
+ label: style.label
63
+ });
64
+ }
65
+ }, [
66
+ element,
67
+ isQuoteSelected,
68
+ isParagraphSelected,
69
+ isHeadingSelected
70
+ ]);
71
+ return /*#__PURE__*/ react.createElement(TypographyActionContext.Provider, {
72
+ value: {
73
+ value: typography,
74
+ applyTypography: onTypographySelect
75
+ }
76
+ }, /*#__PURE__*/ react.createElement(BaseTypographyActionDropDown, null));
108
77
  };
109
78
  TypographyAction.TypographyDropDown = TypographyActionDropDown;
79
+ export { BaseTypographyActionDropDown, TypographyAction };
110
80
 
111
81
  //# sourceMappingURL=TypographyAction.js.map
@@ -1 +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","theme","isParagraphSelected","isHeadingSelected","isQuoteSelected","onTypographySelect","value","tag","includes","dispatchCommand","themeStyleId","id","styleId","getStyleId","style","getTypographyById","label","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.js\";\nimport { TypographyActionContext } from \"~/context/TypographyActionContext.js\";\nimport { $isHeadingNode, $isListNode, $isParagraphNode, $isQuoteNode } from \"@webiny/lexical-nodes\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor.js\";\nimport type {\n ListCommandPayload,\n QuoteCommandPayload,\n TypographyPayload\n} from \"~/commands/index.js\";\nimport {\n INSERT_ORDERED_LIST_COMMAND,\n INSERT_UNORDERED_LIST_COMMAND,\n INSERT_QUOTE_COMMAND,\n ADD_TYPOGRAPHY_COMMAND\n} from \"~/commands/index.js\";\nimport { useCurrentElement } from \"~/hooks/useCurrentElement.js\";\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 (): React.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: React.JSX.Element;\n}\n\nconst TypographyActionDropDown = ({\n element\n}: TypographyActionDropdownProps): React.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, theme } = 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 return;\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 return;\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 return;\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) {\n return;\n }\n\n if (isParagraphSelected || isHeadingSelected || isQuoteSelected) {\n const styleId = element.getStyleId();\n if (!styleId) {\n return;\n }\n\n const style = theme.getTypographyById(styleId);\n if (style) {\n setTypography({\n id: style.id,\n label: style.label\n });\n }\n return;\n }\n\n // list and quote element\n if ($isListNode(element)) {\n const styleId = element.getStyleId();\n if (!styleId) {\n return;\n }\n\n const style = theme.getTypographyById(styleId);\n if (style) {\n setTypography({\n id: style.id,\n label: style.label\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":[]}
1
+ {"version":3,"file":"components/ToolbarActions/TypographyAction.js","sources":["../../../src/components/ToolbarActions/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.js\";\nimport { TypographyActionContext } from \"~/context/TypographyActionContext.js\";\nimport { $isHeadingNode, $isListNode, $isParagraphNode, $isQuoteNode } from \"@webiny/lexical-nodes\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor.js\";\nimport type {\n ListCommandPayload,\n QuoteCommandPayload,\n TypographyPayload\n} from \"~/commands/index.js\";\nimport {\n INSERT_ORDERED_LIST_COMMAND,\n INSERT_UNORDERED_LIST_COMMAND,\n INSERT_QUOTE_COMMAND,\n ADD_TYPOGRAPHY_COMMAND\n} from \"~/commands/index.js\";\nimport { useCurrentElement } from \"~/hooks/useCurrentElement.js\";\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 (): React.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: React.JSX.Element;\n}\n\nconst TypographyActionDropDown = ({\n element\n}: TypographyActionDropdownProps): React.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, theme } = 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 return;\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 return;\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 return;\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) {\n return;\n }\n\n if (isParagraphSelected || isHeadingSelected || isQuoteSelected) {\n const styleId = element.getStyleId();\n if (!styleId) {\n return;\n }\n\n const style = theme.getTypographyById(styleId);\n if (style) {\n setTypography({\n id: style.id,\n label: style.label\n });\n }\n return;\n }\n\n // list and quote element\n if ($isListNode(element)) {\n const styleId = element.getStyleId();\n if (!styleId) {\n return;\n }\n\n const style = theme.getTypographyById(styleId);\n if (style) {\n setTypography({\n id: style.id,\n label: style.label\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"],"names":["quoteTagNames","BaseTypographyActionDropDown","makeDecoratable","useEffect","console","TypographyActionDropDown","element","Compose","TypographyAction","typography","setTypography","useState","editor","theme","useRichTextEditor","useCurrentElement","isParagraphSelected","$isParagraphNode","isHeadingSelected","$isHeadingNode","isQuoteSelected","$isQuoteNode","onTypographySelect","useCallback","value","ADD_TYPOGRAPHY_COMMAND","INSERT_ORDERED_LIST_COMMAND","INSERT_UNORDERED_LIST_COMMAND","INSERT_QUOTE_COMMAND","styleId","style","$isListNode","TypographyActionContext"],"mappings":";;;;;;;AAsBA,MAAMA,gBAAgB;IAAC;IAAc;CAAa;AAM3C,MAAMC,+BAA+BC,gBACxC,gCACA;IACIC,UAAU;QACNC,QAAQ,GAAG,CAAC;IAChB,GAAG,EAAE;IACL,OAAO;AACX;AAOJ,MAAMC,2BAA2B,CAAC,EAC9BC,OAAO,EACqB,GACrB,WAAP,GAAO,oBAACC,SAAOA;QAAC,WAAWN;QAA8B,MAAM,IAAM,IAAMK;;AAOxE,MAAME,mBAAqC;IAC9C,MAAM,CAACC,YAAYC,cAAc,GAAGC;IACpC,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAC1B,MAAM,EAAER,OAAO,EAAE,GAAGS;IACpB,MAAMC,sBAAsBC,iBAAiBX;IAC7C,MAAMY,oBAAoBC,eAAeb;IACzC,MAAMc,kBAAkBC,aAAaf;IAErC,MAAMgB,qBAAqBC,YAAY,CAACC;QACpCd,cAAcc;QAEd,IAAIA,MAAM,GAAG,CAAC,QAAQ,CAAC,QAAQA,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,YACpDZ,OAAO,eAAe,CAAoCa,wBAAwB;YAC9ED;QACJ;QAIJ,IAAIA,AAAc,SAAdA,MAAM,GAAG,EAAW,YACpBZ,OAAO,eAAe,CAClBc,6BACA;YACI,cAAcF,MAAM,EAAE;QAC1B;QAKR,IAAIA,AAAc,SAAdA,MAAM,GAAG,EAAW,YACpBZ,OAAO,eAAe,CAClBe,+BACA;YACI,cAAcH,MAAM,EAAE;QAC1B;QAKR,IAAIxB,cAAc,QAAQ,CAACwB,MAAM,GAAG,GAChCZ,OAAO,eAAe,CAAsCgB,sBAAsB;YAC9E,cAAcJ,MAAM,EAAE;QAC1B;IAER,GAAG,EAAE;IAELrB,UAAU;QACN,IAAI,CAACG,SACD;QAGJ,IAAIU,uBAAuBE,qBAAqBE,iBAAiB;YAC7D,MAAMS,UAAUvB,QAAQ,UAAU;YAClC,IAAI,CAACuB,SACD;YAGJ,MAAMC,QAAQjB,MAAM,iBAAiB,CAACgB;YACtC,IAAIC,OACApB,cAAc;gBACV,IAAIoB,MAAM,EAAE;gBACZ,OAAOA,MAAM,KAAK;YACtB;YAEJ;QACJ;QAGA,IAAIC,YAAYzB,UAAU;YACtB,MAAMuB,UAAUvB,QAAQ,UAAU;YAClC,IAAI,CAACuB,SACD;YAGJ,MAAMC,QAAQjB,MAAM,iBAAiB,CAACgB;YACtC,IAAIC,OACApB,cAAc;gBACV,IAAIoB,MAAM,EAAE;gBACZ,OAAOA,MAAM,KAAK;YACtB;QAER;IACJ,GAAG;QAACxB;QAASc;QAAiBJ;QAAqBE;KAAkB;IAErE,OAAO,WAAP,GACI,oBAACc,wBAAwB,QAAQ;QAC7B,OAAO;YACH,OAAOvB;YACP,iBAAiBa;QACrB;qBAEA,oBAACrB,8BAA4BA;AAGzC;AAEAO,iBAAiB,kBAAkB,GAAGH"}
@@ -1,24 +1,21 @@
1
- import React from "react";
1
+ import react from "react";
2
2
  import { FORMAT_TEXT_COMMAND } from "lexical";
3
3
  import { useCurrentSelection, useRichTextEditor } from "../../hooks/index.js";
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
- }));
4
+ const UnderlineAction = ()=>{
5
+ const { editor } = useRichTextEditor();
6
+ const { rangeSelection } = useCurrentSelection();
7
+ const isUnderlineSelected = rangeSelection ? rangeSelection.hasFormat("underline") : false;
8
+ const handleClick = ()=>{
9
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, "underline");
10
+ };
11
+ return /*#__PURE__*/ react.createElement("button", {
12
+ onClick: handleClick,
13
+ className: "popup-item spaced " + (isUnderlineSelected ? "active" : ""),
14
+ "aria-label": "Underline text"
15
+ }, /*#__PURE__*/ react.createElement("i", {
16
+ className: "format underline"
17
+ }));
22
18
  };
19
+ export { UnderlineAction };
23
20
 
24
21
  //# sourceMappingURL=UnderlineAction.js.map
@@ -1 +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/index.js\";\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":[]}
1
+ {"version":3,"file":"components/ToolbarActions/UnderlineAction.js","sources":["../../../src/components/ToolbarActions/UnderlineAction.tsx"],"sourcesContent":["import React from \"react\";\nimport { FORMAT_TEXT_COMMAND } from \"lexical\";\nimport { useCurrentSelection, useRichTextEditor } from \"~/hooks/index.js\";\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"],"names":["UnderlineAction","editor","useRichTextEditor","rangeSelection","useCurrentSelection","isUnderlineSelected","handleClick","FORMAT_TEXT_COMMAND"],"mappings":";;;AAIO,MAAMA,kBAAkB;IAC3B,MAAM,EAAEC,MAAM,EAAE,GAAGC;IACnB,MAAM,EAAEC,cAAc,EAAE,GAAGC;IAC3B,MAAMC,sBAAsBF,iBAAiBA,eAAe,SAAS,CAAC,eAAe;IAErF,MAAMG,cAAc;QAChBL,OAAO,eAAe,CAACM,qBAAqB;IAChD;IAEA,OAAO,WAAP,GACI,oBAAC;QACG,SAASD;QACT,WAAW,uBAAwBD,CAAAA,sBAAsB,WAAW,EAAC;QACrE,cAAW;qBAEX,oBAAC;QAAE,WAAU;;AAGzB"}
@@ -1,4 +1,5 @@
1
- import React from "react";
2
- export const FontColorActionContext = /*#__PURE__*/React.createContext(undefined);
1
+ import react from "react";
2
+ const FontColorActionContext = /*#__PURE__*/ react.createContext(void 0);
3
+ export { FontColorActionContext };
3
4
 
4
5
  //# sourceMappingURL=FontColorActionContext.js.map
@@ -1 +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":[]}
1
+ {"version":3,"file":"context/FontColorActionContext.js","sources":["../../src/context/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"],"names":["FontColorActionContext","React","undefined"],"mappings":";AAeO,MAAMA,yBAAyB,WAAHA,GAAGC,MAAAA,aAAmB,CACrDC"}
@@ -1,34 +1,31 @@
1
- import React, { createContext, useCallback, useMemo } from "react";
1
+ import react, { createContext, useCallback, useMemo } from "react";
2
2
  import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
3
3
  import { Theme } from "@webiny/lexical-theme";
4
- export const RichTextEditorContext = /*#__PURE__*/createContext(undefined);
5
- export const RichTextEditorProvider = ({
6
- theme,
7
- toolbarActionPlugins = [],
8
- children
9
- }) => {
10
- const [editor] = useLexicalComposerContext();
11
- const getOverlaysElement = useCallback(() => {
12
- const rootElement = editor.getRootElement();
13
- if (!rootElement) {
14
- return document.body;
15
- }
16
- const shell = rootElement.closest(".editor-shell");
17
- if (!shell) {
18
- return document.body;
19
- }
20
- const overlays = shell.previousElementSibling;
21
- return overlays ?? document.body;
22
- }, [editor]);
23
- const internalTheme = useMemo(() => new Theme(theme.colors, theme.typography, theme.tokens), [theme]);
24
- return /*#__PURE__*/React.createElement(RichTextEditorContext.Provider, {
25
- value: {
26
- editor,
27
- getOverlaysElement,
28
- theme: internalTheme,
29
- toolbarActionPlugins
30
- }
31
- }, children);
4
+ const RichTextEditorContext = /*#__PURE__*/ createContext(void 0);
5
+ const RichTextEditorProvider = ({ theme, toolbarActionPlugins = [], children })=>{
6
+ const [editor] = useLexicalComposerContext();
7
+ const getOverlaysElement = useCallback(()=>{
8
+ const rootElement = editor.getRootElement();
9
+ if (!rootElement) return document.body;
10
+ const shell = rootElement.closest(".editor-shell");
11
+ if (!shell) return document.body;
12
+ const overlays = shell.previousElementSibling;
13
+ return overlays ?? document.body;
14
+ }, [
15
+ editor
16
+ ]);
17
+ const internalTheme = useMemo(()=>new Theme(theme.colors, theme.typography, theme.tokens), [
18
+ theme
19
+ ]);
20
+ return /*#__PURE__*/ react.createElement(RichTextEditorContext.Provider, {
21
+ value: {
22
+ editor,
23
+ getOverlaysElement,
24
+ theme: internalTheme,
25
+ toolbarActionPlugins
26
+ }
27
+ }, children);
32
28
  };
29
+ export { RichTextEditorContext, RichTextEditorProvider };
33
30
 
34
31
  //# sourceMappingURL=RichTextEditorContext.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","createContext","useCallback","useMemo","useLexicalComposerContext","Theme","RichTextEditorContext","undefined","RichTextEditorProvider","theme","toolbarActionPlugins","children","editor","getOverlaysElement","rootElement","getRootElement","document","body","shell","closest","overlays","previousElementSibling","internalTheme","colors","typography","tokens","createElement","Provider","value"],"sources":["RichTextEditorContext.tsx"],"sourcesContent":["import React, { createContext, useCallback, useMemo } from \"react\";\nimport type { LexicalEditor } from \"lexical\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { type EditorTheme, Theme } from \"@webiny/lexical-theme\";\nimport type { ToolbarActionPlugin } from \"~/types.js\";\n\nexport interface RichTextEditorContext {\n editor: LexicalEditor;\n getOverlaysElement: () => HTMLElement;\n toolbarActionPlugins: ToolbarActionPlugin[];\n theme: Theme;\n}\n\nexport const RichTextEditorContext = createContext<RichTextEditorContext | undefined>(undefined);\n\ninterface RichTextEditorProviderProps {\n theme: EditorTheme;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n children?: React.ReactNode | React.ReactNode[];\n}\n\nexport const RichTextEditorProvider = ({\n theme,\n toolbarActionPlugins = [],\n children\n}: RichTextEditorProviderProps) => {\n const [editor] = useLexicalComposerContext();\n\n const getOverlaysElement = useCallback(() => {\n const rootElement = editor.getRootElement();\n if (!rootElement) {\n return document.body;\n }\n\n const shell = rootElement.closest(\".editor-shell\");\n if (!shell) {\n return document.body;\n }\n const overlays = shell.previousElementSibling;\n\n return (overlays ?? document.body) as HTMLElement;\n }, [editor]);\n\n const internalTheme = useMemo(\n () => new Theme(theme.colors, theme.typography, theme.tokens),\n [theme]\n );\n\n return (\n <RichTextEditorContext.Provider\n value={{\n editor,\n getOverlaysElement,\n theme: internalTheme,\n toolbarActionPlugins\n }}\n >\n {children}\n </RichTextEditorContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAElE,SAASC,yBAAyB,QAAQ,uCAAuC;AACjF,SAA2BC,KAAK,QAAQ,uBAAuB;AAU/D,OAAO,MAAMC,qBAAqB,gBAAGL,aAAa,CAAoCM,SAAS,CAAC;AAQhG,OAAO,MAAMC,sBAAsB,GAAGA,CAAC;EACnCC,KAAK;EACLC,oBAAoB,GAAG,EAAE;EACzBC;AACyB,CAAC,KAAK;EAC/B,MAAM,CAACC,MAAM,CAAC,GAAGR,yBAAyB,CAAC,CAAC;EAE5C,MAAMS,kBAAkB,GAAGX,WAAW,CAAC,MAAM;IACzC,MAAMY,WAAW,GAAGF,MAAM,CAACG,cAAc,CAAC,CAAC;IAC3C,IAAI,CAACD,WAAW,EAAE;MACd,OAAOE,QAAQ,CAACC,IAAI;IACxB;IAEA,MAAMC,KAAK,GAAGJ,WAAW,CAACK,OAAO,CAAC,eAAe,CAAC;IAClD,IAAI,CAACD,KAAK,EAAE;MACR,OAAOF,QAAQ,CAACC,IAAI;IACxB;IACA,MAAMG,QAAQ,GAAGF,KAAK,CAACG,sBAAsB;IAE7C,OAAQD,QAAQ,IAAIJ,QAAQ,CAACC,IAAI;EACrC,CAAC,EAAE,CAACL,MAAM,CAAC,CAAC;EAEZ,MAAMU,aAAa,GAAGnB,OAAO,CACzB,MAAM,IAAIE,KAAK,CAACI,KAAK,CAACc,MAAM,EAAEd,KAAK,CAACe,UAAU,EAAEf,KAAK,CAACgB,MAAM,CAAC,EAC7D,CAAChB,KAAK,CACV,CAAC;EAED,oBACIT,KAAA,CAAA0B,aAAA,CAACpB,qBAAqB,CAACqB,QAAQ;IAC3BC,KAAK,EAAE;MACHhB,MAAM;MACNC,kBAAkB;MAClBJ,KAAK,EAAEa,aAAa;MACpBZ;IACJ;EAAE,GAEDC,QAC2B,CAAC;AAEzC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"context/RichTextEditorContext.js","sources":["../../src/context/RichTextEditorContext.tsx"],"sourcesContent":["import React, { createContext, useCallback, useMemo } from \"react\";\nimport type { LexicalEditor } from \"lexical\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { type EditorTheme, Theme } from \"@webiny/lexical-theme\";\nimport type { ToolbarActionPlugin } from \"~/types.js\";\n\nexport interface RichTextEditorContext {\n editor: LexicalEditor;\n getOverlaysElement: () => HTMLElement;\n toolbarActionPlugins: ToolbarActionPlugin[];\n theme: Theme;\n}\n\nexport const RichTextEditorContext = createContext<RichTextEditorContext | undefined>(undefined);\n\ninterface RichTextEditorProviderProps {\n theme: EditorTheme;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n children?: React.ReactNode | React.ReactNode[];\n}\n\nexport const RichTextEditorProvider = ({\n theme,\n toolbarActionPlugins = [],\n children\n}: RichTextEditorProviderProps) => {\n const [editor] = useLexicalComposerContext();\n\n const getOverlaysElement = useCallback(() => {\n const rootElement = editor.getRootElement();\n if (!rootElement) {\n return document.body;\n }\n\n const shell = rootElement.closest(\".editor-shell\");\n if (!shell) {\n return document.body;\n }\n const overlays = shell.previousElementSibling;\n\n return (overlays ?? document.body) as HTMLElement;\n }, [editor]);\n\n const internalTheme = useMemo(\n () => new Theme(theme.colors, theme.typography, theme.tokens),\n [theme]\n );\n\n return (\n <RichTextEditorContext.Provider\n value={{\n editor,\n getOverlaysElement,\n theme: internalTheme,\n toolbarActionPlugins\n }}\n >\n {children}\n </RichTextEditorContext.Provider>\n );\n};\n"],"names":["RichTextEditorContext","createContext","undefined","RichTextEditorProvider","theme","toolbarActionPlugins","children","editor","useLexicalComposerContext","getOverlaysElement","useCallback","rootElement","document","shell","overlays","internalTheme","useMemo","Theme"],"mappings":";;;AAaO,MAAMA,wBAAwB,WAAHA,GAAGC,cAAiDC;AAQ/E,MAAMC,yBAAyB,CAAC,EACnCC,KAAK,EACLC,uBAAuB,EAAE,EACzBC,QAAQ,EACkB;IAC1B,MAAM,CAACC,OAAO,GAAGC;IAEjB,MAAMC,qBAAqBC,YAAY;QACnC,MAAMC,cAAcJ,OAAO,cAAc;QACzC,IAAI,CAACI,aACD,OAAOC,SAAS,IAAI;QAGxB,MAAMC,QAAQF,YAAY,OAAO,CAAC;QAClC,IAAI,CAACE,OACD,OAAOD,SAAS,IAAI;QAExB,MAAME,WAAWD,MAAM,sBAAsB;QAE7C,OAAQC,YAAYF,SAAS,IAAI;IACrC,GAAG;QAACL;KAAO;IAEX,MAAMQ,gBAAgBC,QAClB,IAAM,IAAIC,MAAMb,MAAM,MAAM,EAAEA,MAAM,UAAU,EAAEA,MAAM,MAAM,GAC5D;QAACA;KAAM;IAGX,OAAO,WAAP,GACI,oBAACJ,sBAAsB,QAAQ;QAC3B,OAAO;YACHO;YACAE;YACA,OAAOM;YACPV;QACJ;OAECC;AAGb"}
@@ -1,19 +1,15 @@
1
- import * as React from "react";
2
- import { createContext, useContext, useMemo } from "react";
3
1
  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);
2
+ import * as __rspack_external_react from "react";
3
+ const Context = /*#__PURE__*/ (0, __rspack_external_react.createContext)({});
4
+ const SharedHistoryContext = ({ children })=>{
5
+ const historyContext = (0, __rspack_external_react.useMemo)(()=>({
6
+ historyState: createEmptyHistoryState()
7
+ }), []);
8
+ return /*#__PURE__*/ __rspack_external_react.createElement(Context.Provider, {
9
+ value: historyContext
10
+ }, children);
17
11
  };
12
+ const useSharedHistoryContext = ()=>(0, __rspack_external_react.useContext)(Context);
13
+ export { SharedHistoryContext, useSharedHistoryContext };
18
14
 
19
15
  //# sourceMappingURL=SharedHistoryContext.js.map
@@ -1 +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 }): React.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,KAAwB;EAC9F,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":[]}
1
+ {"version":3,"file":"context/SharedHistoryContext.js","sources":["../../src/context/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 }): React.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"],"names":["Context","createContext","SharedHistoryContext","children","historyContext","useMemo","createEmptyHistoryState","useSharedHistoryContext","useContext"],"mappings":";;AAUA,MAAMA,UAAuCC,AAAhCD,WAAAA,GAAgCC,IAAAA,wBAAAA,aAAAA,AAAAA,EAAc,CAAC;AAErD,MAAMC,uBAAuB,CAAC,EAAEC,QAAQ,EAA2B;IACtE,MAAMC,iBAAiBC,AAAAA,IAAAA,wBAAAA,OAAAA,AAAAA,EAAQ,IAAO;YAAE,cAAcC;QAA0B,IAAI,EAAE;IACtF,OAAO,WAAP,GAAO,sCAACN,QAAQ,QAAQ;QAAC,OAAOI;OAAiBD;AACrD;AAEO,MAAMI,0BAA0B,IAC5BC,AAAAA,IAAAA,wBAAAA,UAAAA,AAAAA,EAAWR"}
@@ -1,4 +1,5 @@
1
- import React from "react";
2
- export const TextAlignmentActionContext = /*#__PURE__*/React.createContext(undefined);
1
+ import react from "react";
2
+ const TextAlignmentActionContext = /*#__PURE__*/ react.createContext(void 0);
3
+ export { TextAlignmentActionContext };
3
4
 
4
5
  //# sourceMappingURL=TextAlignmentActionContextProps.js.map
@@ -1 +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":[]}
1
+ {"version":3,"file":"context/TextAlignmentActionContextProps.js","sources":["../../src/context/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"],"names":["TextAlignmentActionContext","React","undefined"],"mappings":";AAmBO,MAAMA,6BAA6B,WAAHA,GAAGC,MAAAA,aAAmB,CAE3DC"}
@@ -1,4 +1,5 @@
1
- import React from "react";
2
- export const TypographyActionContext = /*#__PURE__*/React.createContext(undefined);
1
+ import react from "react";
2
+ const TypographyActionContext = /*#__PURE__*/ react.createContext(void 0);
3
+ export { TypographyActionContext };
3
4
 
4
5
  //# sourceMappingURL=TypographyActionContext.js.map
@@ -1 +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\" | \"label\">;\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":[]}
1
+ {"version":3,"file":"context/TypographyActionContext.js","sources":["../../src/context/TypographyActionContext.tsx"],"sourcesContent":["import React from \"react\";\nimport type { TypographyValue } from \"@webiny/lexical-theme\";\n\nexport type ActiveTypography = Pick<TypographyValue, \"id\" | \"label\">;\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"],"names":["TypographyActionContext","React","undefined"],"mappings":";AAkBO,MAAMA,0BAA0B,WAAHA,GAAGC,MAAAA,aAAmB,CAExDC"}
@@ -1,23 +1,5 @@
1
- // render
2
1
  export { LexicalHtmlRenderer } from "../../components/LexicalHtmlRenderer.js";
3
- // hooks
4
- export { getNodeFromSelection } from "../../hooks/index.js";
5
- export { useCurrentElement } from "../../hooks/index.js";
6
- export { useCurrentSelection } from "../../hooks/index.js";
7
- export { useDeriveValueFromSelection } from "../../hooks/index.js";
8
- export { useRichTextEditor } from "../../hooks/index.js";
9
- export { useFontColorPicker } from "../../hooks/index.js";
10
- export { useTextAlignmentAction } from "../../hooks/index.js";
11
- export { useTypographyAction } from "../../hooks/index.js";
12
- export { useIsMounted } from "../../hooks/index.js";
13
- // UI elements
2
+ export { getNodeFromSelection, useCurrentElement, useCurrentSelection, useDeriveValueFromSelection, useFontColorPicker, useIsMounted, useRichTextEditor, useTextAlignmentAction, useTypographyAction } from "../../hooks/index.js";
14
3
  export { Divider } from "../../ui/Divider.js";
15
- export { DropDownItem } from "../../ui/DropDown.js";
16
- export { DropDown } from "../../ui/DropDown.js";
17
-
18
- // types
19
-
20
- // config
4
+ export { DropDown, DropDownItem } from "../../ui/DropDown.js";
21
5
  export { LexicalEditorConfig, useLexicalEditorConfig } from "../../components/LexicalEditorConfig/LexicalEditorConfig.js";
22
-
23
- //# sourceMappingURL=lexical.js.map
package/hooks/index.js CHANGED
@@ -5,5 +5,3 @@ export * from "./useTextAlignmentAction.js";
5
5
  export * from "./useCurrentSelection.js";
6
6
  export * from "./useCurrentElement.js";
7
7
  export * from "./useIsMounted.js";
8
-
9
- //# sourceMappingURL=index.js.map
@@ -1,26 +1,23 @@
1
- import { $isRootOrShadowRoot, $findMatchingParent } from "lexical";
1
+ import { $findMatchingParent, $isRootOrShadowRoot } from "lexical";
2
2
  import { useDeriveValueFromSelection } from "./useCurrentSelection.js";
3
- export function useCurrentElement() {
4
- return useDeriveValueFromSelection(({
5
- rangeSelection
6
- }) => {
7
- if (!rangeSelection) {
8
- return {
9
- element: null
10
- };
11
- }
12
- return {
13
- element: getNodeFromSelection(rangeSelection)
14
- };
15
- });
3
+ function useCurrentElement() {
4
+ return useDeriveValueFromSelection(({ rangeSelection })=>{
5
+ if (!rangeSelection) return {
6
+ element: null
7
+ };
8
+ return {
9
+ element: getNodeFromSelection(rangeSelection)
10
+ };
11
+ });
16
12
  }
17
- export function getNodeFromSelection(selection) {
18
- const anchorNode = selection.anchor.getNode();
19
- const element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent(anchorNode, e => {
20
- const parent = e.getParent();
21
- return parent !== null && $isRootOrShadowRoot(parent);
22
- });
23
- return element || anchorNode.getTopLevelElementOrThrow();
13
+ function getNodeFromSelection(selection) {
14
+ const anchorNode = selection.anchor.getNode();
15
+ const element = "root" === anchorNode.getKey() ? anchorNode : $findMatchingParent(anchorNode, (e)=>{
16
+ const parent = e.getParent();
17
+ return null !== parent && $isRootOrShadowRoot(parent);
18
+ });
19
+ return element || anchorNode.getTopLevelElementOrThrow();
24
20
  }
21
+ export { getNodeFromSelection, useCurrentElement };
25
22
 
26
23
  //# sourceMappingURL=useCurrentElement.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["$isRootOrShadowRoot","$findMatchingParent","useDeriveValueFromSelection","useCurrentElement","rangeSelection","element","getNodeFromSelection","selection","anchorNode","anchor","getNode","getKey","e","parent","getParent","getTopLevelElementOrThrow"],"sources":["useCurrentElement.ts"],"sourcesContent":["import type { RangeSelection } from \"lexical\";\nimport { $isRootOrShadowRoot, $findMatchingParent } from \"lexical\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection.js\";\n\nexport function useCurrentElement() {\n return useDeriveValueFromSelection(({ rangeSelection }) => {\n if (!rangeSelection) {\n return { element: null };\n }\n\n return { element: getNodeFromSelection(rangeSelection) };\n });\n}\n\nexport function getNodeFromSelection(selection: RangeSelection) {\n const anchorNode = selection.anchor.getNode();\n\n const element =\n anchorNode.getKey() === \"root\"\n ? anchorNode\n : $findMatchingParent(anchorNode, e => {\n const parent = e.getParent();\n return parent !== null && $isRootOrShadowRoot(parent);\n });\n\n return element || anchorNode.getTopLevelElementOrThrow();\n}\n"],"mappings":"AACA,SAASA,mBAAmB,EAAEC,mBAAmB,QAAQ,SAAS;AAClE,SAASC,2BAA2B;AAEpC,OAAO,SAASC,iBAAiBA,CAAA,EAAG;EAChC,OAAOD,2BAA2B,CAAC,CAAC;IAAEE;EAAe,CAAC,KAAK;IACvD,IAAI,CAACA,cAAc,EAAE;MACjB,OAAO;QAAEC,OAAO,EAAE;MAAK,CAAC;IAC5B;IAEA,OAAO;MAAEA,OAAO,EAAEC,oBAAoB,CAACF,cAAc;IAAE,CAAC;EAC5D,CAAC,CAAC;AACN;AAEA,OAAO,SAASE,oBAAoBA,CAACC,SAAyB,EAAE;EAC5D,MAAMC,UAAU,GAAGD,SAAS,CAACE,MAAM,CAACC,OAAO,CAAC,CAAC;EAE7C,MAAML,OAAO,GACTG,UAAU,CAACG,MAAM,CAAC,CAAC,KAAK,MAAM,GACxBH,UAAU,GACVP,mBAAmB,CAACO,UAAU,EAAEI,CAAC,IAAI;IACjC,MAAMC,MAAM,GAAGD,CAAC,CAACE,SAAS,CAAC,CAAC;IAC5B,OAAOD,MAAM,KAAK,IAAI,IAAIb,mBAAmB,CAACa,MAAM,CAAC;EACzD,CAAC,CAAC;EAEZ,OAAOR,OAAO,IAAIG,UAAU,CAACO,yBAAyB,CAAC,CAAC;AAC5D","ignoreList":[]}
1
+ {"version":3,"file":"hooks/useCurrentElement.js","sources":["../../src/hooks/useCurrentElement.ts"],"sourcesContent":["import type { RangeSelection } from \"lexical\";\nimport { $isRootOrShadowRoot, $findMatchingParent } from \"lexical\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection.js\";\n\nexport function useCurrentElement() {\n return useDeriveValueFromSelection(({ rangeSelection }) => {\n if (!rangeSelection) {\n return { element: null };\n }\n\n return { element: getNodeFromSelection(rangeSelection) };\n });\n}\n\nexport function getNodeFromSelection(selection: RangeSelection) {\n const anchorNode = selection.anchor.getNode();\n\n const element =\n anchorNode.getKey() === \"root\"\n ? anchorNode\n : $findMatchingParent(anchorNode, e => {\n const parent = e.getParent();\n return parent !== null && $isRootOrShadowRoot(parent);\n });\n\n return element || anchorNode.getTopLevelElementOrThrow();\n}\n"],"names":["useCurrentElement","useDeriveValueFromSelection","rangeSelection","getNodeFromSelection","selection","anchorNode","element","$findMatchingParent","e","parent","$isRootOrShadowRoot"],"mappings":";;AAIO,SAASA;IACZ,OAAOC,4BAA4B,CAAC,EAAEC,cAAc,EAAE;QAClD,IAAI,CAACA,gBACD,OAAO;YAAE,SAAS;QAAK;QAG3B,OAAO;YAAE,SAASC,qBAAqBD;QAAgB;IAC3D;AACJ;AAEO,SAASC,qBAAqBC,SAAyB;IAC1D,MAAMC,aAAaD,UAAU,MAAM,CAAC,OAAO;IAE3C,MAAME,UACFD,AAAwB,WAAxBA,WAAW,MAAM,KACXA,aACAE,oBAAoBF,YAAYG,CAAAA;QAC5B,MAAMC,SAASD,EAAE,SAAS;QAC1B,OAAOC,AAAW,SAAXA,UAAmBC,oBAAoBD;IAClD;IAEV,OAAOH,WAAWD,WAAW,yBAAyB;AAC1D"}