@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.
- package/commands/image.js +2 -8
- package/commands/image.js.map +1 -1
- package/commands/index.js +4 -49
- package/commands/index.js.map +1 -1
- package/commands/list.js +4 -10
- package/commands/list.js.map +1 -1
- package/commands/quote.js +2 -8
- package/commands/quote.js.map +1 -1
- package/commands/toolbar.js +2 -8
- package/commands/toolbar.js.map +1 -1
- package/components/Editor/EnsureHeadingTagPlugin.js +10 -16
- package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
- package/components/Editor/HeadingEditor.js +13 -21
- package/components/Editor/HeadingEditor.js.map +1 -1
- package/components/Editor/ParagraphEditor.js +12 -19
- package/components/Editor/ParagraphEditor.js.map +1 -1
- package/components/Editor/RichTextEditor.js +92 -105
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/Editor/normalizeInputValue.js +2 -8
- package/components/Editor/normalizeInputValue.js.map +1 -1
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +39 -49
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
- package/components/LexicalEditorConfig/components/Node.js +17 -26
- package/components/LexicalEditorConfig/components/Node.js.map +1 -1
- package/components/LexicalEditorConfig/components/Plugin.js +17 -26
- package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
- package/components/LexicalEditorConfig/components/ToolbarElement.js +17 -26
- package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
- package/components/LexicalHtmlRenderer.js +37 -46
- package/components/LexicalHtmlRenderer.js.map +1 -1
- package/components/Toolbar/StaticToolbar.d.ts +3 -1
- package/components/Toolbar/StaticToolbar.js +19 -23
- package/components/Toolbar/StaticToolbar.js.map +1 -1
- package/components/Toolbar/Toolbar.js +66 -75
- package/components/Toolbar/Toolbar.js.map +1 -1
- package/components/ToolbarActions/BoldAction.js +16 -21
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.js +26 -31
- package/components/ToolbarActions/BulletListAction.js.map +1 -1
- package/components/ToolbarActions/CodeHighlightAction.js +16 -21
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
- package/components/ToolbarActions/FontColorAction.js +32 -42
- package/components/ToolbarActions/FontColorAction.js.map +1 -1
- package/components/ToolbarActions/FontSizeAction.js +53 -71
- package/components/ToolbarActions/FontSizeAction.js.map +1 -1
- package/components/ToolbarActions/ImageAction.js +19 -34
- package/components/ToolbarActions/ImageAction.js.map +1 -1
- package/components/ToolbarActions/ItalicAction.js +16 -21
- package/components/ToolbarActions/ItalicAction.js.map +1 -1
- package/components/ToolbarActions/LinkAction.js +19 -24
- package/components/ToolbarActions/LinkAction.js.map +1 -1
- package/components/ToolbarActions/NumberedListAction.js +26 -33
- package/components/ToolbarActions/NumberedListAction.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.js +20 -25
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/TextAlignmentAction.js +36 -45
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
- package/components/ToolbarActions/TypographyAction.js +43 -55
- package/components/ToolbarActions/TypographyAction.js.map +1 -1
- package/components/ToolbarActions/UnderlineAction.js +16 -21
- package/components/ToolbarActions/UnderlineAction.js.map +1 -1
- package/context/FontColorActionContext.js +2 -9
- package/context/FontColorActionContext.js.map +1 -1
- package/context/RichTextEditorContext.js +15 -26
- package/context/RichTextEditorContext.js.map +1 -1
- package/context/SharedHistoryContext.js +12 -20
- package/context/SharedHistoryContext.js.map +1 -1
- package/context/TextAlignmentActionContextProps.js +2 -9
- package/context/TextAlignmentActionContextProps.js.map +1 -1
- package/context/TypographyActionContext.js +2 -9
- package/context/TypographyActionContext.js.map +1 -1
- package/hooks/index.js +8 -93
- package/hooks/index.js.map +1 -1
- package/hooks/useCurrentElement.d.ts +2 -2
- package/hooks/useCurrentElement.js +12 -18
- package/hooks/useCurrentElement.js.map +1 -1
- package/hooks/useCurrentSelection.js +27 -40
- package/hooks/useCurrentSelection.js.map +1 -1
- package/hooks/useFontColorPicker.js +5 -11
- package/hooks/useFontColorPicker.js.map +1 -1
- package/hooks/useIsMounted.js +6 -14
- package/hooks/useIsMounted.js.map +1 -1
- package/hooks/useList.js +31 -35
- package/hooks/useList.js.map +1 -1
- package/hooks/useQuote.js +12 -17
- package/hooks/useQuote.js.map +1 -1
- package/hooks/useRichTextEditor.js +5 -11
- package/hooks/useRichTextEditor.js.map +1 -1
- package/hooks/useTextAlignmentAction.js +5 -11
- package/hooks/useTextAlignmentAction.js.map +1 -1
- package/hooks/useTypographyAction.js +5 -11
- package/hooks/useTypographyAction.js.map +1 -1
- package/index.js +49 -322
- package/index.js.map +1 -1
- package/package.json +8 -7
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +16 -22
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +9 -14
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/index.js +1 -16
- package/plugins/CodeHighlightPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +16 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +158 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +8 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +62 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +2 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +5 -16
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +11 -180
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +2 -3
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +54 -68
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +1 -1
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +16 -26
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.js +1 -16
- package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +3 -9
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
- package/plugins/FontColorPlugin/FontColorPlugin.js +19 -22
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToNode.js +4 -10
- package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToSelection.js +28 -44
- package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
- package/plugins/ImagesPlugin/ImagesPlugin.js +59 -58
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
- package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js +23 -23
- package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js.map +1 -1
- package/plugins/LexicalUpdateStatePlugin/index.js +1 -16
- package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -1
- package/plugins/LinkPlugin/LinkPlugin.js +30 -37
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
- package/plugins/ListPLugin/ListPlugin.js +10 -15
- package/plugins/ListPLugin/ListPlugin.js.map +1 -1
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +11 -16
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
- package/plugins/TypographyPlugin/TypographyPlugin.js +16 -21
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
- package/types.d.ts +3 -3
- package/types.js +6 -38
- package/types.js.map +1 -1
- package/ui/ContentEditable.js +7 -14
- package/ui/ContentEditable.js.map +1 -1
- package/ui/Divider.js +3 -10
- package/ui/Divider.js.map +1 -1
- package/ui/DropDown.js +61 -88
- package/ui/DropDown.js.map +1 -1
- package/ui/ImageResizer.js +78 -83
- package/ui/ImageResizer.js.map +1 -1
- package/ui/LinkPreview.js +22 -29
- package/ui/LinkPreview.js.map +1 -1
- package/ui/Placeholder.js +10 -16
- package/ui/Placeholder.js.map +1 -1
- package/ui/TextInput.js +11 -18
- package/ui/TextInput.js.map +1 -1
- package/ui/ToolbarActionDialog.js +30 -42
- package/ui/ToolbarActionDialog.js.map +1 -1
- package/utils/canUseDOM.js +1 -7
- package/utils/canUseDOM.js.map +1 -1
- package/utils/files.js +9 -26
- package/utils/files.js.map +1 -1
- package/utils/generateInitialLexicalValue.js +2 -8
- package/utils/generateInitialLexicalValue.js.map +1 -1
- package/utils/getDOMRangeRect.js +4 -10
- package/utils/getDOMRangeRect.js.map +1 -1
- package/utils/getSelectedNode.js +9 -16
- package/utils/getSelectedNode.js.map +1 -1
- package/utils/getTransparentImage.js +1 -7
- package/utils/getTransparentImage.js.map +1 -1
- package/utils/insertImage.js +8 -14
- package/utils/insertImage.js.map +1 -1
- package/utils/isAnchorLink.js +1 -7
- package/utils/isAnchorLink.js.map +1 -1
- package/utils/isChildOfFloatingToolbar.js +3 -9
- package/utils/isChildOfFloatingToolbar.js.map +1 -1
- package/utils/isHTMLElement.js +1 -7
- package/utils/isHTMLElement.js.map +1 -1
- package/utils/isValidJSON.js +3 -9
- package/utils/isValidJSON.js.map +1 -1
- package/utils/isValidLexicalData.d.ts +1 -1
- package/utils/isValidLexicalData.js +6 -12
- package/utils/isValidLexicalData.js.map +1 -1
- package/utils/point.js +35 -60
- package/utils/point.js.map +1 -1
- package/utils/rect.js +114 -149
- package/utils/rect.js.map +1 -1
- package/utils/sanitizeUrl.js +6 -13
- package/utils/sanitizeUrl.js.map +1 -1
- package/utils/setFloatingElemPosition.js +11 -19
- package/utils/setFloatingElemPosition.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.d.ts +0 -2
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +0 -96
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +0 -1
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
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":["
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
25
|
-
theme
|
|
26
|
-
themeEmotionMap
|
|
27
|
-
toolbarActionPlugins
|
|
13
|
+
editor,
|
|
14
|
+
theme,
|
|
15
|
+
themeEmotionMap,
|
|
16
|
+
toolbarActionPlugins
|
|
28
17
|
}
|
|
29
18
|
}, children);
|
|
30
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
24
|
-
return
|
|
15
|
+
export const useSharedHistoryContext = () => {
|
|
16
|
+
return useContext(Context);
|
|
25
17
|
};
|
|
26
18
|
|
|
27
19
|
//# sourceMappingURL=SharedHistoryContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
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
|
-
|
|
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":["
|
|
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
|
-
|
|
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":["
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
package/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
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").
|
|
5
|
+
element: import("lexical").LexicalNode | import("lexical").TextNode;
|
|
6
6
|
};
|
|
7
|
-
export declare function getNodeFromSelection(selection: RangeSelection): import("lexical").
|
|
7
|
+
export declare function getNodeFromSelection(selection: RangeSelection): import("lexical").LexicalNode | import("lexical").TextNode;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return parent !== null &&
|
|
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":["
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
17
|
-
rangeSelection:
|
|
18
|
-
nodeSelection:
|
|
7
|
+
selection,
|
|
8
|
+
rangeSelection: $isRangeSelection(selection) ? selection : null,
|
|
9
|
+
nodeSelection: $isNodeSelection(selection) ? selection : null
|
|
19
10
|
};
|
|
20
11
|
}
|
|
21
|
-
function useCurrentSelection() {
|
|
22
|
-
|
|
23
|
-
editor
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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(
|
|
21
|
+
setSelection(getOutput($getSelection()));
|
|
33
22
|
}
|
|
34
23
|
});
|
|
35
24
|
}, [editor]);
|
|
36
|
-
|
|
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
|
-
|
|
47
|
-
editor
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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(
|
|
43
|
+
setValue(generator(getOutput($getSelection())));
|
|
57
44
|
}
|
|
58
45
|
});
|
|
59
46
|
}, [editor]);
|
|
60
|
-
|
|
47
|
+
useEffect(() => {
|
|
61
48
|
// On first mount, generate current value.
|
|
62
49
|
generateValue();
|
|
63
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
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,GAAGZ,QAAQ,CAAmBM,SAAS,CAAC,IAAI,CAAC,CAAC;EAC7E,MAAMO,SAAS,GAAGT,YAAY,CAAC,CAAC;EAEhC,MAAMU,cAAc,GAAGhB,WAAW,CAAC,MAAM;IACrCa,MAAM,CAACI,cAAc,CAAC,CAAC,CAACC,IAAI,CAAC,MAAM;MAC/B,IAAIH,SAAS,CAAC,CAAC,EAAE;QACbD,YAAY,CAACN,SAAS,CAACL,aAAa,CAAC,CAAC,CAAC,CAAC;MAC5C;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAACU,MAAM,CAAC,CAAC;EAEZZ,SAAS,CAAC,MAAM;IACZ;IACAe,cAAc,CAAC,CAAC;;IAEhB;IACA,OAAOH,MAAM,CAACM,sBAAsB,CAACH,cAAc,CAAC;EACxD,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOP,SAAS;AACpB;AAEA,OAAO,SAASW,2BAA2BA,CAAIC,SAAuB,EAAE;EACpE,MAAM;IAAER;EAAO,CAAC,GAAGN,iBAAiB,CAAC,CAAC;EACtC,MAAM,CAACe,KAAK,EAAEC,QAAQ,CAAC,GAAGrB,QAAQ,CAAImB,SAAS,CAACb,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;EACjE,MAAMO,SAAS,GAAGT,YAAY,CAAC,CAAC;EAEhC,MAAMkB,aAAa,GAAGxB,WAAW,CAAC,MAAM;IACpCa,MAAM,CAACI,cAAc,CAAC,CAAC,CAACC,IAAI,CAAC,MAAM;MAC/B,IAAIH,SAAS,CAAC,CAAC,EAAE;QACbQ,QAAQ,CAACF,SAAS,CAACb,SAAS,CAACL,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;MACnD;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAACU,MAAM,CAAC,CAAC;EAEZZ,SAAS,CAAC,MAAM;IACZ;IACAuB,aAAa,CAAC,CAAC;;IAEf;IACA,OAAOX,MAAM,CAACM,sBAAsB,CAACK,aAAa,CAAC;EACvD,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOF,KAAK;AAChB","ignoreList":[]}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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(
|
|
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":["
|
|
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":[]}
|
package/hooks/useIsMounted.js
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
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":["
|
|
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":[]}
|