@webiny/lexical-editor 5.43.2 → 6.0.0-alpha.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 (196) hide show
  1. package/commands/image.js +2 -8
  2. package/commands/image.js.map +1 -1
  3. package/commands/index.js +4 -49
  4. package/commands/index.js.map +1 -1
  5. package/commands/list.js +4 -10
  6. package/commands/list.js.map +1 -1
  7. package/commands/quote.js +2 -8
  8. package/commands/quote.js.map +1 -1
  9. package/commands/toolbar.js +2 -8
  10. package/commands/toolbar.js.map +1 -1
  11. package/components/Editor/EnsureHeadingTagPlugin.js +10 -16
  12. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
  13. package/components/Editor/HeadingEditor.js +13 -21
  14. package/components/Editor/HeadingEditor.js.map +1 -1
  15. package/components/Editor/ParagraphEditor.js +12 -19
  16. package/components/Editor/ParagraphEditor.js.map +1 -1
  17. package/components/Editor/RichTextEditor.js +92 -105
  18. package/components/Editor/RichTextEditor.js.map +1 -1
  19. package/components/Editor/normalizeInputValue.js +2 -8
  20. package/components/Editor/normalizeInputValue.js.map +1 -1
  21. package/components/LexicalEditorConfig/LexicalEditorConfig.js +39 -49
  22. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
  23. package/components/LexicalEditorConfig/components/Node.js +17 -26
  24. package/components/LexicalEditorConfig/components/Node.js.map +1 -1
  25. package/components/LexicalEditorConfig/components/Plugin.js +17 -26
  26. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
  27. package/components/LexicalEditorConfig/components/ToolbarElement.js +17 -26
  28. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
  29. package/components/LexicalHtmlRenderer.js +37 -46
  30. package/components/LexicalHtmlRenderer.js.map +1 -1
  31. package/components/Toolbar/StaticToolbar.d.ts +3 -1
  32. package/components/Toolbar/StaticToolbar.js +19 -23
  33. package/components/Toolbar/StaticToolbar.js.map +1 -1
  34. package/components/Toolbar/Toolbar.js +66 -75
  35. package/components/Toolbar/Toolbar.js.map +1 -1
  36. package/components/ToolbarActions/BoldAction.js +16 -21
  37. package/components/ToolbarActions/BoldAction.js.map +1 -1
  38. package/components/ToolbarActions/BulletListAction.js +26 -31
  39. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  40. package/components/ToolbarActions/CodeHighlightAction.js +16 -21
  41. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
  42. package/components/ToolbarActions/FontColorAction.js +32 -42
  43. package/components/ToolbarActions/FontColorAction.js.map +1 -1
  44. package/components/ToolbarActions/FontSizeAction.js +53 -71
  45. package/components/ToolbarActions/FontSizeAction.js.map +1 -1
  46. package/components/ToolbarActions/ImageAction.js +19 -34
  47. package/components/ToolbarActions/ImageAction.js.map +1 -1
  48. package/components/ToolbarActions/ItalicAction.js +16 -21
  49. package/components/ToolbarActions/ItalicAction.js.map +1 -1
  50. package/components/ToolbarActions/LinkAction.js +19 -24
  51. package/components/ToolbarActions/LinkAction.js.map +1 -1
  52. package/components/ToolbarActions/NumberedListAction.js +26 -33
  53. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  54. package/components/ToolbarActions/QuoteAction.js +20 -25
  55. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  56. package/components/ToolbarActions/TextAlignmentAction.js +36 -45
  57. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
  58. package/components/ToolbarActions/TypographyAction.js +43 -55
  59. package/components/ToolbarActions/TypographyAction.js.map +1 -1
  60. package/components/ToolbarActions/UnderlineAction.js +16 -21
  61. package/components/ToolbarActions/UnderlineAction.js.map +1 -1
  62. package/context/FontColorActionContext.js +2 -9
  63. package/context/FontColorActionContext.js.map +1 -1
  64. package/context/RichTextEditorContext.js +15 -26
  65. package/context/RichTextEditorContext.js.map +1 -1
  66. package/context/SharedHistoryContext.js +12 -20
  67. package/context/SharedHistoryContext.js.map +1 -1
  68. package/context/TextAlignmentActionContextProps.js +2 -9
  69. package/context/TextAlignmentActionContextProps.js.map +1 -1
  70. package/context/TypographyActionContext.js +2 -9
  71. package/context/TypographyActionContext.js.map +1 -1
  72. package/hooks/index.js +8 -93
  73. package/hooks/index.js.map +1 -1
  74. package/hooks/useCurrentElement.d.ts +2 -2
  75. package/hooks/useCurrentElement.js +12 -18
  76. package/hooks/useCurrentElement.js.map +1 -1
  77. package/hooks/useCurrentSelection.js +27 -40
  78. package/hooks/useCurrentSelection.js.map +1 -1
  79. package/hooks/useFontColorPicker.js +5 -11
  80. package/hooks/useFontColorPicker.js.map +1 -1
  81. package/hooks/useIsMounted.js +6 -14
  82. package/hooks/useIsMounted.js.map +1 -1
  83. package/hooks/useList.js +31 -35
  84. package/hooks/useList.js.map +1 -1
  85. package/hooks/useQuote.js +12 -17
  86. package/hooks/useQuote.js.map +1 -1
  87. package/hooks/useRichTextEditor.js +5 -11
  88. package/hooks/useRichTextEditor.js.map +1 -1
  89. package/hooks/useTextAlignmentAction.js +5 -11
  90. package/hooks/useTextAlignmentAction.js.map +1 -1
  91. package/hooks/useTypographyAction.js +5 -11
  92. package/hooks/useTypographyAction.js.map +1 -1
  93. package/index.js +49 -322
  94. package/index.js.map +1 -1
  95. package/package.json +8 -7
  96. package/plugins/BlurEventPlugin/BlurEventPlugin.js +16 -22
  97. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
  98. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +9 -14
  99. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
  100. package/plugins/CodeHighlightPlugin/index.js +1 -16
  101. package/plugins/CodeHighlightPlugin/index.js.map +1 -1
  102. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +16 -0
  103. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +158 -0
  104. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
  105. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +8 -0
  106. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +62 -0
  107. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
  108. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +2 -1
  109. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +5 -16
  110. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +11 -180
  111. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  112. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +2 -3
  113. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +54 -68
  114. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +1 -1
  115. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +1 -1
  116. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +16 -26
  117. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +1 -1
  118. package/plugins/FloatingLinkEditorPlugin/index.js +1 -16
  119. package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
  120. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +3 -9
  121. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
  122. package/plugins/FontColorPlugin/FontColorPlugin.js +19 -22
  123. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
  124. package/plugins/FontColorPlugin/applyColorToNode.js +4 -10
  125. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
  126. package/plugins/FontColorPlugin/applyColorToSelection.js +28 -44
  127. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
  128. package/plugins/ImagesPlugin/ImagesPlugin.js +59 -58
  129. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
  130. package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js +23 -23
  131. package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js.map +1 -1
  132. package/plugins/LexicalUpdateStatePlugin/index.js +1 -16
  133. package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -1
  134. package/plugins/LinkPlugin/LinkPlugin.js +30 -37
  135. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
  136. package/plugins/ListPLugin/ListPlugin.js +10 -15
  137. package/plugins/ListPLugin/ListPlugin.js.map +1 -1
  138. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +11 -16
  139. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
  140. package/plugins/TypographyPlugin/TypographyPlugin.js +16 -21
  141. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
  142. package/types.d.ts +3 -3
  143. package/types.js +6 -38
  144. package/types.js.map +1 -1
  145. package/ui/ContentEditable.js +7 -14
  146. package/ui/ContentEditable.js.map +1 -1
  147. package/ui/Divider.js +3 -10
  148. package/ui/Divider.js.map +1 -1
  149. package/ui/DropDown.js +61 -88
  150. package/ui/DropDown.js.map +1 -1
  151. package/ui/ImageResizer.js +78 -83
  152. package/ui/ImageResizer.js.map +1 -1
  153. package/ui/LinkPreview.js +22 -29
  154. package/ui/LinkPreview.js.map +1 -1
  155. package/ui/Placeholder.js +10 -16
  156. package/ui/Placeholder.js.map +1 -1
  157. package/ui/TextInput.js +11 -18
  158. package/ui/TextInput.js.map +1 -1
  159. package/ui/ToolbarActionDialog.js +30 -42
  160. package/ui/ToolbarActionDialog.js.map +1 -1
  161. package/utils/canUseDOM.js +1 -7
  162. package/utils/canUseDOM.js.map +1 -1
  163. package/utils/files.js +9 -26
  164. package/utils/files.js.map +1 -1
  165. package/utils/generateInitialLexicalValue.js +2 -8
  166. package/utils/generateInitialLexicalValue.js.map +1 -1
  167. package/utils/getDOMRangeRect.js +4 -10
  168. package/utils/getDOMRangeRect.js.map +1 -1
  169. package/utils/getSelectedNode.js +9 -16
  170. package/utils/getSelectedNode.js.map +1 -1
  171. package/utils/getTransparentImage.js +1 -7
  172. package/utils/getTransparentImage.js.map +1 -1
  173. package/utils/insertImage.js +8 -14
  174. package/utils/insertImage.js.map +1 -1
  175. package/utils/isAnchorLink.js +1 -7
  176. package/utils/isAnchorLink.js.map +1 -1
  177. package/utils/isChildOfFloatingToolbar.js +3 -9
  178. package/utils/isChildOfFloatingToolbar.js.map +1 -1
  179. package/utils/isHTMLElement.js +1 -7
  180. package/utils/isHTMLElement.js.map +1 -1
  181. package/utils/isValidJSON.js +3 -9
  182. package/utils/isValidJSON.js.map +1 -1
  183. package/utils/isValidLexicalData.d.ts +1 -1
  184. package/utils/isValidLexicalData.js +6 -12
  185. package/utils/isValidLexicalData.js.map +1 -1
  186. package/utils/point.js +35 -60
  187. package/utils/point.js.map +1 -1
  188. package/utils/rect.js +114 -149
  189. package/utils/rect.js.map +1 -1
  190. package/utils/sanitizeUrl.js +6 -13
  191. package/utils/sanitizeUrl.js.map +1 -1
  192. package/utils/setFloatingElemPosition.js +11 -19
  193. package/utils/setFloatingElemPosition.js.map +1 -1
  194. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.d.ts +0 -2
  195. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +0 -96
  196. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +0 -1
