@webiny/lexical-editor 5.40.6 → 5.41.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.
@@ -1,5 +1,5 @@
1
1
  import { LexicalCommand } from "lexical";
2
- export declare type ListCommandPayload = {
2
+ export type ListCommandPayload = {
3
3
  themeStyleId?: string;
4
4
  };
5
5
  export declare const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload>;
@@ -1,5 +1,5 @@
1
1
  import { LexicalCommand } from "lexical";
2
- export declare type QuoteCommandPayload = {
2
+ export type QuoteCommandPayload = {
3
3
  themeStyleId: string;
4
4
  };
5
5
  export declare const INSERT_QUOTE_COMMAND: LexicalCommand<QuoteCommandPayload>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * In the "Heading" editor, we only want to support heading tags.
3
+ * However, when the editor is empty, and you start typing, Lexical automatically creates an empty "paragraph" node.
4
+ * This ensures that any paragraph node is automatically converted to a heading node.
5
+ */
6
+ export declare const EnsureHeadingTagPlugin: () => null;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EnsureHeadingTagPlugin = void 0;
7
+ var _react = require("react");
8
+ var _lexicalNodes = require("@webiny/lexical-nodes");
9
+ var _hooks = require("../../hooks");
10
+ /**
11
+ * In the "Heading" editor, we only want to support heading tags.
12
+ * However, when the editor is empty, and you start typing, Lexical automatically creates an empty "paragraph" node.
13
+ * This ensures that any paragraph node is automatically converted to a heading node.
14
+ */
15
+ var EnsureHeadingTagPlugin = exports.EnsureHeadingTagPlugin = function EnsureHeadingTagPlugin() {
16
+ var _useRichTextEditor = (0, _hooks.useRichTextEditor)(),
17
+ editor = _useRichTextEditor.editor;
18
+ (0, _react.useEffect)(function () {
19
+ return editor.registerNodeTransform(_lexicalNodes.ParagraphNode, function (node) {
20
+ node.replace((0, _lexicalNodes.$createHeadingNode)("h1"), true);
21
+ });
22
+ }, []);
23
+ return null;
24
+ };
25
+
26
+ //# sourceMappingURL=EnsureHeadingTagPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_lexicalNodes","_hooks","EnsureHeadingTagPlugin","exports","_useRichTextEditor","useRichTextEditor","editor","useEffect","registerNodeTransform","ParagraphNode","node","replace","$createHeadingNode"],"sources":["EnsureHeadingTagPlugin.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { ParagraphNode, $createHeadingNode } from \"@webiny/lexical-nodes\";\nimport { useRichTextEditor } from \"~/hooks\";\n\n/**\n * In the \"Heading\" editor, we only want to support heading tags.\n * However, when the editor is empty, and you start typing, Lexical automatically creates an empty \"paragraph\" node.\n * This ensures that any paragraph node is automatically converted to a heading node.\n */\nexport const EnsureHeadingTagPlugin = () => {\n const { editor } = useRichTextEditor();\n\n useEffect(\n () =>\n editor.registerNodeTransform(ParagraphNode, node => {\n node.replace($createHeadingNode(\"h1\"), true);\n }),\n []\n );\n return null;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACO,IAAMG,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,SAAzBA,sBAAsBA,CAAA,EAAS;EACxC,IAAAE,kBAAA,GAAmB,IAAAC,wBAAiB,EAAC,CAAC;IAA9BC,MAAM,GAAAF,kBAAA,CAANE,MAAM;EAEd,IAAAC,gBAAS,EACL;IAAA,OACID,MAAM,CAACE,qBAAqB,CAACC,2BAAa,EAAE,UAAAC,IAAI,EAAI;MAChDA,IAAI,CAACC,OAAO,CAAC,IAAAC,gCAAkB,EAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IAChD,CAAC,CAAC;EAAA,GACN,EACJ,CAAC;EACD,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
@@ -9,6 +9,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _RichTextEditor = require("./RichTextEditor");
11
11
  var _Toolbar = require("../Toolbar/Toolbar");
12
+ var _EnsureHeadingTagPlugin = require("./EnsureHeadingTagPlugin");
12
13
  var _excluded = ["tag", "placeholder"];
13
14
  var styles = {
14
15
  padding: 5
@@ -23,7 +24,7 @@ var HeadingEditor = exports.HeadingEditor = function HeadingEditor(_ref) {
23
24
  placeholder: placeholder ?? "Enter your heading text here..."
24
25
  }, rest, {
25
26
  styles: styles
26
- }), rest?.children);
27
+ }), /*#__PURE__*/_react.default.createElement(_EnsureHeadingTagPlugin.EnsureHeadingTagPlugin, null), rest?.children);
27
28
  };
