@webiny/lexical-editor 0.0.0-unstable.ecd8734205 → 5.35.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/webiny-list.d.ts +7 -0
- package/commands/webiny-list.js +13 -0
- package/commands/webiny-list.js.map +1 -0
- package/commands/webiny-quote.d.ts +5 -0
- package/commands/webiny-quote.js +9 -0
- package/commands/webiny-quote.js.map +1 -0
- 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 +2 -1
- package/components/Editor/HeadingEditor.js.map +1 -1
- package/components/Editor/ParagraphEditor.js +3 -3
- package/components/Editor/ParagraphEditor.js.map +1 -1
- package/components/Editor/RichTextEditor.d.ts +4 -1
- package/components/Editor/RichTextEditor.js +37 -6
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +9 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +17 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
- package/components/LexicalHtmlRenderer.d.ts +8 -1
- package/components/LexicalHtmlRenderer.js +29 -6
- 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 +25 -5
- package/components/Toolbar/Toolbar.js.map +1 -1
- package/components/ToolbarActions/BoldAction.d.ts +0 -3
- package/components/ToolbarActions/BoldAction.js +8 -3
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.d.ts +0 -3
- package/components/ToolbarActions/BulletListAction.js +17 -55
- package/components/ToolbarActions/BulletListAction.js.map +1 -1
- package/components/ToolbarActions/CodeHighlightAction.d.ts +0 -4
- package/components/ToolbarActions/CodeHighlightAction.js +8 -4
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
- package/components/ToolbarActions/FontColorAction.d.ts +11 -0
- package/components/ToolbarActions/FontColorAction.js +83 -0
- package/components/ToolbarActions/FontColorAction.js.map +1 -0
- package/components/ToolbarActions/FontSizeAction.js +0 -3
- package/components/ToolbarActions/FontSizeAction.js.map +1 -1
- package/components/ToolbarActions/ItalicAction.d.ts +0 -3
- package/components/ToolbarActions/ItalicAction.js +8 -3
- package/components/ToolbarActions/ItalicAction.js.map +1 -1
- package/components/ToolbarActions/LinkAction.d.ts +0 -5
- package/components/ToolbarActions/LinkAction.js +0 -5
- package/components/ToolbarActions/LinkAction.js.map +1 -1
- package/components/ToolbarActions/NumberedListAction.d.ts +0 -3
- package/components/ToolbarActions/NumberedListAction.js +17 -53
- package/components/ToolbarActions/NumberedListAction.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.d.ts +0 -2
- package/components/ToolbarActions/QuoteAction.js +16 -29
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/TypographyAction.d.ts +11 -0
- package/components/ToolbarActions/TypographyAction.js +118 -0
- package/components/ToolbarActions/TypographyAction.js.map +1 -0
- package/components/ToolbarActions/UnderlineAction.d.ts +0 -3
- package/components/ToolbarActions/UnderlineAction.js +8 -3
- package/components/ToolbarActions/UnderlineAction.js.map +1 -1
- package/components/ToolbarPresets/HeadingToolbarPreset.js +8 -0
- package/components/ToolbarPresets/HeadingToolbarPreset.js.map +1 -1
- package/components/ToolbarPresets/ParagraphToolbarPreset.js +8 -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.d.ts +10 -0
- package/context/RichTextEditorContext.js +28 -1
- package/context/RichTextEditorContext.js.map +1 -1
- package/context/SharedHistoryContext.d.ts +11 -0
- package/context/SharedHistoryContext.js +26 -0
- package/context/SharedHistoryContext.js.map +1 -0
- package/context/TypographyActionContext.d.ts +7 -0
- package/context/TypographyActionContext.js +10 -0
- package/context/TypographyActionContext.js.map +1 -0
- 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/hooks/useTypographyAction.d.ts +1 -0
- package/hooks/useTypographyAction.js +15 -0
- package/hooks/useTypographyAction.js.map +1 -0
- package/hooks/useWebinyList.d.ts +2 -0
- package/hooks/useWebinyList.js +39 -0
- package/hooks/useWebinyList.js.map +1 -0
- package/hooks/useWebinyQuote.d.ts +2 -0
- package/hooks/useWebinyQuote.js +20 -0
- package/hooks/useWebinyQuote.js.map +1 -0
- package/images/icons/font-color.svg +1 -0
- package/index.d.ts +7 -1
- package/index.js +44 -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/TypographyElementNode.d.ts +42 -0
- package/nodes/TypographyElementNode.js +154 -0
- package/nodes/TypographyElementNode.js.map +1 -0
- package/nodes/WebinyQuoteNode.d.ts +29 -0
- package/nodes/WebinyQuoteNode.js +148 -0
- package/nodes/WebinyQuoteNode.js.map +1 -0
- package/nodes/list-node/WebinyListItemNode.d.ts +46 -0
- package/nodes/list-node/WebinyListItemNode.js +441 -0
- package/nodes/list-node/WebinyListItemNode.js.map +1 -0
- package/nodes/list-node/WebinyListNode.d.ts +38 -0
- package/nodes/list-node/WebinyListNode.js +253 -0
- package/nodes/list-node/WebinyListNode.js.map +1 -0
- package/nodes/list-node/formatList.d.ts +12 -0
- package/nodes/list-node/formatList.js +423 -0
- package/nodes/list-node/formatList.js.map +1 -0
- package/nodes/webinyNodes.d.ts +6 -1
- package/nodes/webinyNodes.js +8 -2
- package/nodes/webinyNodes.js.map +1 -1
- package/package.json +9 -6
- 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/plugins/TypographyPlugin/TypographyPlugin.d.ts +2 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js +31 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.d.ts +1 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.js +25 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.js.map +1 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.d.ts +1 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js +24 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js.map +1 -0
- package/themes/webinyLexicalTheme.css +0 -2
- package/themes/webinyLexicalTheme.d.ts +7 -8
- package/themes/webinyLexicalTheme.js +7 -27
- package/themes/webinyLexicalTheme.js.map +1 -1
- package/types.d.ts +59 -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 +106 -0
- package/ui/ToolbarActionDialog.js.map +1 -0
- package/utils/generateInitialLexicalValue.js.map +1 -1
- package/utils/getDOMRangeRect.js.map +1 -1
- package/utils/getLexicalTextSelectionState.d.ts +5 -0
- package/utils/getLexicalTextSelectionState.js +141 -0
- package/utils/getLexicalTextSelectionState.js.map +1 -0
- package/utils/getSelectedNode.js.map +1 -1
- package/utils/isValidJSON.js.map +1 -1
- package/utils/isValidLexicalData.js.map +1 -1
- package/utils/nodes/clearNodeFormating.d.ts +2 -0
- package/utils/nodes/clearNodeFormating.js +28 -0
- package/utils/nodes/clearNodeFormating.js.map +1 -0
- package/utils/nodes/formatToParagraph.d.ts +2 -0
- package/utils/nodes/formatToParagraph.js +19 -0
- package/utils/nodes/formatToParagraph.js.map +1 -0
- package/utils/nodes/formatToQuote.d.ts +2 -0
- package/utils/nodes/formatToQuote.js +20 -0
- package/utils/nodes/formatToQuote.js.map +1 -0
- package/utils/nodes/list-node.d.ts +11 -0
- package/utils/nodes/list-node.js +107 -0
- package/utils/nodes/list-node.js.map +1 -0
- 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
- package/utils/styleObjectToString.d.ts +2 -0
- package/utils/styleObjectToString.js +22 -0
- package/utils/styleObjectToString.js.map +1 -0
- package/utils/toTypographyEmotionMap.d.ts +3 -0
- package/utils/toTypographyEmotionMap.js +36 -0
- package/utils/toTypographyEmotionMap.js.map +1 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LexicalCommand } from "lexical";
|
|
2
|
+
export declare type WebinyListCommandPayload = {
|
|
3
|
+
themeStyleId: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const INSERT_UNORDERED_WEBINY_LIST_COMMAND: LexicalCommand<WebinyListCommandPayload>;
|
|
6
|
+
export declare const INSERT_ORDERED_WEBINY_LIST_COMMAND: LexicalCommand<WebinyListCommandPayload>;
|
|
7
|
+
export declare const REMOVE_WEBINY_LIST_COMMAND: LexicalCommand<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.REMOVE_WEBINY_LIST_COMMAND = exports.INSERT_UNORDERED_WEBINY_LIST_COMMAND = exports.INSERT_ORDERED_WEBINY_LIST_COMMAND = void 0;
|
|
7
|
+
var _lexical = require("lexical");
|
|
8
|
+
var INSERT_UNORDERED_WEBINY_LIST_COMMAND = (0, _lexical.createCommand)("INSERT_UNORDERED_WEBINY_LIST_COMMAND");
|
|
9
|
+
exports.INSERT_UNORDERED_WEBINY_LIST_COMMAND = INSERT_UNORDERED_WEBINY_LIST_COMMAND;
|
|
10
|
+
var INSERT_ORDERED_WEBINY_LIST_COMMAND = (0, _lexical.createCommand)("INSERT_ORDERED_WEBINY_LIST_COMMAND");
|
|
11
|
+
exports.INSERT_ORDERED_WEBINY_LIST_COMMAND = INSERT_ORDERED_WEBINY_LIST_COMMAND;
|
|
12
|
+
var REMOVE_WEBINY_LIST_COMMAND = (0, _lexical.createCommand)("REMOVE_WEBINY_LIST_COMMAND");
|
|
13
|
+
exports.REMOVE_WEBINY_LIST_COMMAND = REMOVE_WEBINY_LIST_COMMAND;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["INSERT_UNORDERED_WEBINY_LIST_COMMAND","createCommand","INSERT_ORDERED_WEBINY_LIST_COMMAND","REMOVE_WEBINY_LIST_COMMAND"],"sources":["webiny-list.ts"],"sourcesContent":["import { createCommand, LexicalCommand } from \"lexical\";\n\nexport type WebinyListCommandPayload = {\n themeStyleId: string;\n};\n\nexport const INSERT_UNORDERED_WEBINY_LIST_COMMAND: LexicalCommand<WebinyListCommandPayload> =\n createCommand(\"INSERT_UNORDERED_WEBINY_LIST_COMMAND\");\nexport const INSERT_ORDERED_WEBINY_LIST_COMMAND: LexicalCommand<WebinyListCommandPayload> =\n createCommand(\"INSERT_ORDERED_WEBINY_LIST_COMMAND\");\n\nexport const REMOVE_WEBINY_LIST_COMMAND: LexicalCommand<void> = createCommand(\n \"REMOVE_WEBINY_LIST_COMMAND\"\n);\n"],"mappings":";;;;;;AAAA;AAMO,IAAMA,oCAA8E,GACvF,IAAAC,sBAAa,EAAC,sCAAsC,CAAC;AAAC;AACnD,IAAMC,kCAA4E,GACrF,IAAAD,sBAAa,EAAC,oCAAoC,CAAC;AAAC;AAEjD,IAAME,0BAAgD,GAAG,IAAAF,sBAAa,EACzE,4BAA4B,CAC/B;AAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.INSERT_WEBINY_QUOTE_COMMAND = void 0;
|
|
7
|
+
var _lexical = require("lexical");
|
|
8
|
+
var INSERT_WEBINY_QUOTE_COMMAND = (0, _lexical.createCommand)("INSERT_WEBINY_QUOTE_COMMAND");
|
|
9
|
+
exports.INSERT_WEBINY_QUOTE_COMMAND = INSERT_WEBINY_QUOTE_COMMAND;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["INSERT_WEBINY_QUOTE_COMMAND","createCommand"],"sources":["webiny-quote.ts"],"sourcesContent":["import { createCommand, LexicalCommand } from \"lexical\";\n\nexport type WebinyQuoteCommandPayload = {\n themeStyleId: string;\n};\n\nexport const INSERT_WEBINY_QUOTE_COMMAND: LexicalCommand<WebinyQuoteCommandPayload> = createCommand(\n \"INSERT_WEBINY_QUOTE_COMMAND\"\n);\n"],"mappings":";;;;;;AAAA;AAMO,IAAMA,2BAAsE,GAAG,IAAAC,sBAAa,EAC/F,6BAA6B,CAChC;AAAC"}
|
|
@@ -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"}
|
|
@@ -12,6 +12,7 @@ var _ClickableLinkPlugin = require("../../plugins/ClickableLinkPlugin/ClickableL
|
|
|
12
12
|
var _FloatingLinkEditorPlugin = require("../../plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin");
|
|
13
13
|
var _HeadingToolbar = require("../Toolbar/HeadingToolbar");
|
|
14
14
|
var _RichTextEditor = require("./RichTextEditor");
|
|
15
|
+
var _WebinyQuoteNodePlugin = require("../../plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin");
|
|
15
16
|
var _excluded = ["tag", "placeholder"];
|
|
16
17
|
var HeadingEditor = function HeadingEditor(_ref) {
|
|
17
18
|
var tag = _ref.tag,
|
|
@@ -21,7 +22,7 @@ var HeadingEditor = function HeadingEditor(_ref) {
|
|
|
21
22
|
toolbar: /*#__PURE__*/_react.default.createElement(_HeadingToolbar.HeadingToolbar, null),
|
|
22
23
|
tag: tag !== null && tag !== void 0 ? tag : "h1",
|
|
23
24
|
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Enter your heading text here..."
|
|
24
|
-
}, rest), /*#__PURE__*/_react.default.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/_react.default.createElement(_ClickableLinkPlugin.ClickableLinkPlugin, null), /*#__PURE__*/_react.default.createElement(_FloatingLinkEditorPlugin.FloatingLinkEditorPlugin, {
|
|
25
|
+
}, rest), /*#__PURE__*/_react.default.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/_react.default.createElement(_WebinyQuoteNodePlugin.WebinyQuotePlugin, null), /*#__PURE__*/_react.default.createElement(_ClickableLinkPlugin.ClickableLinkPlugin, null), /*#__PURE__*/_react.default.createElement(_FloatingLinkEditorPlugin.FloatingLinkEditorPlugin, {
|
|
25
26
|
anchorElem: document.body
|
|
26
27
|
}));
|
|
27
28
|
};
|
|
@@ -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\";\nimport { WebinyQuotePlugin } from \"~/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin\";\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 <WebinyQuotePlugin />\n <ClickableLinkPlugin />\n <FloatingLinkEditorPlugin anchorElem={document.body} />\n </RichTextEditor>\n );\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAA0F;AAMnF,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,wCAAiB,OAAG,eACrB,6BAAC,wCAAmB,OAAG,eACvB,6BAAC,kDAAwB;IAAC,UAAU,EAAEC,QAAQ,CAACC;EAAK,EAAG,CAC1C;AAEzB,CAAC;AAAC"}
|
|
@@ -7,13 +7,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.ParagraphEditor = void 0;
|
|
8
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _LexicalListPlugin = require("@lexical/react/LexicalListPlugin");
|
|
11
10
|
var _CodeHighlightPlugin = require("../../plugins/CodeHighlightPlugin/CodeHighlightPlugin");
|
|
12
11
|
var _LexicalLinkPlugin = require("@lexical/react/LexicalLinkPlugin");
|
|
13
12
|
var _FloatingLinkEditorPlugin = require("../../plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin");
|
|
14
13
|
var _ClickableLinkPlugin = require("../../plugins/ClickableLinkPlugin/ClickableLinkPlugin");
|
|
15
14
|
var _ParagraphToolbar = require("../Toolbar/ParagraphToolbar");
|
|
16
15
|
var _RichTextEditor = require("./RichTextEditor");
|
|
16
|
+
var _WebinyListPlugin = require("../../plugins/WebinyListPLugin/WebinyListPlugin");
|
|
17
17
|
var _excluded = ["placeholder", "tag"];
|
|
18
18
|
var ParagraphEditor = function ParagraphEditor(_ref) {
|
|
19
19
|
var placeholder = _ref.placeholder,
|
|
@@ -23,8 +23,8 @@ var ParagraphEditor = function ParagraphEditor(_ref) {
|
|
|
23
23
|
toolbar: /*#__PURE__*/_react.default.createElement(_ParagraphToolbar.ParagraphToolbar, null),
|
|
24
24
|
tag: tag !== null && tag !== void 0 ? tag : "p",
|
|
25
25
|
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Enter your text here..."
|
|
26
|
-
}, rest), /*#__PURE__*/_react.default.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/_react.default.createElement(_CodeHighlightPlugin.CodeHighlightPlugin, null), /*#__PURE__*/_react.default.createElement(_ClickableLinkPlugin.ClickableLinkPlugin, null), /*#__PURE__*/_react.default.createElement(_FloatingLinkEditorPlugin.FloatingLinkEditorPlugin, {
|
|
26
|
+
}, rest), /*#__PURE__*/_react.default.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/_react.default.createElement(_WebinyListPlugin.WebinyListPlugin, null), /*#__PURE__*/_react.default.createElement(_CodeHighlightPlugin.CodeHighlightPlugin, null), /*#__PURE__*/_react.default.createElement(_ClickableLinkPlugin.ClickableLinkPlugin, null), /*#__PURE__*/_react.default.createElement(_FloatingLinkEditorPlugin.FloatingLinkEditorPlugin, {
|
|
27
27
|
anchorElem: document.body
|
|
28
|
-
})
|
|
28
|
+
}));
|
|
29
29
|
};
|
|
30
30
|
exports.ParagraphEditor = ParagraphEditor;
|
|
@@ -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 { 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\";\nimport { WebinyListPlugin } from \"~/plugins/WebinyListPLugin/WebinyListPlugin\";\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 <WebinyListPlugin />\n <CodeHighlightPlugin />\n <ClickableLinkPlugin />\n <FloatingLinkEditorPlugin anchorElem={document.body} />\n </RichTextEditor>\n );\n};\n\nexport { ParagraphEditor };\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAA+E;AAM/E,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,kCAAgB,OAAG,eACpB,6BAAC,wCAAmB,OAAG,eACvB,6BAAC,wCAAmB,OAAG,eACvB,6BAAC,kDAAwB;IAAC,UAAU,EAAEC,QAAQ,CAACC;EAAK,EAAG,CAC1C;AAEzB,CAAC;AAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { LexicalValue } from "../../types";
|
|
2
|
+
import { LexicalValue, ThemeEmotionMap } 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,8 @@ export interface RichTextEditorProps {
|
|
|
16
17
|
onBlur?: (editorState: LexicalValue) => void;
|
|
17
18
|
height?: number | string;
|
|
18
19
|
width?: number | string;
|
|
20
|
+
theme: WebinyTheme;
|
|
21
|
+
themeEmotionMap?: ThemeEmotionMap;
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
24
|
* @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,16 @@ 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");
|
|
30
|
+
var _TypographyPlugin = require("../../plugins/TypographyPlugin/TypographyPlugin");
|
|
31
|
+
var _WebinyQuoteNodePlugin = require("../../plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin");
|
|
32
|
+
var _LexicalHistoryPlugin = require("@lexical/react/LexicalHistoryPlugin");
|
|
33
|
+
var _SharedHistoryContext = require("../../context/SharedHistoryContext");
|
|
34
|
+
var _useRichTextEditor2 = require("../../hooks/useRichTextEditor");
|
|
35
|
+
var _react2 = require("@emotion/react");
|
|
36
|
+
var _toTypographyEmotionMap = require("../../utils/toTypographyEmotionMap");
|
|
29
37
|
var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
30
38
|
var toolbar = _ref.toolbar,
|
|
31
39
|
onChange = _ref.onChange,
|
|
@@ -36,13 +44,24 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
36
44
|
onBlur = _ref.onBlur,
|
|
37
45
|
focus = _ref.focus,
|
|
38
46
|
width = _ref.width,
|
|
39
|
-
height = _ref.height
|
|
47
|
+
height = _ref.height,
|
|
48
|
+
theme = _ref.theme,
|
|
49
|
+
themeEmotionMap = _ref.themeEmotionMap;
|
|
50
|
+
var _useSharedHistoryCont = (0, _SharedHistoryContext.useSharedHistoryContext)(),
|
|
51
|
+
historyState = _useSharedHistoryCont.historyState;
|
|
40
52
|
var placeholderElem = /*#__PURE__*/_react.default.createElement(_Placeholder.Placeholder, null, placeholder || "Enter text...");
|
|
41
53
|
var scrollRef = (0, _react.useRef)(null);
|
|
42
54
|
var _useState = (0, _react.useState)(undefined),
|
|
43
55
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
44
56
|
floatingAnchorElem = _useState2[0],
|
|
45
57
|
setFloatingAnchorElem = _useState2[1];
|
|
58
|
+
var _useRichTextEditor = (0, _useRichTextEditor2.useRichTextEditor)(),
|
|
59
|
+
setTheme = _useRichTextEditor.setTheme,
|
|
60
|
+
setThemeEmotionMap = _useRichTextEditor.setThemeEmotionMap;
|
|
61
|
+
(0, _react.useEffect)(function () {
|
|
62
|
+
setTheme(theme);
|
|
63
|
+
setThemeEmotionMap(themeEmotionMap);
|
|
64
|
+
}, [themeEmotionMap]);
|
|
46
65
|
var onRef = function onRef(_floatingAnchorElem) {
|
|
47
66
|
if (_floatingAnchorElem !== null) {
|
|
48
67
|
setFloatingAnchorElem(_floatingAnchorElem);
|
|
@@ -59,12 +78,15 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
59
78
|
throw error;
|
|
60
79
|
},
|
|
61
80
|
nodes: [].concat((0, _toConsumableArray2.default)(_webinyNodes.WebinyNodes), (0, _toConsumableArray2.default)(nodes || [])),
|
|
62
|
-
theme: _webinyLexicalTheme.
|
|
81
|
+
theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _webinyLexicalTheme.webinyEditorTheme), {}, {
|
|
82
|
+
emotionMap: themeEmotionMap
|
|
83
|
+
})
|
|
63
84
|
};
|
|
64
85
|
function handleOnChange(editorState, editor) {
|
|
65
86
|
editorState.read(function () {
|
|
66
87
|
if (typeof onChange === "function") {
|
|
67
88
|
var _editorState = editor.getEditorState();
|
|
89
|
+
//TODO: send plain JSON object
|
|
68
90
|
onChange(JSON.stringify(_editorState.toJSON()));
|
|
69
91
|
}
|
|
70
92
|
});
|
|
@@ -78,7 +100,9 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
78
100
|
onChange: handleOnChange
|
|
79
101
|
}), value && /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.LexicalUpdateStatePlugin, {
|
|
80
102
|
value: value
|
|
81
|
-
}), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null),
|
|
103
|
+
}), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null), /*#__PURE__*/_react.default.createElement(_FontColorPlugin.FontColorPlugin, null), /*#__PURE__*/_react.default.createElement(_TypographyPlugin.TypographyPlugin, null), /*#__PURE__*/_react.default.createElement(_WebinyQuoteNodePlugin.WebinyQuotePlugin, null), /*#__PURE__*/_react.default.createElement(_LexicalHistoryPlugin.HistoryPlugin, {
|
|
104
|
+
externalHistoryState: historyState
|
|
105
|
+
}), onBlur && /*#__PURE__*/_react.default.createElement(_BlurEventPlugin.BlurEventPlugin, {
|
|
82
106
|
onBlur: onBlur
|
|
83
107
|
}), focus && /*#__PURE__*/_react.default.createElement(_LexicalAutoFocusPlugin.AutoFocusPlugin, null), children, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
|
|
84
108
|
contentEditable: /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -102,6 +126,13 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
102
126
|
* @description Main editor container
|
|
103
127
|
*/
|
|
104
128
|
var RichTextEditor = (0, _reactComposition.makeComposable)("RichTextEditor", function (props) {
|
|
105
|
-
return /*#__PURE__*/_react.default.createElement(_RichTextEditorContext.RichTextEditorProvider, null, /*#__PURE__*/_react.default.createElement(
|
|
129
|
+
return /*#__PURE__*/_react.default.createElement(_RichTextEditorContext.RichTextEditorProvider, null, /*#__PURE__*/_react.default.createElement(_react2.ClassNames, null, function (_ref2) {
|
|
130
|
+
var _props$themeEmotionMa;
|
|
131
|
+
var css = _ref2.css;
|
|
132
|
+
var themeEmotionMap = (_props$themeEmotionMa = props === null || props === void 0 ? void 0 : props.themeEmotionMap) !== null && _props$themeEmotionMa !== void 0 ? _props$themeEmotionMa : (0, _toTypographyEmotionMap.toTypographyEmotionMap)(css, props.theme);
|
|
133
|
+
return /*#__PURE__*/_react.default.createElement(_SharedHistoryContext.SharedHistoryContext, null, /*#__PURE__*/_react.default.createElement(BaseRichTextEditor, Object.assign({}, props, {
|
|
134
|
+
themeEmotionMap: themeEmotionMap
|
|
135
|
+
})));
|
|
136
|
+
}));
|
|
106
137
|
});
|
|
107
138
|
exports.RichTextEditor = RichTextEditor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_Placeholder","_generateInitialLexicalValue","_webinyNodes","_webinyLexicalTheme","_LexicalComposer","_LexicalOnChangePlugin","_LexicalAutoFocusPlugin","_LexicalClearEditorPlugin","_LexicalRichTextPlugin","_LexicalErrorBoundary","_interopRequireDefault","_reactComposition","_LexicalContentEditable","_RichTextEditorContext","_isValidLexicalData","_LexicalUpdateStatePlugin","_BlurEventPlugin","BaseRichTextEditor","_ref","toolbar","onChange","value","nodes","placeholder","children","onBlur","focus","width","height","placeholderElem","default","createElement","Placeholder","scrollRef","useRef","_useState","useState","undefined","_useState2","_slicedToArray2","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","sizeStyle","initialConfig","editorState","isValidLexicalData","generateInitialLexicalValue","namespace","onError","error","concat","_toConsumableArray2","WebinyNodes","theme","handleOnChange","editor","read","getEditorState","JSON","stringify","toJSON","LexicalComposer","ref","style","_objectSpread2","OnChangePlugin","LexicalUpdateStatePlugin","ClearEditorPlugin","BlurEventPlugin","AutoFocusPlugin","RichTextPlugin","contentEditable","className","ContentEditable","outline","ErrorBoundary","LexicalErrorBoundary","RichTextEditor","makeComposable","props","RichTextEditorProvider","exports"],"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 { WebinyNodes } from \"~/nodes/webinyNodes\";\nimport { theme } from \"~/themes/webinyLexicalTheme\";\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\";\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\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}: 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: theme\n };\n\n function handleOnChange(editorState: EditorState, editor: LexicalEditor) {\n editorState.read(() => {\n if (typeof onChange === \"function\") {\n const editorState = editor.getEditorState();\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 {/* 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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,4BAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AAGA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,uBAAA,GAAAP,OAAA;AACA,IAAAQ,yBAAA,GAAAR,OAAA;AACA,IAAAS,sBAAA,GAAAT,OAAA;AACA,IAAAU,qBAAA,GAAAC,sBAAA,CAAAX,OAAA;AACA,IAAAY,iBAAA,GAAAZ,OAAA;AACA,IAAAa,uBAAA,GAAAb,OAAA;AACA,IAAAc,sBAAA,GAAAd,OAAA;AACA,IAAAe,mBAAA,GAAAf,OAAA;AACA,IAAAgB,yBAAA,GAAAhB,OAAA;AACA,IAAAiB,gBAAA,GAAAjB,OAAA;AAmBA,IAAMkB,kBAAiD,GAAG,SAApDA,kBAAiDA,CAAAC,IAAA,EAW5B;EAAA,IAVvBC,OAAO,GAAAD,IAAA,CAAPC,OAAO;IACPC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,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aAAA;MAAK2C,SAAS,EAAC,iBAAiB;MAACT,KAAK,MAAAC,cAAA,CAAApC,OAAA,MAAOc,SAAS;IAAG,gBACrD/C,MAAA,CAAAiC,OAAA,CAAAC,aAAA;MAAK2C,SAAS,EAAC,QAAQ;MAACV,GAAG,EAAEtB,KAAM;MAACuB,KAAK,MAAAC,cAAA,CAAApC,OAAA,MAAOc,SAAS;IAAG,gBACxD/C,MAAA,CAAAiC,OAAA,CAAAC,aAAA,CAACnB,uBAAA,CAAA+D,eAAe;MAACV,KAAK,MAAAC,cAAA,CAAApC,OAAA;QAAI8C,OAAO,EAAE;MAAC,GAAKhC,SAAS;IAAG,EAAG,CACtD,CAEb;IACDrB,WAAW,EAAEM,eAAgB;IAC7BgD,aAAa,EAAEC;EAAqB,EACtC,EAEDtC,kBAAkB,IAAIrB,OAAO,CAC5B,CACQ;AAE1B,CAAC;;AAED;AACA;AACA;AACO,IAAM4D,cAAc,GAAG,IAAAC,gCAAc,EAAsB,gBAAgB,EAAE,UAAAC,KAAK,EAAI;EACzF,oBACIpF,MAAA,CAAAiC,OAAA,CAAAC,aAAA,CAAClB,sBAAA,CAAAqE,sBAAsB,qBACnBrF,MAAA,CAAAiC,OAAA,CAAAC,aAAA,CAACd,kBAAkB,EAAKgE,KAAK,CAAI,CACZ;AAEjC,CAAC,CAAC;AAACE,OAAA,CAAAJ,cAAA,GAAAA,cAAA"}
|
|
1
|
+
{"version":3,"names":["BaseRichTextEditor","toolbar","onChange","value","nodes","placeholder","children","onBlur","focus","width","height","theme","themeEmotionMap","useSharedHistoryContext","historyState","placeholderElem","scrollRef","useRef","useState","undefined","floatingAnchorElem","setFloatingAnchorElem","useRichTextEditor","setTheme","setThemeEmotionMap","useEffect","onRef","_floatingAnchorElem","sizeStyle","initialConfig","editorState","isValidLexicalData","generateInitialLexicalValue","namespace","onError","error","WebinyNodes","webinyEditorTheme","emotionMap","handleOnChange","editor","read","getEditorState","JSON","stringify","toJSON","outline","LexicalErrorBoundary","RichTextEditor","makeComposable","props","css","toTypographyEmotionMap"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { LexicalValue, ThemeEmotionMap } 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\";\nimport { TypographyPlugin } from \"~/plugins/TypographyPlugin/TypographyPlugin\";\nimport { WebinyQuotePlugin } from \"~/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\nimport { ClassNames } from \"@emotion/react\";\nimport { toTypographyEmotionMap } from \"~/utils/toTypographyEmotionMap\";\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 themeEmotionMap?: ThemeEmotionMap;\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 themeEmotionMap\n}: RichTextEditorProps) => {\n const { historyState } = useSharedHistoryContext();\n const placeholderElem = <Placeholder>{placeholder || \"Enter text...\"}</Placeholder>;\n const scrollRef = useRef(null);\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n const { setTheme, setThemeEmotionMap } = useRichTextEditor();\n\n useEffect(() => {\n setTheme(theme);\n setThemeEmotionMap(themeEmotionMap);\n }, [themeEmotionMap]);\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, emotionMap: themeEmotionMap }\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 <TypographyPlugin />\n <WebinyQuotePlugin />\n <HistoryPlugin externalHistoryState={historyState} />\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 <ClassNames>\n {({ css }) => {\n const themeEmotionMap =\n props?.themeEmotionMap ?? toTypographyEmotionMap(css, props.theme);\n return (\n <SharedHistoryContext>\n <BaseRichTextEditor {...props} themeEmotionMap={themeEmotionMap} />\n </SharedHistoryContext>\n );\n }}\n </ClassNames>\n </RichTextEditorProvider>\n );\n});\n"],"mappings":";;;;;;;;;;;AAAA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAwBA,IAAMA,kBAAiD,GAAG,SAApDA,kBAAiD,OAa5B;EAAA,IAZvBC,OAAO,QAAPA,OAAO;IACPC,QAAQ,QAARA,QAAQ;IACRC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IACLC,WAAW,QAAXA,WAAW;IACXC,QAAQ,QAARA,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AqB,EACtC,EAED3B,kBAAkB,IAAInB,OAAO,CAC5B,CACQ;AAE1B,CAAC;;AAED;AACA;AACA;AACO,IAAM+C,cAAc,GAAG,IAAAC,gCAAc,EAAsB,gBAAgB,EAAE,UAAAC,KAAK,EAAI;EACzF,oBACI,6BAAC,6CAAsB,qBACnB,6BAAC,kBAAU,QACN,iBAAa;IAAA;IAAA,IAAVC,GAAG,SAAHA,GAAG;IACH,IAAMvC,eAAe,4BACjBsC,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEtC,eAAe,yEAAI,IAAAwC,8CAAsB,EAACD,GAAG,EAAED,KAAK,CAACvC,KAAK,CAAC;IACtE,oBACI,6BAAC,0CAAoB,qBACjB,6BAAC,kBAAkB,oBAAKuC,KAAK;MAAE,eAAe,EAAEtC;IAAgB,GAAG,CAChD;EAE/B,CAAC,CACQ,CACQ;AAEjC,CAAC,CAAC;AAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FontColorAction } from "../ToolbarActions/FontColorAction";
|
|
3
|
+
import { TypographyAction } from "../ToolbarActions/TypographyAction";
|
|
4
|
+
interface LexicalEditorConfig extends React.FC<unknown> {
|
|
5
|
+
FontColorAction: typeof FontColorAction;
|
|
6
|
+
TypographyAction: typeof TypographyAction;
|
|
7
|
+
}
|
|
8
|
+
export declare const LexicalEditorConfig: LexicalEditorConfig;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
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 _TypographyAction = require("../ToolbarActions/TypographyAction");
|
|
11
|
+
var LexicalEditorConfig = function LexicalEditorConfig(_ref) {
|
|
12
|
+
var children = _ref.children;
|
|
13
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
14
|
+
};
|
|
15
|
+
exports.LexicalEditorConfig = LexicalEditorConfig;
|
|
16
|
+
LexicalEditorConfig.FontColorAction = _FontColorAction.FontColorAction;
|
|
17
|
+
LexicalEditorConfig.TypographyAction = _TypographyAction.TypographyAction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LexicalEditorConfig","children","FontColorAction","TypographyAction"],"sources":["LexicalEditorConfig.tsx"],"sourcesContent":["import React from \"react\";\nimport { FontColorAction } from \"~/components/ToolbarActions/FontColorAction\";\nimport { TypographyAction } from \"~/components/ToolbarActions/TypographyAction\";\n\ninterface LexicalEditorConfig extends React.FC<unknown> {\n FontColorAction: typeof FontColorAction;\n TypographyAction: typeof TypographyAction;\n}\n\nexport const LexicalEditorConfig: LexicalEditorConfig = ({ children }) => {\n return <>{children}</>;\n};\n\nLexicalEditorConfig.FontColorAction = FontColorAction;\nLexicalEditorConfig.TypographyAction = TypographyAction;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAOO,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;AACrDF,mBAAmB,CAACG,gBAAgB,GAAGA,kCAAgB"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { LexicalValue } from "../types";
|
|
2
|
+
import { LexicalValue, ThemeEmotionMap } 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;
|
|
9
|
+
themeEmotionMap?: ThemeEmotionMap;
|
|
7
10
|
}
|
|
11
|
+
export declare const BaseLexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps>;
|
|
12
|
+
/**
|
|
13
|
+
* @description Main editor container
|
|
14
|
+
*/
|
|
8
15
|
export declare const LexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps>;
|
|
9
16
|
export {};
|
|
@@ -4,21 +4,26 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.LexicalHtmlRenderer = void 0;
|
|
7
|
+
exports.LexicalHtmlRenderer = exports.BaseLexicalHtmlRenderer = 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");
|
|
19
|
-
var
|
|
18
|
+
var _webinyNodes = require("../nodes/webinyNodes");
|
|
19
|
+
var _webinyLexicalTheme = require("../themes/webinyLexicalTheme");
|
|
20
|
+
var _react2 = require("@emotion/react");
|
|
21
|
+
var _toTypographyEmotionMap = require("../utils/toTypographyEmotionMap");
|
|
22
|
+
var BaseLexicalHtmlRenderer = function BaseLexicalHtmlRenderer(_ref) {
|
|
20
23
|
var nodes = _ref.nodes,
|
|
21
|
-
value = _ref.value
|
|
24
|
+
value = _ref.value,
|
|
25
|
+
theme = _ref.theme,
|
|
26
|
+
themeEmotionMap = _ref.themeEmotionMap;
|
|
22
27
|
var initialConfig = {
|
|
23
28
|
editorState: (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)(),
|
|
24
29
|
namespace: "webiny",
|
|
@@ -27,7 +32,10 @@ var LexicalHtmlRenderer = function LexicalHtmlRenderer(_ref) {
|
|
|
27
32
|
},
|
|
28
33
|
editable: false,
|
|
29
34
|
nodes: [].concat((0, _toConsumableArray2.default)(_webinyNodes.WebinyNodes), (0, _toConsumableArray2.default)(nodes || [])),
|
|
30
|
-
theme: _webinyLexicalTheme.
|
|
35
|
+
theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _webinyLexicalTheme.webinyEditorTheme), {}, {
|
|
36
|
+
emotionMap: themeEmotionMap,
|
|
37
|
+
styles: theme.styles
|
|
38
|
+
})
|
|
31
39
|
};
|
|
32
40
|
return /*#__PURE__*/_react.default.createElement(_LexicalComposer.LexicalComposer, {
|
|
33
41
|
initialConfig: initialConfig
|
|
@@ -41,4 +49,19 @@ var LexicalHtmlRenderer = function LexicalHtmlRenderer(_ref) {
|
|
|
41
49
|
value: value
|
|
42
50
|
}));
|
|
43
51
|
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @description Main editor container
|
|
55
|
+
*/
|
|
56
|
+
exports.BaseLexicalHtmlRenderer = BaseLexicalHtmlRenderer;
|
|
57
|
+
var LexicalHtmlRenderer = function LexicalHtmlRenderer(props) {
|
|
58
|
+
return /*#__PURE__*/_react.default.createElement(_react2.ClassNames, null, function (_ref2) {
|
|
59
|
+
var _props$themeEmotionMa;
|
|
60
|
+
var css = _ref2.css;
|
|
61
|
+
var themeEmotionMap = (_props$themeEmotionMa = props === null || props === void 0 ? void 0 : props.themeEmotionMap) !== null && _props$themeEmotionMa !== void 0 ? _props$themeEmotionMa : (0, _toTypographyEmotionMap.toTypographyEmotionMap)(css, props.theme);
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(BaseLexicalHtmlRenderer, Object.assign({}, props, {
|
|
63
|
+
themeEmotionMap: themeEmotionMap
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
};
|
|
44
67
|
exports.LexicalHtmlRenderer = LexicalHtmlRenderer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["BaseLexicalHtmlRenderer","nodes","value","theme","themeEmotionMap","initialConfig","editorState","isValidLexicalData","generateInitialLexicalValue","namespace","onError","error","editable","WebinyNodes","webinyEditorTheme","emotionMap","styles","LexicalErrorBoundary","LexicalHtmlRenderer","props","css","toTypographyEmotionMap"],"sources":["LexicalHtmlRenderer.tsx"],"sourcesContent":["import React from \"react\";\nimport { LexicalValue, ThemeEmotionMap } 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\";\nimport { ClassNames } from \"@emotion/react\";\nimport { toTypographyEmotionMap } from \"~/utils/toTypographyEmotionMap\";\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 themeEmotionMap?: ThemeEmotionMap;\n}\n\nexport const BaseLexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps> = ({\n nodes,\n value,\n theme,\n themeEmotionMap\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, emotionMap: themeEmotionMap, 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\n/**\n * @description Main editor container\n */\nexport const LexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps> = props => {\n return (\n <ClassNames>\n {({ css }) => {\n const themeEmotionMap =\n props?.themeEmotionMap ?? toTypographyEmotionMap(css, props.theme);\n return <BaseLexicalHtmlRenderer {...props} themeEmotionMap={themeEmotionMap} />;\n }}\n </ClassNames>\n );\n};\n"],"mappings":";;;;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAYO,IAAMA,uBAA2D,GAAG,SAA9DA,uBAA2D,OAKlE;EAAA,IAJFC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IACLC,eAAe,QAAfA,eAAe;EAEf,IAAMC,aAAa,GAAG;IAClBC,WAAW,EAAE,IAAAC,sCAAkB,EAACL,KAAK,CAAC,GAAGA,KAAK,GAAG,IAAAM,wDAA2B,GAAE;IAC9EC,SAAS,EAAE,QAAQ;IACnBC,OAAO,EAAE,iBAACC,KAAY,EAAK;MACvB,MAAMA,KAAK;IACf,CAAC;IACDC,QAAQ,EAAE,KAAK;IACfX,KAAK,6CAAMY,wBAAW,oCAAMZ,KAAK,IAAI,EAAE,EAAE;IACzCE,KAAK,8DAAOW,qCAAiB;MAAEC,UAAU,EAAEX,eAAe;MAAEY,MAAM,EAAEb,KAAK,CAACa;IAAM;EACpF,CAAC;EAED,oBACI,6BAAC,gCAAe;IAAC,aAAa,EAAEX;EAAc,gBAC1C,6BAAC,qCAAc;IACX,eAAe,eACX;MAAK,SAAS,EAAC;IAAQ,gBACnB,6BAAC,uCAAe,OAAG,CAE1B;IACD,aAAa,EAAEY,6BAAqB;IACpC,WAAW,EAAE;EAAK,EACpB,eACF,6BAAC,kDAAwB;IAAC,KAAK,EAAEf;EAAM,EAAG,CAC5B;AAE1B,CAAC;;AAED;AACA;AACA;AAFA;AAGO,IAAMgB,mBAAuD,GAAG,SAA1DA,mBAAuD,CAAGC,KAAK,EAAI;EAC5E,oBACI,6BAAC,kBAAU,QACN,iBAAa;IAAA;IAAA,IAAVC,GAAG,SAAHA,GAAG;IACH,IAAMhB,eAAe,4BACjBe,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEf,eAAe,yEAAI,IAAAiB,8CAAsB,EAACD,GAAG,EAAED,KAAK,CAAChB,KAAK,CAAC;IACtE,oBAAO,6BAAC,uBAAuB,oBAAKgB,KAAK;MAAE,eAAe,EAAEf;IAAgB,GAAG;EACnF,CAAC,CACQ;AAErB,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;
|