@@ -1,11 +1,4 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.FontColorActionContext = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var FontColorActionContext = exports.FontColorActionContext = /*#__PURE__*/_react.default.createContext(undefined);
1
+ import React from "react";
2
+ export const FontColorActionContext = /*#__PURE__*/React.createContext(undefined);
10
3
 
11
4
  //# sourceMappingURL=FontColorActionContext.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","FontColorActionContext","exports","React","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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAeO,IAAMC,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,gBAAGE,cAAK,CAACC,aAAa,CACrDC,SACJ,CAAC","ignoreList":[]}
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,30 +1,19 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.RichTextEditorProvider = exports.RichTextEditorContext = void 0;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _react = _interopRequireWildcard(require("react"));
11
- var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
12
- var RichTextEditorContext = exports.RichTextEditorContext = /*#__PURE__*/(0, _react.createContext)(undefined);
13
- var RichTextEditorProvider = exports.RichTextEditorProvider = function RichTextEditorProvider(_ref) {
14
- var themeEmotionMap = _ref.themeEmotionMap,
15
- theme = _ref.theme,
16
- _ref$toolbarActionPlu = _ref.toolbarActionPlugins,
17
- toolbarActionPlugins = _ref$toolbarActionPlu === void 0 ? [] : _ref$toolbarActionPlu,
18
- children = _ref.children;
19
- var _useLexicalComposerCo = (0, _LexicalComposerContext.useLexicalComposerContext)(),
20
- _useLexicalComposerCo2 = (0, _slicedToArray2.default)(_useLexicalComposerCo, 1),
21
- editor = _useLexicalComposerCo2[0];
22
- return /*#__PURE__*/_react.default.createElement(RichTextEditorContext.Provider, {
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, {
23
12
  value: {
24
- editor: editor,
25
- theme: theme,
26
- themeEmotionMap: themeEmotionMap,
27
- toolbarActionPlugins: toolbarActionPlugins
13
+ editor,
14
+ theme,
15
+ themeEmotionMap,
16
+ toolbarActionPlugins
28
17
  }
29
18
  }, children);
30
19
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_LexicalComposerContext","RichTextEditorContext","exports","createContext","undefined","RichTextEditorProvider","_ref","themeEmotionMap","theme","_ref$toolbarActionPlu","toolbarActionPlugins","children","_useLexicalComposerCo","useLexicalComposerContext","_useLexicalComposerCo2","_slicedToArray2","default","editor","createElement","Provider","value"],"sources":["RichTextEditorContext.tsx"],"sourcesContent":["import React, { createContext } from \"react\";\nimport { LexicalEditor } from \"lexical\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { ThemeEmotionMap, EditorTheme } from \"@webiny/lexical-theme\";\nimport { 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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,uBAAA,GAAAD,OAAA;AAWO,IAAME,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,gBAAG,IAAAE,oBAAa,EAAoCC,SAAS,CAAC;AASzF,IAAMC,sBAAsB,GAAAH,OAAA,CAAAG,sBAAA,GAAG,SAAzBA,sBAAsBA,CAAAC,IAAA,EAKA;EAAA,IAJ/BC,eAAe,GAAAD,IAAA,CAAfC,eAAe;IACfC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAAAC,qBAAA,GAAAH,IAAA,CACLI,oBAAoB;IAApBA,oBAAoB,GAAAD,qBAAA,cAAG,EAAE,GAAAA,qBAAA;IACzBE,QAAQ,GAAAL,IAAA,CAARK,QAAQ;EAER,IAAAC,qBAAA,GAAiB,IAAAC,iDAAyB,EAAC,CAAC;IAAAC,sBAAA,OAAAC,eAAA,CAAAC,OAAA,EAAAJ,qBAAA;IAArCK,MAAM,GAAAH,sBAAA;EAEb,oBACIjB,MAAA,CAAAmB,OAAA,CAAAE,aAAA,CAACjB,qBAAqB,CAACkB,QAAQ;IAC3BC,KAAK,EAAE;MACHH,MAAM,EAANA,MAAM;MACNT,KAAK,EAALA,KAAK;MACLD,eAAe,EAAfA,eAAe;MACfG,oBAAoB,EAApBA;IACJ;EAAE,GAEDC,QAC2B,CAAC;AAEzC,CAAC","ignoreList":[]}
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 { LexicalEditor } from \"lexical\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { ThemeEmotionMap, EditorTheme } from \"@webiny/lexical-theme\";\nimport { 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":[]}
@@ -1,27 +1,19 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.useSharedHistoryContext = exports.SharedHistoryContext = void 0;
8
- var _react = _interopRequireWildcard(require("react"));
9
- var React = _react;
10
- var _history = require("@lexical/history");
11
- var Context = /*#__PURE__*/(0, _react.createContext)({});
12
- var SharedHistoryContext = exports.SharedHistoryContext = function SharedHistoryContext(_ref) {
13
- var children = _ref.children;
14
- var historyContext = (0, _react.useMemo)(function () {
15
- return {
16
- historyState: (0, _history.createEmptyHistoryState)()
17
- };
18
- }, []);
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
+ }), []);
19
11
  return /*#__PURE__*/React.createElement(Context.Provider, {
20
12
  value: historyContext
21
13
  }, children);