28
29
 
29
30
  //# sourceMappingURL=HeadingEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_RichTextEditor","_Toolbar","_excluded","styles","padding","HeadingEditor","exports","_ref","tag","placeholder","rest","_objectWithoutProperties2","default","createElement","RichTextEditor","Object","assign","toolbar","Toolbar","children"],"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\nconst styles = { padding: 5 };\n\nexport const HeadingEditor = ({ tag, placeholder, ...rest }: HeadingEditorProps) => {\n return (\n <RichTextEditor\n toolbar={<Toolbar />}\n tag={tag ?? \"h1\"}\n placeholder={placeholder ?? \"Enter your heading text here...\"}\n {...rest}\n styles={styles}\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;AAMvD,IAAMC,MAAM,GAAG;EAAEC,OAAO,EAAE;AAAE,CAAC;AAEtB,IAAMC,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,SAAhBA,aAAaA,CAAAE,IAAA,EAA0D;EAAA,IAApDC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IAAKC,IAAI,OAAAC,yBAAA,CAAAC,OAAA,EAAAL,IAAA,EAAAL,SAAA;EACrD,oBACIL,MAAA,CAAAe,OAAA,CAAAC,aAAA,CAACb,eAAA,CAAAc,cAAc,EAAAC,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAEpB,MAAA,CAAAe,OAAA,CAAAC,aAAA,CAACZ,QAAA,CAAAiB,OAAO,MAAE,CAAE;IACrBV,GAAG,EAAEA,GAAG,IAAI,IAAK;IACjBC,WAAW,EAAEA,WAAW,IAAI;EAAkC,GAC1DC,IAAI;IACRP,MAAM,EAAEA;EAAO,IAEdO,IAAI,EAAES,QACK,CAAC;AAEzB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_RichTextEditor","_Toolbar","_EnsureHeadingTagPlugin","_excluded","styles","padding","HeadingEditor","exports","_ref","tag","placeholder","rest","_objectWithoutProperties2","default","createElement","RichTextEditor","Object","assign","toolbar","Toolbar","EnsureHeadingTagPlugin","children"],"sources":["HeadingEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { RichTextEditor, RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\nimport { EnsureHeadingTagPlugin } from \"~/components/Editor/EnsureHeadingTagPlugin\";\n\ninterface HeadingEditorProps extends RichTextEditorProps {\n tag?: \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n}\n\nconst styles = { padding: 5 };\n\nexport const HeadingEditor = ({ tag, placeholder, ...rest }: HeadingEditorProps) => {\n return (\n <RichTextEditor\n toolbar={<Toolbar />}\n tag={tag ?? \"h1\"}\n placeholder={placeholder ?? \"Enter your heading text here...\"}\n {...rest}\n styles={styles}\n >\n <EnsureHeadingTagPlugin />\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;AACA,IAAAG,uBAAA,GAAAH,OAAA;AAAoF,IAAAI,SAAA;AAMpF,IAAMC,MAAM,GAAG;EAAEC,OAAO,EAAE;AAAE,CAAC;AAEtB,IAAMC,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,SAAhBA,aAAaA,CAAAE,IAAA,EAA0D;EAAA,IAApDC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IAAKC,IAAI,OAAAC,yBAAA,CAAAC,OAAA,EAAAL,IAAA,EAAAL,SAAA;EACrD,oBACIN,MAAA,CAAAgB,OAAA,CAAAC,aAAA,CAACd,eAAA,CAAAe,cAAc,EAAAC,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAErB,MAAA,CAAAgB,OAAA,CAAAC,aAAA,CAACb,QAAA,CAAAkB,OAAO,MAAE,CAAE;IACrBV,GAAG,EAAEA,GAAG,IAAI,IAAK;IACjBC,WAAW,EAAEA,WAAW,IAAI;EAAkC,GAC1DC,IAAI;IACRP,MAAM,EAAEA;EAAO,iBAEfP,MAAA,CAAAgB,OAAA,CAAAC,aAAA,CAACZ,uBAAA,CAAAkB,sBAAsB,MAAE,CAAC,EACzBT,IAAI,EAAEU,QACK,CAAC;AAEzB,CAAC","ignoreList":[]}
@@ -24,14 +24,27 @@ export interface RichTextEditorProps {
24
24
  toolbar?: React.ReactNode;
25
25
  value: LexicalValue | null | undefined;
26
26
  width?: number | string;
27
+ generateInitialValue?: () => LexicalValue;
27
28
  }
