@webiny/lexical-editor 5.37.0-beta.0 → 5.37.0-beta.2
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/insertFiles.d.ts +14 -0
- package/commands/insertFiles.js +9 -0
- package/commands/insertFiles.js.map +1 -0
- package/commands/webiny-list.js.map +1 -1
- package/commands/webiny-quote.js.map +1 -1
- package/components/Editor/HeadingEditor.js +7 -9
- package/components/Editor/HeadingEditor.js.map +1 -1
- package/components/Editor/ParagraphEditor.js +7 -10
- package/components/Editor/ParagraphEditor.js.map +1 -1
- package/components/Editor/RichTextEditor.d.ts +9 -1
- package/components/Editor/RichTextEditor.js +41 -20
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/ImageComponent.d.ts +23 -0
- package/components/ImageComponent.js +252 -0
- package/components/ImageComponent.js.map +1 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +19 -10
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +63 -9
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
- package/components/LexicalEditorConfig/components/Node.d.ts +14 -0
- package/components/LexicalEditorConfig/components/Node.js +38 -0
- package/components/LexicalEditorConfig/components/Node.js.map +1 -0
- package/components/LexicalEditorConfig/components/Plugin.d.ts +13 -0
- package/components/LexicalEditorConfig/components/Plugin.js +38 -0
- package/components/LexicalEditorConfig/components/Plugin.js.map +1 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.d.ts +13 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.js +38 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -0
- package/components/LexicalHtmlRenderer.d.ts +2 -0
- package/components/LexicalHtmlRenderer.js +1 -1
- package/components/LexicalHtmlRenderer.js.map +1 -1
- package/components/Toolbar/StaticToolbar.css +260 -0
- package/components/Toolbar/StaticToolbar.d.ts +3 -0
- package/components/Toolbar/StaticToolbar.js +101 -0
- package/components/Toolbar/StaticToolbar.js.map +1 -0
- package/components/Toolbar/Toolbar.css +215 -4
- package/components/Toolbar/Toolbar.d.ts +2 -8
- package/components/Toolbar/Toolbar.js +25 -37
- package/components/Toolbar/Toolbar.js.map +1 -1
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.js +2 -2
- package/components/ToolbarActions/BulletListAction.js.map +1 -1
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
- package/components/ToolbarActions/FontColorAction.js +1 -1
- package/components/ToolbarActions/FontColorAction.js.map +1 -1
- package/components/ToolbarActions/FontSizeAction.js.map +1 -1
- package/components/ToolbarActions/ImageAction.d.ts +2 -0
- package/components/ToolbarActions/ImageAction.js +53 -0
- package/components/ToolbarActions/ImageAction.js.map +1 -0
- package/components/ToolbarActions/ItalicAction.js.map +1 -1
- package/components/ToolbarActions/LinkAction.js.map +1 -1
- package/components/ToolbarActions/NumberedListAction.js +16 -4
- package/components/ToolbarActions/NumberedListAction.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
- package/components/ToolbarActions/TypographyAction.js +1 -1
- package/components/ToolbarActions/TypographyAction.js.map +1 -1
- package/components/ToolbarActions/UnderlineAction.js.map +1 -1
- package/context/FontColorActionContext.js.map +1 -1
- package/context/RichTextEditorContext.d.ts +3 -1
- package/context/RichTextEditorContext.js +17 -11
- package/context/RichTextEditorContext.js.map +1 -1
- package/context/SharedHistoryContext.js.map +1 -1
- package/context/TextAlignmentActionContextProps.js.map +1 -1
- package/context/TypographyActionContext.js.map +1 -1
- package/hooks/useFontColorPicker.js.map +1 -1
- package/hooks/useList.js.map +1 -1
- package/hooks/useQuote.js.map +1 -1
- package/hooks/useRichTextEditor.js.map +1 -1
- package/hooks/useTextAlignmentAction.js.map +1 -1
- package/hooks/useTypographyAction.js.map +1 -1
- package/images/icons/insert-image.svg +4 -0
- package/index.d.ts +9 -9
- package/index.js +50 -44
- package/index.js.map +1 -1
- package/nodes/FontColorNode.js +0 -4
- package/nodes/FontColorNode.js.map +1 -1
- package/nodes/HeadingNode.js.map +1 -1
- package/nodes/ImageNode.d.ts +50 -0
- package/nodes/ImageNode.js +206 -0
- package/nodes/ImageNode.js.map +1 -0
- package/nodes/ListItemNode.js +0 -4
- package/nodes/ListItemNode.js.map +1 -1
- package/nodes/ListNode/formatList.js.map +1 -1
- package/nodes/ListNode.js +0 -6
- package/nodes/ListNode.js.map +1 -1
- package/nodes/ParagraphNode.js.map +1 -1
- package/nodes/QuoteNode.js.map +1 -1
- package/nodes/TypographyElementNode.js +2 -6
- package/nodes/TypographyElementNode.js.map +1 -1
- package/nodes/imageNode.css +43 -0
- package/nodes/webinyNodes.js +2 -1
- package/nodes/webinyNodes.js.map +1 -1
- package/package.json +6 -5
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +5 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +52 -14
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
- package/plugins/ImagesPlugin/ImagesPlugin.d.ts +13 -0
- package/plugins/ImagesPlugin/ImagesPlugin.js +152 -0
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -0
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +1 -1
- package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -1
- package/plugins/ListPLugin/ListPlugin.d.ts +1 -0
- package/plugins/{WebinyListPLugin/WebinyListPlugin.js → ListPLugin/ListPlugin.js} +3 -3
- package/plugins/ListPLugin/ListPlugin.js.map +1 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js.map +1 -1
- package/themes/webinyLexicalTheme.css +0 -6
- package/themes/webinyLexicalTheme.js +4 -1
- package/themes/webinyLexicalTheme.js.map +1 -1
- package/types.d.ts +9 -0
- package/types.js +28 -1
- package/types.js.map +1 -1
- package/ui/ContentEditable.css +22 -0
- package/ui/ContentEditable.d.ts +12 -0
- package/ui/ContentEditable.js +24 -0
- package/ui/ContentEditable.js.map +1 -0
- package/ui/Divider.js.map +1 -1
- package/ui/DropDown.js.map +1 -1
- package/ui/ImageResizer.d.ts +26 -0
- package/ui/ImageResizer.js +213 -0
- package/ui/ImageResizer.js.map +1 -0
- package/ui/LinkPreview.js +7 -7
- package/ui/LinkPreview.js.map +1 -1
- package/ui/Placeholder.css +2 -5
- package/ui/Placeholder.d.ts +3 -1
- package/ui/Placeholder.js +5 -1
- package/ui/Placeholder.js.map +1 -1
- package/ui/TextInput.js.map +1 -1
- package/ui/ToolbarActionDialog.js.map +1 -1
- package/utils/canUseDOM.d.ts +1 -0
- package/utils/canUseDOM.js +8 -0
- package/utils/canUseDOM.js.map +1 -0
- package/utils/files.d.ts +12 -0
- package/utils/files.js +62 -0
- package/utils/files.js.map +1 -0
- package/utils/findTypographyStyleByHtmlTag.js.map +1 -1
- package/utils/generateInitialLexicalValue.js.map +1 -1
- package/utils/getDOMRangeRect.js.map +1 -1
- package/utils/getLexicalTextSelectionState.js.map +1 -1
- package/utils/getSelectedNode.js.map +1 -1
- package/utils/getTransparentImage.d.ts +1 -0
- package/utils/getTransparentImage.js +10 -0
- package/utils/getTransparentImage.js.map +1 -0
- package/{plugins/AutoLinkPlugin/AutoLinkPlugin.d.ts → utils/isHTMLElement.d.ts} +3 -4
- package/utils/isHTMLElement.js +16 -0
- package/utils/isHTMLElement.js.map +1 -0
- package/utils/isValidJSON.js.map +1 -1
- package/utils/isValidLexicalData.js.map +1 -1
- package/utils/nodes/clearNodeFormating.js.map +1 -1
- package/utils/nodes/formatToHeading.js.map +1 -1
- package/utils/nodes/formatToParagraph.js.map +1 -1
- package/utils/nodes/formatToQuote.js.map +1 -1
- package/utils/nodes/insertImage.d.ts +2 -0
- package/utils/nodes/insertImage.js +22 -0
- package/utils/nodes/insertImage.js.map +1 -0
- package/utils/nodes/listNode.js.map +1 -1
- package/utils/point.js +0 -3
- package/utils/point.js.map +1 -1
- package/utils/rect.js +0 -5
- package/utils/rect.js.map +1 -1
- package/utils/sanitizeUrl.js.map +1 -1
- package/utils/setFloatingElemPosition.js.map +1 -1
- package/utils/styleObjectToString.js.map +1 -1
- package/utils/toTypographyEmotionMap.d.ts +1 -1
- package/utils/toTypographyEmotionMap.js +7 -2
- package/utils/toTypographyEmotionMap.js.map +1 -1
- package/components/AddRichTextEditorNodeType.d.ts +0 -6
- package/components/AddRichTextEditorNodeType.js +0 -28
- package/components/AddRichTextEditorNodeType.js.map +0 -1
- package/components/AddRichTextEditorPlugin.d.ts +0 -12
- package/components/AddRichTextEditorPlugin.js +0 -33
- package/components/AddRichTextEditorPlugin.js.map +0 -1
- package/components/AddToolbarAction.d.ts +0 -7
- package/components/AddToolbarAction.js +0 -33
- package/components/AddToolbarAction.js.map +0 -1
- package/components/Toolbar/HeadingToolbar.d.ts +0 -12
- package/components/Toolbar/HeadingToolbar.js +0 -23
- package/components/Toolbar/HeadingToolbar.js.map +0 -1
- package/components/Toolbar/ParagraphToolbar.d.ts +0 -12
- package/components/Toolbar/ParagraphToolbar.js +0 -23
- package/components/Toolbar/ParagraphToolbar.js.map +0 -1
- package/components/ToolbarPresets/HeadingToolbarPreset.d.ts +0 -2
- package/components/ToolbarPresets/HeadingToolbarPreset.js +0 -56
- package/components/ToolbarPresets/HeadingToolbarPreset.js.map +0 -1
- package/components/ToolbarPresets/ParagraphToolbarPreset.d.ts +0 -2
- package/components/ToolbarPresets/ParagraphToolbarPreset.js +0 -71
- package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +0 -1
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.js +0 -46
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.js.map +0 -1
- package/plugins/AutoLinkPlugin/index.d.ts +0 -1
- package/plugins/AutoLinkPlugin/index.js +0 -16
- package/plugins/AutoLinkPlugin/index.js.map +0 -1
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.d.ts +0 -17
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js +0 -88
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js.map +0 -1
- package/plugins/ClickableLinkPlugin/index.d.ts +0 -1
- package/plugins/ClickableLinkPlugin/index.js +0 -16
- package/plugins/ClickableLinkPlugin/index.js.map +0 -1
- package/plugins/WebinyListPLugin/WebinyListPlugin.d.ts +0 -1
- package/plugins/WebinyListPLugin/WebinyListPlugin.js.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LexicalCommand, LexicalEditor, NodeKey } from "lexical";
|
|
2
|
+
export interface ImagePayload {
|
|
3
|
+
id: string;
|
|
4
|
+
altText: string;
|
|
5
|
+
caption?: LexicalEditor;
|
|
6
|
+
height?: number;
|
|
7
|
+
key?: NodeKey;
|
|
8
|
+
maxWidth?: number;
|
|
9
|
+
showCaption?: boolean;
|
|
10
|
+
src: string;
|
|
11
|
+
width?: number;
|
|
12
|
+
captionsEnabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const INSERT_IMAGE_COMMAND: LexicalCommand<ImagePayload>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.INSERT_IMAGE_COMMAND = void 0;
|
|
7
|
+
var _lexical = require("lexical");
|
|
8
|
+
var INSERT_IMAGE_COMMAND = (0, _lexical.createCommand)("INSERT_IMAGE_COMMAND");
|
|
9
|
+
exports.INSERT_IMAGE_COMMAND = INSERT_IMAGE_COMMAND;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_lexical","require","INSERT_IMAGE_COMMAND","createCommand","exports"],"sources":["insertFiles.ts"],"sourcesContent":["import { createCommand, LexicalCommand, LexicalEditor, NodeKey } from \"lexical\";\n\nexport interface ImagePayload {\n id: string;\n altText: string;\n caption?: LexicalEditor;\n height?: number;\n key?: NodeKey;\n maxWidth?: number;\n showCaption?: boolean;\n src: string;\n width?: number;\n captionsEnabled?: boolean;\n}\n\nexport const INSERT_IMAGE_COMMAND: LexicalCommand<ImagePayload> =\n createCommand(\"INSERT_IMAGE_COMMAND\");\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAeO,IAAMC,oBAAkD,GAC3D,IAAAC,sBAAa,EAAC,sBAAsB,CAAC;AAACC,OAAA,CAAAF,oBAAA,GAAAA,oBAAA"}
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"names":["_lexical","require","INSERT_UNORDERED_WEBINY_LIST_COMMAND","createCommand","exports","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,IAAAA,QAAA,GAAAC,OAAA;AAMO,IAAMC,oCAA8E,GACvF,IAAAC,sBAAa,EAAC,sCAAsC,CAAC;AAACC,OAAA,CAAAF,oCAAA,GAAAA,oCAAA;AACnD,IAAMG,kCAA4E,GACrF,IAAAF,sBAAa,EAAC,oCAAoC,CAAC;AAACC,OAAA,CAAAC,kCAAA,GAAAA,kCAAA;AAEjD,IAAMC,0BAAgD,GAAG,IAAAH,sBAAa,EACzE,4BACJ,CAAC;AAACC,OAAA,CAAAE,0BAAA,GAAAA,0BAAA"}
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"names":["_lexical","require","INSERT_WEBINY_QUOTE_COMMAND","createCommand","exports"],"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,IAAAA,QAAA,GAAAC,OAAA;AAMO,IAAMC,2BAAsE,GAAG,IAAAC,sBAAa,EAC/F,6BACJ,CAAC;AAACC,OAAA,CAAAF,2BAAA,GAAAA,2BAAA"}
|
|
@@ -7,23 +7,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.HeadingEditor = void 0;
|
|
8
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _LexicalLinkPlugin = require("@lexical/react/LexicalLinkPlugin");
|
|
11
|
-
var _ClickableLinkPlugin = require("../../plugins/ClickableLinkPlugin/ClickableLinkPlugin");
|
|
12
|
-
var _FloatingLinkEditorPlugin = require("../../plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin");
|
|
13
|
-
var _HeadingToolbar = require("../Toolbar/HeadingToolbar");
|
|
14
10
|
var _RichTextEditor = require("./RichTextEditor");
|
|
15
|
-
var
|
|
11
|
+
var _Toolbar = require("../Toolbar/Toolbar");
|
|
16
12
|
var _excluded = ["tag", "placeholder"];
|
|
17
13
|
var HeadingEditor = function HeadingEditor(_ref) {
|
|
18
14
|
var tag = _ref.tag,
|
|
19
15
|
placeholder = _ref.placeholder,
|
|
20
16
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
21
17
|
return /*#__PURE__*/_react.default.createElement(_RichTextEditor.RichTextEditor, Object.assign({
|
|
22
|
-
toolbar: /*#__PURE__*/_react.default.createElement(
|
|
18
|
+
toolbar: /*#__PURE__*/_react.default.createElement(_Toolbar.Toolbar, null),
|
|
23
19
|
tag: tag !== null && tag !== void 0 ? tag : "h1",
|
|
24
20
|
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Enter your heading text here..."
|
|
25
|
-
}, rest
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
}, rest, {
|
|
22
|
+
styles: {
|
|
23
|
+
padding: 5
|
|
24
|
+
}
|
|
25
|
+
}), rest === null || rest === void 0 ? void 0 : rest.children);
|
|
28
26
|
};
|
|
29
27
|
exports.HeadingEditor = HeadingEditor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HeadingEditor","tag","placeholder","rest","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_RichTextEditor","_Toolbar","_excluded","HeadingEditor","_ref","tag","placeholder","rest","_objectWithoutProperties2","default","createElement","RichTextEditor","Object","assign","toolbar","Toolbar","styles","padding","children","exports"],"sources":["HeadingEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { RichTextEditor, RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\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={<Toolbar />}\n tag={tag ?? \"h1\"}\n placeholder={placeholder ?? \"Enter your heading text here...\"}\n {...rest}\n styles={{ padding: 5 }}\n >\n {rest?.children}\n </RichTextEditor>\n );\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAAuD,IAAAG,SAAA;AAMhD,IAAMC,aAA2C,GAAG,SAA9CA,aAA2CA,CAAAC,IAAA,EAAsC;EAAA,IAAhCC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IAAKC,IAAI,OAAAC,yBAAA,CAAAC,OAAA,EAAAL,IAAA,EAAAF,SAAA;EACnF,oBACIL,MAAA,CAAAY,OAAA,CAAAC,aAAA,CAACV,eAAA,CAAAW,cAAc,EAAAC,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAEjB,MAAA,CAAAY,OAAA,CAAAC,aAAA,CAACT,QAAA,CAAAc,OAAO,MAAE,CAAE;IACrBV,GAAG,EAAEA,GAAG,aAAHA,GAAG,cAAHA,GAAG,GAAI,IAAK;IACjBC,WAAW,EAAEA,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAI;EAAkC,GAC1DC,IAAI;IACRS,MAAM,EAAE;MAAEC,OAAO,EAAE;IAAE;EAAE,IAEtBV,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEW,QACK,CAAC;AAEzB,CAAC;AAACC,OAAA,CAAAhB,aAAA,GAAAA,aAAA"}
|
|
@@ -7,24 +7,21 @@ 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 _CodeHighlightPlugin = require("../../plugins/CodeHighlightPlugin/CodeHighlightPlugin");
|
|
11
|
-
var _LexicalLinkPlugin = require("@lexical/react/LexicalLinkPlugin");
|
|
12
|
-
var _FloatingLinkEditorPlugin = require("../../plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin");
|
|
13
|
-
var _ClickableLinkPlugin = require("../../plugins/ClickableLinkPlugin/ClickableLinkPlugin");
|
|
14
|
-
var _ParagraphToolbar = require("../Toolbar/ParagraphToolbar");
|
|
15
10
|
var _RichTextEditor = require("./RichTextEditor");
|
|
16
|
-
var
|
|
11
|
+
var _Toolbar = require("../Toolbar/Toolbar");
|
|
17
12
|
var _excluded = ["placeholder", "tag"];
|
|
18
13
|
var ParagraphEditor = function ParagraphEditor(_ref) {
|
|
19
14
|
var placeholder = _ref.placeholder,
|
|
20
15
|
tag = _ref.tag,
|
|
21
16
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
22
17
|
return /*#__PURE__*/_react.default.createElement(_RichTextEditor.RichTextEditor, Object.assign({
|
|
23
|
-
toolbar: /*#__PURE__*/_react.default.createElement(
|
|
18
|
+
toolbar: /*#__PURE__*/_react.default.createElement(_Toolbar.Toolbar, null),
|
|
24
19
|
tag: tag !== null && tag !== void 0 ? tag : "p",
|
|
25
20
|
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Enter your text here..."
|
|
26
|
-
}, rest
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
}, rest, {
|
|
22
|
+
styles: {
|
|
23
|
+
padding: 5
|
|
24
|
+
}
|
|
25
|
+
}), rest === null || rest === void 0 ? void 0 : rest.children);
|
|
29
26
|
};
|
|
30
27
|
exports.ParagraphEditor = ParagraphEditor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ParagraphEditor","placeholder","tag","rest","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_RichTextEditor","_Toolbar","_excluded","ParagraphEditor","_ref","placeholder","tag","rest","_objectWithoutProperties2","default","createElement","RichTextEditor","Object","assign","toolbar","Toolbar","styles","padding","children","exports"],"sources":["ParagraphEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { RichTextEditor, RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\n\ninterface ParagraphLexicalEditorProps extends RichTextEditorProps {\n tag?: \"p\";\n}\n\nconst ParagraphEditor: React.FC<ParagraphLexicalEditorProps> = ({ placeholder, tag, ...rest }) => {\n return (\n <RichTextEditor\n toolbar={<Toolbar />}\n tag={tag ?? \"p\"}\n placeholder={placeholder ?? \"Enter your text here...\"}\n {...rest}\n styles={{ padding: 5 }}\n >\n {rest?.children}\n </RichTextEditor>\n );\n};\n\nexport { ParagraphEditor };\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAAuD,IAAAG,SAAA;AAMvD,IAAMC,eAAsD,GAAG,SAAzDA,eAAsDA,CAAAC,IAAA,EAAsC;EAAA,IAAhCC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IAAEC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IAAKC,IAAI,OAAAC,yBAAA,CAAAC,OAAA,EAAAL,IAAA,EAAAF,SAAA;EACvF,oBACIL,MAAA,CAAAY,OAAA,CAAAC,aAAA,CAACV,eAAA,CAAAW,cAAc,EAAAC,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAEjB,MAAA,CAAAY,OAAA,CAAAC,aAAA,CAACT,QAAA,CAAAc,OAAO,MAAE,CAAE;IACrBT,GAAG,EAAEA,GAAG,aAAHA,GAAG,cAAHA,GAAG,GAAI,GAAI;IAChBD,WAAW,EAAEA,WAAW,aAAXA,WAAW,cAAXA,WAAW,GAAI;EAA0B,GAClDE,IAAI;IACRS,MAAM,EAAE;MAAEC,OAAO,EAAE;IAAE;EAAE,IAEtBV,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEW,QACK,CAAC;AAEzB,CAAC;AAACC,OAAA,CAAAhB,eAAA,GAAAA,eAAA"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { LexicalValue, ThemeEmotionMap } from "../../types";
|
|
2
|
+
import { LexicalValue, ThemeEmotionMap, ToolbarActionPlugin } from "../../types";
|
|
3
3
|
import { Klass, LexicalNode } from "lexical";
|
|
4
4
|
import { WebinyTheme } from "../../themes/webinyLexicalTheme";
|
|
5
|
+
import { CSSObject } from "@emotion/react";
|
|
5
6
|
export interface RichTextEditorProps {
|
|
6
7
|
toolbar?: React.ReactNode;
|
|
8
|
+
staticToolbar?: React.ReactNode;
|
|
9
|
+
toolbarActionPlugins?: ToolbarActionPlugin[];
|
|
7
10
|
tag?: string;
|
|
8
11
|
onChange?: (json: LexicalValue) => void;
|
|
9
12
|
value: LexicalValue | null;
|
|
@@ -18,7 +21,12 @@ export interface RichTextEditorProps {
|
|
|
18
21
|
height?: number | string;
|
|
19
22
|
width?: number | string;
|
|
20
23
|
theme: WebinyTheme;
|
|
24
|
+
themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;
|
|
21
25
|
themeEmotionMap?: ThemeEmotionMap;
|
|
26
|
+
placeholderStyles?: React.CSSProperties;
|
|
27
|
+
styles?: React.CSSProperties;
|
|
28
|
+
contentEditableStyles?: React.CSSProperties;
|
|
29
|
+
classes?: string;
|
|
22
30
|
}
|
|
23
31
|
/**
|
|
24
32
|
* @description Main editor container
|
|
@@ -24,18 +24,17 @@ var _RichTextEditorContext = require("../../context/RichTextEditorContext");
|
|
|
24
24
|
var _isValidLexicalData = require("../../utils/isValidLexicalData");
|
|
25
25
|
var _LexicalUpdateStatePlugin = require("../../plugins/LexicalUpdateStatePlugin");
|
|
26
26
|
var _BlurEventPlugin = require("../../plugins/BlurEventPlugin/BlurEventPlugin");
|
|
27
|
-
var _FontColorPlugin = require("../../plugins/FontColorPlugin/FontColorPlugin");
|
|
28
27
|
var _webinyLexicalTheme = require("../../themes/webinyLexicalTheme");
|
|
29
28
|
var _webinyNodes = require("../../nodes/webinyNodes");
|
|
30
|
-
var _TypographyPlugin = require("../../plugins/TypographyPlugin/TypographyPlugin");
|
|
31
|
-
var _WebinyQuoteNodePlugin = require("../../plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin");
|
|
32
29
|
var _LexicalHistoryPlugin = require("@lexical/react/LexicalHistoryPlugin");
|
|
33
30
|
var _SharedHistoryContext = require("../../context/SharedHistoryContext");
|
|
34
31
|
var _useRichTextEditor2 = require("../../hooks/useRichTextEditor");
|
|
35
32
|
var _react2 = require("@emotion/react");
|
|
36
33
|
var _toTypographyEmotionMap = require("../../utils/toTypographyEmotionMap");
|
|
34
|
+
var _LexicalEditorConfig = require("../LexicalEditorConfig/LexicalEditorConfig");
|
|
37
35
|
var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
38
36
|
var toolbar = _ref.toolbar,
|
|
37
|
+
staticToolbar = _ref.staticToolbar,
|
|
39
38
|
onChange = _ref.onChange,
|
|
40
39
|
value = _ref.value,
|
|
41
40
|
nodes = _ref.nodes,
|
|
@@ -43,13 +42,20 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
43
42
|
children = _ref.children,
|
|
44
43
|
onBlur = _ref.onBlur,
|
|
45
44
|
focus = _ref.focus,
|
|
45
|
+
styles = _ref.styles,
|
|
46
46
|
width = _ref.width,
|
|
47
47
|
height = _ref.height,
|
|
48
48
|
theme = _ref.theme,
|
|
49
|
-
themeEmotionMap = _ref.themeEmotionMap
|
|
49
|
+
themeEmotionMap = _ref.themeEmotionMap,
|
|
50
|
+
toolbarActionPlugins = _ref.toolbarActionPlugins,
|
|
51
|
+
contentEditableStyles = _ref.contentEditableStyles,
|
|
52
|
+
placeholderStyles = _ref.placeholderStyles;
|
|
53
|
+
var config = (0, _LexicalEditorConfig.useLexicalEditorConfig)();
|
|
50
54
|
var _useSharedHistoryCont = (0, _SharedHistoryContext.useSharedHistoryContext)(),
|
|
51
55
|
historyState = _useSharedHistoryCont.historyState;
|
|
52
|
-
var placeholderElem = /*#__PURE__*/_react.default.createElement(_Placeholder.Placeholder,
|
|
56
|
+
var placeholderElem = /*#__PURE__*/_react.default.createElement(_Placeholder.Placeholder, {
|
|
57
|
+
styles: placeholderStyles
|
|
58
|
+
}, placeholder || "Enter text...");
|
|
53
59
|
var scrollRef = (0, _react.useRef)(null);
|
|
54
60
|
var _useState = (0, _react.useState)(undefined),
|
|
55
61
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -57,11 +63,17 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
57
63
|
setFloatingAnchorElem = _useState2[1];
|
|
58
64
|
var _useRichTextEditor = (0, _useRichTextEditor2.useRichTextEditor)(),
|
|
59
65
|
setTheme = _useRichTextEditor.setTheme,
|
|
60
|
-
setThemeEmotionMap = _useRichTextEditor.setThemeEmotionMap
|
|
66
|
+
setThemeEmotionMap = _useRichTextEditor.setThemeEmotionMap,
|
|
67
|
+
setToolbarActionPlugins = _useRichTextEditor.setToolbarActionPlugins;
|
|
61
68
|
(0, _react.useEffect)(function () {
|
|
62
69
|
setTheme(theme);
|
|
63
70
|
setThemeEmotionMap(themeEmotionMap);
|
|
64
|
-
}, [themeEmotionMap]);
|
|
71
|
+
}, [themeEmotionMap, theme]);
|
|
72
|
+
(0, _react.useEffect)(function () {
|
|
73
|
+
if (toolbarActionPlugins) {
|
|
74
|
+
setToolbarActionPlugins(toolbarActionPlugins || []);
|
|
75
|
+
}
|
|
76
|
+
}, [toolbarActionPlugins]);
|
|
65
77
|
var onRef = function onRef(_floatingAnchorElem) {
|
|
66
78
|
if (_floatingAnchorElem !== null) {
|
|
67
79
|
setFloatingAnchorElem(_floatingAnchorElem);
|
|
@@ -71,13 +83,21 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
71
83
|
height: height || "",
|
|
72
84
|
width: width || ""
|
|
73
85
|
};
|
|
86
|
+
var configNodes = config.nodes.map(function (node) {
|
|
87
|
+
return node.node;
|
|
88
|
+
});
|
|
89
|
+
var configPlugins = config.plugins.map(function (plugin) {
|
|
90
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
91
|
+
key: plugin.name
|
|
92
|
+
}, plugin.element);
|
|
93
|
+
});
|
|
74
94
|
var initialConfig = {
|
|
75
95
|
editorState: (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)(),
|
|
76
96
|
namespace: "webiny",
|
|
77
97
|
onError: function onError(error) {
|
|
78
98
|
throw error;
|
|
79
99
|
},
|
|
80
|
-
nodes: [].concat((0, _toConsumableArray2.default)(_webinyNodes.WebinyNodes), (0, _toConsumableArray2.default)(nodes || [])),
|
|
100
|
+
nodes: [].concat((0, _toConsumableArray2.default)(_webinyNodes.WebinyNodes), (0, _toConsumableArray2.default)(configNodes), (0, _toConsumableArray2.default)(nodes || [])),
|
|
81
101
|
theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _webinyLexicalTheme.webinyEditorTheme), {}, {
|
|
82
102
|
emotionMap: themeEmotionMap
|
|
83
103
|
})
|
|
@@ -86,53 +106,54 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
86
106
|
editorState.read(function () {
|
|
87
107
|
if (typeof onChange === "function") {
|
|
88
108
|
var _editorState = editor.getEditorState();
|
|
89
|
-
//TODO: send plain JSON object
|
|
90
109
|
onChange(JSON.stringify(_editorState.toJSON()));
|
|
91
110
|
}
|
|
92
111
|
});
|
|
93
112
|
}
|
|
94
113
|
return /*#__PURE__*/_react.default.createElement(_LexicalComposer.LexicalComposer, {
|
|
95
114
|
initialConfig: initialConfig
|
|
96
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
115
|
+
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, staticToolbar && staticToolbar, /*#__PURE__*/_react.default.createElement("div", {
|
|
116
|
+
className: "editor-shell",
|
|
97
117
|
ref: scrollRef,
|
|
98
|
-
style: (0, _objectSpread2.default)({}, sizeStyle)
|
|
118
|
+
style: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, styles), sizeStyle), {}, {
|
|
119
|
+
overflow: "auto"
|
|
120
|
+
})
|
|
99
121
|
}, /*#__PURE__*/_react.default.createElement(_LexicalOnChangePlugin.OnChangePlugin, {
|
|
100
122
|
onChange: handleOnChange
|
|
101
123
|
}), value && /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.LexicalUpdateStatePlugin, {
|
|
102
124
|
value: value
|
|
103
|
-
}), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null), /*#__PURE__*/_react.default.createElement(
|
|
125
|
+
}), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null), /*#__PURE__*/_react.default.createElement(_LexicalHistoryPlugin.HistoryPlugin, {
|
|
104
126
|
externalHistoryState: historyState
|
|
105
127
|
}), onBlur && /*#__PURE__*/_react.default.createElement(_BlurEventPlugin.BlurEventPlugin, {
|
|
106
128
|
onBlur: onBlur
|
|
107
|
-
}), focus && /*#__PURE__*/_react.default.createElement(_LexicalAutoFocusPlugin.AutoFocusPlugin, null), children, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
|
|
129
|
+
}), focus && /*#__PURE__*/_react.default.createElement(_LexicalAutoFocusPlugin.AutoFocusPlugin, null), configPlugins, children, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
|
|
108
130
|
contentEditable: /*#__PURE__*/_react.default.createElement("div", {
|
|
109
131
|
className: "editor-scroller",
|
|
110
132
|
style: (0, _objectSpread2.default)({}, sizeStyle)
|
|
111
133
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
112
134
|
className: "editor",
|
|
113
|
-
ref: onRef
|
|
114
|
-
style: (0, _objectSpread2.default)({}, sizeStyle)
|
|
135
|
+
ref: onRef
|
|
115
136
|
}, /*#__PURE__*/_react.default.createElement(_LexicalContentEditable.ContentEditable, {
|
|
116
137
|
style: (0, _objectSpread2.default)({
|
|
117
138
|
outline: 0
|
|
118
|
-
},
|
|
139
|
+
}, contentEditableStyles)
|
|
119
140
|
}))),
|
|
120
141
|
placeholder: placeholderElem,
|
|
121
142
|
ErrorBoundary: _LexicalErrorBoundary.default
|
|
122
|
-
}), floatingAnchorElem && toolbar));
|
|
143
|
+
}), floatingAnchorElem && toolbar)));
|
|
123
144
|
};
|
|
124
145
|
|
|
125
146
|
/**
|
|
126
147
|
* @description Main editor container
|
|
127
148
|
*/
|
|
128
149
|
var RichTextEditor = (0, _reactComposition.makeComposable)("RichTextEditor", function (props) {
|
|
129
|
-
return /*#__PURE__*/_react.default.createElement(_RichTextEditorContext.RichTextEditorProvider, null, /*#__PURE__*/_react.default.createElement(_react2.ClassNames, null, function (_ref2) {
|
|
150
|
+
return /*#__PURE__*/_react.default.createElement(_LexicalEditorConfig.LexicalEditorWithConfig, null, /*#__PURE__*/_react.default.createElement(_RichTextEditorContext.RichTextEditorProvider, null, /*#__PURE__*/_react.default.createElement(_react2.ClassNames, null, function (_ref2) {
|
|
130
151
|
var _props$themeEmotionMa;
|
|
131
152
|
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);
|
|
153
|
+
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, props.themeStylesTransformer);
|
|
133
154
|
return /*#__PURE__*/_react.default.createElement(_SharedHistoryContext.SharedHistoryContext, null, /*#__PURE__*/_react.default.createElement(BaseRichTextEditor, Object.assign({}, props, {
|
|
134
155
|
themeEmotionMap: themeEmotionMap
|
|
135
156
|
})));
|
|
136
|
-
}));
|
|
157
|
+
})));
|
|
137
158
|
});
|
|
138
159
|
exports.RichTextEditor = RichTextEditor;
|
|
@@ -1 +1 @@
|
|
|
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 { QuotePlugin } 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 <QuotePlugin />\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;A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,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,EAAEb,eAAgB;IAC7B,aAAa,EAAEgC;EAAqB,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"}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_Placeholder","_generateInitialLexicalValue","_LexicalComposer","_LexicalOnChangePlugin","_LexicalAutoFocusPlugin","_LexicalClearEditorPlugin","_LexicalRichTextPlugin","_LexicalErrorBoundary","_interopRequireDefault","_reactComposition","_LexicalContentEditable","_RichTextEditorContext","_isValidLexicalData","_LexicalUpdateStatePlugin","_BlurEventPlugin","_webinyLexicalTheme","_webinyNodes","_LexicalHistoryPlugin","_SharedHistoryContext","_useRichTextEditor2","_react2","_toTypographyEmotionMap","_LexicalEditorConfig","BaseRichTextEditor","_ref","toolbar","staticToolbar","onChange","value","nodes","placeholder","children","onBlur","focus","styles","width","height","theme","themeEmotionMap","toolbarActionPlugins","contentEditableStyles","placeholderStyles","config","useLexicalEditorConfig","_useSharedHistoryCont","useSharedHistoryContext","historyState","placeholderElem","default","createElement","Placeholder","scrollRef","useRef","_useState","useState","undefined","_useState2","_slicedToArray2","floatingAnchorElem","setFloatingAnchorElem","_useRichTextEditor","useRichTextEditor","setTheme","setThemeEmotionMap","setToolbarActionPlugins","useEffect","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","Fragment","key","name","element","initialConfig","editorState","isValidLexicalData","generateInitialLexicalValue","namespace","onError","error","concat","_toConsumableArray2","WebinyNodes","_objectSpread2","webinyEditorTheme","emotionMap","handleOnChange","editor","read","getEditorState","JSON","stringify","toJSON","LexicalComposer","className","ref","style","overflow","OnChangePlugin","LexicalUpdateStatePlugin","ClearEditorPlugin","HistoryPlugin","externalHistoryState","BlurEventPlugin","AutoFocusPlugin","RichTextPlugin","contentEditable","ContentEditable","outline","ErrorBoundary","LexicalErrorBoundary","RichTextEditor","makeComposable","props","LexicalEditorWithConfig","RichTextEditorProvider","ClassNames","_ref2","_props$themeEmotionMa","css","toTypographyEmotionMap","themeStylesTransformer","SharedHistoryContext","Object","assign","exports"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useEffect, useRef, useState } from \"react\";\nimport { LexicalValue, ThemeEmotionMap, ToolbarActionPlugin } 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 { webinyEditorTheme, WebinyTheme } from \"~/themes/webinyLexicalTheme\";\nimport { WebinyNodes } from \"~/nodes/webinyNodes\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\nimport { ClassNames, CSSObject } from \"@emotion/react\";\nimport { toTypographyEmotionMap } from \"~/utils/toTypographyEmotionMap\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig\";\n\nexport interface RichTextEditorProps {\n toolbar?: React.ReactNode;\n staticToolbar?: React.ReactNode;\n toolbarActionPlugins?: ToolbarActionPlugin[];\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 themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;\n themeEmotionMap?: ThemeEmotionMap;\n\n placeholderStyles?: React.CSSProperties;\n /*\n * Set inline styles to lexical editor container\n * */\n styles?: React.CSSProperties;\n\n /*\n * Set inline styles to lexical editor editable content\n * */\n contentEditableStyles?: React.CSSProperties;\n\n /*\n * Set classes to lexical input container\n * */\n classes?: string;\n}\n\nconst BaseRichTextEditor: React.FC<RichTextEditorProps> = ({\n toolbar,\n staticToolbar,\n onChange,\n value,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n height,\n theme,\n themeEmotionMap,\n toolbarActionPlugins,\n contentEditableStyles,\n placeholderStyles\n}: RichTextEditorProps) => {\n const config = useLexicalEditorConfig();\n const { historyState } = useSharedHistoryContext();\n const placeholderElem = (\n <Placeholder styles={placeholderStyles}>{placeholder || \"Enter text...\"}</Placeholder>\n );\n const scrollRef = useRef(null);\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n const { setTheme, setThemeEmotionMap, setToolbarActionPlugins } = useRichTextEditor();\n\n useEffect(() => {\n setTheme(theme);\n setThemeEmotionMap(themeEmotionMap);\n }, [themeEmotionMap, theme]);\n\n useEffect(() => {\n if (toolbarActionPlugins) {\n setToolbarActionPlugins(toolbarActionPlugins || []);\n }\n }, [toolbarActionPlugins]);\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 configNodes = config.nodes.map(node => node.node);\n const configPlugins = config.plugins.map(plugin => (\n <Fragment key={plugin.name}>{plugin.element}</Fragment>\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, ...configNodes, ...(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 onChange(JSON.stringify(editorState.toJSON()));\n }\n });\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig}>\n <>\n {staticToolbar && staticToolbar}\n <div\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{ ...styles, ...sizeStyle, overflow: \"auto\" }}\n >\n {/* data */}\n <OnChangePlugin onChange={handleOnChange} />\n {value && <LexicalUpdateStatePlugin value={value} />}\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Events */}\n {onBlur && <BlurEventPlugin onBlur={onBlur} />}\n {focus && <AutoFocusPlugin />}\n {/* External plugins and components */}\n {configPlugins}\n {children}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\" style={{ ...sizeStyle }}>\n <div className=\"editor\" ref={onRef}>\n <ContentEditable\n style={{ outline: 0, ...contentEditableStyles }}\n />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar */}\n {floatingAnchorElem && toolbar}\n </div>\n </>\n </LexicalComposer>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeComposable<RichTextEditorProps>(\"RichTextEditor\", props => {\n return (\n <LexicalEditorWithConfig>\n <RichTextEditorProvider>\n <ClassNames>\n {({ css }) => {\n const themeEmotionMap =\n props?.themeEmotionMap ??\n toTypographyEmotionMap(css, props.theme, props.themeStylesTransformer);\n return (\n <SharedHistoryContext>\n <BaseRichTextEditor {...props} themeEmotionMap={themeEmotionMap} />\n </SharedHistoryContext>\n );\n }}\n </ClassNames>\n </RichTextEditorProvider>\n </LexicalEditorWithConfig>\n );\n});\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,4BAAA,GAAAF,OAAA;AAGA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA;AACA,IAAAM,yBAAA,GAAAN,OAAA;AACA,IAAAO,sBAAA,GAAAP,OAAA;AACA,IAAAQ,qBAAA,GAAAC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KAAK,EAAEkF,KAAK,CAACQ,sBAAsB,CAAC;IAC1E,oBACIlI,MAAA,CAAAmD,OAAA,CAAAC,aAAA,CAAC/B,qBAAA,CAAA8G,oBAAoB,qBACjBnI,MAAA,CAAAmD,OAAA,CAAAC,aAAA,CAAC1B,kBAAkB,EAAA0G,MAAA,CAAAC,MAAA,KAAKX,KAAK;MAAEjF,eAAe,EAAEA;IAAgB,EAAE,CAChD,CAAC;EAE/B,CACQ,CACQ,CACH,CAAC;AAElC,CAAC,CAAC;AAAC6F,OAAA,CAAAd,cAAA,GAAAA,cAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
/// <reference types="react" />
|
|
9
|
+
import type { LexicalEditor, NodeKey } from "lexical";
|
|
10
|
+
import "~/nodes/imageNode.css";
|
|
11
|
+
export default function ImageComponent({ id, src, altText, nodeKey, width, height, maxWidth, resizable, showCaption, caption, captionsEnabled }: {
|
|
12
|
+
id: string;
|
|
13
|
+
altText: string;
|
|
14
|
+
caption: LexicalEditor;
|
|
15
|
+
height: "inherit" | number;
|
|
16
|
+
maxWidth: number;
|
|
17
|
+
nodeKey: NodeKey;
|
|
18
|
+
resizable: boolean;
|
|
19
|
+
showCaption: boolean;
|
|
20
|
+
src: string;
|
|
21
|
+
width: "inherit" | number;
|
|
22
|
+
captionsEnabled: boolean;
|
|
23
|
+
}): JSX.Element;
|