22
14
  };
23
- var useSharedHistoryContext = exports.useSharedHistoryContext = function useSharedHistoryContext() {
24
- return (0, _react.useContext)(Context);
15
+ export const useSharedHistoryContext = () => {
16
+ return useContext(Context);
25
17
  };
26
18
 
27
19
  //# sourceMappingURL=SharedHistoryContext.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","React","_history","Context","createContext","SharedHistoryContext","exports","_ref","children","historyContext","useMemo","historyState","createEmptyHistoryState","createElement","Provider","value","useSharedHistoryContext","useContext"],"sources":["SharedHistoryContext.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { createContext, ReactNode, useContext, useMemo } from \"react\";\nimport { createEmptyHistoryState, HistoryState } 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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+B,IAAAC,KAAA,GAAAH,MAAA;AAE/B,IAAAI,QAAA,GAAAF,OAAA;AAMA,IAAMG,OAAoC,gBAAG,IAAAC,oBAAa,EAAC,CAAC,CAAC,CAAC;AAEvD,IAAMC,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,SAAvBA,oBAAoBA,CAAAE,IAAA,EAA2D;EAAA,IAArDC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EAC3C,IAAMC,cAAc,GAAG,IAAAC,cAAO,EAAC;IAAA,OAAO;MAAEC,YAAY,EAAE,IAAAC,gCAAuB,EAAC;IAAE,CAAC;EAAA,CAAC,EAAE,EAAE,CAAC;EACvF,oBAAOX,KAAA,CAAAY,aAAA,CAACV,OAAO,CAACW,QAAQ;IAACC,KAAK,EAAEN;EAAe,GAAED,QAA2B,CAAC;AACjF,CAAC;AAEM,IAAMQ,uBAAuB,GAAAV,OAAA,CAAAU,uBAAA,GAAG,SAA1BA,uBAAuBA,CAAA,EAAuB;EACvD,OAAO,IAAAC,iBAAU,EAACd,OAAO,CAAC;AAC9B,CAAC","ignoreList":[]}
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 { createContext, ReactNode, useContext, useMemo } from \"react\";\nimport { createEmptyHistoryState, HistoryState } 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;AAC9B,SAASC,aAAa,EAAaC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AACrE,SAASC,uBAAuB,QAAsB,kBAAkB;AAMxE,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":[]}
@@ -1,11 +1,4 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.TextAlignmentActionContext = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var TextAlignmentActionContext = exports.TextAlignmentActionContext = /*#__PURE__*/_react.default.createContext(undefined);
1
+ import React from "react";
2
+ export const TextAlignmentActionContext = /*#__PURE__*/React.createContext(undefined);
10
3
 