28
29
  /**
29
30
  * @description Main editor container
30
31
  */
31
- export declare const RichTextEditor: import("@webiny/react-composition").GenericComponent<RichTextEditorProps> & {
32
- original: import("@webiny/react-composition").GenericComponent<RichTextEditorProps>;
32
+ export declare const RichTextEditor: ((props: RichTextEditorProps) => React.JSX.Element) & {
33
+ original: (props: RichTextEditorProps) => React.JSX.Element;
33
34
  originalName: string;
34
35
  displayName: string;
35
36
  } & {
36
- createDecorator: (decorator: import("@webiny/react-composition").Decorator<(props: RichTextEditorProps) => JSX.Element | null>) => (props: unknown) => React.JSX.Element;
37
+ original: ((props: RichTextEditorProps) => React.JSX.Element) & {
38
+ original: (props: RichTextEditorProps) => React.JSX.Element;
39
+ originalName: string;
40
+ displayName: string;
41
+ };
42
+ originalName: string;
43
+ displayName: string;
44
+ } & {
45
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<((props: RichTextEditorProps) => React.JSX.Element) & {
46
+ original: (props: RichTextEditorProps) => React.JSX.Element;
47
+ originalName: string;
48
+ displayName: string;
49
+ }>) => (props: unknown) => React.JSX.Element;
37
50
  };
@@ -33,7 +33,7 @@ var _generateInitialLexicalValue = require("../../utils/generateInitialLexicalVa
33
33
  var _SharedHistoryContext = require("../../context/SharedHistoryContext");
34
34
  var _LexicalEditorConfig = require("../LexicalEditorConfig/LexicalEditorConfig");
35
35
  var _normalizeInputValue = require("./normalizeInputValue");
36
- var _excluded = ["toolbar", "staticToolbar", "onChange", "nodes", "placeholder", "children", "onBlur", "focus", "styles", "width", "height", "contentEditableStyles", "placeholderStyles"];
36
+ var _excluded = ["toolbar", "staticToolbar", "onChange", "nodes", "placeholder", "children", "onBlur", "focus", "styles", "width", "height", "contentEditableStyles", "placeholderStyles", "generateInitialValue"];
37
37
  var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
38
38
  var toolbar = _ref.toolbar,
39
39
  staticToolbar = _ref.staticToolbar,
@@ -48,6 +48,8 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
48
48
  height = _ref.height,
49
49
  contentEditableStyles = _ref.contentEditableStyles,
50
50
  placeholderStyles = _ref.placeholderStyles,
51
+ _ref$generateInitialV = _ref.generateInitialValue,
52
+ generateInitialValue = _ref$generateInitialV === void 0 ? _generateInitialLexicalValue.generateInitialLexicalValue : _ref$generateInitialV,
51
53
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
52
54
  var themeEmotionMap = props.themeEmotionMap ?? (0, _lexicalTheme.toTypographyEmotionMap)(_emotion.css, props.theme, props.themeStylesTransformer);
53
55
  var editorTheme = (0, _react.useRef)((0, _lexicalTheme.createTheme)());
@@ -80,7 +82,7 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
80
82
  }, plugin.element);
81
83
  });
82
84
  var value = (0, _normalizeInputValue.normalizeInputValue)(props.value);
