@webiny/lexical-editor 0.0.0-unstable.d65ec29d44 → 0.0.0-unstable.dbdf5d6258
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 +6 -0
- package/commands/image.js +4 -0
- package/commands/image.js.map +1 -0
- package/commands/index.d.ts +5 -0
- package/commands/index.js +7 -0
- package/commands/index.js.map +1 -0
- package/commands/list.d.ts +7 -0
- package/commands/list.js +6 -0
- package/commands/list.js.map +1 -0
- package/commands/quote.d.ts +5 -0
- package/commands/quote.js +4 -0
- package/commands/quote.js.map +1 -0
- 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 +45 -13
- package/components/Editor/RichTextEditor.js +125 -90
- 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 +18 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +25 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
- package/components/LexicalEditorConfig/components/Node.d.ts +14 -0
- package/components/LexicalEditorConfig/components/Node.js +30 -0
- package/components/LexicalEditorConfig/components/Node.js.map +1 -0
- package/components/LexicalEditorConfig/components/Plugin.d.ts +13 -0
- package/components/LexicalEditorConfig/components/Plugin.js +30 -0
- package/components/LexicalEditorConfig/components/Plugin.js.map +1 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.d.ts +13 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.js +30 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -0
- package/components/LexicalHtmlRenderer.d.ts +5 -3
- package/components/LexicalHtmlRenderer.js +42 -36
- package/components/LexicalHtmlRenderer.js.map +1 -1
- package/components/Toolbar/StaticToolbar.css +676 -0
- package/components/Toolbar/StaticToolbar.d.ts +5 -0
- package/components/Toolbar/StaticToolbar.js +22 -0
- package/components/Toolbar/StaticToolbar.js.map +1 -0
- package/components/ToolbarActions/BoldAction.d.ts +2 -5
- package/components/ToolbarActions/BoldAction.js +20 -33
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.d.ts +2 -5
- package/components/ToolbarActions/BulletListAction.js +30 -80
- package/components/ToolbarActions/BulletListAction.js.map +1 -1
- package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -6
- package/components/ToolbarActions/CodeHighlightAction.js +20 -34
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
- package/components/ToolbarActions/FontColorAction.d.ts +29 -0
- package/components/ToolbarActions/FontColorAction.js +50 -0
- package/components/ToolbarActions/FontColorAction.js.map +1 -0
- package/components/ToolbarActions/ImageAction.d.ts +2 -0
- package/components/ToolbarActions/ImageAction.js +37 -0
- package/components/ToolbarActions/ImageAction.js.map +1 -0
- package/components/ToolbarActions/ItalicAction.d.ts +2 -5
- package/components/ToolbarActions/ItalicAction.js +20 -33
- package/components/ToolbarActions/ItalicAction.js.map +1 -1
- package/components/ToolbarActions/LinkAction.d.ts +2 -7
- package/components/ToolbarActions/LinkAction.js +27 -59
- package/components/ToolbarActions/LinkAction.js.map +1 -1
- package/components/ToolbarActions/NumberedListAction.d.ts +2 -5
- package/components/ToolbarActions/NumberedListAction.js +35 -80
- package/components/ToolbarActions/NumberedListAction.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.d.ts +2 -4
- package/components/ToolbarActions/QuoteAction.js +26 -59
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/TextAlignmentAction.d.ts +29 -0
- package/components/ToolbarActions/TextAlignmentAction.js +61 -0
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -0
- package/components/ToolbarActions/TypographyAction.d.ts +29 -0
- package/components/ToolbarActions/TypographyAction.js +111 -0
- package/components/ToolbarActions/TypographyAction.js.map +1 -0
- package/components/ToolbarActions/UnderlineAction.d.ts +2 -5
- package/components/ToolbarActions/UnderlineAction.js +20 -34
- package/components/ToolbarActions/UnderlineAction.js.map +1 -1
- package/context/FontColorActionContext.d.ts +6 -0
- package/context/FontColorActionContext.js +4 -0
- package/context/FontColorActionContext.js.map +1 -0
- package/context/RichTextEditorContext.d.ts +10 -3
- package/context/RichTextEditorContext.js +30 -25
- package/context/RichTextEditorContext.js.map +1 -1
- package/context/SharedHistoryContext.d.ts +10 -0
- package/context/SharedHistoryContext.js +19 -0
- package/context/SharedHistoryContext.js.map +1 -0
- package/context/TextAlignmentActionContextProps.d.ts +9 -0
- package/context/TextAlignmentActionContextProps.js +4 -0
- package/context/TextAlignmentActionContextProps.js.map +1 -0
- package/context/TypographyActionContext.d.ts +8 -0
- package/context/TypographyActionContext.js +4 -0
- package/context/TypographyActionContext.js.map +1 -0
- 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 -0
- package/hooks/index.js +9 -0
- package/hooks/index.js.map +1 -0
- package/hooks/useCurrentElement.d.ts +7 -0
- package/hooks/useCurrentElement.js +26 -0
- package/hooks/useCurrentElement.js.map +1 -0
- package/hooks/useCurrentSelection.d.ts +13 -0
- package/hooks/useCurrentSelection.js +57 -0
- package/hooks/useCurrentSelection.js.map +1 -0
- package/hooks/useFontColorPicker.d.ts +2 -0
- package/hooks/useFontColorPicker.js +11 -0
- package/hooks/useFontColorPicker.js.map +1 -0
- package/hooks/useIsMounted.d.ts +1 -0
- package/hooks/useIsMounted.js +12 -0
- package/hooks/useIsMounted.js.map +1 -0
- package/hooks/useRichTextEditor.d.ts +1 -1
- package/hooks/useRichTextEditor.js +8 -12
- package/hooks/useRichTextEditor.js.map +1 -1
- package/hooks/useTextAlignmentAction.d.ts +1 -0
- package/hooks/useTextAlignmentAction.js +11 -0
- package/hooks/useTextAlignmentAction.js.map +1 -0
- package/hooks/useTypographyAction.d.ts +1 -0
- package/hooks/useTypographyAction.js +11 -0
- package/hooks/useTypographyAction.js.map +1 -0
- package/images/icons/font-color.svg +1 -0
- package/images/icons/indent.svg +3 -0
- package/images/icons/insert-image.svg +4 -0
- package/images/icons/justify.svg +3 -0
- package/images/icons/outdent.svg +3 -0
- package/index.d.ts +33 -34
- package/index.js +45 -238
- package/index.js.map +1 -1
- package/package.json +20 -22
- package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +2 -2
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +18 -26
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +12 -18
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/index.d.ts +1 -1
- package/plugins/CodeHighlightPlugin/index.js +2 -15
- package/plugins/CodeHighlightPlugin/index.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +10 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +28 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +7 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +61 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +2 -79
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +5 -6
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +8 -220
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.js +2 -15
- 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/FloatingLinkEditorPlugin/types.d.ts +10 -0
- package/plugins/FloatingLinkEditorPlugin/types.js +3 -0
- package/plugins/FloatingLinkEditorPlugin/types.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.d.ts +8 -0
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +128 -0
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -0
- package/plugins/FontColorPlugin/FontColorPlugin.d.ts +1 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js +27 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
- 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 +11 -0
- package/plugins/ImagesPlugin/ImagesPlugin.js +148 -0
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -0
- package/plugins/LinkPlugin/LinkPlugin.d.ts +5 -0
- package/plugins/LinkPlugin/LinkPlugin.js +58 -0
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -0
- package/plugins/ListPLugin/ListPlugin.d.ts +1 -0
- package/plugins/ListPLugin/ListPlugin.js +59 -0
- package/plugins/ListPLugin/ListPlugin.js.map +1 -0
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.d.ts +1 -0
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +26 -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.d.ts +1 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js +27 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
- package/types.d.ts +12 -2
- package/types.js +8 -4
- package/types.js.map +1 -1
- package/ui/ContentEditable.css +22 -0
- package/{plugins/AutoLinkPlugin/AutoLinkPlugin.d.ts → ui/ContentEditable.d.ts} +4 -4
- package/ui/ContentEditable.js +19 -0
- package/ui/ContentEditable.js.map +1 -0
- package/ui/Divider.d.ts +0 -1
- package/ui/Divider.js +6 -11
- package/ui/Divider.js.map +1 -1
- package/ui/DropDown.d.ts +4 -4
- package/ui/DropDown.js +105 -90
- package/ui/DropDown.js.map +1 -1
- package/ui/ImageResizer.d.ts +23 -0
- package/ui/ImageResizer.js +211 -0
- package/ui/ImageResizer.js.map +1 -0
- package/ui/LinkPreview.d.ts +0 -1
- package/ui/LinkPreview.js +32 -36
- package/ui/LinkPreview.js.map +1 -1
- package/ui/Placeholder.css +2 -5
- package/ui/Placeholder.d.ts +4 -2
- package/ui/Placeholder.js +13 -13
- package/ui/Placeholder.js.map +1 -1
- package/ui/TextInput.d.ts +1 -2
- package/ui/TextInput.js +14 -19
- package/ui/TextInput.js.map +1 -1
- package/ui/ToolbarActionDialog.d.ts +11 -0
- package/ui/ToolbarActionDialog.js +77 -0
- package/ui/ToolbarActionDialog.js.map +1 -0
- package/utils/canUseDOM.d.ts +1 -0
- package/utils/canUseDOM.js +3 -0
- package/utils/canUseDOM.js.map +1 -0
- package/utils/files.d.ts +11 -0
- package/utils/files.js +11 -0
- package/utils/files.js.map +1 -0
- package/utils/getDOMRangeRect.d.ts +0 -2
- package/utils/getDOMRangeRect.js +7 -11
- package/utils/getDOMRangeRect.js.map +1 -1
- package/utils/getSelectedNode.d.ts +1 -1
- package/utils/getSelectedNode.js +12 -17
- package/utils/getSelectedNode.js.map +1 -1
- package/utils/getTransparentImage.d.ts +1 -0
- package/utils/getTransparentImage.js +5 -0
- package/utils/getTransparentImage.js.map +1 -0
- package/utils/insertImage.d.ts +2 -0
- package/utils/insertImage.js +16 -0
- package/utils/insertImage.js.map +1 -0
- 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/{themes/webinyLexicalTheme.d.ts → utils/isHTMLElement.d.ts} +1 -3
- package/utils/isHTMLElement.js +12 -0
- package/utils/isHTMLElement.js.map +1 -0
- package/utils/isValidJSON.js +5 -10
- package/utils/isValidJSON.js.map +1 -1
- package/utils/isValidLexicalData.d.ts +4 -2
- package/utils/isValidLexicalData.js +18 -18
- package/utils/isValidLexicalData.js.map +1 -1
- package/utils/point.js +38 -66
- package/utils/point.js.map +1 -1
- package/utils/rect.d.ts +2 -4
- package/utils/rect.js +117 -156
- package/utils/rect.js.map +1 -1
- package/utils/sanitizeUrl.d.ts +0 -7
- package/utils/sanitizeUrl.js +10 -12
- package/utils/sanitizeUrl.js.map +1 -1
- package/utils/setFloatingElemPosition.d.ts +1 -3
- package/utils/setFloatingElemPosition.js +31 -39
- package/utils/setFloatingElemPosition.js.map +1 -1
- package/components/AddRichTextEditorNodeType.d.ts +0 -6
- package/components/AddRichTextEditorNodeType.js +0 -28
- package/components/AddRichTextEditorNodeType.js.map +0 -1
- package/components/AddRichTextEditorPlugin.d.ts +0 -10
- package/components/AddRichTextEditorPlugin.js +0 -31
- package/components/AddRichTextEditorPlugin.js.map +0 -1
- package/components/AddToolbarAction.d.ts +0 -7
- package/components/AddToolbarAction.js +0 -33
- package/components/AddToolbarAction.js.map +0 -1
- package/components/Editor/HeadingEditor.d.ts +0 -7
- package/components/Editor/HeadingEditor.js +0 -28
- 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/Toolbar/HeadingToolbar.d.ts +0 -12
- package/components/Toolbar/HeadingToolbar.js +0 -23
- package/components/Toolbar/HeadingToolbar.js.map +0 -1
- package/components/Toolbar/ParagraphToolbar.d.ts +0 -12
- package/components/Toolbar/ParagraphToolbar.js +0 -23
- package/components/Toolbar/ParagraphToolbar.js.map +0 -1
- package/components/Toolbar/Toolbar.css +0 -414
- package/components/Toolbar/Toolbar.d.ts +0 -13
- package/components/Toolbar/Toolbar.js +0 -161
- package/components/Toolbar/Toolbar.js.map +0 -1
- package/components/ToolbarActions/FontSizeAction.d.ts +0 -2
- package/components/ToolbarActions/FontSizeAction.js +0 -104
- package/components/ToolbarActions/FontSizeAction.js.map +0 -1
- package/components/ToolbarPresets/HeadingToolbarPreset.d.ts +0 -2
- package/components/ToolbarPresets/HeadingToolbarPreset.js +0 -44
- package/components/ToolbarPresets/HeadingToolbarPreset.js.map +0 -1
- package/components/ToolbarPresets/ParagraphToolbarPreset.d.ts +0 -2
- package/components/ToolbarPresets/ParagraphToolbarPreset.js +0 -59
- package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +0 -1
- package/nodes/webinyNodes.d.ts +0 -2
- package/nodes/webinyNodes.js +0 -15
- package/nodes/webinyNodes.js.map +0 -1
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.js +0 -46
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.js.map +0 -1
- package/plugins/AutoLinkPlugin/index.d.ts +0 -1
- package/plugins/AutoLinkPlugin/index.js +0 -16
- package/plugins/AutoLinkPlugin/index.js.map +0 -1
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.d.ts +0 -17
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js +0 -88
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js.map +0 -1
- package/plugins/ClickableLinkPlugin/index.d.ts +0 -1
- package/plugins/ClickableLinkPlugin/index.js +0 -16
- package/plugins/ClickableLinkPlugin/index.js.map +0 -1
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.d.ts +0 -8
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js +0 -34
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +0 -1
- package/plugins/LexicalUpdateStatePlugin/index.d.ts +0 -1
- package/plugins/LexicalUpdateStatePlugin/index.js +0 -16
- package/plugins/LexicalUpdateStatePlugin/index.js.map +0 -1
- package/themes/webinyLexicalTheme.css +0 -422
- package/themes/webinyLexicalTheme.js +0 -107
- package/themes/webinyLexicalTheme.js.map +0 -1
- package/utils/generateInitialLexicalValue.d.ts +0 -5
- package/utils/generateInitialLexicalValue.js +0 -29
- package/utils/generateInitialLexicalValue.js.map +0 -1
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._
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LexicalCommand, NodeKey } from "lexical";
|
|
2
|
+
import type { ImageNodeProps } from "@webiny/lexical-nodes";
|
|
3
|
+
export interface ImagePayload extends ImageNodeProps {
|
|
4
|
+
key?: NodeKey;
|
|
5
|
+
}
|
|
6
|
+
export declare const INSERT_IMAGE_COMMAND: LexicalCommand<ImagePayload>;
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LexicalCommand } from "lexical";
|
|
2
|
+
export type ListCommandPayload = {
|
|
3
|
+
themeStyleId?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload>;
|
|
6
|
+
export declare const INSERT_ORDERED_LIST_COMMAND: LexicalCommand<ListCommandPayload>;
|
|
7
|
+
export declare const REMOVE_LIST_COMMAND: LexicalCommand<void>;
|
package/commands/list.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
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");
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
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,23 +1,55 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
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
|
+
};
|
|
4
9
|
export interface RichTextEditorProps {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
children?: React.ReactNode | React.ReactNode[];
|
|
11
|
+
classes?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
contentEditableStyles?: React.CSSProperties;
|
|
9
14
|
focus?: boolean;
|
|
10
|
-
|
|
15
|
+
height?: number | string;
|
|
11
16
|
nodes?: Klass<LexicalNode>[];
|
|
12
|
-
/**
|
|
13
|
-
* @description Lexical plugins
|
|
14
|
-
*/
|
|
15
|
-
children?: React.ReactNode | React.ReactNode[];
|
|
16
17
|
onBlur?: (editorState: LexicalValue) => void;
|
|
17
|
-
|
|
18
|
+
onChange?: (value: LexicalValue) => void;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
placeholderStyles?: React.CSSProperties;
|
|
21
|
+
staticToolbar?: React.ReactNode;
|
|
22
|
+
styles?: React.CSSProperties;
|
|
23
|
+
tag?: string;
|
|
24
|
+
theme: EditorTheme;
|
|
25
|
+
toolbarActionPlugins?: ToolbarActionPlugin[];
|
|
26
|
+
toolbar?: React.ReactNode;
|
|
27
|
+
value: LexicalValue | null | undefined;
|
|
28
|
+
configRef?: React.MutableRefObject<InitialEditorConfig | undefined>;
|
|
18
29
|
width?: number | string;
|
|
19
30
|
}
|
|
20
31
|
/**
|
|
21
32
|
* @description Main editor container
|
|
22
33
|
*/
|
|
23
|
-
export declare const RichTextEditor:
|
|
34
|
+
export declare const RichTextEditor: ((props: RichTextEditorProps) => React.JSX.Element) & {
|
|
35
|
+
original: (props: RichTextEditorProps) => React.JSX.Element;
|
|
36
|
+
originalName: string;
|
|
37
|
+
displayName: string;
|
|
38
|
+
} & {
|
|
39
|
+
original: ((props: RichTextEditorProps) => React.JSX.Element) & {
|
|
40
|
+
original: (props: RichTextEditorProps) => React.JSX.Element;
|
|
41
|
+
originalName: string;
|
|
42
|
+
displayName: string;
|
|
43
|
+
};
|
|
44
|
+
originalName: string;
|
|
45
|
+
displayName: string;
|
|
46
|
+
} & {
|
|
47
|
+
createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<((props: RichTextEditorProps) => React.JSX.Element) & {
|
|
48
|
+
original: (props: RichTextEditorProps) => React.JSX.Element;
|
|
49
|
+
originalName: string;
|
|
50
|
+
displayName: string;
|
|
51
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
52
|
+
};
|
|
53
|
+
export declare namespace RichTextEditor {
|
|
54
|
+
type InitialConfig = InitialEditorConfig;
|
|
55
|
+
}
|
|
@@ -1,107 +1,142 @@
|
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
setFloatingAnchorElem = _useState2[1];
|
|
46
|
-
var onRef = function onRef(_floatingAnchorElem) {
|
|
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
|
+
disabled = false,
|
|
29
|
+
height,
|
|
30
|
+
contentEditableStyles,
|
|
31
|
+
placeholderStyles,
|
|
32
|
+
...props
|
|
33
|
+
}) => {
|
|
34
|
+
const editorTheme = useRef(props.theme);
|
|
35
|
+
const config = useLexicalEditorConfig();
|
|
36
|
+
const {
|
|
37
|
+
historyState
|
|
38
|
+
} = useSharedHistoryContext();
|
|
39
|
+
const placeholderElem = /*#__PURE__*/React.createElement(Placeholder, {
|
|
40
|
+
styles: placeholderStyles
|
|
41
|
+
}, placeholder || "Enter text...");
|
|
42
|
+
const scrollRef = useRef(null);
|
|
43
|
+
const [floatingAnchorElem, setFloatingAnchorElem] = useState(undefined);
|
|
44
|
+
const onRef = _floatingAnchorElem => {
|
|
47
45
|
if (_floatingAnchorElem !== null) {
|
|
48
46
|
setFloatingAnchorElem(_floatingAnchorElem);
|
|
49
47
|
}
|
|
50
48
|
};
|
|
51
|
-
|
|
49
|
+
const sizeStyle = {
|
|
52
50
|
height: height || "",
|
|
53
51
|
width: width || ""
|
|
54
52
|
};
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const configNodes = config.nodes.map(node => node.node);
|
|
54
|
+
const configPlugins = config.plugins.map(plugin => /*#__PURE__*/React.createElement(Fragment, {
|
|
55
|
+
key: plugin.name
|
|
56
|
+
}, plugin.element));
|
|
57
|
+
const initialConfig = {
|
|
58
|
+
editorId: useId(),
|
|
59
|
+
editable: !disabled,
|
|
57
60
|
namespace: "webiny",
|
|
58
|
-
onError:
|
|
59
|
-
|
|
61
|
+
onError: () => {
|
|
62
|
+
// Ignore errors. We don't want to break the app because of errors caused by config/value updates.
|
|
63
|
+
// These are usually resolved in the next component render cycle.
|
|
60
64
|
},
|
|
61
|
-
nodes: [
|
|
62
|
-
theme:
|
|
65
|
+
nodes: [...allNodes, ...configNodes, ...(nodes || [])],
|
|
66
|
+
theme: {
|
|
67
|
+
...editorTheme.current.tokens,
|
|
68
|
+
// I'm not aware of a better way to pass custom data to nodes.
|
|
69
|
+
// For now, we're using Lexical's theme to pass colors and typography.
|
|
70
|
+
$colors: editorTheme.current.colors,
|
|
71
|
+
$typography: editorTheme.current.typography,
|
|
72
|
+
$cacheKey: JSON.stringify(editorTheme.current)
|
|
73
|
+
}
|
|
63
74
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (typeof onChange === "function") {
|
|
67
|
-
var _editorState = editor.getEditorState();
|
|
68
|
-
onChange(JSON.stringify(_editorState.toJSON()));
|
|
69
|
-
}
|
|
70
|
-
});
|
|
75
|
+
if (props.configRef) {
|
|
76
|
+
props.configRef.current = initialConfig;
|
|
71
77
|
}
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}, /*#__PURE__*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
78
|
+
return (
|
|
79
|
+
/*#__PURE__*/
|
|
80
|
+
/**
|
|
81
|
+
* Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future
|
|
82
|
+
* updates to the config will be ignored. This is a problem because we pull in Nodes from our config,
|
|
83
|
+
* and initially, there can be multiple re-renders, while the config object is settled.
|
|
84
|
+
*
|
|
85
|
+
* To bypass this issue, we generate a naive `key` based on the number of Nodes.
|
|
86
|
+
*/
|
|
87
|
+
React.createElement(SharedHistoryContext, null, /*#__PURE__*/React.createElement(LexicalComposer, {
|
|
88
|
+
initialConfig: initialConfig,
|
|
89
|
+
key: initialConfig.nodes.length
|
|
90
|
+
}, /*#__PURE__*/React.createElement(RichTextEditorProvider, {
|
|
91
|
+
theme: props.theme,
|
|
92
|
+
toolbarActionPlugins: props.toolbarActionPlugins
|
|
93
|
+
}, staticToolbar && !disabled ? staticToolbar : null, /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
"data-role": "overlays",
|
|
95
|
+
className: "relative"
|
|
96
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
97
|
+
/* This className is necessary for targeting of editor container from CSS files. */
|
|
98
|
+
className: "editor-shell",
|
|
99
|
+
ref: scrollRef,
|
|
100
|
+
style: {
|
|
101
|
+
...styles,
|
|
102
|
+
...sizeStyle,
|
|
103
|
+
overflow: "auto",
|
|
104
|
+
position: "relative"
|
|
105
|
+
}
|
|
106
|
+
}, /*#__PURE__*/React.createElement(StateHandlingPlugin, {
|
|
107
|
+
value: props.value,
|
|
108
|
+
onChange: disabled ? undefined : onChange
|
|
109
|
+
}), /*#__PURE__*/React.createElement(ClearEditorPlugin, null), /*#__PURE__*/React.createElement(HistoryPlugin, {
|
|
110
|
+
externalHistoryState: historyState
|
|
111
|
+
}), onBlur && /*#__PURE__*/React.createElement(BlurEventPlugin, {
|
|
112
|
+
onBlur: onBlur
|
|
113
|
+
}), focus && /*#__PURE__*/React.createElement(AutoFocusPlugin, null), configPlugins, children, /*#__PURE__*/React.createElement(RichTextPlugin, {
|
|
114
|
+
contentEditable: /*#__PURE__*/React.createElement("div", {
|
|
115
|
+
className: "editor-scroller",
|
|
116
|
+
style: {
|
|
117
|
+
...sizeStyle
|
|
118
|
+
}
|
|
119
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
120
|
+
className: "editor",
|
|
121
|
+
ref: onRef
|
|
122
|
+
}, /*#__PURE__*/React.createElement(ContentEditable, {
|
|
123
|
+
disabled: disabled,
|
|
124
|
+
style: {
|
|
125
|
+
outline: 0,
|
|
126
|
+
...contentEditableStyles
|
|
127
|
+
}
|
|
128
|
+
}))),
|
|
129
|
+
placeholder: placeholderElem,
|
|
130
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
131
|
+
}), disabled ? null : floatingAnchorElem && toolbar))))
|
|
132
|
+
);
|
|
99
133
|
};
|
|
100
134
|
|
|
101
135
|
/**
|
|
102
136
|
* @description Main editor container
|
|
103
137
|
*/
|
|
104
|
-
|
|
105
|
-
return /*#__PURE__*/
|
|
138
|
+
export const RichTextEditor = makeDecoratable("RichTextEditor", props => {
|
|
139
|
+
return /*#__PURE__*/React.createElement(LexicalEditorWithConfig, null, /*#__PURE__*/React.createElement(BaseRichTextEditor, props));
|
|
106
140
|
});
|
|
107
|
-
|
|
141
|
+
|
|
142
|
+
//# sourceMappingURL=RichTextEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_Placeholder","_generateInitialLexicalValue","_webinyNodes","_webinyLexicalTheme","_LexicalComposer","_LexicalOnChangePlugin","_LexicalAutoFocusPlugin","_LexicalClearEditorPlugin","_LexicalRichTextPlugin","_LexicalErrorBoundary","_interopRequireDefault","_reactComposition","_LexicalContentEditable","_RichTextEditorContext","_isValidLexicalData","_LexicalUpdateStatePlugin","_BlurEventPlugin","BaseRichTextEditor","_ref","toolbar","onChange","value","nodes","placeholder","children","onBlur","focus","width","height","placeholderElem","default","createElement","Placeholder","scrollRef","useRef","_useState","useState","undefined","_useState2","_slicedToArray2","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","sizeStyle","initialConfig","editorState","isValidLexicalData","generateInitialLexicalValue","namespace","onError","error","concat","_toConsumableArray2","WebinyNodes","theme","handleOnChange","editor","read","getEditorState","JSON","stringify","toJSON","LexicalComposer","ref","style","_objectSpread2","OnChangePlugin","LexicalUpdateStatePlugin","ClearEditorPlugin","BlurEventPlugin","AutoFocusPlugin","RichTextPlugin","contentEditable","className","ContentEditable","outline","ErrorBoundary","LexicalErrorBoundary","RichTextEditor","makeComposable","props","RichTextEditorProvider","exports"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\";\nimport { LexicalValue } from \"~/types\";\nimport { Placeholder } from \"~/ui/Placeholder\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { WebinyNodes } from \"~/nodes/webinyNodes\";\nimport { theme } from \"~/themes/webinyLexicalTheme\";\nimport { EditorState } from \"lexical/LexicalEditorState\";\nimport { Klass, LexicalEditor, LexicalNode } from \"lexical\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { OnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\nimport { AutoFocusPlugin } from \"@lexical/react/LexicalAutoFocusPlugin\";\nimport { ClearEditorPlugin } from \"@lexical/react/LexicalClearEditorPlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport LexicalErrorBoundary from \"@lexical/react/LexicalErrorBoundary\";\nimport { makeComposable } from \"@webiny/react-composition\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { LexicalUpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin\";\n\nexport interface RichTextEditorProps {\n toolbar?: React.ReactNode;\n tag?: string;\n onChange?: (json: LexicalValue) => void;\n value: LexicalValue | null;\n focus?: boolean;\n placeholder?: string;\n nodes?: Klass<LexicalNode>[];\n /**\n * @description Lexical plugins\n */\n children?: React.ReactNode | React.ReactNode[];\n onBlur?: (editorState: LexicalValue) => void;\n height?: number | string;\n width?: number | string;\n}\n\nconst BaseRichTextEditor: React.FC<RichTextEditorProps> = ({\n toolbar,\n onChange,\n value,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n width,\n height\n}: RichTextEditorProps) => {\n const placeholderElem = <Placeholder>{placeholder || \"Enter text...\"}</Placeholder>;\n const scrollRef = useRef(null);\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem);\n }\n };\n\n const sizeStyle = {\n height: height || \"\",\n width: width || \"\"\n };\n\n const initialConfig = {\n editorState: isValidLexicalData(value) ? value : generateInitialLexicalValue(),\n namespace: \"webiny\",\n onError: (error: Error) => {\n throw error;\n },\n nodes: [...WebinyNodes, ...(nodes || [])],\n theme: theme\n };\n\n function handleOnChange(editorState: EditorState, editor: LexicalEditor) {\n editorState.read(() => {\n if (typeof onChange === \"function\") {\n const editorState = editor.getEditorState();\n onChange(JSON.stringify(editorState.toJSON()));\n }\n });\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig}>\n <div ref={scrollRef} style={{ ...sizeStyle }}>\n {/* data */}\n <OnChangePlugin onChange={handleOnChange} />\n {value && <LexicalUpdateStatePlugin value={value} />}\n <ClearEditorPlugin />\n {/* Events */}\n {onBlur && <BlurEventPlugin onBlur={onBlur} />}\n {focus && <AutoFocusPlugin />}\n {/* External plugins and components */}\n {children}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\" style={{ ...sizeStyle }}>\n <div className=\"editor\" ref={onRef} style={{ ...sizeStyle }}>\n <ContentEditable style={{ outline: 0, ...sizeStyle }} />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar */}\n {floatingAnchorElem && toolbar}\n </div>\n </LexicalComposer>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeComposable<RichTextEditorProps>(\"RichTextEditor\", props => {\n return (\n <RichTextEditorProvider>\n <BaseRichTextEditor {...props} />\n </RichTextEditorProvider>\n );\n});\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,4BAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AAGA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,uBAAA,GAAAP,OAAA;AACA,IAAAQ,yBAAA,GAAAR,OAAA;AACA,IAAAS,sBAAA,GAAAT,OAAA;AACA,IAAAU,qBAAA,GAAAC,sBAAA,CAAAX,OAAA;AACA,IAAAY,iBAAA,GAAAZ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cAAA"}
|
|
1
|
+
{"version":3,"names":["React","Fragment","useId","useRef","useState","LexicalComposer","AutoFocusPlugin","ClearEditorPlugin","RichTextPlugin","LexicalErrorBoundary","makeDecoratable","HistoryPlugin","ContentEditable","allNodes","RichTextEditorProvider","BlurEventPlugin","Placeholder","SharedHistoryContext","useSharedHistoryContext","LexicalEditorWithConfig","useLexicalEditorConfig","StateHandlingPlugin","BaseRichTextEditor","onChange","toolbar","staticToolbar","nodes","placeholder","children","onBlur","focus","styles","width","disabled","height","contentEditableStyles","placeholderStyles","props","editorTheme","theme","config","historyState","placeholderElem","createElement","scrollRef","floatingAnchorElem","setFloatingAnchorElem","undefined","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","key","name","element","initialConfig","editorId","editable","namespace","onError","current","tokens","$colors","colors","$typography","typography","$cacheKey","JSON","stringify","configRef","length","toolbarActionPlugins","className","ref","style","overflow","position","value","externalHistoryState","contentEditable","outline","ErrorBoundary","RichTextEditor"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useId, useRef, useState } from \"react\";\nimport type { Klass, LexicalNode } from \"lexical\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\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 type { EditorTheme } from \"@webiny/lexical-theme\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext.js\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin.js\";\nimport type { LexicalValue, ToolbarActionPlugin } from \"~/types.js\";\nimport { Placeholder } from \"~/ui/Placeholder.js\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext.js\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig.js\";\nimport { StateHandlingPlugin } from \"~/plugins/StateHandlingPlugin.js\";\n\nexport type InitialEditorConfig = React.ComponentProps<typeof LexicalComposer>[\"initialConfig\"] & {\n editorId: string;\n};\n\nexport interface RichTextEditorProps {\n children?: React.ReactNode | React.ReactNode[];\n classes?: string;\n disabled?: boolean;\n contentEditableStyles?: React.CSSProperties;\n focus?: boolean;\n height?: number | string;\n nodes?: Klass<LexicalNode>[];\n onBlur?: (editorState: LexicalValue) => void;\n onChange?: (value: LexicalValue) => void;\n placeholder?: string;\n placeholderStyles?: React.CSSProperties;\n staticToolbar?: React.ReactNode;\n styles?: React.CSSProperties;\n tag?: string;\n theme: EditorTheme;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n toolbar?: React.ReactNode;\n value: LexicalValue | null | undefined;\n configRef?: React.MutableRefObject<InitialEditorConfig | undefined>;\n width?: number | string;\n}\n\nconst BaseRichTextEditor = ({\n onChange,\n toolbar,\n staticToolbar,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n disabled = false,\n height,\n contentEditableStyles,\n placeholderStyles,\n ...props\n}: RichTextEditorProps) => {\n const editorTheme = useRef(props.theme);\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\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 initialConfig = {\n editorId: useId(),\n editable: !disabled,\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: {\n ...editorTheme.current.tokens,\n // I'm not aware of a better way to pass custom data to nodes.\n // For now, we're using Lexical's theme to pass colors and typography.\n $colors: editorTheme.current.colors,\n $typography: editorTheme.current.typography,\n $cacheKey: JSON.stringify(editorTheme.current)\n }\n };\n\n if (props.configRef) {\n props.configRef.current = initialConfig;\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 toolbarActionPlugins={props.toolbarActionPlugins}\n >\n {staticToolbar && !disabled ? staticToolbar : null}\n <div data-role={\"overlays\"} className={\"relative\"}></div>\n <div\n /* This className is necessary for targeting of editor container from CSS files. */\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{\n ...styles,\n ...sizeStyle,\n overflow: \"auto\",\n position: \"relative\"\n }}\n >\n {/* State plugins. */}\n <StateHandlingPlugin\n value={props.value}\n onChange={disabled ? undefined : onChange}\n />\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 disabled={disabled}\n style={{ outline: 0, ...contentEditableStyles }}\n />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar. */}\n {disabled ? null : 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\nexport namespace RichTextEditor {\n export type InitialConfig = InitialEditorConfig;\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEhE,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,iBAAiB,QAAQ,yCAAyC;AAC3E,SAASC,cAAc,QAAQ,sCAAsC;AACrE,SAASC,oBAAoB,QAAQ,qCAAqC;AAC1E,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,aAAa,QAAQ,qCAAqC;AACnE,SAASC,eAAe,QAAQ,uCAAuC;AAEvE,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,sBAAsB;AAC/B,SAASC,eAAe;AAExB,SAASC,WAAW;AACpB,SAASC,oBAAoB,EAAEC,uBAAuB;AACtD,SACIC,uBAAuB,EACvBC,sBAAsB;AAE1B,SAASC,mBAAmB;AA6B5B,MAAMC,kBAAkB,GAAGA,CAAC;EACxBC,QAAQ;EACRC,OAAO;EACPC,aAAa;EACbC,KAAK;EACLC,WAAW;EACXC,QAAQ;EACRC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC,KAAK;EACLC,QAAQ,GAAG,KAAK;EAChBC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]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LexicalValue, NormalizedInputValue } from "../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes
|
|
4
|
+
* of input into a value that is either a `null` or a `LexicalValue`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeInputValue(value: LexicalValue | null | undefined): NormalizedInputValue;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const isValueEmpty = value => {
|
|
2
|
+
return [undefined, null, "", '""', "null"].includes(value);
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes
|
|
7
|
+
* of input into a value that is either a `null` or a `LexicalValue`.
|
|
8
|
+
*/
|
|
9
|
+
export function normalizeInputValue(value) {
|
|
10
|
+
if (isValueEmpty(value)) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=normalizeInputValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isValueEmpty","value","undefined","includes","normalizeInputValue"],"sources":["normalizeInputValue.ts"],"sourcesContent":["import type { LexicalValue, NormalizedInputValue } from \"~/types.js\";\n\nconst isValueEmpty = (value: any) => {\n return [undefined, null, \"\", '\"\"', \"null\"].includes(value);\n};\n\n/**\n * Value passed to the `RichTextEditor` component can be anything. This function normalizes some of the more common shapes\n * of input into a value that is either a `null` or a `LexicalValue`.\n */\nexport function normalizeInputValue(value: LexicalValue | null | undefined) {\n if (isValueEmpty(value)) {\n return null;\n }\n\n return value as NormalizedInputValue;\n}\n"],"mappings":"AAEA,MAAMA,YAAY,GAAIC,KAAU,IAAK;EACjC,OAAO,CAACC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAACC,QAAQ,CAACF,KAAK,CAAC;AAC9D,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,SAASG,mBAAmBA,CAACH,KAAsC,EAAE;EACxE,IAAID,YAAY,CAACC,KAAK,CAAC,EAAE;IACrB,OAAO,IAAI;EACf;EAEA,OAAOA,KAAK;AAChB","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToolbarElementConfig } from "./components/ToolbarElement.js";
|
|
2
|
+
import type { PluginConfig } from "./components/Plugin.js";
|
|
3
|
+
import type { NodeConfig } from "./components/Node.js";
|
|
4
|
+
export type { ToolbarElementConfig } from "./components/ToolbarElement.js";
|
|
5
|
+
export type { PluginConfig } from "./components/Plugin.js";
|
|
6
|
+
export type { NodeConfig } from "./components/Node.js";
|
|
7
|
+
export declare const LexicalEditorConfig: (({ priority, children }: import("@webiny/react-properties").ConfigProps) => React.JSX.Element) & {
|
|
8
|
+
ToolbarElement: ({ name, element, after, before, remove }: import("./components/ToolbarElement.js").ToolbarElementProps) => import("react").JSX.Element;
|
|
9
|
+
Plugin: ({ name, element, after, before, remove }: import("./components/Plugin.js").PluginProps) => import("react").JSX.Element;
|
|
10
|
+
Node: ({ name, node, after, before, remove }: import("./components/Node.js").NodeProps) => import("react").JSX.Element;
|
|
11
|
+
};
|
|
12
|
+
export declare const LexicalEditorWithConfig: ({ onProperties, children }: import("@webiny/react-properties").WithConfigProps) => React.JSX.Element;
|
|
13
|
+
interface LexicalEditorConfigData {
|
|
14
|
+
toolbarElements: ToolbarElementConfig[];
|
|
15
|
+
plugins: PluginConfig[];
|
|
16
|
+
nodes: NodeConfig[];
|
|
17
|
+
}
|
|
18
|
+
export declare function useLexicalEditorConfig(): LexicalEditorConfigData;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { createConfigurableComponent } from "@webiny/react-properties";
|
|
3
|
+
import { ToolbarElement } from "./components/ToolbarElement.js";
|
|
4
|
+
import { Plugin } from "./components/Plugin.js";
|
|
5
|
+
import { Node } from "./components/Node.js";
|
|
6
|
+
const base = createConfigurableComponent("LexicalEditor");
|
|
7
|
+
export const LexicalEditorConfig = Object.assign(base.Config, {
|
|
8
|
+
ToolbarElement,
|
|
9
|
+
Plugin,
|
|
10
|
+
Node
|
|
11
|
+
});
|
|
12
|
+
export const LexicalEditorWithConfig = base.WithConfig;
|
|
13
|
+
export function useLexicalEditorConfig() {
|
|
14
|
+
const config = base.useConfig();
|
|
15
|
+
const toolbarElements = config.toolbarElements || [];
|
|
16
|
+
const plugins = config.plugins || [];
|
|
17
|
+
const nodes = config.nodes || [];
|
|
18
|
+
return useMemo(() => ({
|
|
19
|
+
toolbarElements: [...toolbarElements],
|
|
20
|
+
plugins: [...plugins],
|
|
21
|
+
nodes: [...nodes]
|
|
22
|
+
}), [config]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=LexicalEditorConfig.js.map
|