11
4
  //# sourceMappingURL=TextAlignmentActionContextProps.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","TextAlignmentActionContext","exports","React","createContext","undefined"],"sources":["TextAlignmentActionContextProps.tsx"],"sourcesContent":["import React from \"react\";\nimport { 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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAmBO,IAAMC,0BAA0B,GAAAC,OAAA,CAAAD,0BAAA,gBAAGE,cAAK,CAACC,aAAa,CAE3DC,SAAS,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","TextAlignmentActionContext","createContext","undefined"],"sources":["TextAlignmentActionContextProps.tsx"],"sourcesContent":["import React from \"react\";\nimport { 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,11 +1,4 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.TypographyActionContext = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var TypographyActionContext = exports.TypographyActionContext = /*#__PURE__*/_react.default.createContext(undefined);
1
+ import React from "react";
2
+ export const TypographyActionContext = /*#__PURE__*/React.createContext(undefined);
10
3
 
11
4
  //# sourceMappingURL=TypographyActionContext.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","TypographyActionContext","exports","React","createContext","undefined"],"sources":["TypographyActionContext.tsx"],"sourcesContent":["import React from \"react\";\nimport { TypographyValue } from \"@webiny/lexical-theme\";\n\nexport interface TypographyActionContextProps {\n /*\n * @desc Current selected typography\n * */\n value: TypographyValue | 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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAgBO,IAAMC,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,gBAAGE,cAAK,CAACC,aAAa,CAExDC,SAAS,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","TypographyActionContext","createContext","undefined"],"sources":["TypographyActionContext.tsx"],"sourcesContent":["import React from \"react\";\nimport { TypographyValue } from \"@webiny/lexical-theme\";\n\nexport interface TypographyActionContextProps {\n /*\n * @desc Current selected typography\n * */\n value: TypographyValue | 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;AAgBzB,OAAO,MAAMC,uBAAuB,gBAAGD,KAAK,CAACE,aAAa,CAExDC,SAAS,CAAC","ignoreList":[]}
package/hooks/index.js CHANGED
@@ -1,95 +1,10 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _useRichTextEditor = require("./useRichTextEditor");
7
- Object.keys(_useRichTextEditor).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _useRichTextEditor[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function get() {
13
- return _useRichTextEditor[key];
14
- }
15
- });
16
- });
17
- var _useFontColorPicker = require("./useFontColorPicker");
18
- Object.keys(_useFontColorPicker).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _useFontColorPicker[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function get() {
24
- return _useFontColorPicker[key];
25
- }
26
- });
27
- });
28
- var _useTypographyAction = require("./useTypographyAction");
29
- Object.keys(_useTypographyAction).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _useTypographyAction[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function get() {
35
- return _useTypographyAction[key];
36
- }
37
- });
38
- });
39
- var _useTextAlignmentAction = require("./useTextAlignmentAction");
40
- Object.keys(_useTextAlignmentAction).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _useTextAlignmentAction[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function get() {
46
- return _useTextAlignmentAction[key];
47
- }
48
- });
49
- });
50
- var _useCurrentSelection = require("./useCurrentSelection");
51
- Object.keys(_useCurrentSelection).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _useCurrentSelection[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function get() {
57
- return _useCurrentSelection[key];
58
- }
59
- });
60
- });
61
- var _useCurrentElement = require("./useCurrentElement");
62
- Object.keys(_useCurrentElement).forEach(function (key) {
63
- if (key === "default" || key === "__esModule") return;
64
- if (key in exports && exports[key] === _useCurrentElement[key]) return;
65
- Object.defineProperty(exports, key, {
66
- enumerable: true,
67
- get: function get() {
68
- return _useCurrentElement[key];
69
- }
70
- });
71
- });
72
- var _useList = require("./useList");
73
- Object.keys(_useList).forEach(function (key) {
74
- if (key === "default" || key === "__esModule") return;
75
- if (key in exports && exports[key] === _useList[key]) return;
76
- Object.defineProperty(exports, key, {
77
- enumerable: true,
78
- get: function get() {
79
- return _useList[key];
80
- }
81
- });
82
- });
83
- var _useIsMounted = require("./useIsMounted");
84
- Object.keys(_useIsMounted).forEach(function (key) {
85
- if (key === "default" || key === "__esModule") return;
86
- if (key in exports && exports[key] === _useIsMounted[key]) return;
87
- Object.defineProperty(exports, key, {
88
- enumerable: true,
89
- get: function get() {
90
- return _useIsMounted[key];
91
- }
92
- });
93
- });
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";
94
9
 