83
- var editorValue = (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)();
85
+ var editorValue = (0, _isValidLexicalData.isValidLexicalData)(value) ? value : generateInitialValue();
84
86
  var initialConfig = {
85
87
  editorState: null,
86
88
  namespace: "webiny",
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_emotion","_LexicalComposer","_text","_LexicalOnChangePlugin","_LexicalAutoFocusPlugin","_LexicalClearEditorPlugin","_LexicalRichTextPlugin","_LexicalErrorBoundary","_reactComposition","_LexicalHistoryPlugin","_LexicalContentEditable","_lexicalTheme","_lexicalNodes","_RichTextEditorContext","_isValidLexicalData","_LexicalUpdateStatePlugin","_BlurEventPlugin","_Placeholder","_generateInitialLexicalValue","_SharedHistoryContext","_LexicalEditorConfig","_normalizeInputValue","_excluded","BaseRichTextEditor","_ref","toolbar","staticToolbar","onChange","nodes","placeholder","children","onBlur","focus","styles","width","height","contentEditableStyles","placeholderStyles","props","_objectWithoutProperties2","default","themeEmotionMap","toTypographyEmotionMap","css","theme","themeStylesTransformer","editorTheme","useRef","createTheme","config","useLexicalEditorConfig","_useSharedHistoryCont","useSharedHistoryContext","historyState","placeholderElem","createElement","Placeholder","scrollRef","_useState","useState","undefined","_useState2","_slicedToArray2","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","Fragment","key","name","element","value","normalizeInputValue","editorValue","isValidLexicalData","generateInitialLexicalValue","initialConfig","editorState","namespace","onError","concat","_toConsumableArray2","allNodes","_objectSpread2","current","emotionMap","handleOnChange","editor","read","getEditorState","isEditorEmpty","$isRootTextContentEmpty","isComposing","newValue","JSON","stringify","toJSON","SharedHistoryContext","LexicalComposer","length","RichTextEditorProvider","toolbarActionPlugins","className","ref","style","overflow","position","OnChangePlugin","UpdateStatePlugin","ClearEditorPlugin","HistoryPlugin","externalHistoryState","BlurEventPlugin","AutoFocusPlugin","RichTextPlugin","contentEditable","ContentEditable","outline","ErrorBoundary","LexicalErrorBoundary","RichTextEditor","exports","makeDecoratable","LexicalEditorWithConfig"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useRef, useState } from \"react\";\nimport { css } from \"emotion\";\nimport { CSSObject } from \"@emotion/react\";\nimport { Klass, LexicalEditor, LexicalNode } from \"lexical\";\nimport { EditorState } from \"lexical/LexicalEditorState\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { $isRootTextContentEmpty } from \"@lexical/text\";\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 { makeDecoratable } from \"@webiny/react-composition\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport {\n createTheme,\n WebinyTheme,\n ThemeEmotionMap,\n toTypographyEmotionMap\n} from \"@webiny/lexical-theme\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { UpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin\";\nimport { LexicalValue, ToolbarActionPlugin } from \"~/types\";\nimport { Placeholder } from \"~/ui/Placeholder\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig\";\nimport { normalizeInputValue } from \"./normalizeInputValue\";\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 toolbarActionPlugins?: ToolbarActionPlugin[];\n themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;\n toolbar?: React.ReactNode;\n value: LexicalValue | null | undefined;\n width?: number | string;\n}\n\nconst BaseRichTextEditor = ({\n toolbar,\n staticToolbar,\n onChange,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n height,\n contentEditableStyles,\n placeholderStyles,\n ...props\n}: RichTextEditorProps) => {\n const themeEmotionMap =\n props.themeEmotionMap ??\n toTypographyEmotionMap(css, props.theme, props.themeStylesTransformer);\n\n const editorTheme = useRef(createTheme());\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 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 value = normalizeInputValue(props.value);\n const editorValue = isValidLexicalData(value) ? value : generateInitialLexicalValue();\n\n const initialConfig = {\n editorState: null,\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n nodes: [...allNodes, ...configNodes, ...(nodes || [])],\n theme: { ...editorTheme.current, 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 const isEditorEmpty = $isRootTextContentEmpty(editor.isComposing(), true);\n\n const newValue = JSON.stringify(editorState.toJSON());\n\n // We don't want to call \"onChange\" if editor text is empty, and original `value` is empty.\n if (!value && isEditorEmpty) {\n return;\n }\n\n if (value !== newValue) {\n onChange(newValue);\n }\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 <SharedHistoryContext>\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider\n theme={props.theme}\n themeEmotionMap={themeEmotionMap}\n toolbarActionPlugins={props.toolbarActionPlugins}\n >\n {staticToolbar ? staticToolbar : null}\n <div\n /* This className is necessary for targeting of editor container from CSS files. */\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{ ...styles, ...sizeStyle, overflow: \"auto\", position: \"relative\" }}\n >\n {/* State plugins. */}\n <OnChangePlugin onChange={handleOnChange} />\n <UpdateStatePlugin value={editorValue} />\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Event plugins. */}\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 </RichTextEditorProvider>\n </LexicalComposer>\n </SharedHistoryContext>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeDecoratable(\"RichTextEditor\", (props: RichTextEditorProps) => {\n return (\n <LexicalEditorWithConfig>\n <BaseRichTextEditor {...props} />\n </LexicalEditorWithConfig>\n );\n});\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAIA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,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,GAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AACA,IAAAU,qBA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,CAAAe,aAAA,CAACvC,gBAAA,CAAAuG,eAAe;MAACxF,MAAM,EAAEA;IAAO,CAAE,CAAC,EAC7CC,KAAK,iBAAInC,MAAA,CAAA2C,OAAA,CAAAe,aAAA,CAACnD,uBAAA,CAAAoH,eAAe,MAAE,CAAC,EAE5BjD,aAAa,EACbzC,QAAQ,eACTjC,MAAA,CAAA2C,OAAA,CAAAe,aAAA,CAACjD,sBAAA,CAAAmH,cAAc;MACXC,eAAe,eACX7H,MAAA,CAAA2C,OAAA,CAAAe,aAAA;QAAKsD,SAAS,EAAC,iBAAiB;QAACE,KAAK,MAAArB,cAAA,CAAAlD,OAAA,MAAO2B,SAAS;MAAG,gBACrDtE,MAAA,CAAA2C,OAAA,CAAAe,aAAA;QAAKsD,SAAS,EAAC,QAAQ;QAACC,GAAG,EAAE7C;MAAM,gBAC/BpE,MAAA,CAAA2C,OAAA,CAAAe,aAAA,CAAC7C,uBAAA,CAAAiH,eAAe;QACZZ,KAAK,MAAArB,cAAA,CAAAlD,OAAA;UAAIoF,OAAO,EAAE;QAAC,GAAKxF,qBAAqB;MAAG,CACnD,CACA,CACJ,CACR;MACDP,WAAW,EAAEyB,eAAgB;MAC7BuE,aAAa,EAAEC;IAAqB,CACvC,CAAC,EAED/D,kBAAkB,IAAItC,OACtB,CACe,CACX,CACC;EAAC;AAE/B,CAAC;;AAED;AACA;AACA;AACO,IAAMsG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,IAAAE,iCAAe,EAAC,gBAAgB,EAAE,UAAC3F,KAA0B,EAAK;EAC5F,oBACIzC,MAAA,CAAA2C,OAAA,CAAAe,aAAA,CAACnC,oBAAA,CAAA8G,uBAAuB,qBACpBrI,MAAA,CAAA2C,OAAA,CAAAe,aAAA,CAAChC,kBAAkB,EAAKe,KAAQ,CACX,CAAC;AAElC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_emotion","_LexicalComposer","_text","_LexicalOnChangePlugin","_LexicalAutoFocusPlugin","_LexicalClearEditorPlugin","_LexicalRichTextPlugin","_LexicalErrorBoundary","_reactComposition","_LexicalHistoryPlugin","_LexicalContentEditable","_lexicalTheme","_lexicalNodes","_RichTextEditorContext","_isValidLexicalData","_LexicalUpdateStatePlugin","_BlurEventPlugin","_Placeholder","_generateInitialLexicalValue","_SharedHistoryContext","_LexicalEditorConfig","_normalizeInputValue","_excluded","BaseRichTextEditor","_ref","toolbar","staticToolbar","onChange","nodes","placeholder","children","onBlur","focus","styles","width","height","contentEditableStyles","placeholderStyles","_ref$generateInitialV","generateInitialValue","generateInitialLexicalValue","props","_objectWithoutProperties2","default","themeEmotionMap","toTypographyEmotionMap","css","theme","themeStylesTransformer","editorTheme","useRef","createTheme","config","useLexicalEditorConfig","_useSharedHistoryCont","useSharedHistoryContext","historyState","placeholderElem","createElement","Placeholder","scrollRef","_useState","useState","undefined","_useState2","_slicedToArray2","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","Fragment","key","name","element","value","normalizeInputValue","editorValue","isValidLexicalData","initialConfig","editorState","namespace","onError","concat","_toConsumableArray2","allNodes","_objectSpread2","current","emotionMap","handleOnChange","editor","read","getEditorState","isEditorEmpty","$isRootTextContentEmpty","isComposing","newValue","JSON","stringify","toJSON","SharedHistoryContext","LexicalComposer","length","RichTextEditorProvider","toolbarActionPlugins","className","ref","style","overflow","position","OnChangePlugin","UpdateStatePlugin","ClearEditorPlugin","HistoryPlugin","externalHistoryState","BlurEventPlugin","AutoFocusPlugin","RichTextPlugin","contentEditable","ContentEditable","outline","ErrorBoundary","LexicalErrorBoundary","RichTextEditor","exports","makeDecoratable","LexicalEditorWithConfig"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useRef, useState } from \"react\";\nimport { css } from \"emotion\";\nimport { CSSObject } from \"@emotion/react\";\nimport { Klass, LexicalEditor, LexicalNode } from \"lexical\";\nimport { EditorState } from \"lexical/LexicalEditorState\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { $isRootTextContentEmpty } from \"@lexical/text\";\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 { makeDecoratable } from \"@webiny/react-composition\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport {\n createTheme,\n WebinyTheme,\n ThemeEmotionMap,\n toTypographyEmotionMap\n} from \"@webiny/lexical-theme\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { UpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin\";\nimport { LexicalValue, ToolbarActionPlugin } from \"~/types\";\nimport { Placeholder } from \"~/ui/Placeholder\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig\";\nimport { normalizeInputValue } from \"./normalizeInputValue\";\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 toolbarActionPlugins?: ToolbarActionPlugin[];\n themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;\n toolbar?: React.ReactNode;\n value: LexicalValue | null | undefined;\n width?: number | string;\n generateInitialValue?: () => LexicalValue;\n}\n\nconst BaseRichTextEditor = ({\n toolbar,\n staticToolbar,\n onChange,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n height,\n contentEditableStyles,\n placeholderStyles,\n generateInitialValue = generateInitialLexicalValue,\n ...props\n}: RichTextEditorProps) => {\n const themeEmotionMap =\n props.themeEmotionMap ??\n toTypographyEmotionMap(css, props.theme, props.themeStylesTransformer);\n\n const editorTheme = useRef(createTheme());\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 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 value = normalizeInputValue(props.value);\n const editorValue = isValidLexicalData(value) ? value : generateInitialValue();\n\n const initialConfig = {\n editorState: null,\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n nodes: [...allNodes, ...configNodes, ...(nodes || [])],\n theme: { ...editorTheme.current, 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 const isEditorEmpty = $isRootTextContentEmpty(editor.isComposing(), true);\n\n const newValue = JSON.stringify(editorState.toJSON());\n\n // We don't want to call \"onChange\" if editor text is empty, and original `value` is empty.\n if (!value && isEditorEmpty) {\n return;\n }\n\n if (value !== newValue) {\n onChange(newValue);\n }\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 <SharedHistoryContext>\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider\n theme={props.theme}\n themeEmotionMap={themeEmotionMap}\n toolbarActionPlugins={props.toolbarActionPlugins}\n >\n {staticToolbar ? staticToolbar : null}\n <div\n /* This className is necessary for targeting of editor container from CSS files. */\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{ ...styles, ...sizeStyle, overflow: \"auto\", position: \"relative\" }}\n >\n {/* State plugins. */}\n <OnChangePlugin onChange={handleOnChange} />\n <UpdateStatePlugin value={editorValue} />\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Event plugins. */}\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 </RichTextEditorProvider>\n </LexicalComposer>\n </SharedHistoryContext>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeDecoratable(\"RichTextEditor\", (props: RichTextEditorProps) => {\n return (\n <LexicalEditorWithConfig>\n <BaseRichTextEditor {...props} />\n </LexicalEditorWithConfig>\n );\n});\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAIA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,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,GAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AACA,IAAAU,qBAAA,GAAAV,OAAA;AACA,IAAAW,uBAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AAMA,IAAAa,aAAA,GAAAb,OAAA;AACA,IAAAc,sBAAA,GAAAd,OAAA;AACA,IAAAe,mBAAA,GAAAf,OAAA;AACA,IAAAgB,yBAAA,GAAAhB,OAAA;AACA,IAAAiB,gBAAA,GAAAjB,OAAA;AAEA,IAAAkB,YAAA,GAAAlB,OAAA;AACA,IAAAmB,4BAAA,GAAAnB,OAAA;AACA,IAAAoB,qBAAA,GAAApB,OAAA;AACA,IAAAqB,oBAAA,GAAArB,OAAA;AAIA,IAAAsB,oBAAA,GAAAtB,OAAA;AAA4D,IAAAuB,SAAA;AA0B5D,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAAC,IAAA,EAgBG;EAAA,IAfvBC,OAAO,GAAAD,IAAA,CAAPC,OAAO;IACPC,aAAa,GAAAF,IAAA,CAAbE,aAAa;IACbC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IACLC,WAAW,GAAAL,IAAA,CAAXK,WAAW;I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AAArB,cAAA,CAAAjD,OAAA;UAAImF,OAAO,EAAE;QAAC,GAAK1F,qBAAqB;MAAG,CACnD,CACA,CACJ,CACR;MACDP,WAAW,EAAE4B,eAAgB;MAC7BsE,aAAa,EAAEC;IAAqB,CACvC,CAAC,EAED9D,kBAAkB,IAAIzC,OACtB,CACe,CACX,CACC;EAAC;AAE/B,CAAC;;AAED;AACA;AACA;AACO,IAAMwG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,IAAAE,iCAAe,EAAC,gBAAgB,EAAE,UAAC1F,KAA0B,EAAK;EAC5F,oBACI5C,MAAA,CAAA8C,OAAA,CAAAe,aAAA,CAACtC,oBAAA,CAAAgH,uBAAuB,qBACpBvI,MAAA,CAAA8C,OAAA,CAAAe,aAAA,CAACnC,kBAAkB,EAAKkB,KAAQ,CACX,CAAC;AAElC,CAAC,CAAC","ignoreList":[]}
@@ -1,16 +1,28 @@
1
1
  import React from "react";
