@webiny/lexical-editor 5.37.5 → 5.37.6-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/insertFiles.js +1 -3
- package/commands/webiny-list.js +1 -3
- package/commands/webiny-quote.js +1 -3
- package/components/Editor/HeadingEditor.js +1 -3
- package/components/Editor/ParagraphEditor.js +1 -3
- package/components/Editor/RichTextEditor.d.ts +15 -18
- package/components/Editor/RichTextEditor.js +43 -34
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/ImageComponent.js +1 -3
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +1 -3
- package/components/LexicalEditorConfig/components/Node.js +1 -3
- package/components/LexicalEditorConfig/components/Plugin.js +1 -3
- package/components/LexicalEditorConfig/components/ToolbarElement.js +1 -3
- package/components/LexicalHtmlRenderer.js +1 -3
- package/components/Toolbar/StaticToolbar.js +1 -3
- package/components/Toolbar/Toolbar.js +1 -3
- package/components/ToolbarActions/BoldAction.js +1 -3
- package/components/ToolbarActions/BulletListAction.js +1 -3
- package/components/ToolbarActions/CodeHighlightAction.js +1 -3
- package/components/ToolbarActions/FontColorAction.js +1 -3
- package/components/ToolbarActions/FontSizeAction.js +1 -3
- package/components/ToolbarActions/ImageAction.js +1 -3
- package/components/ToolbarActions/ItalicAction.js +1 -3
- package/components/ToolbarActions/LinkAction.js +1 -3
- package/components/ToolbarActions/NumberedListAction.js +1 -3
- package/components/ToolbarActions/QuoteAction.js +1 -3
- package/components/ToolbarActions/TextAlignmentAction.js +1 -3
- package/components/ToolbarActions/TypographyAction.js +1 -3
- package/components/ToolbarActions/UnderlineAction.js +1 -3
- package/context/FontColorActionContext.js +1 -3
- package/context/RichTextEditorContext.js +1 -3
- package/context/SharedHistoryContext.js +1 -3
- package/context/TextAlignmentActionContextProps.js +1 -3
- package/context/TypographyActionContext.js +1 -3
- package/hooks/useFontColorPicker.js +1 -3
- package/hooks/useList.js +1 -3
- package/hooks/useQuote.js +1 -3
- package/hooks/useRichTextEditor.js +1 -3
- package/hooks/useTextAlignmentAction.js +1 -3
- package/hooks/useTypographyAction.js +1 -3
- package/index.js +1 -3
- package/nodes/FontColorNode.js +1 -3
- package/nodes/HeadingNode.js +1 -3
- package/nodes/ImageNode.js +1 -3
- package/nodes/ListItemNode.js +1 -3
- package/nodes/ListNode/formatList.js +1 -3
- package/nodes/ListNode.js +1 -3
- package/nodes/ParagraphNode.js +1 -3
- package/nodes/QuoteNode.js +1 -3
- package/nodes/TypographyElementNode.js +1 -3
- package/nodes/link-node.js +1 -3
- package/nodes/types.js +1 -3
- package/nodes/webinyNodes.js +1 -3
- package/package.json +6 -6
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +1 -3
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +1 -3
- package/plugins/CodeHighlightPlugin/index.js +1 -3
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +1 -3
- package/plugins/FloatingLinkEditorPlugin/index.js +1 -3
- package/plugins/FontColorPlugin/FontColorPlugin.js +1 -3
- package/plugins/ImagesPlugin/ImagesPlugin.js +1 -3
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js +1 -3
- package/plugins/LexicalUpdateStatePlugin/index.js +1 -3
- package/plugins/ListPLugin/ListPlugin.js +1 -3
- package/plugins/TypographyPlugin/TypographyPlugin.js +1 -3
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js +1 -3
- package/themes/webinyLexicalTheme.js +1 -3
- package/types.js +1 -3
- package/ui/ContentEditable.js +1 -3
- package/ui/Divider.js +1 -3
- package/ui/DropDown.js +1 -3
- package/ui/ImageResizer.js +1 -3
- package/ui/LinkPreview.js +1 -3
- package/ui/Placeholder.js +1 -3
- package/ui/TextInput.js +1 -3
- package/ui/ToolbarActionDialog.js +1 -3
- package/utils/canUseDOM.js +1 -3
- package/utils/files.js +1 -3
- package/utils/findTypographyStyleByHtmlTag.js +1 -3
- package/utils/generateInitialLexicalValue.js +1 -3
- package/utils/getDOMRangeRect.js +1 -3
- package/utils/getLexicalTextSelectionState.js +1 -3
- package/utils/getSelectedNode.js +1 -3
- package/utils/getTransparentImage.js +1 -3
- package/utils/isHTMLElement.js +1 -3
- package/utils/isUrlLinkReference.js +1 -3
- package/utils/isValidJSON.js +1 -3
- package/utils/isValidLexicalData.js +1 -3
- package/utils/nodes/clearNodeFormating.js +1 -3
- package/utils/nodes/formatToHeading.js +1 -3
- package/utils/nodes/formatToParagraph.js +1 -3
- package/utils/nodes/formatToQuote.js +1 -3
- package/utils/nodes/insertImage.js +1 -3
- package/utils/nodes/listNode.js +1 -3
- package/utils/point.js +1 -3
- package/utils/rect.js +1 -3
- package/utils/sanitizeUrl.js +1 -3
- package/utils/setFloatingElemPosition.js +1 -3
- package/utils/styleObjectToString.js +1 -3
- package/utils/toTypographyEmotionMap.js +1 -3
package/commands/insertFiles.js
CHANGED
|
@@ -6,6 +6,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.INSERT_IMAGE_COMMAND = void 0;
|
|
7
7
|
var _lexical = require("lexical");
|
|
8
8
|
var INSERT_IMAGE_COMMAND = (0, _lexical.createCommand)("INSERT_IMAGE_COMMAND");
|
|
9
|
-
exports.INSERT_IMAGE_COMMAND = INSERT_IMAGE_COMMAND;
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=insertFiles.js.map
|
|
9
|
+
exports.INSERT_IMAGE_COMMAND = INSERT_IMAGE_COMMAND;
|
package/commands/webiny-list.js
CHANGED
|
@@ -10,6 +10,4 @@ exports.INSERT_UNORDERED_WEBINY_LIST_COMMAND = INSERT_UNORDERED_WEBINY_LIST_COMM
|
|
|
10
10
|
var INSERT_ORDERED_WEBINY_LIST_COMMAND = (0, _lexical.createCommand)("INSERT_ORDERED_WEBINY_LIST_COMMAND");
|
|
11
11
|
exports.INSERT_ORDERED_WEBINY_LIST_COMMAND = INSERT_ORDERED_WEBINY_LIST_COMMAND;
|
|
12
12
|
var REMOVE_WEBINY_LIST_COMMAND = (0, _lexical.createCommand)("REMOVE_WEBINY_LIST_COMMAND");
|
|
13
|
-
exports.REMOVE_WEBINY_LIST_COMMAND = REMOVE_WEBINY_LIST_COMMAND;
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=webiny-list.js.map
|
|
13
|
+
exports.REMOVE_WEBINY_LIST_COMMAND = REMOVE_WEBINY_LIST_COMMAND;
|
package/commands/webiny-quote.js
CHANGED
|
@@ -6,6 +6,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.INSERT_WEBINY_QUOTE_COMMAND = void 0;
|
|
7
7
|
var _lexical = require("lexical");
|
|
8
8
|
var INSERT_WEBINY_QUOTE_COMMAND = (0, _lexical.createCommand)("INSERT_WEBINY_QUOTE_COMMAND");
|
|
9
|
-
exports.INSERT_WEBINY_QUOTE_COMMAND = INSERT_WEBINY_QUOTE_COMMAND;
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=webiny-quote.js.map
|
|
9
|
+
exports.INSERT_WEBINY_QUOTE_COMMAND = INSERT_WEBINY_QUOTE_COMMAND;
|
|
@@ -24,6 +24,4 @@ var ParagraphEditor = function ParagraphEditor(_ref) {
|
|
|
24
24
|
}
|
|
25
25
|
}), rest === null || rest === void 0 ? void 0 : rest.children);
|
|
26
26
|
};
|
|
27
|
-
exports.ParagraphEditor = ParagraphEditor;
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=ParagraphEditor.js.map
|
|
27
|
+
exports.ParagraphEditor = ParagraphEditor;
|
|
@@ -4,29 +4,26 @@ import { Klass, LexicalNode } from "lexical";
|
|
|
4
4
|
import { LexicalValue, ThemeEmotionMap, ToolbarActionPlugin } from "../../types";
|
|
5
5
|
import { WebinyTheme } from "../../themes/webinyLexicalTheme";
|
|
6
6
|
export interface RichTextEditorProps {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
tag?: string;
|
|
11
|
-
onChange?: (json: LexicalValue) => void;
|
|
12
|
-
value: LexicalValue | null;
|
|
7
|
+
children?: React.ReactNode | React.ReactNode[];
|
|
8
|
+
classes?: string;
|
|
9
|
+
contentEditableStyles?: React.CSSProperties;
|
|
13
10
|
focus?: boolean;
|
|
14
|
-
|
|
11
|
+
height?: number | string;
|
|
15
12
|
nodes?: Klass<LexicalNode>[];
|
|
16
|
-
/**
|
|
17
|
-
* @description Lexical plugins
|
|
18
|
-
*/
|
|
19
|
-
children?: React.ReactNode | React.ReactNode[];
|
|
20
13
|
onBlur?: (editorState: LexicalValue) => void;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
theme: WebinyTheme;
|
|
24
|
-
themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;
|
|
25
|
-
themeEmotionMap?: ThemeEmotionMap;
|
|
14
|
+
onChange?: (json: LexicalValue) => void;
|
|
15
|
+
placeholder?: string;
|
|
26
16
|
placeholderStyles?: React.CSSProperties;
|
|
17
|
+
staticToolbar?: React.ReactNode;
|
|
27
18
|
styles?: React.CSSProperties;
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
tag?: string;
|
|
20
|
+
theme: WebinyTheme;
|
|
21
|
+
themeEmotionMap?: ThemeEmotionMap;
|
|
22
|
+
themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;
|
|
23
|
+
toolbar?: React.ReactNode;
|
|
24
|
+
toolbarActionPlugins?: ToolbarActionPlugin[];
|
|
25
|
+
value: LexicalValue | null;
|
|
26
|
+
width?: number | string;
|
|
30
27
|
}
|
|
31
28
|
/**
|
|
32
29
|
* @description Main editor container
|
|
@@ -110,37 +110,48 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
113
|
+
return (
|
|
114
|
+
/*#__PURE__*/
|
|
115
|
+
/**
|
|
116
|
+
* Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future
|
|
117
|
+
* updates to the config will be ignored. This is a problem because we pull in Nodes from our config,
|
|
118
|
+
* and initially, there can be multiple re-renders, while the config object is settled.
|
|
119
|
+
*
|
|
120
|
+
* To bypass this issue, we generate a naive `key` based on the number of Nodes.
|
|
121
|
+
*/
|
|
122
|
+
_react.default.createElement(_LexicalComposer.LexicalComposer, {
|
|
123
|
+
initialConfig: initialConfig,
|
|
124
|
+
key: initialConfig.nodes.length
|
|
125
|
+
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, staticToolbar && staticToolbar, /*#__PURE__*/_react.default.createElement("div", {
|
|
126
|
+
ref: scrollRef,
|
|
127
|
+
style: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, styles), sizeStyle), {}, {
|
|
128
|
+
overflow: "auto",
|
|
129
|
+
position: "relative"
|
|
130
|
+
})
|
|
131
|
+
}, /*#__PURE__*/_react.default.createElement(_LexicalOnChangePlugin.OnChangePlugin, {
|
|
132
|
+
onChange: handleOnChange
|
|
133
|
+
}), value && /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.LexicalUpdateStatePlugin, {
|
|
134
|
+
value: value
|
|
135
|
+
}), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null), /*#__PURE__*/_react.default.createElement(_LexicalHistoryPlugin.HistoryPlugin, {
|
|
136
|
+
externalHistoryState: historyState
|
|
137
|
+
}), onBlur && /*#__PURE__*/_react.default.createElement(_BlurEventPlugin.BlurEventPlugin, {
|
|
138
|
+
onBlur: onBlur
|
|
139
|
+
}), focus && /*#__PURE__*/_react.default.createElement(_LexicalAutoFocusPlugin.AutoFocusPlugin, null), configPlugins, children, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
|
|
140
|
+
contentEditable: /*#__PURE__*/_react.default.createElement("div", {
|
|
141
|
+
className: "editor-scroller",
|
|
142
|
+
style: (0, _objectSpread2.default)({}, sizeStyle)
|
|
143
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
144
|
+
className: "editor",
|
|
145
|
+
ref: onRef
|
|
146
|
+
}, /*#__PURE__*/_react.default.createElement(_LexicalContentEditable.ContentEditable, {
|
|
147
|
+
style: (0, _objectSpread2.default)({
|
|
148
|
+
outline: 0
|
|
149
|
+
}, contentEditableStyles)
|
|
150
|
+
}))),
|
|
151
|
+
placeholder: placeholderElem,
|
|
152
|
+
ErrorBoundary: _LexicalErrorBoundary.default
|
|
153
|
+
}), floatingAnchorElem && toolbar)))
|
|
154
|
+
);
|
|
144
155
|
};
|
|
145
156
|
|
|
146
157
|
/**
|
|
@@ -156,6 +167,4 @@ var RichTextEditor = (0, _reactComposition.makeComposable)("RichTextEditor", fun
|
|
|
156
167
|
})));
|
|
157
168
|
})));
|
|
158
169
|
});
|
|
159
|
-
exports.RichTextEditor = RichTextEditor;
|
|
160
|
-
|
|
161
|
-
//# sourceMappingURL=RichTextEditor.js.map
|
|
170
|
+
exports.RichTextEditor = RichTextEditor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_react2","_LexicalComposer","_LexicalOnChangePlugin","_LexicalAutoFocusPlugin","_LexicalClearEditorPlugin","_LexicalRichTextPlugin","_LexicalErrorBoundary","_interopRequireDefault","_reactComposition","_LexicalHistoryPlugin","_LexicalContentEditable","_RichTextEditorContext","_isValidLexicalData","_LexicalUpdateStatePlugin","_BlurEventPlugin","_Placeholder","_generateInitialLexicalValue","_webinyLexicalTheme","_webinyNodes","_SharedHistoryContext","_useRichTextEditor2","_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","ref","style","overflow","position","OnChangePlugin","LexicalUpdateStatePlugin","ClearEditorPlugin","HistoryPlugin","externalHistoryState","BlurEventPlugin","AutoFocusPlugin","RichTextPlugin","contentEditable","className","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 { ClassNames, CSSObject } from \"@emotion/react\";\nimport { Klass, LexicalEditor, LexicalNode } from \"lexical\";\nimport { EditorState } from \"lexical/LexicalEditorState\";\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 { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\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 { LexicalValue, ThemeEmotionMap, ToolbarActionPlugin } from \"~/types\";\nimport { Placeholder } from \"~/ui/Placeholder\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { webinyEditorTheme, WebinyTheme } from \"~/themes/webinyLexicalTheme\";\nimport { WebinyNodes } from \"~/nodes/webinyNodes\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\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 ref={scrollRef}\n style={{ ...styles, ...sizeStyle, overflow: \"auto\", position: \"relative\" }}\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;AACA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C,KAAA,EAAa;IAAA,IAAAC,qBAAA;IAAA,IAAVC,GAAG,GAAAF,KAAA,CAAHE,GAAG;IACH,IAAMxF,eAAe,IAAAuF,qBAAA,GACjBL,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAElF,eAAe,cAAAuF,qBAAA,cAAAA,qBAAA,GACtB,IAAAE,8CAAsB,EAACD,GAAG,EAAEN,KAAK,CAACnF,KAAK,EAAEmF,KAAK,CAACQ,sBAAsB,CAAC;IAC1E,oBACInI,MAAA,CAAAmD,OAAA,CAAAC,aAAA,CAAC9B,qBAAA,CAAA8G,oBAAoB,qBACjBpI,MAAA,CAAAmD,OAAA,CAAAC,aAAA,CAAC1B,kBAAkB,EAAA2G,MAAA,CAAAC,MAAA,KAAKX,KAAK;MAAElF,eAAe,EAAEA;IAAgB,EAAE,CAChD,CAAC;EAE/B,CACQ,CACQ,CACH,CAAC;AAElC,CAAC,CAAC;AAAC8F,OAAA,CAAAd,cAAA,GAAAA,cAAA"}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_react2","_LexicalComposer","_LexicalOnChangePlugin","_LexicalAutoFocusPlugin","_LexicalClearEditorPlugin","_LexicalRichTextPlugin","_LexicalErrorBoundary","_interopRequireDefault","_reactComposition","_LexicalHistoryPlugin","_LexicalContentEditable","_RichTextEditorContext","_isValidLexicalData","_LexicalUpdateStatePlugin","_BlurEventPlugin","_Placeholder","_generateInitialLexicalValue","_webinyLexicalTheme","_webinyNodes","_SharedHistoryContext","_useRichTextEditor2","_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","length","ref","style","overflow","position","OnChangePlugin","LexicalUpdateStatePlugin","ClearEditorPlugin","HistoryPlugin","externalHistoryState","BlurEventPlugin","AutoFocusPlugin","RichTextPlugin","contentEditable","className","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 { ClassNames, CSSObject } from \"@emotion/react\";\nimport { Klass, LexicalEditor, LexicalNode } from \"lexical\";\nimport { EditorState } from \"lexical/LexicalEditorState\";\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 { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\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 { LexicalValue, ThemeEmotionMap, ToolbarActionPlugin } from \"~/types\";\nimport { Placeholder } from \"~/ui/Placeholder\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { webinyEditorTheme, WebinyTheme } from \"~/themes/webinyLexicalTheme\";\nimport { WebinyNodes } from \"~/nodes/webinyNodes\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext\";\nimport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\nimport { toTypographyEmotionMap } from \"~/utils/toTypographyEmotionMap\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig\";\n\nexport interface RichTextEditorProps {\n children?: React.ReactNode | React.ReactNode[];\n classes?: string;\n contentEditableStyles?: React.CSSProperties;\n focus?: boolean;\n height?: number | string;\n nodes?: Klass<LexicalNode>[];\n onBlur?: (editorState: LexicalValue) => void;\n onChange?: (json: LexicalValue) => void;\n placeholder?: string;\n placeholderStyles?: React.CSSProperties;\n staticToolbar?: React.ReactNode;\n styles?: React.CSSProperties;\n tag?: string;\n theme: WebinyTheme;\n themeEmotionMap?: ThemeEmotionMap;\n themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;\n toolbar?: React.ReactNode;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n value: LexicalValue | null;\n width?: number | 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 /**\n * Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future\n * updates to the config will be ignored. This is a problem because we pull in Nodes from our config,\n * and initially, there can be multiple re-renders, while the config object is settled.\n *\n * To bypass this issue, we generate a naive `key` based on the number of Nodes.\n */\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <>\n {staticToolbar && staticToolbar}\n <div\n ref={scrollRef}\n style={{ ...styles, ...sizeStyle, overflow: \"auto\", position: \"relative\" }}\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;AACA,IAAAC,OAAA,GAAAD,OAAA;AAGA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,uBAAA,GAAAJ,OAAA;AACA,IAAAK,yBAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,qBAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AACA,IAAAU,qBAAA,GAAAV,OAAA;AACA,IAAAW,uBAAA,GAAAX,OAAA;AACA,IAAAY,sBAAA,GAAAZ,OAAA;AACA,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B,CAAC;IAC1E,oBACIpI,MAAA,CAAAmD,OAAA,CAAAC,aAAA,CAAC9B,qBAAA,CAAA+G,oBAAoB,qBACjBrI,MAAA,CAAAmD,OAAA,CAAAC,aAAA,CAAC1B,kBAAkB,EAAA4G,MAAA,CAAAC,MAAA,KAAKX,KAAK;MAAEnF,eAAe,EAAEA;IAAgB,EAAE,CAChD,CAAC;EAE/B,CACQ,CACQ,CACH,CAAC;AAElC,CAAC,CAAC;AAAC+F,OAAA,CAAAd,cAAA,GAAAA,cAAA"}
|
|
@@ -67,6 +67,4 @@ var TextAlignmentAction = function TextAlignmentAction() {
|
|
|
67
67
|
}, /*#__PURE__*/_react.default.createElement(BaseTextAlignmentDropDown, null));
|
|
68
68
|
};
|
|
69
69
|
exports.TextAlignmentAction = TextAlignmentAction;
|
|
70
|
-
TextAlignmentAction.TextAlignmentDropDown = TextAlignmentActionDropDown;
|
|
71
|
-
|
|
72
|
-
//# sourceMappingURL=TextAlignmentAction.js.map
|
|
70
|
+
TextAlignmentAction.TextAlignmentDropDown = TextAlignmentActionDropDown;
|
|
@@ -142,6 +142,4 @@ exports.TypographyAction = TypographyAction;
|
|
|
142
142
|
{
|
|
143
143
|
/* Typography dropdown settings */
|
|
144
144
|
}
|
|
145
|
-
TypographyAction.TypographyDropDown = TypographyActionDropDown;
|
|
146
|
-
|
|
147
|
-
//# sourceMappingURL=TypographyAction.js.map
|
|
145
|
+
TypographyAction.TypographyDropDown = TypographyActionDropDown;
|
|
@@ -7,6 +7,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.FontColorActionContext = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var FontColorActionContext = /*#__PURE__*/_react.default.createContext(undefined);
|
|
10
|
-
exports.FontColorActionContext = FontColorActionContext;
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=FontColorActionContext.js.map
|
|
10
|
+
exports.FontColorActionContext = FontColorActionContext;
|
|
@@ -71,6 +71,4 @@ var RichTextEditorProvider = function RichTextEditorProvider(_ref) {
|
|
|
71
71
|
}
|
|
72
72
|
}, children);
|
|
73
73
|
};
|
|
74
|
-
exports.RichTextEditorProvider = RichTextEditorProvider;
|
|
75
|
-
|
|
76
|
-
//# sourceMappingURL=RichTextEditorContext.js.map
|
|
74
|
+
exports.RichTextEditorProvider = RichTextEditorProvider;
|
|
@@ -23,6 +23,4 @@ exports.SharedHistoryContext = SharedHistoryContext;
|
|
|
23
23
|
var useSharedHistoryContext = function useSharedHistoryContext() {
|
|
24
24
|
return (0, React.useContext)(Context);
|
|
25
25
|
};
|
|
26
|
-
exports.useSharedHistoryContext = useSharedHistoryContext;
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=SharedHistoryContext.js.map
|
|
26
|
+
exports.useSharedHistoryContext = useSharedHistoryContext;
|
|
@@ -7,6 +7,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.TextAlignmentActionContext = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var TextAlignmentActionContext = /*#__PURE__*/_react.default.createContext(undefined);
|
|
10
|
-
exports.TextAlignmentActionContext = TextAlignmentActionContext;
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=TextAlignmentActionContextProps.js.map
|
|
10
|
+
exports.TextAlignmentActionContext = TextAlignmentActionContext;
|
|
@@ -7,6 +7,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.TypographyActionContext = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var TypographyActionContext = /*#__PURE__*/_react.default.createContext(undefined);
|
|
10
|
-
exports.TypographyActionContext = TypographyActionContext;
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=TypographyActionContext.js.map
|
|
10
|
+
exports.TypographyActionContext = TypographyActionContext;
|
package/hooks/useList.js
CHANGED
package/hooks/useQuote.js
CHANGED
|
@@ -12,6 +12,4 @@ function useTextAlignmentAction() {
|
|
|
12
12
|
throw Error("Missing TextAlignmentActionContext in the component hierarchy. Are you using \"useTextAlignmentAction()\" in the right place?");
|
|
13
13
|
}
|
|
14
14
|
return context;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=useTextAlignmentAction.js.map
|
|
15
|
+
}
|
package/index.js
CHANGED
|
@@ -298,6 +298,4 @@ var _clearNodeFormating = require("./utils/nodes/clearNodeFormating");
|
|
|
298
298
|
var _insertFiles = require("./commands/insertFiles");
|
|
299
299
|
var _types = _interopRequireWildcard(require("./types"));
|
|
300
300
|
exports.types = _types;
|
|
301
|
-
var _LexicalEditorConfig = require("./components/LexicalEditorConfig/LexicalEditorConfig");
|
|
302
|
-
|
|
303
|
-
//# sourceMappingURL=index.js.map
|
|
301
|
+
var _LexicalEditorConfig = require("./components/LexicalEditorConfig/LexicalEditorConfig");
|
package/nodes/FontColorNode.js
CHANGED
package/nodes/HeadingNode.js
CHANGED
package/nodes/ImageNode.js
CHANGED
package/nodes/ListItemNode.js
CHANGED