95
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_useRichTextEditor","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_useFontColorPicker","_useTypographyAction","_useTextAlignmentAction","_useCurrentSelection","_useCurrentElement","_useList","_useIsMounted"],"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,IAAAA,kBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,kBAAA,EAAAI,OAAA,WAAAC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IAAAW,aAAA,GAAAf,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAa,aAAA,EAAAZ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAW,aAAA,CAAAX,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAO,aAAA,CAAAX,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
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":[]}
@@ -2,6 +2,6 @@ import { RangeSelection } from "lexical";
2
2
  export declare function useCurrentElement(): {
3
3
  element: null;
4
4
  } | {
5
- element: import("lexical").TextNode | import("lexical").LexicalNode;
5
+ element: import("lexical").LexicalNode | import("lexical").TextNode;
6
6
  };
7
- export declare function getNodeFromSelection(selection: RangeSelection): import("lexical").TextNode | import("lexical").LexicalNode;
7
+ export declare function getNodeFromSelection(selection: RangeSelection): import("lexical").LexicalNode | import("lexical").TextNode;
@@ -1,16 +1,10 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getNodeFromSelection = getNodeFromSelection;
7
- exports.useCurrentElement = useCurrentElement;
8
- var _utils = require("@lexical/utils");
9
- var _lexical = require("lexical");
10
- var _useCurrentSelection = require("./useCurrentSelection");
11
- function useCurrentElement() {
12
- return (0, _useCurrentSelection.useDeriveValueFromSelection)(function (_ref) {
13
- var rangeSelection = _ref.rangeSelection;
1
+ import { $findMatchingParent } from "@lexical/utils";
2
+ import { $isRootOrShadowRoot } from "lexical";
3
+ import { useDeriveValueFromSelection } from "./useCurrentSelection";
4
+ export function useCurrentElement() {
5
+ return useDeriveValueFromSelection(({
6
+ rangeSelection
7
+ }) => {
14
8
  if (!rangeSelection) {
15
9
  return {
16
10
  element: null
@@ -21,11 +15,11 @@ function useCurrentElement() {
21
15
  };
22
16
  });
23
17
  }
24
- function getNodeFromSelection(selection) {
25
- var anchorNode = selection.anchor.getNode();
26
- var element = anchorNode.getKey() === "root" ? anchorNode : (0, _utils.$findMatchingParent)(anchorNode, function (e) {
27
- var parent = e.getParent();
28
- return parent !== null && (0, _lexical.$isRootOrShadowRoot)(parent);
18
+ export function getNodeFromSelection(selection) {
19
+ const anchorNode = selection.anchor.getNode();
20
+ const element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent(anchorNode, e => {
21
+ const parent = e.getParent();
22
+ return parent !== null && $isRootOrShadowRoot(parent);
29
23
  });
30
24
  return element || anchorNode.getTopLevelElementOrThrow();
31
25
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","_lexical","_useCurrentSelection","useCurrentElement","useDeriveValueFromSelection","_ref","rangeSelection","element","getNodeFromSelection","selection","anchorNode","anchor","getNode","getKey","$findMatchingParent","e","parent","getParent","$isRootOrShadowRoot","getTopLevelElementOrThrow"],"sources":["useCurrentElement.ts"],"sourcesContent":["import { $findMatchingParent } from \"@lexical/utils\";\nimport { $isRootOrShadowRoot, RangeSelection } from \"lexical\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection\";\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":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AAEO,SAASG,iBAAiBA,CAAA,EAAG;EAChC,OAAO,IAAAC,gDAA2B,EAAC,UAAAC,IAAA,EAAwB;IAAA,IAArBC,cAAc,GAAAD,IAAA,CAAdC,cAAc;IAChD,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;AAEO,SAASE,oBAAoBA,CAACC,SAAyB,EAAE;EAC5D,IAAMC,UAAU,GAAGD,SAAS,CAACE,MAAM,CAACC,OAAO,CAAC,CAAC;EAE7C,IAAML,OAAO,GACTG,UAAU,CAACG,MAAM,CAAC,CAAC,KAAK,MAAM,GACxBH,UAAU,GACV,IAAAI,0BAAmB,EAACJ,UAAU,EAAE,UAAAK,CAAC,EAAI;IACjC,IAAMC,MAAM,GAAGD,CAAC,CAACE,SAAS,CAAC,CAAC;IAC5B,OAAOD,MAAM,KAAK,IAAI,IAAI,IAAAE,4BAAmB,EAACF,MAAM,CAAC;EACzD,CAAC,CAAC;EAEZ,OAAOT,OAAO,IAAIG,UAAU,CAACS,yBAAyB,CAAC,CAAC;AAC5D","ignoreList":[]}
1
+ {"version":3,"names":["$findMatchingParent","$isRootOrShadowRoot","useDeriveValueFromSelection","useCurrentElement","rangeSelection","element","getNodeFromSelection","selection","anchorNode","anchor","getNode","getKey","e","parent","getParent","getTopLevelElementOrThrow"],"sources":["useCurrentElement.ts"],"sourcesContent":["import { $findMatchingParent } from \"@lexical/utils\";\nimport { $isRootOrShadowRoot, RangeSelection } from \"lexical\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection\";\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":"AAAA,SAASA,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,mBAAmB,QAAwB,SAAS;AAC7D,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,GACVR,mBAAmB,CAACQ,UAAU,EAAEI,CAAC,IAAI;IACjC,MAAMC,MAAM,GAAGD,CAAC,CAACE,SAAS,CAAC,CAAC;IAC5B,OAAOD,MAAM,KAAK,IAAI,IAAIZ,mBAAmB,CAACY,MAAM,CAAC;EACzD,CAAC,CAAC;EAEZ,OAAOR,OAAO,IAAIG,UAAU,CAACO,yBAAyB,CAAC,CAAC;AAC5D","ignoreList":[]}
@@ -1,39 +1,28 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.useCurrentSelection = useCurrentSelection;
8
- exports.useDeriveValueFromSelection = useDeriveValueFromSelection;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _react = require("react");
11
- var _lexical = require("lexical");
12
- var _useIsMounted = require("./useIsMounted");
13
- var _useRichTextEditor3 = require("./useRichTextEditor");
1
+ import { useCallback, useEffect, useState } from "react";
2
+ import { $getSelection, $isRangeSelection, $isNodeSelection } from "lexical";
3
+ import { useIsMounted } from "./useIsMounted";
4
+ import { useRichTextEditor } from "./useRichTextEditor";
14
5
  function getOutput(selection) {
15
6
  return {
16
- selection: selection,
17
- rangeSelection: (0, _lexical.$isRangeSelection)(selection) ? selection : null,
18
- nodeSelection: (0, _lexical.$isNodeSelection)(selection) ? selection : null
7
+ selection,
8
+ rangeSelection: $isRangeSelection(selection) ? selection : null,
9
+ nodeSelection: $isNodeSelection(selection) ? selection : null
19
10
  };
20
11
  }
21
- function useCurrentSelection() {
22
- var _useRichTextEditor = (0, _useRichTextEditor3.useRichTextEditor)(),
23
- editor = _useRichTextEditor.editor;
24
- var _useState = (0, _react.useState)(getOutput(null)),
25
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
26
- selection = _useState2[0],
27
- setSelection = _useState2[1];
28
- var isMounted = (0, _useIsMounted.useIsMounted)();
29
- var storeSelection = (0, _react.useCallback)(function () {
30
- editor.getEditorState().read(function () {
12
+ export function useCurrentSelection() {
13
+ const {
14
+ editor
15
+ } = useRichTextEditor();
16
+ const [selection, setSelection] = useState(getOutput(null));
17
+ const isMounted = useIsMounted();
18
+ const storeSelection = useCallback(() => {
19
+ editor.getEditorState().read(() => {
31
20
  if (isMounted()) {
32
- setSelection(getOutput((0, _lexical.$getSelection)()));
21
+ setSelection(getOutput($getSelection()));
33
22
  }
34
23
  });
35
24
  }, [editor]);
36
- (0, _react.useEffect)(function () {
25
+ useEffect(() => {
37
26
  // On first mount, store current selection.
38
27
  storeSelection();
39
28
 
@@ -42,22 +31,20 @@ function useCurrentSelection() {
42
31
  }, []);
43
32
  return selection;
44
33
  }
45
- function useDeriveValueFromSelection(generator) {
46
- var _useRichTextEditor2 = (0, _useRichTextEditor3.useRichTextEditor)(),
47
- editor = _useRichTextEditor2.editor;
48
- var _useState3 = (0, _react.useState)(generator(getOutput(null))),
49
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
50
- value = _useState4[0],
51
- setValue = _useState4[1];
52
- var isMounted = (0, _useIsMounted.useIsMounted)();
53
- var generateValue = (0, _react.useCallback)(function () {
54
- editor.getEditorState().read(function () {
34
+ export function useDeriveValueFromSelection(generator) {
35
+ const {
36
+ editor
37
+ } = useRichTextEditor();
38
+ const [value, setValue] = useState(generator(getOutput(null)));
39
+ const isMounted = useIsMounted();
40
+ const generateValue = useCallback(() => {
41
+ editor.getEditorState().read(() => {
55
42
  if (isMounted()) {
56
- setValue(generator(getOutput((0, _lexical.$getSelection)())));
43
+ setValue(generator(getOutput($getSelection())));
57
44
  }
58
45
  });
59
46
  }, [editor]);
60
- (0, _react.useEffect)(function () {
47
+ useEffect(() => {
61
48
  // On first mount, generate current value.
62
49
  generateValue();
63
50
 
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_lexical","_useIsMounted","_useRichTextEditor3","getOutput","selection","rangeSelection","$isRangeSelection","nodeSelection","$isNodeSelection","useCurrentSelection","_useRichTextEditor","useRichTextEditor","editor","_useState","useState","_useState2","_slicedToArray2","default","setSelection","isMounted","useIsMounted","storeSelection","useCallback","getEditorState","read","$getSelection","useEffect","registerUpdateListener","useDeriveValueFromSelection","generator","_useRichTextEditor2","_useState3","_useState4","value","setValue","generateValue"],"sources":["useCurrentSelection.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\nimport {\n $getSelection,\n $isRangeSelection,\n $isNodeSelection,\n RangeSelection,\n NodeSelection\n} from \"lexical\";\nimport { useIsMounted } from \"./useIsMounted\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\n\nexport interface CurrentSelection {\n selection: ReturnType<typeof $getSelection>;\n rangeSelection: RangeSelection | null;\n nodeSelection: NodeSelection | null;\n}\n\ninterface Generator<T> {\n (params: CurrentSelection): T;\n}\n\nfunction getOutput(selection: ReturnType<typeof $getSelection>) {\n return {\n selection,\n rangeSelection: $isRangeSelection(selection) ? selection : null,\n nodeSelection: $isNodeSelection(selection) ? selection : null\n };\n}\n\nexport function useCurrentSelection() {\n const { editor } = useRichTextEditor();\n const [selection, setSelection] = useState<CurrentSelection>(getOutput(null));\n const isMounted = useIsMounted();\n\n const storeSelection = useCallback(() => {\n editor.getEditorState().read(() => {\n if (isMounted()) {\n setSelection(getOutput($getSelection()));\n }\n });\n }, [editor]);\n\n useEffect(() => {\n // On first mount, store current selection.\n storeSelection();\n\n // Subscribe to editor updates and keep track of the selection.\n return editor.registerUpdateListener(storeSelection);\n }, []);\n\n return selection;\n}\n\nexport function useDeriveValueFromSelection<T>(generator: Generator<T>) {\n const { editor } = useRichTextEditor();\n const [value, setValue] = useState<T>(generator(getOutput(null)));\n const isMounted = useIsMounted();\n\n const generateValue = useCallback(() => {\n editor.getEditorState().read(() => {\n if (isMounted()) {\n setValue(generator(getOutput($getSelection())));\n }\n });\n }, [editor]);\n\n useEffect(() => {\n // On first mount, generate current value.\n generateValue();\n\n // Subscribe to editor updates and regenerate the value.\n return editor.registerUpdateListener(generateValue);\n }, []);\n\n return value;\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAYA,SAASI,SAASA,CAACC,SAA2C,EAAE;EAC5D,OAAO;IACHA,SAAS,EAATA,SAAS;IACTC,cAAc,EAAE,IAAAC,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UAAA,OAAAhB,eAAA,CAAAC,OAAA,EAAAc,UAAA;IAA1DE,KAAK,GAAAD,UAAA;IAAEE,QAAQ,GAAAF,UAAA;EACtB,IAAMb,SAAS,GAAG,IAAAC,0BAAY,EAAC,CAAC;EAEhC,IAAMe,aAAa,GAAG,IAAAb,kBAAW,EAAC,YAAM;IACpCV,MAAM,CAACW,cAAc,CAAC,CAAC,CAACC,IAAI,CAAC,YAAM;MAC/B,IAAIL,SAAS,CAAC,CAAC,EAAE;QACbe,QAAQ,CAACL,SAAS,CAAC1B,SAAS,CAAC,IAAAsB,sBAAa,EAAC,CAAC,CAAC,CAAC,CAAC;MACnD;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAACb,MAAM,CAAC,CAAC;EAEZ,IAAAc,gBAAS,EAAC,YAAM;IACZ;IACAS,aAAa,CAAC,CAAC;;IAEf;IACA,OAAOvB,MAAM,CAACe,sBAAsB,CAACQ,aAAa,CAAC;EACvD,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOF,KAAK;AAChB","ignoreList":[]}
1
+ {"version":3,"names":["useCallback","useEffect","useState","$getSelection","$isRangeSelection","$isNodeSelection","useIsMounted","useRichTextEditor","getOutput","selection","rangeSelection","nodeSelection","useCurrentSelection","editor","setSelection","isMounted","storeSelection","getEditorState","read","registerUpdateListener","useDeriveValueFromSelection","generator","value","setValue","generateValue"],"sources":["useCurrentSelection.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\nimport {\n $getSelection,\n $isRangeSelection,\n $isNodeSelection,\n RangeSelection,\n NodeSelection\n} from \"lexical\";\nimport { useIsMounted } from \"./useIsMounted\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\n\nexport interface CurrentSelection {\n selection: ReturnType<typeof $getSelection>;\n rangeSelection: RangeSelection | null;\n nodeSelection: NodeSelection | null;\n}\n\ninterface Generator<T> {\n (params: CurrentSelection): T;\n}\n\nfunction getOutput(selection: ReturnType<typeof $getSelection>) {\n return {\n selection,\n rangeSelection: $isRangeSelection(selection) ? selection : null,\n nodeSelection: $isNodeSelection(selection) ? selection : null\n };\n}\n\nexport function useCurrentSelection() {\n const { editor } = useRichTextEditor();\n const [selection, setSelection] = useState<CurrentSelection>(getOutput(null));\n const isMounted = useIsMounted();\n\n const storeSelection = useCallback(() => {\n editor.getEditorState().read(() => {\n if (isMounted()) {\n setSelection(getOutput($getSelection()));\n }\n });\n }, [editor]);\n\n useEffect(() => {\n // On first mount, store current selection.\n storeSelection();\n\n // Subscribe to editor updates and keep track of the selection.\n return editor.registerUpdateListener(storeSelection);\n }, []);\n\n return selection;\n}\n\nexport function useDeriveValueFromSelection<T>(generator: Generator<T>) {\n const { editor } = useRichTextEditor();\n const [value, setValue] = useState<T>(generator(getOutput(null)));\n const isMounted = useIsMounted();\n\n const generateValue = useCallback(() => {\n editor.getEditorState().read(() => {\n if (isMounted()) {\n setValue(generator(getOutput($getSelection())));\n }\n });\n }, [editor]);\n\n useEffect(() => {\n // On first mount, generate current value.\n generateValue();\n\n // Subscribe to editor updates and regenerate the value.\n return editor.registerUpdateListener(generateValue);\n }, []);\n\n return value;\n}\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACxD,SACIC,aAAa,EACbC,iBAAiB,EACjBC,gBAAgB,QAGb,SAAS;AAChB,SAASC,YAAY;AACrB,SAASC,iBAAiB;AAY1B,SAASC,SAASA,CAACC,SAA2C,EAAE;EAC5D,OAAO;IACHA,SAAS;IACTC,cAAc,EAAEN,iBAAiB,CAACK,SAAS,CAAC,GAAGA,SAAS,GAAG,IAAI;IAC/DE,aAAa,EAAEN,gBAAgB,CAACI,SAAS,CAAC,GAAGA,SAAS,GAAG;EAC7D,CAAC;AACL;AAEA,OAAO,SAASG,mBAAmBA,CAAA,EAAG;EAClC,MAAM;IAAEC;EAAO,CAAC,GAAGN,iBAAiB,CAAC,CAAC;EACtC,MAAM,CAACE,SAAS,EAAEK,YAAY,CAAC,GA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E,EAAE,CAAC;EAEN,OAAOF,KAAK;AAChB","ignoreList":[]}
@@ -1,15 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useFontColorPicker = useFontColorPicker;
7
- var _react = require("react");
8
- var _FontColorActionContext = require("../context/FontColorActionContext");
9
- function useFontColorPicker() {
10
- var context = (0, _react.useContext)(_FontColorActionContext.FontColorActionContext);
1
+ import { useContext } from "react";
2
+ import { FontColorActionContext } from "../context/FontColorActionContext";
3
+ export function useFontColorPicker() {
4
+ const context = useContext(FontColorActionContext);
11
5
  if (!context) {
12
- throw Error("Missing FontColorActionContext in the component hierarchy. Are you using \"useFontColorPicker()\" in the right place?");
6
+ throw Error(`Missing FontColorActionContext in the component hierarchy. Are you using "useFontColorPicker()" in the right place?`);
13
7
  }
14
8
  return context;
15
9
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_FontColorActionContext","useFontColorPicker","context","useContext","FontColorActionContext","Error"],"sources":["useFontColorPicker.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { FontColorActionContext } from \"~/context/FontColorActionContext\";\n\nexport function useFontColorPicker() {\n const context = useContext(FontColorActionContext);\n if (!context) {\n throw Error(\n `Missing FontColorActionContext in the component hierarchy. Are you using \"useFontColorPicker()\" in the right place?`\n );\n }\n\n return context;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AAEO,SAASE,kBAAkBA,CAAA,EAAG;EACjC,IAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACC,8CAAsB,CAAC;EAClD,IAAI,CAACF,OAAO,EAAE;IACV,MAAMG,KAAK,wHAEX,CAAC;EACL;EAEA,OAAOH,OAAO;AAClB","ignoreList":[]}
1
+ {"version":3,"names":["useContext","FontColorActionContext","useFontColorPicker","context","Error"],"sources":["useFontColorPicker.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { FontColorActionContext } from \"~/context/FontColorActionContext\";\n\nexport function useFontColorPicker() {\n const context = useContext(FontColorActionContext);\n if (!context) {\n throw Error(\n `Missing FontColorActionContext in the component hierarchy. Are you using \"useFontColorPicker()\" in the right place?`\n );\n }\n\n return context;\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,sBAAsB;AAE/B,OAAO,SAASC,kBAAkBA,CAAA,EAAG;EACjC,MAAMC,OAAO,GAAGH,UAAU,CAACC,sBAAsB,CAAC;EAClD,IAAI,CAACE,OAAO,EAAE;IACV,MAAMC,KAAK,CACP,qHACJ,CAAC;EACL;EAEA,OAAOD,OAAO;AAClB","ignoreList":[]}
@@ -1,20 +1,12 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useIsMounted = useIsMounted;
7
- var _react = require("react");
8
- function useIsMounted() {
9
- var isMounted = (0, _react.useRef)(true);
10
- (0, _react.useEffect)(function () {
11
- return function () {
1
+ import { useEffect, useRef } from "react";
2
+ export function useIsMounted() {
3
+ const isMounted = useRef(true);
4
+ useEffect(() => {
5
+ return () => {
12
6
  isMounted.current = false;
13
7
  };
14
8
  }, []);
15
- return function () {
16
- return isMounted.current;
17
- };
9
+ return () => isMounted.current;
18
10
  }
19
11
 
20
12
  //# sourceMappingURL=useIsMounted.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","useIsMounted","isMounted","useRef","useEffect","current"],"sources":["useIsMounted.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nexport function useIsMounted() {\n const isMounted = useRef(true);\n\n useEffect(() => {\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return () => isMounted.current;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,SAASC,YAAYA,CAAA,EAAG;EAC3B,IAAMC,SAAS,GAAG,IAAAC,aAAM,EAAC,IAAI,CAAC;EAE9B,IAAAC,gBAAS,EAAC,YAAM;IACZ,OAAO,YAAM;MACTF,SAAS,CAACG,OAAO,GAAG,KAAK;IAC7B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAA,OAAMH,SAAS,CAACG,OAAO;EAAA;AAClC","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","useRef","useIsMounted","isMounted","current"],"sources":["useIsMounted.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nexport function useIsMounted() {\n const isMounted = useRef(true);\n\n useEffect(() => {\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return () => isMounted.current;\n}\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEzC,OAAO,SAASC,YAAYA,CAAA,EAAG;EAC3B,MAAMC,SAAS,GAAGF,MAAM,CAAC,IAAI,CAAC;EAE9BD,SAAS,CAAC,MAAM;IACZ,OAAO,MAAM;MACTG,SAAS,CAACC,OAAO,GAAG,KAAK;IAC7B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,MAAMD,SAAS,CAACC,OAAO;AAClC","ignoreList":[]}