@webiny/lexical-editor 0.0.0-unstable.de38392959 → 0.0.0-unstable.df7a8bb475
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/README.md +6 -12
- package/commands/image.d.ts +2 -2
- package/commands/image.js +2 -9
- package/commands/image.js.map +1 -1
- package/commands/index.d.ts +5 -3
- package/commands/index.js +5 -38
- package/commands/index.js.map +1 -1
- package/commands/list.d.ts +2 -2
- package/commands/list.js +4 -13
- package/commands/list.js.map +1 -1
- package/commands/quote.d.ts +2 -2
- package/commands/quote.js +2 -9
- package/commands/quote.js.map +1 -1
- package/commands/toolbar.d.ts +1 -0
- package/commands/toolbar.js +4 -0
- package/commands/toolbar.js.map +1 -0
- package/commands/typography.d.ts +8 -0
- package/commands/typography.js +4 -0
- package/commands/typography.js.map +1 -0
- package/components/Editor/EnsureHeadingTagPlugin.d.ts +6 -0
- package/components/Editor/EnsureHeadingTagPlugin.js +20 -0
- package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -0
- package/components/Editor/RichTextEditor.d.ts +32 -12
- package/components/Editor/RichTextEditor.js +89 -129
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/Editor/normalizeInputValue.d.ts +6 -0
- package/components/Editor/normalizeInputValue.js +16 -0
- package/components/Editor/normalizeInputValue.js.map +1 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +14 -16
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +21 -71
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
- package/components/LexicalEditorConfig/components/Node.d.ts +3 -3
- package/components/LexicalEditorConfig/components/Node.js +17 -27
- package/components/LexicalEditorConfig/components/Node.js.map +1 -1
- package/components/LexicalEditorConfig/components/Plugin.d.ts +1 -1
- package/components/LexicalEditorConfig/components/Plugin.js +17 -27
- package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
- package/components/LexicalEditorConfig/components/ToolbarElement.d.ts +1 -1
- package/components/LexicalEditorConfig/components/ToolbarElement.js +17 -27
- package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
- package/components/LexicalHtmlRenderer.d.ts +6 -13
- package/components/LexicalHtmlRenderer.js +36 -59
- package/components/LexicalHtmlRenderer.js.map +1 -1
- package/components/Toolbar/StaticToolbar.css +1 -1
- package/components/Toolbar/StaticToolbar.d.ts +4 -2
- package/components/Toolbar/StaticToolbar.js +19 -27
- package/components/Toolbar/StaticToolbar.js.map +1 -1
- package/components/Toolbar/Toolbar.css +72 -75
- package/components/Toolbar/Toolbar.js +78 -80
- package/components/Toolbar/Toolbar.js.map +1 -1
- package/components/ToolbarActions/BoldAction.d.ts +2 -2
- package/components/ToolbarActions/BoldAction.js +16 -24
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.d.ts +2 -2
- package/components/ToolbarActions/BulletListAction.js +25 -35
- package/components/ToolbarActions/BulletListAction.js.map +1 -1
- package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -2
- package/components/ToolbarActions/CodeHighlightAction.js +16 -24
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
- package/components/ToolbarActions/FontColorAction.d.ts +18 -3
- package/components/ToolbarActions/FontColorAction.js +36 -48
- package/components/ToolbarActions/FontColorAction.js.map +1 -1
- package/components/ToolbarActions/ImageAction.d.ts +2 -2
- package/components/ToolbarActions/ImageAction.js +19 -38
- package/components/ToolbarActions/ImageAction.js.map +1 -1
- package/components/ToolbarActions/ItalicAction.d.ts +2 -2
- package/components/ToolbarActions/ItalicAction.js +16 -24
- package/components/ToolbarActions/ItalicAction.js.map +1 -1
- package/components/ToolbarActions/LinkAction.d.ts +2 -2
- package/components/ToolbarActions/LinkAction.js +19 -28
- package/components/ToolbarActions/LinkAction.js.map +1 -1
- package/components/ToolbarActions/NumberedListAction.d.ts +2 -2
- package/components/ToolbarActions/NumberedListAction.js +25 -41
- package/components/ToolbarActions/NumberedListAction.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.d.ts +2 -2
- package/components/ToolbarActions/QuoteAction.js +20 -30
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/TextAlignmentAction.d.ts +18 -3
- package/components/ToolbarActions/TextAlignmentAction.js +36 -50
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
- package/components/ToolbarActions/TypographyAction.d.ts +18 -3
- package/components/ToolbarActions/TypographyAction.js +57 -84
- package/components/ToolbarActions/TypographyAction.js.map +1 -1
- package/components/ToolbarActions/UnderlineAction.d.ts +2 -2
- package/components/ToolbarActions/UnderlineAction.js +16 -25
- package/components/ToolbarActions/UnderlineAction.js.map +1 -1
- package/context/FontColorActionContext.js +2 -10
- package/context/FontColorActionContext.js.map +1 -1
- package/context/RichTextEditorContext.d.ts +8 -15
- package/context/RichTextEditorContext.js +15 -52
- package/context/RichTextEditorContext.js.map +1 -1
- package/context/SharedHistoryContext.d.ts +3 -3
- package/context/SharedHistoryContext.js +12 -21
- package/context/SharedHistoryContext.js.map +1 -1
- package/context/TextAlignmentActionContextProps.d.ts +1 -1
- package/context/TextAlignmentActionContextProps.js +2 -10
- package/context/TextAlignmentActionContextProps.js.map +1 -1
- package/context/TypographyActionContext.d.ts +3 -2
- package/context/TypographyActionContext.js +2 -10
- package/context/TypographyActionContext.js.map +1 -1
- package/exports/admin/lexical.d.ts +15 -0
- package/exports/admin/lexical.js +23 -0
- package/exports/admin/lexical.js.map +1 -0
- package/hooks/index.d.ts +7 -7
- package/hooks/index.js +7 -82
- package/hooks/index.js.map +1 -1
- package/hooks/useCurrentElement.d.ts +3 -3
- package/hooks/useCurrentElement.js +12 -18
- package/hooks/useCurrentElement.js.map +1 -1
- package/hooks/useCurrentSelection.d.ts +2 -1
- package/hooks/useCurrentSelection.js +27 -42
- package/hooks/useCurrentSelection.js.map +1 -1
- package/hooks/useFontColorPicker.d.ts +1 -1
- package/hooks/useFontColorPicker.js +5 -11
- package/hooks/useFontColorPicker.js.map +1 -1
- package/hooks/useIsMounted.js +6 -14
- package/hooks/useIsMounted.js.map +1 -1
- package/hooks/useRichTextEditor.d.ts +1 -1
- package/hooks/useRichTextEditor.js +5 -11
- package/hooks/useRichTextEditor.js.map +1 -1
- package/hooks/useTextAlignmentAction.d.ts +1 -1
- package/hooks/useTextAlignmentAction.js +5 -11
- package/hooks/useTextAlignmentAction.js.map +1 -1
- package/hooks/useTypographyAction.d.ts +1 -1
- package/hooks/useTypographyAction.js +5 -11
- package/hooks/useTypographyAction.js.map +1 -1
- package/index.d.ts +34 -38
- package/index.js +45 -322
- package/index.js.map +1 -1
- package/package.json +19 -22
- package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +2 -2
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +16 -26
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +9 -17
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/index.d.ts +1 -1
- package/plugins/CodeHighlightPlugin/index.js +1 -16
- package/plugins/CodeHighlightPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +16 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +158 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +8 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +62 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +60 -6
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +4 -3
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +11 -261
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +8 -0
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +104 -0
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +9 -0
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +34 -0
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.js +1 -16
- package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.d.ts +1 -0
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +12 -0
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js +19 -32
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToNode.d.ts +3 -0
- package/plugins/FontColorPlugin/applyColorToNode.js +8 -0
- package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -0
- package/plugins/FontColorPlugin/applyColorToSelection.d.ts +3 -0
- package/plugins/FontColorPlugin/applyColorToSelection.js +66 -0
- package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -0
- package/plugins/ImagesPlugin/ImagesPlugin.d.ts +2 -3
- package/plugins/ImagesPlugin/ImagesPlugin.js +60 -64
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
- package/plugins/LinkPlugin/LinkPlugin.d.ts +1 -1
- package/plugins/LinkPlugin/LinkPlugin.js +31 -40
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
- package/plugins/ListPLugin/ListPlugin.js +54 -20
- package/plugins/ListPLugin/ListPlugin.js.map +1 -1
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +27 -0
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -0
- package/plugins/StateHandlingPlugin.d.ts +8 -0
- package/plugins/StateHandlingPlugin.js +75 -0
- package/plugins/StateHandlingPlugin.js.map +1 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js +17 -25
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
- package/types.d.ts +8 -8
- package/types.js +6 -38
- package/types.js.map +1 -1
- package/ui/ContentEditable.d.ts +0 -1
- package/ui/ContentEditable.js +7 -14
- package/ui/ContentEditable.js.map +1 -1
- package/ui/Divider.d.ts +0 -1
- package/ui/Divider.js +3 -10
- package/ui/Divider.js.map +1 -1
- package/ui/DropDown.d.ts +2 -2
- package/ui/DropDown.js +64 -89
- package/ui/DropDown.js.map +1 -1
- package/ui/ImageResizer.d.ts +0 -1
- package/ui/ImageResizer.js +84 -88
- package/ui/ImageResizer.js.map +1 -1
- package/ui/LinkPreview.d.ts +0 -1
- package/ui/LinkPreview.js +22 -28
- package/ui/LinkPreview.js.map +1 -1
- package/ui/Placeholder.d.ts +1 -1
- package/ui/Placeholder.js +10 -16
- package/ui/Placeholder.js.map +1 -1
- package/ui/TextInput.d.ts +1 -2
- package/ui/TextInput.js +11 -18
- package/ui/TextInput.js.map +1 -1
- package/ui/ToolbarActionDialog.d.ts +2 -3
- package/ui/ToolbarActionDialog.js +22 -53
- package/ui/ToolbarActionDialog.js.map +1 -1
- package/utils/canUseDOM.js +1 -8
- package/utils/canUseDOM.js.map +1 -1
- package/utils/files.d.ts +6 -7
- package/utils/files.js +5 -58
- package/utils/files.js.map +1 -1
- package/utils/getDOMRangeRect.js +4 -10
- package/utils/getDOMRangeRect.js.map +1 -1
- package/utils/getSelectedNode.d.ts +1 -1
- package/utils/getSelectedNode.js +9 -16
- package/utils/getSelectedNode.js.map +1 -1
- package/utils/getTransparentImage.js +1 -8
- package/utils/getTransparentImage.js.map +1 -1
- package/utils/insertImage.d.ts +1 -1
- package/utils/insertImage.js +8 -15
- package/utils/insertImage.js.map +1 -1
- package/utils/isAnchorLink.d.ts +1 -0
- package/utils/isAnchorLink.js +5 -0
- package/utils/isAnchorLink.js.map +1 -0
- package/utils/isChildOfFloatingToolbar.d.ts +1 -0
- package/utils/isChildOfFloatingToolbar.js +12 -0
- package/utils/isChildOfFloatingToolbar.js.map +1 -0
- package/utils/isHTMLElement.js +1 -7
- package/utils/isHTMLElement.js.map +1 -1
- package/utils/isValidJSON.js +3 -10
- package/utils/isValidJSON.js.map +1 -1
- package/utils/isValidLexicalData.d.ts +3 -3
- package/utils/isValidLexicalData.js +6 -14
- package/utils/isValidLexicalData.js.map +1 -1
- package/utils/point.js +35 -62
- package/utils/point.js.map +1 -1
- package/utils/rect.d.ts +2 -2
- package/utils/rect.js +115 -151
- package/utils/rect.js.map +1 -1
- package/utils/sanitizeUrl.js +6 -14
- package/utils/sanitizeUrl.js.map +1 -1
- package/utils/setFloatingElemPosition.d.ts +1 -1
- package/utils/setFloatingElemPosition.js +27 -39
- package/utils/setFloatingElemPosition.js.map +1 -1
- package/components/Editor/HeadingEditor.d.ts +0 -7
- package/components/Editor/HeadingEditor.js +0 -30
- package/components/Editor/HeadingEditor.js.map +0 -1
- package/components/Editor/ParagraphEditor.d.ts +0 -7
- package/components/Editor/ParagraphEditor.js +0 -30
- package/components/Editor/ParagraphEditor.js.map +0 -1
- package/components/ToolbarActions/FontSizeAction.d.ts +0 -2
- package/components/ToolbarActions/FontSizeAction.js +0 -85
- package/components/ToolbarActions/FontSizeAction.js.map +0 -1
- package/hooks/useList.d.ts +0 -2
- package/hooks/useList.js +0 -54
- package/hooks/useList.js.map +0 -1
- package/hooks/useQuote.d.ts +0 -2
- package/hooks/useQuote.js +0 -22
- package/hooks/useQuote.js.map +0 -1
- package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.d.ts +0 -9
- package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js +0 -49
- package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js.map +0 -1
- package/plugins/LexicalUpdateStatePlugin/index.d.ts +0 -1
- package/plugins/LexicalUpdateStatePlugin/index.js +0 -18
- package/plugins/LexicalUpdateStatePlugin/index.js.map +0 -1
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js +0 -26
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js.map +0 -1
- package/utils/generateInitialLexicalValue.d.ts +0 -5
- package/utils/generateInitialLexicalValue.js +0 -34
- package/utils/generateInitialLexicalValue.js.map +0 -1
- package/utils/isUrlLinkReference.d.ts +0 -1
- package/utils/isUrlLinkReference.js +0 -12
- package/utils/isUrlLinkReference.js.map +0 -1
- /package/plugins/{WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.d.ts → QuoteNodePlugin/QuoteNodePlugin.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
# @webiny/lexical-editor
|
|
2
|
-
[](https://www.npmjs.com/package/@webiny/lexical-editor)
|
|
3
|
-
[](https://www.npmjs.com/package/@webiny/lexical-editor)
|
|
4
|
-
[](https://github.com/prettier/prettier)
|
|
5
|
-
[](http://makeapullrequest.com)
|
|
6
2
|
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
---
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
To find more about the Lexical framework go to their website [lexical.dev](https://lexical.dev/)
|
|
14
|
-
|
|
15
|
-
## Where is it used?
|
|
16
|
-
|
|
17
|
-
Currently, this packaged is used in [@webiny/app-pagebuilder](../app-page-builder).
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/commands/image.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LexicalCommand, NodeKey } from "lexical";
|
|
2
|
-
import { ImageNodeProps } from "@webiny/lexical-nodes";
|
|
1
|
+
import type { LexicalCommand, NodeKey } from "lexical";
|
|
2
|
+
import type { ImageNodeProps } from "@webiny/lexical-nodes";
|
|
3
3
|
export interface ImagePayload extends ImageNodeProps {
|
|
4
4
|
key?: NodeKey;
|
|
5
5
|
}
|
package/commands/image.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
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;
|
|
1
|
+
import { createCommand } from "lexical";
|
|
2
|
+
export const INSERT_IMAGE_COMMAND = createCommand("INSERT_IMAGE_COMMAND");
|
|
10
3
|
|
|
11
4
|
//# sourceMappingURL=image.js.map
|
package/commands/image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createCommand","INSERT_IMAGE_COMMAND"],"sources":["image.ts"],"sourcesContent":["import type { LexicalCommand, NodeKey } from \"lexical\";\nimport { createCommand } from \"lexical\";\nimport type { ImageNodeProps } from \"@webiny/lexical-nodes\";\n\nexport interface ImagePayload extends ImageNodeProps {\n key?: NodeKey;\n}\n\nexport const INSERT_IMAGE_COMMAND: LexicalCommand<ImagePayload> =\n createCommand(\"INSERT_IMAGE_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAOvC,OAAO,MAAMC,oBAAkD,GAC3DD,aAAa,CAAC,sBAAsB,CAAC","ignoreList":[]}
|
package/commands/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export * from "
|
|
2
|
-
export * from "
|
|
3
|
-
export * from "
|
|
1
|
+
export * from "../commands/typography.js";
|
|
2
|
+
export * from "../commands/image.js";
|
|
3
|
+
export * from "../commands/list.js";
|
|
4
|
+
export * from "../commands/quote.js";
|
|
5
|
+
export * from "../commands/toolbar.js";
|
package/commands/index.js
CHANGED
|
@@ -1,40 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _image = require("./image");
|
|
7
|
-
Object.keys(_image).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _image[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _image[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _list = require("./list");
|
|
18
|
-
Object.keys(_list).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _list[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function get() {
|
|
24
|
-
return _list[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _quote = require("./quote");
|
|
29
|
-
Object.keys(_quote).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _quote[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function get() {
|
|
35
|
-
return _quote[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
1
|
+
export * from "./typography.js";
|
|
2
|
+
export * from "./image.js";
|
|
3
|
+
export * from "./list.js";
|
|
4
|
+
export * from "./quote.js";
|
|
5
|
+
export * from "./toolbar.js";
|
|
39
6
|
|
|
40
7
|
//# sourceMappingURL=index.js.map
|
package/commands/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"~/commands/typography.js\";\nexport * from \"~/commands/image.js\";\nexport * from \"~/commands/list.js\";\nexport * from \"~/commands/quote.js\";\nexport * from \"~/commands/toolbar.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/commands/list.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LexicalCommand } from "lexical";
|
|
2
|
-
export
|
|
1
|
+
import type { LexicalCommand } from "lexical";
|
|
2
|
+
export type ListCommandPayload = {
|
|
3
3
|
themeStyleId?: string;
|
|
4
4
|
};
|
|
5
5
|
export declare const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload>;
|
package/commands/list.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.REMOVE_LIST_COMMAND = exports.INSERT_UNORDERED_LIST_COMMAND = exports.INSERT_ORDERED_LIST_COMMAND = void 0;
|
|
7
|
-
var _lexical = require("lexical");
|
|
8
|
-
var INSERT_UNORDERED_LIST_COMMAND = (0, _lexical.createCommand)("INSERT_UNORDERED_LIST_COMMAND");
|
|
9
|
-
exports.INSERT_UNORDERED_LIST_COMMAND = INSERT_UNORDERED_LIST_COMMAND;
|
|
10
|
-
var INSERT_ORDERED_LIST_COMMAND = (0, _lexical.createCommand)("INSERT_ORDERED_LIST_COMMAND");
|
|
11
|
-
exports.INSERT_ORDERED_LIST_COMMAND = INSERT_ORDERED_LIST_COMMAND;
|
|
12
|
-
var REMOVE_LIST_COMMAND = (0, _lexical.createCommand)("REMOVE_LIST_COMMAND");
|
|
13
|
-
exports.REMOVE_LIST_COMMAND = REMOVE_LIST_COMMAND;
|
|
1
|
+
import { createCommand } from "lexical";
|
|
2
|
+
export const INSERT_UNORDERED_LIST_COMMAND = createCommand("INSERT_UNORDERED_LIST_COMMAND");
|
|
3
|
+
export const INSERT_ORDERED_LIST_COMMAND = createCommand("INSERT_ORDERED_LIST_COMMAND");
|
|
4
|
+
export const REMOVE_LIST_COMMAND = createCommand("REMOVE_LIST_COMMAND");
|
|
14
5
|
|
|
15
6
|
//# sourceMappingURL=list.js.map
|
package/commands/list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createCommand","INSERT_UNORDERED_LIST_COMMAND","INSERT_ORDERED_LIST_COMMAND","REMOVE_LIST_COMMAND"],"sources":["list.ts"],"sourcesContent":["import type { LexicalCommand } from \"lexical\";\nimport { createCommand } from \"lexical\";\n\nexport type ListCommandPayload = {\n themeStyleId?: string;\n};\n\nexport const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload> = createCommand(\n \"INSERT_UNORDERED_LIST_COMMAND\"\n);\n\nexport const INSERT_ORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload> = createCommand(\n \"INSERT_ORDERED_LIST_COMMAND\"\n);\n\nexport const REMOVE_LIST_COMMAND: LexicalCommand<void> = createCommand(\"REMOVE_LIST_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAMvC,OAAO,MAAMC,6BAAiE,GAAGD,aAAa,CAC1F,+BACJ,CAAC;AAED,OAAO,MAAME,2BAA+D,GAAGF,aAAa,CACxF,6BACJ,CAAC;AAED,OAAO,MAAMG,mBAAyC,GAAGH,aAAa,CAAC,qBAAqB,CAAC","ignoreList":[]}
|
package/commands/quote.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LexicalCommand } from "lexical";
|
|
2
|
-
export
|
|
1
|
+
import type { LexicalCommand } from "lexical";
|
|
2
|
+
export type QuoteCommandPayload = {
|
|
3
3
|
themeStyleId: string;
|
|
4
4
|
};
|
|
5
5
|
export declare const INSERT_QUOTE_COMMAND: LexicalCommand<QuoteCommandPayload>;
|
package/commands/quote.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.INSERT_QUOTE_COMMAND = void 0;
|
|
7
|
-
var _lexical = require("lexical");
|
|
8
|
-
var INSERT_QUOTE_COMMAND = (0, _lexical.createCommand)("INSERT_QUOTE_COMMAND");
|
|
9
|
-
exports.INSERT_QUOTE_COMMAND = INSERT_QUOTE_COMMAND;
|
|
1
|
+
import { createCommand } from "lexical";
|
|
2
|
+
export const INSERT_QUOTE_COMMAND = createCommand("INSERT_QUOTE_COMMAND");
|
|
10
3
|
|
|
11
4
|
//# sourceMappingURL=quote.js.map
|
package/commands/quote.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createCommand","INSERT_QUOTE_COMMAND"],"sources":["quote.ts"],"sourcesContent":["import type { LexicalCommand } from \"lexical\";\nimport { createCommand } from \"lexical\";\n\nexport type QuoteCommandPayload = {\n themeStyleId: string;\n};\n\nexport const INSERT_QUOTE_COMMAND: LexicalCommand<QuoteCommandPayload> =\n createCommand(\"INSERT_QUOTE_COMMAND\");\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAMvC,OAAO,MAAMC,oBAAyD,GAClED,aAAa,CAAC,sBAAsB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HIDE_FLOATING_TOOLBAR: import("lexical").LexicalCommand<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createCommand","HIDE_FLOATING_TOOLBAR"],"sources":["toolbar.ts"],"sourcesContent":["import { createCommand } from \"lexical\";\n\nexport const HIDE_FLOATING_TOOLBAR = createCommand(\"HIDE_FLOATING_TOOLBAR_COMMAND\");\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,SAAS;AAEvC,OAAO,MAAMC,qBAAqB,GAAGD,aAAa,CAAC,+BAA+B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LexicalCommand, LexicalEditor, NodeKey } from "lexical";
|
|
2
|
+
import type { TypographyValue } from "@webiny/lexical-theme";
|
|
3
|
+
export declare const ADD_TYPOGRAPHY_COMMAND: LexicalCommand<TypographyPayload>;
|
|
4
|
+
export interface TypographyPayload {
|
|
5
|
+
value: TypographyValue;
|
|
6
|
+
caption?: LexicalEditor;
|
|
7
|
+
key?: NodeKey;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createCommand","ADD_TYPOGRAPHY_COMMAND"],"sources":["typography.ts"],"sourcesContent":["import type { LexicalCommand, LexicalEditor, NodeKey } from \"lexical\";\nimport { createCommand } from \"lexical\";\nimport type { TypographyValue } from \"@webiny/lexical-theme\";\n\nexport const ADD_TYPOGRAPHY_COMMAND: LexicalCommand<TypographyPayload> =\n createCommand(\"ADD_TYPOGRAPHY_COMMAND\");\n\nexport interface TypographyPayload {\n value: TypographyValue;\n caption?: LexicalEditor;\n key?: NodeKey;\n}\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,SAAS;AAGvC,OAAO,MAAMC,sBAAyD,GAClED,aAAa,CAAC,wBAAwB,CAAC","ignoreList":[]}
|
|
@@ -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,20 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { ParagraphNode, $createHeadingNode } from "@webiny/lexical-nodes";
|
|
3
|
+
import { useRichTextEditor } from "../../hooks/index.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* In the "Heading" editor, we only want to support heading tags.
|
|
7
|
+
* However, when the editor is empty, and you start typing, Lexical automatically creates an empty "paragraph" node.
|
|
8
|
+
* This ensures that any paragraph node is automatically converted to a heading node.
|
|
9
|
+
*/
|
|
10
|
+
export const EnsureHeadingTagPlugin = () => {
|
|
11
|
+
const {
|
|
12
|
+
editor
|
|
13
|
+
} = useRichTextEditor();
|
|
14
|
+
useEffect(() => editor.registerNodeTransform(ParagraphNode, node => {
|
|
15
|
+
node.replace($createHeadingNode("h1"), true);
|
|
16
|
+
}), []);
|
|
17
|
+
return null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=EnsureHeadingTagPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","ParagraphNode","$createHeadingNode","useRichTextEditor","EnsureHeadingTagPlugin","editor","registerNodeTransform","node","replace"],"sources":["EnsureHeadingTagPlugin.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { ParagraphNode, $createHeadingNode } from \"@webiny/lexical-nodes\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\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,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,uBAAuB;AACzE,SAASC,iBAAiB;;AAE1B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAO,CAAC,GAAGF,iBAAiB,CAAC,CAAC;EAEtCH,SAAS,CACL,MACIK,MAAM,CAACC,qBAAqB,CAACL,aAAa,EAAEM,IAAI,IAAI;IAChDA,IAAI,CAACC,OAAO,CAACN,kBAAkB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;EAChD,CAAC,CAAC,EACN,EACJ,CAAC;EACD,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import type { Klass, LexicalNode } from "lexical";
|
|
3
|
+
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
4
|
+
import type { EditorTheme } from "@webiny/lexical-theme";
|
|
5
|
+
import type { LexicalValue, ToolbarActionPlugin } from "../../types.js";
|
|
6
|
+
export type InitialEditorConfig = React.ComponentProps<typeof LexicalComposer>["initialConfig"] & {
|
|
7
|
+
editorId: string;
|
|
8
|
+
};
|
|
6
9
|
export interface RichTextEditorProps {
|
|
7
10
|
children?: React.ReactNode | React.ReactNode[];
|
|
8
11
|
classes?: string;
|
|
@@ -11,24 +14,41 @@ export interface RichTextEditorProps {
|
|
|
11
14
|
height?: number | string;
|
|
12
15
|
nodes?: Klass<LexicalNode>[];
|
|
13
16
|
onBlur?: (editorState: LexicalValue) => void;
|
|
14
|
-
onChange?: (
|
|
17
|
+
onChange?: (value: LexicalValue) => void;
|
|
15
18
|
placeholder?: string;
|
|
16
19
|
placeholderStyles?: React.CSSProperties;
|
|
17
20
|
staticToolbar?: React.ReactNode;
|
|
18
21
|
styles?: React.CSSProperties;
|
|
19
22
|
tag?: string;
|
|
20
|
-
theme:
|
|
21
|
-
themeEmotionMap?: ThemeEmotionMap;
|
|
22
|
-
themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;
|
|
23
|
-
toolbar?: React.ReactNode;
|
|
23
|
+
theme: EditorTheme;
|
|
24
24
|
toolbarActionPlugins?: ToolbarActionPlugin[];
|
|
25
|
-
|
|
25
|
+
toolbar?: React.ReactNode;
|
|
26
|
+
value: LexicalValue | null | undefined;
|
|
27
|
+
configRef?: React.MutableRefObject<InitialEditorConfig | undefined>;
|
|
26
28
|
width?: number | string;
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
31
|
* @description Main editor container
|
|
30
32
|
*/
|
|
31
|
-
export declare const RichTextEditor: React.
|
|
32
|
-
original: React.
|
|
33
|
+
export declare const RichTextEditor: ((props: RichTextEditorProps) => React.JSX.Element) & {
|
|
34
|
+
original: (props: RichTextEditorProps) => React.JSX.Element;
|
|
33
35
|
originalName: string;
|
|
36
|
+
displayName: string;
|
|
37
|
+
} & {
|
|
38
|
+
original: ((props: RichTextEditorProps) => React.JSX.Element) & {
|
|
39
|
+
original: (props: RichTextEditorProps) => React.JSX.Element;
|
|
40
|
+
originalName: string;
|
|
41
|
+
displayName: string;
|
|
42
|
+
};
|
|
43
|
+
originalName: string;
|
|
44
|
+
displayName: string;
|
|
45
|
+
} & {
|
|
46
|
+
createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<((props: RichTextEditorProps) => React.JSX.Element) & {
|
|
47
|
+
original: (props: RichTextEditorProps) => React.JSX.Element;
|
|
48
|
+
originalName: string;
|
|
49
|
+
displayName: string;
|
|
50
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
34
51
|
};
|
|
52
|
+
export declare namespace RichTextEditor {
|
|
53
|
+
type InitialConfig = InitialEditorConfig;
|
|
54
|
+
}
|
|
@@ -1,117 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
nodes = _ref.nodes,
|
|
40
|
-
placeholder = _ref.placeholder,
|
|
41
|
-
children = _ref.children,
|
|
42
|
-
onBlur = _ref.onBlur,
|
|
43
|
-
focus = _ref.focus,
|
|
44
|
-
styles = _ref.styles,
|
|
45
|
-
width = _ref.width,
|
|
46
|
-
height = _ref.height,
|
|
47
|
-
theme = _ref.theme,
|
|
48
|
-
themeEmotionMap = _ref.themeEmotionMap,
|
|
49
|
-
toolbarActionPlugins = _ref.toolbarActionPlugins,
|
|
50
|
-
contentEditableStyles = _ref.contentEditableStyles,
|
|
51
|
-
placeholderStyles = _ref.placeholderStyles;
|
|
52
|
-
var editorTheme = (0, _react.useRef)((0, _lexicalTheme.createTheme)());
|
|
53
|
-
var config = (0, _LexicalEditorConfig.useLexicalEditorConfig)();
|
|
54
|
-
var _useSharedHistoryCont = (0, _SharedHistoryContext.useSharedHistoryContext)(),
|
|
55
|
-
historyState = _useSharedHistoryCont.historyState;
|
|
56
|
-
var placeholderElem = /*#__PURE__*/_react.default.createElement(_Placeholder.Placeholder, {
|
|
1
|
+
import React, { Fragment, useId, useRef, useState } from "react";
|
|
2
|
+
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
3
|
+
import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
4
|
+
import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
|
|
5
|
+
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
6
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
7
|
+
import { makeDecoratable } from "@webiny/react-composition";
|
|
8
|
+
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
9
|
+
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
10
|
+
import { allNodes } from "@webiny/lexical-nodes";
|
|
11
|
+
import { RichTextEditorProvider } from "../../context/RichTextEditorContext.js";
|
|
12
|
+
import { BlurEventPlugin } from "../../plugins/BlurEventPlugin/BlurEventPlugin.js";
|
|
13
|
+
import { Placeholder } from "../../ui/Placeholder.js";
|
|
14
|
+
import { SharedHistoryContext, useSharedHistoryContext } from "../../context/SharedHistoryContext.js";
|
|
15
|
+
import { LexicalEditorWithConfig, useLexicalEditorConfig } from "../LexicalEditorConfig/LexicalEditorConfig.js";
|
|
16
|
+
import { StateHandlingPlugin } from "../../plugins/StateHandlingPlugin.js";
|
|
17
|
+
const BaseRichTextEditor = ({
|
|
18
|
+
onChange,
|
|
19
|
+
toolbar,
|
|
20
|
+
staticToolbar,
|
|
21
|
+
nodes,
|
|
22
|
+
placeholder,
|
|
23
|
+
children,
|
|
24
|
+
onBlur,
|
|
25
|
+
focus,
|
|
26
|
+
styles,
|
|
27
|
+
width,
|
|
28
|
+
height,
|
|
29
|
+
contentEditableStyles,
|
|
30
|
+
placeholderStyles,
|
|
31
|
+
...props
|
|
32
|
+
}) => {
|
|
33
|
+
const editorTheme = useRef(props.theme);
|
|
34
|
+
const config = useLexicalEditorConfig();
|
|
35
|
+
const {
|
|
36
|
+
historyState
|
|
37
|
+
} = useSharedHistoryContext();
|
|
38
|
+
const placeholderElem = /*#__PURE__*/React.createElement(Placeholder, {
|
|
57
39
|
styles: placeholderStyles
|
|
58
40
|
}, placeholder || "Enter text...");
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
floatingAnchorElem = _useState2[0],
|
|
63
|
-
setFloatingAnchorElem = _useState2[1];
|
|
64
|
-
var _useRichTextEditor = (0, _useRichTextEditor2.useRichTextEditor)(),
|
|
65
|
-
setTheme = _useRichTextEditor.setTheme,
|
|
66
|
-
setThemeEmotionMap = _useRichTextEditor.setThemeEmotionMap,
|
|
67
|
-
setToolbarActionPlugins = _useRichTextEditor.setToolbarActionPlugins;
|
|
68
|
-
(0, _react.useEffect)(function () {
|
|
69
|
-
setTheme(theme);
|
|
70
|
-
setThemeEmotionMap(themeEmotionMap);
|
|
71
|
-
}, [themeEmotionMap, theme]);
|
|
72
|
-
(0, _react.useEffect)(function () {
|
|
73
|
-
if (toolbarActionPlugins) {
|
|
74
|
-
setToolbarActionPlugins(toolbarActionPlugins || []);
|
|
75
|
-
}
|
|
76
|
-
}, [toolbarActionPlugins]);
|
|
77
|
-
var onRef = function onRef(_floatingAnchorElem) {
|
|
41
|
+
const scrollRef = useRef(null);
|
|
42
|
+
const [floatingAnchorElem, setFloatingAnchorElem] = useState(undefined);
|
|
43
|
+
const onRef = _floatingAnchorElem => {
|
|
78
44
|
if (_floatingAnchorElem !== null) {
|
|
79
45
|
setFloatingAnchorElem(_floatingAnchorElem);
|
|
80
46
|
}
|
|
81
47
|
};
|
|
82
|
-
|
|
48
|
+
const sizeStyle = {
|
|
83
49
|
height: height || "",
|
|
84
50
|
width: width || ""
|
|
85
51
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}, plugin.element);
|
|
93
|
-
});
|
|
94
|
-
var editorValue = (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)();
|
|
95
|
-
var initialConfig = {
|
|
96
|
-
// We update the state via the `<LexicalUpdateStatePlugin/>`.
|
|
97
|
-
editorState: null,
|
|
52
|
+
const configNodes = config.nodes.map(node => node.node);
|
|
53
|
+
const configPlugins = config.plugins.map(plugin => /*#__PURE__*/React.createElement(Fragment, {
|
|
54
|
+
key: plugin.name
|
|
55
|
+
}, plugin.element));
|
|
56
|
+
const initialConfig = {
|
|
57
|
+
editorId: useId(),
|
|
98
58
|
namespace: "webiny",
|
|
99
|
-
onError:
|
|
59
|
+
onError: () => {
|
|
100
60
|
// Ignore errors. We don't want to break the app because of errors caused by config/value updates.
|
|
101
61
|
// These are usually resolved in the next component render cycle.
|
|
102
62
|
},
|
|
103
|
-
nodes: [
|
|
104
|
-
theme:
|
|
105
|
-
|
|
106
|
-
|
|
63
|
+
nodes: [...allNodes, ...configNodes, ...(nodes || [])],
|
|
64
|
+
theme: {
|
|
65
|
+
...editorTheme.current.tokens,
|
|
66
|
+
// I'm not aware of a better way to pass custom data to nodes.
|
|
67
|
+
// For now, we're using Lexical's theme to pass colors and typography.
|
|
68
|
+
$colors: editorTheme.current.colors,
|
|
69
|
+
$typography: editorTheme.current.typography,
|
|
70
|
+
$cacheKey: JSON.stringify(editorTheme.current)
|
|
71
|
+
}
|
|
107
72
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (typeof onChange === "function") {
|
|
111
|
-
var _editorState = editor.getEditorState();
|
|
112
|
-
onChange(JSON.stringify(_editorState.toJSON()));
|
|
113
|
-
}
|
|
114
|
-
});
|
|
73
|
+
if (props.configRef) {
|
|
74
|
+
props.configRef.current = initialConfig;
|
|
115
75
|
}
|
|
116
76
|
return (
|
|
117
77
|
/*#__PURE__*/
|
|
@@ -122,55 +82,55 @@ var BaseRichTextEditor = function BaseRichTextEditor(_ref) {
|
|
|
122
82
|
*
|
|
123
83
|
* To bypass this issue, we generate a naive `key` based on the number of Nodes.
|
|
124
84
|
*/
|
|
125
|
-
|
|
85
|
+
React.createElement(SharedHistoryContext, null, /*#__PURE__*/React.createElement(LexicalComposer, {
|
|
126
86
|
initialConfig: initialConfig,
|
|
127
87
|
key: initialConfig.nodes.length
|
|
128
|
-
}, /*#__PURE__*/
|
|
88
|
+
}, /*#__PURE__*/React.createElement(RichTextEditorProvider, {
|
|
89
|
+
theme: props.theme,
|
|
90
|
+
toolbarActionPlugins: props.toolbarActionPlugins
|
|
91
|
+
}, staticToolbar ? staticToolbar : null, /*#__PURE__*/React.createElement("div", {
|
|
129
92
|
/* This className is necessary for targeting of editor container from CSS files. */
|
|
130
93
|
className: "editor-shell",
|
|
131
94
|
ref: scrollRef,
|
|
132
|
-
style:
|
|
95
|
+
style: {
|
|
96
|
+
...styles,
|
|
97
|
+
...sizeStyle,
|
|
133
98
|
overflow: "auto",
|
|
134
99
|
position: "relative"
|
|
135
|
-
}
|
|
136
|
-
}, /*#__PURE__*/
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}), /*#__PURE__*/_react.default.createElement(_LexicalClearEditorPlugin.ClearEditorPlugin, null), /*#__PURE__*/_react.default.createElement(_LexicalHistoryPlugin.HistoryPlugin, {
|
|
100
|
+
}
|
|
101
|
+
}, /*#__PURE__*/React.createElement(StateHandlingPlugin, {
|
|
102
|
+
value: props.value,
|
|
103
|
+
onChange: onChange
|
|
104
|
+
}), /*#__PURE__*/React.createElement(ClearEditorPlugin, null), /*#__PURE__*/React.createElement(HistoryPlugin, {
|
|
141
105
|
externalHistoryState: historyState
|
|
142
|
-
}), onBlur && /*#__PURE__*/
|
|
106
|
+
}), onBlur && /*#__PURE__*/React.createElement(BlurEventPlugin, {
|
|
143
107
|
onBlur: onBlur
|
|
144
|
-
}), focus && /*#__PURE__*/
|
|
145
|
-
contentEditable: /*#__PURE__*/
|
|
108
|
+
}), focus && /*#__PURE__*/React.createElement(AutoFocusPlugin, null), configPlugins, children, /*#__PURE__*/React.createElement(RichTextPlugin, {
|
|
109
|
+
contentEditable: /*#__PURE__*/React.createElement("div", {
|
|
146
110
|
className: "editor-scroller",
|
|
147
|
-
style:
|
|
148
|
-
|
|
111
|
+
style: {
|
|
112
|
+
...sizeStyle
|
|
113
|
+
}
|
|
114
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
149
115
|
className: "editor",
|
|
150
116
|
ref: onRef
|
|
151
|
-
}, /*#__PURE__*/
|
|
152
|
-
style:
|
|
153
|
-
outline: 0
|
|
154
|
-
|
|
117
|
+
}, /*#__PURE__*/React.createElement(ContentEditable, {
|
|
118
|
+
style: {
|
|
119
|
+
outline: 0,
|
|
120
|
+
...contentEditableStyles
|
|
121
|
+
}
|
|
155
122
|
}))),
|
|
156
123
|
placeholder: placeholderElem,
|
|
157
|
-
ErrorBoundary:
|
|
158
|
-
}), floatingAnchorElem && toolbar)))
|
|
124
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
125
|
+
}), floatingAnchorElem && toolbar))))
|
|
159
126
|
);
|
|
160
127
|
};
|
|
161
128
|
|
|
162
129
|
/**
|
|
163
130
|
* @description Main editor container
|
|
164
131
|
*/
|
|
165
|
-
|
|
166
|
-
return /*#__PURE__*/
|
|
167
|
-
var css = _ref2.css;
|
|
168
|
-
var themeEmotionMap = props?.themeEmotionMap ?? (0, _lexicalTheme.toTypographyEmotionMap)(css, props.theme, props.themeStylesTransformer);
|
|
169
|
-
return /*#__PURE__*/_react.default.createElement(_SharedHistoryContext.SharedHistoryContext, null, /*#__PURE__*/_react.default.createElement(BaseRichTextEditor, Object.assign({}, props, {
|
|
170
|
-
themeEmotionMap: themeEmotionMap
|
|
171
|
-
})));
|
|
172
|
-
})));
|
|
132
|
+
export const RichTextEditor = makeDecoratable("RichTextEditor", props => {
|
|
133
|
+
return /*#__PURE__*/React.createElement(LexicalEditorWithConfig, null, /*#__PURE__*/React.createElement(BaseRichTextEditor, props));
|
|
173
134
|
});
|
|
174
|
-
exports.RichTextEditor = RichTextEditor;
|
|
175
135
|
|
|
176
136
|
//# sourceMappingURL=RichTextEditor.js.map
|