@webiny/lexical-editor 0.0.0-unstable.d65ec29d44 → 0.0.0-unstable.da99e0b846
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/components/AddRichTextEditorNodeType.js.map +1 -1
- package/components/AddRichTextEditorPlugin.d.ts +2 -0
- package/components/AddRichTextEditorPlugin.js +4 -2
- package/components/AddRichTextEditorPlugin.js.map +1 -1
- package/components/AddToolbarAction.js.map +1 -1
- package/components/Editor/HeadingEditor.js.map +1 -1
- package/components/Editor/ParagraphEditor.js.map +1 -1
- package/components/Editor/RichTextEditor.d.ts +2 -0
- package/components/Editor/RichTextEditor.js +10 -5
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +7 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +15 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
- package/components/LexicalHtmlRenderer.d.ts +2 -0
- package/components/LexicalHtmlRenderer.js +8 -4
- package/components/LexicalHtmlRenderer.js.map +1 -1
- package/components/Toolbar/HeadingToolbar.js.map +1 -1
- package/components/Toolbar/ParagraphToolbar.js.map +1 -1
- package/components/Toolbar/Toolbar.css +9 -0
- package/components/Toolbar/Toolbar.js.map +1 -1
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.js.map +1 -1
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
- package/components/ToolbarActions/FontColorAction.d.ts +11 -0
- package/components/ToolbarActions/FontColorAction.js +88 -0
- package/components/ToolbarActions/FontColorAction.js.map +1 -0
- package/components/ToolbarActions/FontSizeAction.js.map +1 -1
- package/components/ToolbarActions/ItalicAction.js.map +1 -1
- package/components/ToolbarActions/LinkAction.js.map +1 -1
- package/components/ToolbarActions/NumberedListAction.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/UnderlineAction.js.map +1 -1
- package/components/ToolbarPresets/HeadingToolbarPreset.js +4 -0
- package/components/ToolbarPresets/HeadingToolbarPreset.js.map +1 -1
- package/components/ToolbarPresets/ParagraphToolbarPreset.js +4 -0
- package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +1 -1
- package/context/FontColorActionContext.d.ts +6 -0
- package/context/FontColorActionContext.js +10 -0
- package/context/FontColorActionContext.js.map +1 -0
- package/context/RichTextEditorContext.js.map +1 -1
- package/hooks/useFontColorPicker.d.ts +2 -0
- package/hooks/useFontColorPicker.js +15 -0
- package/hooks/useFontColorPicker.js.map +1 -0
- package/hooks/useRichTextEditor.js.map +1 -1
- package/images/icons/font-color.svg +1 -0
- package/index.d.ts +4 -1
- package/index.js +23 -2
- package/index.js.map +1 -1
- package/nodes/FontColorNode.d.ts +43 -0
- package/nodes/FontColorNode.js +127 -0
- package/nodes/FontColorNode.js.map +1 -0
- package/nodes/webinyNodes.js +2 -1
- package/nodes/webinyNodes.js.map +1 -1
- package/package.json +13 -13
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.js.map +1 -1
- package/plugins/AutoLinkPlugin/index.js.map +1 -1
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js.map +1 -1
- package/plugins/ClickableLinkPlugin/index.js.map +1 -1
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
- package/plugins/FontColorPlugin/FontColorPlugin.d.ts +2 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js +38 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +1 -1
- package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -1
- package/themes/webinyLexicalTheme.d.ts +5 -8
- package/themes/webinyLexicalTheme.js +6 -27
- package/themes/webinyLexicalTheme.js.map +1 -1
- package/types.d.ts +1 -0
- package/types.js +8 -1
- package/types.js.map +1 -1
- package/ui/Divider.js.map +1 -1
- package/ui/DropDown.d.ts +2 -1
- package/ui/DropDown.js +7 -2
- package/ui/DropDown.js.map +1 -1
- package/ui/LinkPreview.js.map +1 -1
- package/ui/Placeholder.js.map +1 -1
- package/ui/TextInput.js.map +1 -1
- package/ui/ToolbarActionDialog.d.ts +12 -0
- package/ui/ToolbarActionDialog.js +107 -0
- package/ui/ToolbarActionDialog.js.map +1 -0
- package/utils/generateInitialLexicalValue.js.map +1 -1
- package/utils/getDOMRangeRect.js.map +1 -1
- package/utils/getSelectedNode.js.map +1 -1
- package/utils/isValidJSON.js.map +1 -1
- package/utils/isValidLexicalData.js.map +1 -1
- package/utils/point.js.map +1 -1
- package/utils/rect.js.map +1 -1
- package/utils/sanitizeUrl.js.map +1 -1
- package/utils/setFloatingElemPosition.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["AddRichTextEditorNodeType","type","NodePlugin","createComponentPlugin","RichTextEditor","Original","nodes","children","rest"],"sources":["AddRichTextEditorNodeType.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { Klass, LexicalNode } from \"lexical\";\nimport { createComponentPlugin } from \"@webiny/react-composition\";\nimport { RichTextEditor } from \"~/components/Editor/RichTextEditor\";\n\nexport interface AddRichTextEditorNodeTypeProps {\n type: Klass<LexicalNode>;\n}\n\nexport const AddRichTextEditorNodeType: FC<AddRichTextEditorNodeTypeProps> = ({ type }) => {\n const NodePlugin = createComponentPlugin(RichTextEditor, Original => {\n return function RichTextEditor({ nodes, children, ...rest }): JSX.Element {\n return (\n <Original {...rest} nodes={[...(nodes || []), type]}>\n {children}\n </Original>\n );\n };\n });\n\n return <NodePlugin />;\n};\n"],"mappings":";;;;;;;;;AAAA;AAEA;AACA;AAAoE;AAM7D,IAAMA,yBAA6D,GAAG,SAAhEA,yBAA6D,OAAiB;EAAA,IAAXC,IAAI,QAAJA,IAAI;EAChF,IAAMC,UAAU,GAAG,IAAAC,uCAAqB,EAACC,8BAAc,EAAE,UAAAC,QAAQ,EAAI;IACjE,OAAO,SAASD,cAAc,QAA4C;MAAA,IAAzCE,KAAK,SAALA,KAAK;QAAEC,QAAQ,SAARA,QAAQ;QAAKC,IAAI;MACrD,oBACI,6BAAC,QAAQ,oBAAKA,IAAI;QAAE,KAAK,6CAAOF,KAAK,IAAI,EAAE,IAAGL,IAAI;MAAE,IAC/CM,QAAQ,CACF;IAEnB,CAAC;EACL,CAAC,CAAC;EAEF,oBAAO,6BAAC,UAAU,OAAG;AACzB,CAAC;AAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, { FC } from "react";
|
|
2
2
|
import { LexicalValue } from "../types";
|
|
3
|
+
import { WebinyTheme } from "../themes/webinyLexicalTheme";
|
|
3
4
|
interface AddRichTextEditorProps {
|
|
4
5
|
toolbar: React.ReactNode;
|
|
5
6
|
placeholder?: string;
|
|
6
7
|
value: LexicalValue;
|
|
7
8
|
children?: React.ReactNode;
|
|
9
|
+
theme: WebinyTheme;
|
|
8
10
|
}
|
|
9
11
|
export declare const AddRichTextEditorPlugin: FC<AddRichTextEditorProps>;
|
|
10
12
|
export {};
|
|
@@ -16,13 +16,15 @@ var AddRichTextEditorPlugin = function AddRichTextEditorPlugin(_ref) {
|
|
|
16
16
|
return function RichTextEditorElem(_ref2) {
|
|
17
17
|
var tag = _ref2.tag,
|
|
18
18
|
value = _ref2.value,
|
|
19
|
-
onChange = _ref2.onChange
|
|
19
|
+
onChange = _ref2.onChange,
|
|
20
|
+
theme = _ref2.theme;
|
|
20
21
|
return /*#__PURE__*/_react.default.createElement(Original, {
|
|
21
22
|
toolbar: toolbar,
|
|
22
23
|
tag: tag,
|
|
23
24
|
placeholder: placeholder,
|
|
24
25
|
value: value,
|
|
25
|
-
onChange: onChange
|
|
26
|
+
onChange: onChange,
|
|
27
|
+
theme: theme
|
|
26
28
|
}, children);
|
|
27
29
|
};
|
|
28
30
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["AddRichTextEditorPlugin","toolbar","placeholder","children","RichTextEditorPlugin","React","memo","createComponentPlugin","RichTextEditor","Original","RichTextEditorElem","tag","value","onChange","theme"],"sources":["AddRichTextEditorPlugin.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { createComponentPlugin } from \"@webiny/react-composition\";\nimport { RichTextEditor } from \"~/components/Editor/RichTextEditor\";\nimport { LexicalValue } from \"~/types\";\nimport { WebinyTheme } from \"~/themes/webinyLexicalTheme\";\n\ninterface AddRichTextEditorProps {\n toolbar: React.ReactNode;\n placeholder?: string;\n value: LexicalValue;\n children?: React.ReactNode;\n /*\n * @description Theme to be injected into lexical editor\n */\n theme: WebinyTheme;\n}\n\nexport const AddRichTextEditorPlugin: FC<AddRichTextEditorProps> = ({\n toolbar,\n placeholder,\n children\n}) => {\n const RichTextEditorPlugin = React.memo(\n createComponentPlugin(RichTextEditor, Original => {\n return function RichTextEditorElem({ tag, value, onChange, theme }): JSX.Element {\n return (\n <Original\n toolbar={toolbar}\n tag={tag}\n placeholder={placeholder}\n value={value}\n onChange={onChange}\n theme={theme}\n >\n {children}\n </Original>\n );\n };\n })\n );\n\n return <RichTextEditorPlugin />;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAeO,IAAMA,uBAAmD,GAAG,SAAtDA,uBAAmD,OAI1D;EAAA,IAHFC,OAAO,QAAPA,OAAO;IACPC,WAAW,QAAXA,WAAW;IACXC,QAAQ,QAARA,QAAQ;EAER,IAAMC,oBAAoB,gBAAGC,cAAK,CAACC,IAAI,CACnC,IAAAC,uCAAqB,EAACC,8BAAc,EAAE,UAAAC,QAAQ,EAAI;IAC9C,OAAO,SAASC,kBAAkB,QAA+C;MAAA,IAA5CC,GAAG,SAAHA,GAAG;QAAEC,KAAK,SAALA,KAAK;QAAEC,QAAQ,SAARA,QAAQ;QAAEC,KAAK,SAALA,KAAK;MAC5D,oBACI,6BAAC,QAAQ;QACL,OAAO,EAAEb,OAAQ;QACjB,GAAG,EAAEU,GAAI;QACT,WAAW,EAAET,WAAY;QACzB,KAAK,EAAEU,KAAM;QACb,QAAQ,EAAEC,QAAS;QACnB,KAAK,EAAEC;MAAM,GAEZX,QAAQ,CACF;IAEnB,CAAC;EACL,CAAC,CAAC,CACL;EAED,oBAAO,6BAAC,oBAAoB,OAAG;AACnC,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["AddToolbarAction","element","targetType","type","ToolbarPlugin","React","memo","createComponentPlugin","Toolbar","Original","children","anchorElem"],"sources":["AddToolbarAction.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { createComponentPlugin } from \"@webiny/react-composition\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\ninterface AddToolbarActionProps {\n type?: \"heading\" | \"paragraph\" | string;\n element: JSX.Element;\n}\n\nexport const AddToolbarAction: FC<AddToolbarActionProps> = ({ element, type: targetType }) => {\n const ToolbarPlugin = React.memo(\n createComponentPlugin(Toolbar, Original => {\n return function Toolbar({ type, children, anchorElem }): JSX.Element {\n if (!targetType || targetType === type) {\n return (\n <Original type={type} anchorElem={anchorElem}>\n {element}\n {children}\n </Original>\n );\n }\n\n return (\n <Original anchorElem={anchorElem} type={type}>\n {children}\n </Original>\n );\n };\n })\n );\n\n return <ToolbarPlugin />;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAMO,IAAMA,gBAA2C,GAAG,SAA9CA,gBAA2C,OAAsC;EAAA,IAAhCC,OAAO,QAAPA,OAAO;IAAQC,UAAU,QAAhBC,IAAI;EACvE,IAAMC,aAAa,gBAAGC,cAAK,CAACC,IAAI,CAC5B,IAAAC,uCAAqB,EAACC,gBAAO,EAAE,UAAAC,QAAQ,EAAI;IACvC,OAAO,SAASD,OAAO,QAA8C;MAAA,IAA3CL,IAAI,SAAJA,IAAI;QAAEO,QAAQ,SAARA,QAAQ;QAAEC,UAAU,SAAVA,UAAU;MAChD,IAAI,CAACT,UAAU,IAAIA,UAAU,KAAKC,IAAI,EAAE;QACpC,oBACI,6BAAC,QAAQ;UAAC,IAAI,EAAEA,IAAK;UAAC,UAAU,EAAEQ;QAAW,GACxCV,OAAO,EACPS,QAAQ,CACF;MAEnB;MAEA,oBACI,6BAAC,QAAQ;QAAC,UAAU,EAAEC,UAAW;QAAC,IAAI,EAAER;MAAK,GACxCO,QAAQ,CACF;IAEnB,CAAC;EACL,CAAC,CAAC,CACL;EAED,oBAAO,6BAAC,aAAa,OAAG;AAC5B,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["HeadingEditor","tag","placeholder","rest","document","body"],"sources":["HeadingEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { LinkPlugin } from \"@lexical/react/LexicalLinkPlugin\";\nimport { ClickableLinkPlugin } from \"~/plugins/ClickableLinkPlugin/ClickableLinkPlugin\";\nimport { FloatingLinkEditorPlugin } from \"~/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin\";\nimport { HeadingToolbar } from \"~/components/Toolbar/HeadingToolbar\";\nimport { RichTextEditor, RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\n\ninterface HeadingEditorProps extends RichTextEditorProps {\n tag?: \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n}\n\nexport const HeadingEditor: React.FC<HeadingEditorProps> = ({ tag, placeholder, ...rest }) => {\n return (\n <RichTextEditor\n toolbar={<HeadingToolbar />}\n tag={tag ?? \"h1\"}\n placeholder={placeholder ?? \"Enter your heading text here...\"}\n {...rest}\n >\n <LinkPlugin />\n <ClickableLinkPlugin />\n <FloatingLinkEditorPlugin anchorElem={document.body} />\n </RichTextEditor>\n );\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAAyF;AAMlF,IAAMA,aAA2C,GAAG,SAA9CA,aAA2C,OAAsC;EAAA,IAAhCC,GAAG,QAAHA,GAAG;IAAEC,WAAW,QAAXA,WAAW;IAAKC,IAAI;EACnF,oBACI,6BAAC,8BAAc;IACX,OAAO,eAAE,6BAAC,8BAAc,OAAI;IAC5B,GAAG,EAAEF,GAAG,aAAHA,GAAG,cAAHA,GAAG,GAAI,IAAK;IACjB,WAAW,EAAEC,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAI;EAAkC,GAC1DC,IAAI,gBAER,6BAAC,6BAAU,OAAG,eACd,6BAAC,wCAAmB,OAAG,eACvB,6BAAC,kDAAwB;IAAC,UAAU,EAAEC,QAAQ,CAACC;EAAK,EAAG,CAC1C;AAEzB,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ParagraphEditor","placeholder","tag","rest","document","body"],"sources":["ParagraphEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { ListPlugin } from \"@lexical/react/LexicalListPlugin\";\nimport { CodeHighlightPlugin } from \"~/plugins/CodeHighlightPlugin/CodeHighlightPlugin\";\nimport { LinkPlugin } from \"@lexical/react/LexicalLinkPlugin\";\nimport { FloatingLinkEditorPlugin } from \"~/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin\";\nimport { ClickableLinkPlugin } from \"~/plugins/ClickableLinkPlugin/ClickableLinkPlugin\";\nimport { ParagraphToolbar } from \"~/components/Toolbar/ParagraphToolbar\";\nimport { RichTextEditor, RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\n\ninterface ParagraphLexicalEditorProps extends RichTextEditorProps {\n tag?: \"p\";\n}\n\nconst ParagraphEditor: React.FC<ParagraphLexicalEditorProps> = ({ placeholder, tag, ...rest }) => {\n return (\n <RichTextEditor\n toolbar={<ParagraphToolbar />}\n tag={tag ?? \"p\"}\n placeholder={placeholder ?? \"Enter your text here...\"}\n {...rest}\n >\n <LinkPlugin />\n <CodeHighlightPlugin />\n <ClickableLinkPlugin />\n <FloatingLinkEditorPlugin anchorElem={document.body} />\n <ListPlugin />\n </RichTextEditor>\n );\n};\n\nexport { ParagraphEditor };\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAyF;AAMzF,IAAMA,eAAsD,GAAG,SAAzDA,eAAsD,OAAsC;EAAA,IAAhCC,WAAW,QAAXA,WAAW;IAAEC,GAAG,QAAHA,GAAG;IAAKC,IAAI;EACvF,oBACI,6BAAC,8BAAc;IACX,OAAO,eAAE,6BAAC,kCAAgB,OAAI;IAC9B,GAAG,EAAED,GAAG,aAAHA,GAAG,cAAHA,GAAG,GAAI,GAAI;IAChB,WAAW,EAAED,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAI;EAA0B,GAClDE,IAAI,gBAER,6BAAC,6BAAU,OAAG,eACd,6BAAC,wCAAmB,OAAG,eACvB,6BAAC,wCAAmB,OAAG,eACvB,6BAAC,kDAAwB;IAAC,UAAU,EAAEC,QAAQ,CAACC;EAAK,EAAG,eACvD,6BAAC,6BAAU,OAAG,CACD;AAEzB,CAAC;AAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { LexicalValue } from "../../types";
|
|
3
3
|
import { Klass, LexicalNode } from "lexical";
|
|
4
|
+
import { WebinyTheme } from "../../themes/webinyLexicalTheme";
|
|
4
5
|
export interface RichTextEditorProps {
|
|
5
6
|
toolbar?: React.ReactNode;
|
|
6
7
|
tag?: string;
|
|
@@ -16,6 +17,7 @@ export interface RichTextEditorProps {
|
|
|
16
17
|
onBlur?: (editorState: LexicalValue) => void;
|
|
17
18
|
height?: number | string;
|
|
18
19
|
width?: number | string;
|
|
20
|
+
theme: WebinyTheme;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* @description Main editor container
|
|
@@ -12,8 +12,6 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _Placeholder = require("../../ui/Placeholder");
|
|
14
14
|
var _generateInitialLexicalValue = require("../../utils/generateInitialLexicalValue");
|
|
15
|
-
var _webinyNodes = require("../../nodes/webinyNodes");
|
|
16
|
-
var _webinyLexicalTheme = require("../../themes/webinyLexicalTheme");
|
|
17
15
|
var _LexicalComposer = require("@lexical/react/LexicalComposer");
|
|
18
16
|
var _LexicalOnChangePlugin = require("@lexical/react/LexicalOnChangePlugin");
|
|
19
17
|
var _LexicalAutoFocusPlugin = require("@lexical/react/LexicalAutoFocusPlugin");
|
|
@@ -26,6 +24,9 @@ var _RichTextEditorContext = require("../../context/RichTextEditorContext");
|
|
|
26
24
|
var _isValidLexicalData = require("../../utils/isValidLexicalData");
|
|
27
25
|
var _LexicalUpdateStatePlugin = require("../../plugins/LexicalUpdateStatePlugin");
|
|
28
26
|
var _BlurEventPlugin = require("../../plugins/BlurEventPlugin/BlurEventPlugin");
|
|
27
|
+
var _FontColorPlugin = require("../../plugins/FontColorPlugin/FontColorPlugin");
|
|
28
|
+
var _webinyLexicalTheme = require("../../themes/webinyLexicalTheme");
|
|
29
|
+
var _webinyNodes = require("../../nodes/webinyNodes");
|
|
29
30
|
var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
30
31
|
var toolbar = _ref.toolbar,
|
|
31
32
|
onChange = _ref.onChange,
|
|
@@ -36,7 +37,8 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
36
37
|
onBlur = _ref.onBlur,
|
|
37
38
|
focus = _ref.focus,
|
|
38
39
|
width = _ref.width,
|
|
39
|
-
height = _ref.height
|
|
40
|
+
height = _ref.height,
|
|
41
|
+
theme = _ref.theme;
|
|
40
42
|
var placeholderElem = /*#__PURE__*/_react.default.createElement(_Placeholder.Placeholder, null, placeholder || "Enter text...");
|
|
41
43
|
var scrollRef = (0, _react.useRef)(null);
|
|
42
44
|
var _useState = (0, _react.useState)(undefined),
|
|
@@ -59,12 +61,15 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
59
61
|
throw error;
|
|
60
62
|
},
|
|
61
63
|
nodes: [].concat((0, _toConsumableArray2.default)(_webinyNodes.WebinyNodes), (0, _toConsumableArray2.default)(nodes || [])),
|
|
62
|
-
theme: _webinyLexicalTheme.
|
|
64
|
+
theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _webinyLexicalTheme.webinyEditorTheme), {}, {
|
|
65
|
+
styles: theme === null || theme === void 0 ? void 0 : theme.styles
|
|
66
|
+
})
|
|
63
67
|
};
|
|
64
68
|
function handleOnChange(editorState, editor) {
|
|
65
69
|
editorState.read(function () {
|
|
66
70
|
if (typeof onChange === "function") {
|
|
67
71
|
var _editorState = editor.getEditorState();
|
|
72
|
+
//TODO: send plain JSON object
|
|
68
73
|
onChange(JSON.stringify(_editorState.toJSON()));
|
|
69
74
|
}
|
|
70
75
|
});
|
|
@@ -78,7 +83,7 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
78
83
|
onChange: handleOnChange
|
|
79
84
|
}), value && /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.LexicalUpdateStatePlugin, {
|
|
80
85
|
value: value
|
|
81
|
-
}), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null), onBlur && /*#__PURE__*/_react.default.createElement(_BlurEventPlugin.BlurEventPlugin, {
|
|
86
|
+
}), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null), /*#__PURE__*/_react.default.createElement(_FontColorPlugin.FontColorPlugin, null), onBlur && /*#__PURE__*/_react.default.createElement(_BlurEventPlugin.BlurEventPlugin, {
|
|
82
87
|
onBlur: onBlur
|
|
83
88
|
}), focus && /*#__PURE__*/_react.default.createElement(_LexicalAutoFocusPlugin.AutoFocusPlugin, null), children, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
|
|
84
89
|
contentEditable: /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["BaseRichTextEditor","toolbar","onChange","value","nodes","placeholder","children","onBlur","focus","width","height","theme","placeholderElem","scrollRef","useRef","useState","undefined","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","sizeStyle","initialConfig","editorState","isValidLexicalData","generateInitialLexicalValue","namespace","onError","error","WebinyNodes","webinyEditorTheme","styles","handleOnChange","editor","read","getEditorState","JSON","stringify","toJSON","outline","LexicalErrorBoundary","RichTextEditor","makeComposable","props"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\";\nimport { LexicalValue } from \"~/types\";\nimport { Placeholder } from \"~/ui/Placeholder\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { EditorState } from \"lexical/LexicalEditorState\";\nimport { Klass, LexicalEditor, LexicalNode } from \"lexical\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { OnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\nimport { AutoFocusPlugin } from \"@lexical/react/LexicalAutoFocusPlugin\";\nimport { ClearEditorPlugin } from \"@lexical/react/LexicalClearEditorPlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport LexicalErrorBoundary from \"@lexical/react/LexicalErrorBoundary\";\nimport { makeComposable } from \"@webiny/react-composition\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { LexicalUpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin\";\nimport { FontColorPlugin } from \"~/plugins/FontColorPlugin/FontColorPlugin\";\nimport { webinyEditorTheme, WebinyTheme } from \"~/themes/webinyLexicalTheme\";\nimport { WebinyNodes } from \"~/nodes/webinyNodes\";\n\nexport interface RichTextEditorProps {\n toolbar?: React.ReactNode;\n tag?: string;\n onChange?: (json: LexicalValue) => void;\n value: LexicalValue | null;\n focus?: boolean;\n placeholder?: string;\n nodes?: Klass<LexicalNode>[];\n /**\n * @description Lexical plugins\n */\n children?: React.ReactNode | React.ReactNode[];\n onBlur?: (editorState: LexicalValue) => void;\n height?: number | string;\n width?: number | string;\n /*\n * @description Theme to be injected into lexical editor\n */\n theme: WebinyTheme;\n}\n\nconst BaseRichTextEditor: React.FC<RichTextEditorProps> = ({\n toolbar,\n onChange,\n value,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n width,\n height,\n theme\n}: RichTextEditorProps) => {\n const placeholderElem = <Placeholder>{placeholder || \"Enter text...\"}</Placeholder>;\n const scrollRef = useRef(null);\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem);\n }\n };\n\n const sizeStyle = {\n height: height || \"\",\n width: width || \"\"\n };\n\n const initialConfig = {\n editorState: isValidLexicalData(value) ? value : generateInitialLexicalValue(),\n namespace: \"webiny\",\n onError: (error: Error) => {\n throw error;\n },\n nodes: [...WebinyNodes, ...(nodes || [])],\n theme: { ...webinyEditorTheme, styles: theme?.styles }\n };\n\n function handleOnChange(editorState: EditorState, editor: LexicalEditor) {\n editorState.read(() => {\n if (typeof onChange === \"function\") {\n const editorState = editor.getEditorState();\n //TODO: send plain JSON object\n onChange(JSON.stringify(editorState.toJSON()));\n }\n });\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig}>\n <div ref={scrollRef} style={{ ...sizeStyle }}>\n {/* data */}\n <OnChangePlugin onChange={handleOnChange} />\n {value && <LexicalUpdateStatePlugin value={value} />}\n <ClearEditorPlugin />\n <FontColorPlugin />\n {/* Events */}\n {onBlur && <BlurEventPlugin onBlur={onBlur} />}\n {focus && <AutoFocusPlugin />}\n {/* External plugins and components */}\n {children}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\" style={{ ...sizeStyle }}>\n <div className=\"editor\" ref={onRef} style={{ ...sizeStyle }}>\n <ContentEditable style={{ outline: 0, ...sizeStyle }} />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar */}\n {floatingAnchorElem && toolbar}\n </div>\n </LexicalComposer>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeComposable<RichTextEditorProps>(\"RichTextEditor\", props => {\n return (\n <RichTextEditorProvider>\n <BaseRichTextEditor {...props} />\n </RichTextEditorProvider>\n );\n});\n"],"mappings":";;;;;;;;;;;AAAA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAuBA,IAAMA,kBAAiD,GAAG,SAApDA,kBAAiD,OAY5B;EAAA,IAXvBC,OAAO,QAAPA,OAAO;IACPC,QAAQ,QAARA,QAAQ;IACRC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IACLC,WAAW,QAAXA,WAAW;IACXC,QAAQ,QAARA,QAAQ;IACRC,MAAM,QAANA,MAAM;IACNC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IACLC,MAAM,QAANA,MAAM;IACNC,KAAK,QAALA,KAAK;EAEL,IAAMC,eAAe,gBAAG,6BAAC,wBAAW,QAAEP,WAAW,IAAI,eAAe,CAAe;EACnF,IAAMQ,SAAS,GAAG,IAAAC,aAAM,EAAC,IAAI,CAAC;EAC9B,gBAAoD,IAAAC,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;IAAC,KAAK,EAAEA;EAAM,EAAG,eACpD,6BAAC,2CAAiB,OAAG,eACrB,6BAAC,gCAAe,OAAG,EAElBI,MAAM,iBAAI,6BAAC,gCAAe;IAAC,MAAM,EAAEA;EAAO,EAAG,EAC7CC,KAAK,iBAAI,6BAAC,uCAAe,OAAG,EAE5BF,QAAQ,eACT,6BAAC,qCAAc;IACX,eAAe,eACX;MAAK,SAAS,EAAC,iBAAiB;MAAC,KAAK,kCAAOe,SAAS;IAAG,gBACrD;MAAK,SAAS,EAAC,QAAQ;MAAC,GAAG,EAAEF,KAAM;MAAC,KAAK,kCAAOE,SAAS;IAAG,gBACxD,6BAAC,uCAAe;MAAC,KAAK;QAAIkB,OAAO,EAAE;MAAC,GAAKlB,SAAS;IAAG,EAAG,CACtD,CAEb;IACD,WAAW,EAAET,eAAgB;IAC7B,aAAa,EAAE4B;EAAqB,EACtC,EAEDvB,kBAAkB,IAAIhB,OAAO,CAC5B,CACQ;AAE1B,CAAC;;AAED;AACA;AACA;AACO,IAAMwC,cAAc,GAAG,IAAAC,gCAAc,EAAsB,gBAAgB,EAAE,UAAAC,KAAK,EAAI;EACzF,oBACI,6BAAC,6CAAsB,qBACnB,6BAAC,kBAAkB,EAAKA,KAAK,CAAI,CACZ;AAEjC,CAAC,CAAC;AAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FontColorAction } from "../ToolbarActions/FontColorAction";
|
|
3
|
+
interface LexicalEditorConfig extends React.FC<unknown> {
|
|
4
|
+
FontColorAction: typeof FontColorAction;
|
|
5
|
+
}
|
|
6
|
+
export declare const LexicalEditorConfig: LexicalEditorConfig;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.LexicalEditorConfig = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _FontColorAction = require("../ToolbarActions/FontColorAction");
|
|
10
|
+
var LexicalEditorConfig = function LexicalEditorConfig(_ref) {
|
|
11
|
+
var children = _ref.children;
|
|
12
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
13
|
+
};
|
|
14
|
+
exports.LexicalEditorConfig = LexicalEditorConfig;
|
|
15
|
+
LexicalEditorConfig.FontColorAction = _FontColorAction.FontColorAction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LexicalEditorConfig","children","FontColorAction"],"sources":["LexicalEditorConfig.tsx"],"sourcesContent":["import React from \"react\";\nimport { FontColorAction } from \"~/components/ToolbarActions/FontColorAction\";\n\ninterface LexicalEditorConfig extends React.FC<unknown> {\n FontColorAction: typeof FontColorAction;\n}\n\nexport const LexicalEditorConfig: LexicalEditorConfig = ({ children }) => {\n return <>{children}</>;\n};\n\nLexicalEditorConfig.FontColorAction = FontColorAction;\n"],"mappings":";;;;;;;AAAA;AACA;AAMO,IAAMA,mBAAwC,GAAG,SAA3CA,mBAAwC,OAAqB;EAAA,IAAfC,QAAQ,QAARA,QAAQ;EAC/D,oBAAO,4DAAGA,QAAQ,CAAI;AAC1B,CAAC;AAAC;AAEFD,mBAAmB,CAACE,eAAe,GAAGA,gCAAe"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { LexicalValue } from "../types";
|
|
3
3
|
import { Klass, LexicalNode } from "lexical";
|
|
4
|
+
import { WebinyTheme } from "../themes/webinyLexicalTheme";
|
|
4
5
|
interface LexicalHtmlRendererProps {
|
|
5
6
|
nodes?: Klass<LexicalNode>[];
|
|
6
7
|
value: LexicalValue | null;
|
|
8
|
+
theme: WebinyTheme;
|
|
7
9
|
}
|
|
8
10
|
export declare const LexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps>;
|
|
9
11
|
export {};
|
|
@@ -5,20 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.LexicalHtmlRenderer = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
8
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
10
|
var _react = _interopRequireDefault(require("react"));
|
|
10
11
|
var _isValidLexicalData = require("../utils/isValidLexicalData");
|
|
11
12
|
var _generateInitialLexicalValue = require("../utils/generateInitialLexicalValue");
|
|
12
|
-
var _webinyNodes = require("../nodes/webinyNodes");
|
|
13
|
-
var _webinyLexicalTheme = require("../themes/webinyLexicalTheme");
|
|
14
13
|
var _LexicalComposer = require("@lexical/react/LexicalComposer");
|
|
15
14
|
var _LexicalRichTextPlugin = require("@lexical/react/LexicalRichTextPlugin");
|
|
16
15
|
var _LexicalContentEditable = require("@lexical/react/LexicalContentEditable");
|
|
17
16
|
var _LexicalErrorBoundary = _interopRequireDefault(require("@lexical/react/LexicalErrorBoundary"));
|
|
18
17
|
var _LexicalUpdateStatePlugin = require("../plugins/LexicalUpdateStatePlugin");
|
|
18
|
+
var _webinyNodes = require("../nodes/webinyNodes");
|
|
19
|
+
var _webinyLexicalTheme = require("../themes/webinyLexicalTheme");
|
|
19
20
|
var LexicalHtmlRenderer = function LexicalHtmlRenderer(_ref) {
|
|
20
21
|
var nodes = _ref.nodes,
|
|
21
|
-
value = _ref.value
|
|
22
|
+
value = _ref.value,
|
|
23
|
+
theme = _ref.theme;
|
|
22
24
|
var initialConfig = {
|
|
23
25
|
editorState: (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)(),
|
|
24
26
|
namespace: "webiny",
|
|
@@ -27,7 +29,9 @@ var LexicalHtmlRenderer = function LexicalHtmlRenderer(_ref) {
|
|
|
27
29
|
},
|
|
28
30
|
editable: false,
|
|
29
31
|
nodes: [].concat((0, _toConsumableArray2.default)(_webinyNodes.WebinyNodes), (0, _toConsumableArray2.default)(nodes || [])),
|
|
30
|
-
theme: _webinyLexicalTheme.
|
|
32
|
+
theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _webinyLexicalTheme.webinyEditorTheme), {}, {
|
|
33
|
+
styles: theme.styles
|
|
34
|
+
})
|
|
31
35
|
};
|
|
32
36
|
return /*#__PURE__*/_react.default.createElement(_LexicalComposer.LexicalComposer, {
|
|
33
37
|
initialConfig: initialConfig
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["LexicalHtmlRenderer","nodes","value","theme","initialConfig","editorState","isValidLexicalData","generateInitialLexicalValue","namespace","onError","error","editable","WebinyNodes","webinyEditorTheme","styles","LexicalErrorBoundary"],"sources":["LexicalHtmlRenderer.tsx"],"sourcesContent":["import React from \"react\";\nimport { LexicalValue } from \"~/types\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport LexicalErrorBoundary from \"@lexical/react/LexicalErrorBoundary\";\nimport { LexicalUpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { Klass, LexicalNode } from \"lexical\";\nimport { WebinyNodes } from \"~/nodes/webinyNodes\";\nimport { webinyEditorTheme, WebinyTheme } from \"~/themes/webinyLexicalTheme\";\n\ninterface LexicalHtmlRendererProps {\n nodes?: Klass<LexicalNode>[];\n value: LexicalValue | null;\n /*\n * @description Theme to be injected into lexical editor\n */\n theme: WebinyTheme;\n}\n\nexport const LexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps> = ({\n nodes,\n value,\n theme\n}) => {\n const initialConfig = {\n editorState: isValidLexicalData(value) ? value : generateInitialLexicalValue(),\n namespace: \"webiny\",\n onError: (error: Error) => {\n throw error;\n },\n editable: false,\n nodes: [...WebinyNodes, ...(nodes || [])],\n theme: { ...webinyEditorTheme, styles: theme.styles }\n };\n\n return (\n <LexicalComposer initialConfig={initialConfig}>\n <RichTextPlugin\n contentEditable={\n <div className=\"editor\">\n <ContentEditable />\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={null}\n />\n <LexicalUpdateStatePlugin value={value} />\n </LexicalComposer>\n );\n};\n"],"mappings":";;;;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAWO,IAAMA,mBAAuD,GAAG,SAA1DA,mBAAuD,OAI9D;EAAA,IAHFC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;EAEL,IAAMC,aAAa,GAAG;IAClBC,WAAW,EAAE,IAAAC,sCAAkB,EAACJ,KAAK,CAAC,GAAGA,KAAK,GAAG,IAAAK,wDAA2B,GAAE;IAC9EC,SAAS,EAAE,QAAQ;IACnBC,OAAO,EAAE,iBAACC,KAAY,EAAK;MACvB,MAAMA,KAAK;IACf,CAAC;IACDC,QAAQ,EAAE,KAAK;IACfV,KAAK,6CAAMW,wBAAW,oCAAMX,KAAK,IAAI,EAAE,EAAE;IACzCE,KAAK,8DAAOU,qCAAiB;MAAEC,MAAM,EAAEX,KAAK,CAACW;IAAM;EACvD,CAAC;EAED,oBACI,6BAAC,gCAAe;IAAC,aAAa,EAAEV;EAAc,gBAC1C,6BAAC,qCAAc;IACX,eAAe,eACX;MAAK,SAAS,EAAC;IAAQ,gBACnB,6BAAC,uCAAe,OAAG,CAE1B;IACD,aAAa,EAAEW,6BAAqB;IACpC,WAAW,EAAE;EAAK,EACpB,eACF,6BAAC,kDAAwB;IAAC,KAAK,EAAEb;EAAM,EAAG,CAC5B;AAE1B,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["HeadingToolbar","anchorElem","document","body"],"sources":["HeadingToolbar.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\n\ninterface HeadingToolbarProps {\n anchorElem?: HTMLElement;\n}\n\n/**\n * Toolbar with actions specific for the heading elements from H1-H6.\n * @param anchorElem\n * @constructor\n */\nexport const HeadingToolbar: FC<HeadingToolbarProps> = ({ anchorElem = document.body }) => {\n return <Toolbar type={\"heading\"} anchorElem={anchorElem} />;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACO,IAAMA,cAAuC,GAAG,SAA1CA,cAAuC,OAAuC;EAAA,2BAAjCC,UAAU;IAAVA,UAAU,gCAAGC,QAAQ,CAACC,IAAI;EAChF,oBAAO,6BAAC,gBAAO;IAAC,IAAI,EAAE,SAAU;IAAC,UAAU,EAAEF;EAAW,EAAG;AAC/D,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ParagraphToolbar","anchorElem","document","body"],"sources":["ParagraphToolbar.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\n\ninterface ParagraphToolbarProps {\n anchorElem?: HTMLElement;\n}\n\n/**\n * Toolbar with actions for rich text editing specific for the paragraph element <p>.\n * @param anchorElem\n * @constructor\n */\nexport const ParagraphToolbar: FC<ParagraphToolbarProps> = ({ anchorElem = document.body }) => {\n return <Toolbar type={\"paragraph\"} anchorElem={anchorElem} />;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACO,IAAMA,gBAA2C,GAAG,SAA9CA,gBAA2C,OAAuC;EAAA,2BAAjCC,UAAU;IAAVA,UAAU,gCAAGC,QAAQ,CAACC,IAAI;EACpF,oBAAO,6BAAC,gBAAO;IAAC,IAAI,EAAE,WAAY;IAAC,UAAU,EAAEF;EAAW,EAAG;AACjE,CAAC;AAAC"}
|
|
@@ -194,6 +194,9 @@ i.chevron-down {
|
|
|
194
194
|
background-color: rgb(223, 232, 250);
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
i.font-color, .icon.font-color {
|
|
198
|
+
background-image: url("../../images/icons/font-color.svg");
|
|
199
|
+
}
|
|
197
200
|
|
|
198
201
|
.floating-text-format-popup button.toolbar-item {
|
|
199
202
|
border: 0;
|
|
@@ -320,6 +323,12 @@ i.chevron-down {
|
|
|
320
323
|
overflow-y: auto;
|
|
321
324
|
}
|
|
322
325
|
|
|
326
|
+
.lexical-dropdown.no-scroll {
|
|
327
|
+
max-height: inherit;
|
|
328
|
+
overflow: auto;
|
|
329
|
+
overflow-y: auto;
|
|
330
|
+
}
|
|
331
|
+
|
|
323
332
|
.lexical-dropdown .item {
|
|
324
333
|
margin: 0 8px 0 8px;
|
|
325
334
|
padding: 8px;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_lexical","_reactComposition","_link","_reactDom","_utils","_code","_LexicalComposerContext","_getDOMRangeRect","_setFloatingElemPosition","_getSelectedNode","_useRichTextEditor2","FloatingToolbar","_ref","children","anchorElem","editor","popupCharStylesEditorRef","useRef","updateTextFormatFloatingToolbar","useCallback","selection","$getSelection","popupCharStylesEditorElem","current","nativeSelection","window","getSelection","isLink","$isRangeSelection","node","getSelectedNode","parent","getParent","$isLinkNode","rootElement","getRootElement","isCollapsed","contains","anchorNode","rangeRect","getDOMRangeRect","setFloatingElemPosition","useEffect","scrollerElem","parentElement","update","getEditorState","read","addEventListener","removeEventListener","mergeRegister","registerUpdateListener","_ref2","editorState","registerCommand","SELECTION_CHANGE_COMMAND","COMMAND_PRIORITY_LOW","default","createElement","ref","className","isEditable","useToolbar","_ref3","_ref3$anchorElem","document","body","type","_useRichTextEditor","useRichTextEditor","nodeIsText","setNodeIsText","updatePopup","isComposing","$isCodeHighlightNode","anchor","getNode","getTextContent","$isTextNode","registerRootListener","createPortal","Toolbar","makeComposable","_ref4","_useLexicalComposerCo","useLexicalComposerContext","_useLexicalComposerCo2","_slicedToArray2","exports"],"sources":["Toolbar.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useRef } from \"react\";\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n LexicalEditor,\n SELECTION_CHANGE_COMMAND\n} from \"lexical\";\nimport { makeComposable } from \"@webiny/react-composition\";\nimport { $isLinkNode } from \"@lexical/link\";\nimport { createPortal } from \"react-dom\";\nimport { mergeRegister } from \"@lexical/utils\";\nimport { $isCodeHighlightNode } from \"@lexical/code\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport \"./Toolbar.css\";\nimport { ToolbarType } from \"~/types\";\nimport { getDOMRangeRect } from \"~/utils/getDOMRangeRect\";\nimport { setFloatingElemPosition } from \"~/utils/setFloatingElemPosition\";\nimport { getSelectedNode } from \"~/utils/getSelectedNode\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\n\ninterface FloatingToolbarProps {\n type: ToolbarType;\n anchorElem: HTMLElement;\n children?: React.ReactNode;\n editor: LexicalEditor;\n}\n\nconst FloatingToolbar: FC<FloatingToolbarProps> = ({ children, anchorElem, editor }) => {\n const popupCharStylesEditorRef = useRef<HTMLDivElement | null>(null);\n\n const updateTextFormatFloatingToolbar = useCallback(() => {\n const selection = $getSelection();\n\n const popupCharStylesEditorElem = popupCharStylesEditorRef.current;\n const nativeSelection = window.getSelection();\n\n if (popupCharStylesEditorElem === null) {\n return;\n }\n\n let isLink = false;\n if ($isRangeSelection(selection)) {\n const node = getSelectedNode(selection);\n // Update links\n const parent = node.getParent();\n\n if ($isLinkNode(parent) || $isLinkNode(node)) {\n isLink = true;\n }\n }\n\n const rootElement = editor.getRootElement();\n if (\n selection !== null &&\n nativeSelection !== null &&\n !nativeSelection.isCollapsed &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode) &&\n !isLink\n ) {\n const rangeRect = getDOMRangeRect(nativeSelection, rootElement);\n setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElem);\n }\n }, [editor, anchorElem]);\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement;\n\n const update = () => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar();\n });\n };\n\n window.addEventListener(\"resize\", update);\n if (scrollerElem) {\n scrollerElem.addEventListener(\"scroll\", update);\n }\n\n return () => {\n window.removeEventListener(\"resize\", update);\n if (scrollerElem) {\n scrollerElem.removeEventListener(\"scroll\", update);\n }\n };\n }, [editor, updateTextFormatFloatingToolbar, anchorElem]);\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar();\n });\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateTextFormatFloatingToolbar();\n });\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n updateTextFormatFloatingToolbar();\n return false;\n },\n COMMAND_PRIORITY_LOW\n )\n );\n }, [editor, updateTextFormatFloatingToolbar]);\n\n return (\n <div ref={popupCharStylesEditorRef} className=\"floating-text-format-popup\">\n {editor.isEditable() && children}\n </div>\n );\n};\n\ninterface useToolbarProps {\n editor: LexicalEditor;\n type: ToolbarType;\n anchorElem: HTMLElement;\n children?: React.ReactNode;\n}\n\nconst useToolbar: FC<useToolbarProps> = ({\n editor,\n anchorElem = document.body,\n type,\n children\n}): JSX.Element | null => {\n const { nodeIsText, setNodeIsText } = useRichTextEditor();\n\n const updatePopup = useCallback(() => {\n editor.getEditorState().read(() => {\n // Should not to pop up the floating toolbar when using IME input\n if (editor.isComposing()) {\n return;\n }\n const selection = $getSelection();\n const nativeSelection = window.getSelection();\n const rootElement = editor.getRootElement();\n\n if (\n nativeSelection !== null &&\n (!$isRangeSelection(selection) ||\n rootElement === null ||\n !rootElement.contains(nativeSelection.anchorNode))\n ) {\n setNodeIsText(false);\n return;\n }\n\n if (!$isRangeSelection(selection)) {\n return;\n }\n\n const node = getSelectedNode(selection);\n\n if (\n !$isCodeHighlightNode(selection.anchor.getNode()) &&\n selection.getTextContent() !== \"\"\n ) {\n setNodeIsText($isTextNode(node));\n } else {\n setNodeIsText(false);\n }\n });\n }, [editor]);\n\n useEffect(() => {\n document.addEventListener(\"selectionchange\", updatePopup);\n return () => {\n document.removeEventListener(\"selectionchange\", updatePopup);\n };\n }, [updatePopup]);\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updatePopup();\n }),\n editor.registerRootListener(() => {\n if (editor.getRootElement() === null) {\n setNodeIsText(false);\n }\n })\n );\n }, [editor, updatePopup]);\n\n if (!nodeIsText) {\n return null;\n }\n\n return createPortal(\n <FloatingToolbar type={type} anchorElem={anchorElem} editor={editor}>\n {children}\n </FloatingToolbar>,\n anchorElem\n );\n};\n\nexport interface ToolbarProps {\n type: ToolbarType;\n anchorElem: HTMLElement;\n children?: React.ReactNode;\n}\n\n/**\n * @description Main toolbar container\n */\nexport const Toolbar = makeComposable<ToolbarProps>(\n \"Toolbar\",\n ({ anchorElem, type, children }): JSX.Element | null => {\n const [editor] = useLexicalComposerContext();\n return useToolbar({ editor, anchorElem, type, children });\n }\n);\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAQA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,uBAAA,GAAAP,OAAA;AACAA,OAAA;AAEA,IAAAQ,gBAAA,GAAAR,OAAA;AACA,IAAAS,wBAAA,GAAAT,OAAA;AACA,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U,EAAEA,UAAW;IAACC,MAAM,EAAEA;EAAO,GAC/DF,QAAQ,CACK,EAClBC,UAAU,CACb;AACL,CAAC;AAQD;AACA;AACA;AACO,IAAMmE,OAAO,GAAG,IAAAC,gCAAc,EACjC,SAAS,EACT,UAAAC,KAAA,EAAwD;EAAA,IAArDrE,UAAU,GAAAqE,KAAA,CAAVrE,UAAU;IAAEqD,IAAI,GAAAgB,KAAA,CAAJhB,IAAI;IAAEtD,QAAQ,GAAAsE,KAAA,CAARtE,QAAQ;EACzB,IAAAuE,qBAAA,GAAiB,IAAAC,iDAAyB,GAAE;IAAAC,sBAAA,OAAAC,eAAA,CAAA9B,OAAA,EAAA2B,qBAAA;IAArCrE,MAAM,GAAAuE,sBAAA;EACb,OAAOxB,UAAU,CAAC;IAAE/C,MAAM,EAANA,MAAM;IAAED,UAAU,EAAVA,UAAU;IAAEqD,IAAI,EAAJA,IAAI;IAAEtD,QAAQ,EAARA;EAAS,CAAC,CAAC;AAC7D,CAAC,CACJ;AAAC2E,OAAA,CAAAP,OAAA,GAAAA,OAAA"}
|
|
1
|
+
{"version":3,"names":["FloatingToolbar","children","anchorElem","editor","popupCharStylesEditorRef","useRef","updateTextFormatFloatingToolbar","useCallback","selection","$getSelection","popupCharStylesEditorElem","current","nativeSelection","window","getSelection","isLink","$isRangeSelection","node","getSelectedNode","parent","getParent","$isLinkNode","rootElement","getRootElement","isCollapsed","contains","anchorNode","rangeRect","getDOMRangeRect","setFloatingElemPosition","useEffect","scrollerElem","parentElement","update","getEditorState","read","addEventListener","removeEventListener","mergeRegister","registerUpdateListener","editorState","registerCommand","SELECTION_CHANGE_COMMAND","COMMAND_PRIORITY_LOW","isEditable","useToolbar","document","body","type","useRichTextEditor","nodeIsText","setNodeIsText","updatePopup","isComposing","$isCodeHighlightNode","anchor","getNode","getTextContent","$isTextNode","registerRootListener","createPortal","Toolbar","makeComposable","useLexicalComposerContext"],"sources":["Toolbar.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useRef } from \"react\";\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n LexicalEditor,\n SELECTION_CHANGE_COMMAND\n} from \"lexical\";\nimport { makeComposable } from \"@webiny/react-composition\";\nimport { $isLinkNode } from \"@lexical/link\";\nimport { createPortal } from \"react-dom\";\nimport { mergeRegister } from \"@lexical/utils\";\nimport { $isCodeHighlightNode } from \"@lexical/code\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport \"./Toolbar.css\";\nimport { ToolbarType } from \"~/types\";\nimport { getDOMRangeRect } from \"~/utils/getDOMRangeRect\";\nimport { setFloatingElemPosition } from \"~/utils/setFloatingElemPosition\";\nimport { getSelectedNode } from \"~/utils/getSelectedNode\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\n\ninterface FloatingToolbarProps {\n type: ToolbarType;\n anchorElem: HTMLElement;\n children?: React.ReactNode;\n editor: LexicalEditor;\n}\n\nconst FloatingToolbar: FC<FloatingToolbarProps> = ({ children, anchorElem, editor }) => {\n const popupCharStylesEditorRef = useRef<HTMLDivElement | null>(null);\n\n const updateTextFormatFloatingToolbar = useCallback(() => {\n const selection = $getSelection();\n\n const popupCharStylesEditorElem = popupCharStylesEditorRef.current;\n const nativeSelection = window.getSelection();\n\n if (popupCharStylesEditorElem === null) {\n return;\n }\n\n let isLink = false;\n if ($isRangeSelection(selection)) {\n const node = getSelectedNode(selection);\n // Update links\n const parent = node.getParent();\n\n if ($isLinkNode(parent) || $isLinkNode(node)) {\n isLink = true;\n }\n }\n\n const rootElement = editor.getRootElement();\n if (\n selection !== null &&\n nativeSelection !== null &&\n !nativeSelection.isCollapsed &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode) &&\n !isLink\n ) {\n const rangeRect = getDOMRangeRect(nativeSelection, rootElement);\n setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElem);\n }\n }, [editor, anchorElem]);\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement;\n\n const update = () => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar();\n });\n };\n\n window.addEventListener(\"resize\", update);\n if (scrollerElem) {\n scrollerElem.addEventListener(\"scroll\", update);\n }\n\n return () => {\n window.removeEventListener(\"resize\", update);\n if (scrollerElem) {\n scrollerElem.removeEventListener(\"scroll\", update);\n }\n };\n }, [editor, updateTextFormatFloatingToolbar, anchorElem]);\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar();\n });\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateTextFormatFloatingToolbar();\n });\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n updateTextFormatFloatingToolbar();\n return false;\n },\n COMMAND_PRIORITY_LOW\n )\n );\n }, [editor, updateTextFormatFloatingToolbar]);\n\n return (\n <div ref={popupCharStylesEditorRef} className=\"floating-text-format-popup\">\n {editor.isEditable() && children}\n </div>\n );\n};\n\ninterface useToolbarProps {\n editor: LexicalEditor;\n type: ToolbarType;\n anchorElem: HTMLElement;\n children?: React.ReactNode;\n}\n\nconst useToolbar: FC<useToolbarProps> = ({\n editor,\n anchorElem = document.body,\n type,\n children\n}): JSX.Element | null => {\n const { nodeIsText, setNodeIsText } = useRichTextEditor();\n\n const updatePopup = useCallback(() => {\n editor.getEditorState().read(() => {\n // Should not to pop up the floating toolbar when using IME input\n if (editor.isComposing()) {\n return;\n }\n const selection = $getSelection();\n const nativeSelection = window.getSelection();\n const rootElement = editor.getRootElement();\n\n if (\n nativeSelection !== null &&\n (!$isRangeSelection(selection) ||\n rootElement === null ||\n !rootElement.contains(nativeSelection.anchorNode))\n ) {\n setNodeIsText(false);\n return;\n }\n\n if (!$isRangeSelection(selection)) {\n return;\n }\n\n const node = getSelectedNode(selection);\n\n if (\n !$isCodeHighlightNode(selection.anchor.getNode()) &&\n selection.getTextContent() !== \"\"\n ) {\n setNodeIsText($isTextNode(node));\n } else {\n setNodeIsText(false);\n }\n });\n }, [editor]);\n\n useEffect(() => {\n document.addEventListener(\"selectionchange\", updatePopup);\n return () => {\n document.removeEventListener(\"selectionchange\", updatePopup);\n };\n }, [updatePopup]);\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updatePopup();\n }),\n editor.registerRootListener(() => {\n if (editor.getRootElement() === null) {\n setNodeIsText(false);\n }\n })\n );\n }, [editor, updatePopup]);\n\n if (!nodeIsText) {\n return null;\n }\n\n return createPortal(\n <FloatingToolbar type={type} anchorElem={anchorElem} editor={editor}>\n {children}\n </FloatingToolbar>,\n anchorElem\n );\n};\n\nexport interface ToolbarProps {\n type: ToolbarType;\n anchorElem: HTMLElement;\n children?: React.ReactNode;\n}\n\n/**\n * @description Main toolbar container\n */\nexport const Toolbar = makeComposable<ToolbarProps>(\n \"Toolbar\",\n ({ anchorElem, type, children }): JSX.Element | null => {\n const [editor] = useLexicalComposerContext();\n return useToolbar({ editor, anchorElem, type, children });\n }\n);\n"],"mappings":";;;;;;;;;AAAA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AASA,IAAMA,eAAyC,GAAG,SAA5CA,eAAyC,OAAyC;EAAA,IAAnCC,QAAQ,QAARA,QAAQ;IAAEC,UAAU,QAAVA,UAAU;IAAEC,MAAM,QAANA,MAAM;EAC7E,IAAMC,wBAAwB,GAAG,IAAAC,aAAM,EAAwB,IAAI,CAAC;EAEpE,IAAMC,+BAA+B,GAAG,IAAAC,kBAAW,EAAC,YAAM;IACtD,IAAMC,SAAS,GAAG,IAAAC,sBAAa,GAAE;IAEjC,IAAMC,yBAAyB,GAAGN,wBAAwB,CAACO,OAAO;IAClE,IAAMC,eAAe,GAAGC,MAAM,CAACC,YAAY,EAAE;IAE7C,IAAIJ,yBAAyB,KAAK,IAAI,EAAE;MACpC;IACJ;IAEA,IAAIK,MAAM,GAAG,KAAK;IAClB,IAAI,IAAAC,0BAAiB,E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wD,oBAAoB,CAAC,YAAM;MAC9B,IAAIxD,MAAM,CAACoB,cAAc,EAAE,KAAK,IAAI,EAAE;QAClC4B,aAAa,CAAC,KAAK,CAAC;MACxB;IACJ,CAAC,CAAC,CACL;EACL,CAAC,EAAE,CAAChD,MAAM,EAAEiD,WAAW,CAAC,CAAC;EAEzB,IAAI,CAACF,UAAU,EAAE;IACb,OAAO,IAAI;EACf;EAEA,oBAAO,IAAAU,sBAAY,gBACf,6BAAC,eAAe;IAAC,IAAI,EAAEZ,IAAK;IAAC,UAAU,EAAE9C,UAAW;IAAC,MAAM,EAAEC;EAAO,GAC/DF,QAAQ,CACK,EAClBC,UAAU,CACb;AACL,CAAC;AAQD;AACA;AACA;AACO,IAAM2D,OAAO,GAAG,IAAAC,gCAAc,EACjC,SAAS,EACT,iBAAwD;EAAA,IAArD5D,UAAU,SAAVA,UAAU;IAAE8C,IAAI,SAAJA,IAAI;IAAE/C,QAAQ,SAARA,QAAQ;EACzB,4BAAiB,IAAA8D,iDAAyB,GAAE;IAAA;IAArC5D,MAAM;EACb,OAAO0C,UAAU,CAAC;IAAE1C,MAAM,EAANA,MAAM;IAAED,UAAU,EAAVA,UAAU;IAAE8C,IAAI,EAAJA,IAAI;IAAE/C,QAAQ,EAARA;EAAS,CAAC,CAAC;AAC7D,CAAC,CACJ;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["BoldAction","useLexicalComposerContext","editor","useState","isBold","setIsBold","handleClick","dispatchCommand","FORMAT_TEXT_COMMAND"],"sources":["BoldAction.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { FORMAT_TEXT_COMMAND } from \"lexical\";\n\n/**\n * Toolbar action. On toolbar, you can see as button that is bold.\n */\nexport const BoldAction = () => {\n const [editor] = useLexicalComposerContext();\n const [isBold, setIsBold] = useState(false);\n const handleClick = () => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, \"bold\");\n setIsBold(!isBold);\n };\n\n return (\n <button\n onClick={() => handleClick()}\n className={\"popup-item spaced \" + (isBold ? \"active\" : \"\")}\n aria-label=\"Format text as bold\"\n >\n <i className=\"format bold\" />\n </button>\n );\n};\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACO,IAAMA,UAAU,GAAG,SAAbA,UAAU,GAAS;EAC5B,4BAAiB,IAAAC,iDAAyB,GAAE;IAAA;IAArCC,MAAM;EACb,gBAA4B,IAAAC,eAAQ,EAAC,KAAK,CAAC;IAAA;IAApCC,MAAM;IAAEC,SAAS;EACxB,IAAMC,WAAW,GAAG,SAAdA,WAAW,GAAS;IACtBJ,MAAM,CAACK,eAAe,CAACC,4BAAmB,EAAE,MAAM,CAAC;IACnDH,SAAS,CAAC,CAACD,MAAM,CAAC;EACtB,CAAC;EAED,oBACI;IACI,OAAO,EAAE;MAAA,OAAME,WAAW,EAAE;IAAA,CAAC;IAC7B,SAAS,EAAE,oBAAoB,IAAIF,MAAM,GAAG,QAAQ,GAAG,EAAE,CAAE;IAC3D,cAAW;EAAqB,gBAEhC;IAAG,SAAS,EAAC;EAAa,EAAG,CACxB;AAEjB,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["BulletListAction","useLexicalComposerContext","editor","useState","activeEditor","setActiveEditor","isActive","setIsActive","updateToolbar","useCallback","selection","$getSelection","$isRangeSelection","anchorNode","anchor","getNode","element","getKey","$findMatchingParent","e","parent","getParent","$isRootOrShadowRoot","getTopLevelElementOrThrow","$isListNode","parentList","$getNearestNodeOfType","ListNode","type","getListType","useEffect","mergeRegister","registerUpdateListener","editorState","read","registerCommand","SELECTION_CHANGE_COMMAND","_payload","newEditor","COMMAND_PRIORITY_CRITICAL","formatBulletList","dispatchCommand","INSERT_UNORDERED_LIST_COMMAND","undefined","REMOVE_LIST_COMMAND"],"sources":["BulletListAction.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport {\n $isListNode,\n INSERT_UNORDERED_LIST_COMMAND,\n ListNode,\n REMOVE_LIST_COMMAND\n} from \"@lexical/list\";\nimport {\n $getSelection,\n $isRangeSelection,\n $isRootOrShadowRoot,\n COMMAND_PRIORITY_CRITICAL,\n SELECTION_CHANGE_COMMAND\n} from \"lexical\";\nimport { $findMatchingParent, $getNearestNodeOfType, mergeRegister } from \"@lexical/utils\";\n\n/**\n * Toolbar button action. On click will wrap the content in bullet list style.\n */\nexport const BulletListAction = () => {\n const [editor] = useLexicalComposerContext();\n const [activeEditor, setActiveEditor] = useState(editor);\n const [isActive, setIsActive] = useState<boolean>(false);\n\n const updateToolbar = useCallback(() => {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n const anchorNode = selection.anchor.getNode();\n let 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 if (element === null) {\n element = anchorNode.getTopLevelElementOrThrow();\n }\n\n if ($isListNode(element)) {\n const parentList = $getNearestNodeOfType<ListNode>(anchorNode, ListNode);\n // get the type of the list that is selected with the cursor\n const type = parentList ? parentList.getListType() : element.getListType();\n // set the button as active for numbered list\n if (type === \"bullet\") {\n setIsActive(true);\n } else {\n setIsActive(false);\n }\n }\n }\n }, [activeEditor]);\n\n useEffect(() => {\n return mergeRegister(\n activeEditor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateToolbar();\n });\n })\n );\n }, [activeEditor, editor, updateToolbar]);\n\n useEffect(() => {\n return editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n (_payload, newEditor) => {\n updateToolbar();\n setActiveEditor(newEditor);\n return false;\n },\n COMMAND_PRIORITY_CRITICAL\n );\n }, [editor, updateToolbar]);\n\n const formatBulletList = () => {\n if (!isActive) {\n // will update the active state in the useEffect\n editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);\n } else {\n editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);\n // removing will not update correctly the active state, so we need to set to false manually.\n setIsActive(false);\n }\n };\n\n return (\n <button\n onClick={() => formatBulletList()}\n className={\"popup-item spaced \" + (isActive ? \"active\" : \"\")}\n aria-label=\"Format text as bullet list\"\n >\n <i className=\"icon bullet-list\" />\n </button>\n );\n};\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AAMA;AAOA;AAEA;AACA;AACA;AACO,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgB,GAAS;EAClC,4BAAiB,IAAAC,iDAAyB,GAAE;IAAA;IAArCC,MAAM;EACb,gBAAwC,IAAAC,eAAQ,EAACD,MAAM,CAAC;IAAA;IAAjDE,YAAY;IAAEC,eAAe;EACpC,iBAAgC,IAAAF,eAAQ,EAAU,KAAK,CAAC;IAAA;IAAjDG,QAAQ;IAAEC,WAAW;EAE5B,IAAMC,aAAa,GAAG,IAAAC,kBAAW,EAAC,YAAM;IACpC,IAAMC,SAAS,GAAG,IAAAC,sBAAa,GAAE;IACjC,IAAI,IAAAC,0BAAiB,EAACF,SAAS,CAAC,EAAE;MAC9B,IAAMG,UAAU,GAAGH,SAAS,CAACI,MAAM,CAACC,OAAO,EAAE;MAC7C,IAAIC,OAAO,GACPH,UAAU,CAACI,MAAM,EAAE,KAAK,MAAM,GACxBJ,UAAU,GACV,IAAAK,0BAAmB,EAACL,UAAU,EAAE,UAAAM,CAAC,EAAI;QACjC,IAAMC,MAAM,GAAGD,CAAC,CAACE,SAAS,EAAE;QAC5B,OAAOD,MAAM,KAAK,IAAI,IAAI,IAAAE,4BAAmB,EAACF,MAAM,CAAC;MACzD,CAAC,CAAC;MAEZ,IAAIJ,OAAO,KAAK,IAAI,EAAE;QAClBA,OAAO,GAAGH,UAAU,CAACU,yBAAyB,EAAE;MACpD;MAEA,IAAI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W,CAAC,KAAK,CAAC;IACtB;EACJ,CAAC;EAED,oBACI;IACI,OAAO,EAAE;MAAA,OAAMiC,gBAAgB,EAAE;IAAA,CAAC;IAClC,SAAS,EAAE,oBAAoB,IAAIlC,QAAQ,GAAG,QAAQ,GAAG,EAAE,CAAE;IAC7D,cAAW;EAA4B,gBAEvC;IAAG,SAAS,EAAC;EAAkB,EAAG,CAC7B;AAEjB,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["CodeHighlightAction","useLexicalComposerContext","editor","useState","isCode","setIsCode","handleClick","dispatchCommand","FORMAT_TEXT_COMMAND"],"sources":["CodeHighlightAction.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { FORMAT_TEXT_COMMAND } from \"lexical\";\n\n/**\n * Toolbar action. User can highlight the selected text.\n * - Gray background will be visible on selected text after clicking on the button.\n */\nexport const CodeHighlightAction = () => {\n const [editor] = useLexicalComposerContext();\n const [isCode, setIsCode] = useState(false);\n const handleClick = () => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, \"code\");\n setIsCode(!isCode);\n };\n\n return (\n <button\n onClick={() => handleClick()}\n className={\"popup-item spaced \" + (isCode ? \"active\" : \"\")}\n aria-label=\"Text code highlight\"\n >\n <i className=\"format code\" />\n </button>\n );\n};\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACO,IAAMA,mBAAmB,GAAG,SAAtBA,mBAAmB,GAAS;EACrC,4BAAiB,IAAAC,iDAAyB,GAAE;IAAA;IAArCC,MAAM;EACb,gBAA4B,IAAAC,eAAQ,EAAC,KAAK,CAAC;IAAA;IAApCC,MAAM;IAAEC,SAAS;EACxB,IAAMC,WAAW,GAAG,SAAdA,WAAW,GAAS;IACtBJ,MAAM,CAACK,eAAe,CAACC,4BAAmB,EAAE,MAAM,CAAC;IACnDH,SAAS,CAAC,CAACD,MAAM,CAAC;EACtB,CAAC;EAED,oBACI;IACI,OAAO,EAAE;MAAA,OAAME,WAAW,EAAE;IAAA,CAAC;IAC7B,SAAS,EAAE,oBAAoB,IAAIF,MAAM,GAAG,QAAQ,GAAG,EAAE,CAAE;IAC3D,cAAW;EAAqB,gBAEhC;IAAG,SAAS,EAAC;EAAa,EAAG,CACxB;AAEjB,CAAC;AAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const FontColorPicker: import("@webiny/react-composition").ComposableFC<unknown>;
|
|
3
|
+
interface FontActionColorPicker {
|
|
4
|
+
element: JSX.Element;
|
|
5
|
+
}
|
|
6
|
+
declare const FontActionColorPicker: React.FC<FontActionColorPicker>;
|
|
7
|
+
export interface FontColorAction extends React.FC<unknown> {
|
|
8
|
+
ColorPicker: typeof FontActionColorPicker;
|
|
9
|
+
}
|
|
10
|
+
export declare const FontColorAction: FontColorAction;
|
|
11
|
+
export {};
|