2
- export declare const FontColorPicker: import("@webiny/react-composition").GenericComponent<any> & {
3
- original: import("@webiny/react-composition").GenericComponent<any>;
2
+ export declare const FontColorPicker: (() => JSX.Element | null) & {
3
+ original: () => JSX.Element | null;
4
4
  originalName: string;
5
5
  displayName: string;
6
6
  } & {
7
- createDecorator: (decorator: import("@webiny/react-composition").Decorator<(props: any) => JSX.Element | null>) => (props: unknown) => React.JSX.Element;
7
+ original: (() => JSX.Element | null) & {
8
+ original: () => JSX.Element | null;
9
+ originalName: string;
10
+ displayName: string;
11
+ };
12
+ originalName: string;
13
+ displayName: string;
14
+ } & {
15
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(() => JSX.Element | null) & {
16
+ original: () => JSX.Element | null;
17
+ originalName: string;
18
+ displayName: string;
19
+ }>) => (props: unknown) => React.JSX.Element;
8
20
  };
9
21
  interface FontActionColorPicker {
10
22
  element: JSX.Element;
11
23
  }
12
24
  declare const FontActionColorPicker: ({ element }: FontActionColorPicker) => JSX.Element;
13
- export declare type FontColorAction = React.ComponentType<unknown> & {
25
+ export type FontColorAction = React.ComponentType<unknown> & {
14
26
  ColorPicker: typeof FontActionColorPicker;
15
27
  };
16
28
  export declare const FontColorAction: FontColorAction;
@@ -1,16 +1,28 @@
1
1
  import React from "react";
2
- export declare const BaseTextAlignmentDropDown: import("@webiny/react-composition").GenericComponent<any> & {
3
- original: import("@webiny/react-composition").GenericComponent<any>;
2
+ export declare const BaseTextAlignmentDropDown: (() => JSX.Element | null) & {
3
+ original: () => JSX.Element | null;
4
4
  originalName: string;
5
5
  displayName: string;
6
6
  } & {
7
- createDecorator: (decorator: import("@webiny/react-composition").Decorator<(props: any) => JSX.Element | null>) => (props: unknown) => React.JSX.Element;
7
+ original: (() => JSX.Element | null) & {
8
+ original: () => JSX.Element | null;
9
+ originalName: string;
10
+ displayName: string;
11
+ };
12
+ originalName: string;
13
+ displayName: string;
14
+ } & {
15
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(() => JSX.Element | null) & {
16
+ original: () => JSX.Element | null;
17
+ originalName: string;
18
+ displayName: string;
19
+ }>) => (props: unknown) => React.JSX.Element;
8
20
  };
9
21
  interface TextAlignmentActionDropdownProps {
10
22
  element: JSX.Element;
11
23
  }
12
24
  declare const TextAlignmentActionDropDown: ({ element }: TextAlignmentActionDropdownProps) => JSX.Element;
13
- export declare type TextAlignmentAction = React.ComponentType<unknown> & {
25
+ export type TextAlignmentAction = React.ComponentType<unknown> & {
14
26
  TextAlignmentDropDown: typeof TextAlignmentActionDropDown;
15
27
  };
16
28
  export declare const TextAlignmentAction: TextAlignmentAction;
@@ -1,16 +1,28 @@
1
1
  import React from "react";
2
- export declare const BaseTypographyActionDropDown: import("@webiny/react-composition").GenericComponent<any> & {
3
- original: import("@webiny/react-composition").GenericComponent<any>;
2
+ export declare const BaseTypographyActionDropDown: (() => JSX.Element | null) & {
3
+ original: () => JSX.Element | null;
4
4
  originalName: string;
5
5
  displayName: string;
6
6
  } & {
7
- createDecorator: (decorator: import("@webiny/react-composition").Decorator<(props: any) => JSX.Element | null>) => (props: unknown) => React.JSX.Element;
7
+ original: (() => JSX.Element | null) & {
8
+ original: () => JSX.Element | null;
9
+ originalName: string;
10
+ displayName: string;
11
+ };
12
+ originalName: string;
13
+ displayName: string;
14
+ } & {
15
+ createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(() => JSX.Element | null) & {
16
+ original: () => JSX.Element | null;
17
+ originalName: string;
18
+ displayName: string;
19
+ }>) => (props: unknown) => React.JSX.Element;
8
20
  };
9
21
  interface TypographyActionDropdownProps {
10
22
  element: JSX.Element;
11
23
  }
12
24
  declare const TypographyActionDropDown: ({ element }: TypographyActionDropdownProps) => JSX.Element;
13
- export declare type TypographyAction = React.ComponentType<unknown> & {
25
+ export type TypographyAction = React.ComponentType<unknown> & {
14
26
  TypographyDropDown: typeof TypographyActionDropDown;
15
27
  };
16
28
  export declare const TypographyAction: TypographyAction;
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from "react";
2
2
  import { HistoryState } from "@lexical/history";
3
- declare type ContextShape = {
3
+ type ContextShape = {
4
4
  historyState?: HistoryState;
5
5
  };
6
6
  export declare const SharedHistoryContext: ({ children }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/lexical-editor",
3
- "version": "5.40.6",
3
+ "version": "5.41.0-beta.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/webiny/webiny-js.git"
@@ -15,10 +15,10 @@
15
15
  "@lexical/selection": "0.16.1",
16
16
  "@lexical/text": "0.16.1",
17
17
  "@lexical/utils": "0.16.1",
18
- "@webiny/lexical-nodes": "5.40.6",
19
- "@webiny/lexical-theme": "5.40.6",
20
- "@webiny/react-composition": "5.40.6",
21
- "@webiny/react-properties": "5.40.6",
18
+ "@webiny/lexical-nodes": "5.41.0-beta.0",
19
+ "@webiny/lexical-theme": "5.41.0-beta.0",
20
+ "@webiny/react-composition": "5.41.0-beta.0",
21
+ "@webiny/react-properties": "5.41.0-beta.0",
22
22
  "emotion": "10.0.27",
23
23
  "lexical": "0.16.1",
24
24
  "lodash": "4.17.21",
@@ -26,8 +26,8 @@
26
26
  "react-dom": "18.2.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@webiny/cli": "5.40.6",
30
- "@webiny/project-utils": "5.40.6"
29
+ "@webiny/cli": "5.41.0-beta.0",
30
+ "@webiny/project-utils": "5.41.0-beta.0"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public",
@@ -37,5 +37,5 @@
37
37
  "build": "yarn webiny run build",
38
38
  "watch": "yarn webiny run watch"
39
39
  },
40
- "gitHead": "f9da84b373e62f9f269599c4301e5e4418a98d51"
40
+ "gitHead": "9ce5e75fc577aa4de2cf08d5ca734b3c98fe65b6"
41
41
  }
@@ -2,7 +2,7 @@
2
2
  position: absolute;
3
3
  top: 0;
4
4
  left: 0;
5
- z-index: 10;
5
+ z-index: 31;
6
6
  max-width: 400px;
7
7
  width: 100%;
8
8
  opacity: 0;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ImagePayload } from "../../commands";
3
- export declare type InsertImagePayload = Readonly<ImagePayload>;
3
+ export type InsertImagePayload = Readonly<ImagePayload>;
4
4
  export declare function ImagesPlugin({ captionsEnabled }: {
5
5
  captionsEnabled?: boolean;
6
6
  }): JSX.Element | null;
@@ -1,4 +1,4 @@
1
- declare type Props = {
1
+ type Props = {
2
2
  validateUrl?: (url: string) => boolean;
3
3
  };
4
4
  export declare function LinkPlugin({ validateUrl }: Props): null;
package/types.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export declare type LexicalValue = string;
2
- export declare type NormalizedInputValue = LexicalValue | null;
1
+ export type LexicalValue = string;
2
+ export type NormalizedInputValue = LexicalValue | null;
3
3
  export { FontColorPicker } from "./components/ToolbarActions/FontColorAction";
4
- export declare type ImageActionType = "image-action";
5
- export declare type ToolbarActionType = ImageActionType | string;
4
+ export type ImageActionType = "image-action";
5
+ export type ToolbarActionType = ImageActionType | string;
6
6
  export interface ToolbarActionPlugin {
7
7
  targetAction: ToolbarActionType;
8
8
  plugin: Record<string, any> | ((cb: (value: any) => void) => any) | undefined;
package/ui/TextInput.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  /// <reference types="react" />
9
9
  import "./Input.css";
10
- declare type Props = Readonly<{
10
+ type Props = Readonly<{
11
11
  "data-test-id"?: string;
12
12
  label: string;
13
13
  onChange: (val: string) => void;
package/utils/rect.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
  import { Point } from "./point";
9
- declare type ContainsPointReturn = {
9
+ type ContainsPointReturn = {
10
10
  result: boolean;
11
11
  reason: {
12
12
  isOnTopSide: boolean;