@webiny/lexical-editor 0.0.0-unstable.e3f4727c56 → 0.0.0-unstable.eb196ccd2f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/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/HeadingEditor.d.ts +2 -2
- package/components/Editor/HeadingEditor.js +21 -27
- package/components/Editor/HeadingEditor.js.map +1 -1
- package/components/Editor/ParagraphEditor.d.ts +2 -2
- package/components/Editor/ParagraphEditor.js +21 -29
- package/components/Editor/ParagraphEditor.js.map +1 -1
- package/components/Editor/RichTextEditor.d.ts +39 -13
- package/components/Editor/RichTextEditor.js +116 -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 +20 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +63 -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 +8 -3
- package/components/LexicalHtmlRenderer.js +47 -36
- package/components/LexicalHtmlRenderer.js.map +1 -1
- package/components/Toolbar/StaticToolbar.css +260 -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/Toolbar/Toolbar.css +265 -36
- package/components/Toolbar/Toolbar.d.ts +2 -9
- package/components/Toolbar/Toolbar.js +116 -129
- package/components/Toolbar/Toolbar.js.map +1 -1
- 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 +31 -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/FontSizeAction.d.ts +14 -2
- package/components/ToolbarActions/FontSizeAction.js +70 -83
- package/components/ToolbarActions/FontSizeAction.js.map +1 -1
- 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 +39 -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 +108 -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 +11 -3
- package/context/RichTextEditorContext.js +17 -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/hooks/index.d.ts +8 -0
- package/hooks/index.js +10 -0
- package/hooks/index.js.map +1 -0
- package/hooks/useCurrentElement.d.ts +7 -0
- package/hooks/useCurrentElement.js +27 -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/useList.d.ts +2 -0
- package/hooks/useList.js +50 -0
- package/hooks/useList.js.map +1 -0
- package/hooks/useQuote.d.ts +2 -0
- package/hooks/useQuote.js +17 -0
- package/hooks/useQuote.js.map +1 -0
- 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 +15 -12
- package/index.js +49 -238
- package/index.js.map +1 -1
- package/package.json +22 -20
- 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.js +2 -15
- 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 +65 -7
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +4 -4
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +12 -220
- 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.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/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 +12 -0
- package/plugins/ImagesPlugin/ImagesPlugin.js +151 -0
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -0
- package/plugins/LinkPlugin/LinkPlugin.d.ts +5 -0
- package/plugins/LinkPlugin/LinkPlugin.js +59 -0
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -0
- package/plugins/ListPLugin/ListPlugin.d.ts +1 -0
- package/plugins/ListPLugin/ListPlugin.js +17 -0
- package/plugins/ListPLugin/ListPlugin.js.map +1 -0
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.d.ts +1 -0
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -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} +5 -4
- package/ui/ContentEditable.js +19 -0
- package/ui/ContentEditable.js.map +1 -0
- package/ui/Divider.js +6 -11
- package/ui/Divider.js.map +1 -1
- package/ui/DropDown.d.ts +4 -4
- package/ui/DropDown.js +102 -88
- package/ui/DropDown.js.map +1 -1
- package/ui/ImageResizer.d.ts +24 -0
- package/ui/ImageResizer.js +211 -0
- package/ui/ImageResizer.js.map +1 -0
- 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 -1
- 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 +21 -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 +29 -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/Toolbar/HeadingToolbar.d.ts +0 -12
- package/components/Toolbar/HeadingToolbar.js +0 -23
- package/components/Toolbar/HeadingToolbar.js.map +0 -1
- package/components/Toolbar/ParagraphToolbar.d.ts +0 -12
- package/components/Toolbar/ParagraphToolbar.js +0 -23
- package/components/Toolbar/ParagraphToolbar.js.map +0 -1
- package/components/ToolbarPresets/HeadingToolbarPreset.d.ts +0 -2
- package/components/ToolbarPresets/HeadingToolbarPreset.js +0 -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
|
@@ -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\";\nexport * from \"~/commands/image\";\nexport * from \"~/commands/list\";\nexport * from \"~/commands/quote\";\nexport * from \"~/commands/toolbar\";\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";
|
|
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\";\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,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { RichTextEditorProps } from "./RichTextEditor";
|
|
2
|
+
import type { RichTextEditorProps } from "./RichTextEditor";
|
|
3
3
|
interface HeadingEditorProps extends RichTextEditorProps {
|
|
4
4
|
tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
5
5
|
}
|
|
6
|
-
export declare const HeadingEditor: React.
|
|
6
|
+
export declare const HeadingEditor: ({ tag, placeholder, ...rest }: HeadingEditorProps) => React.JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return /*#__PURE__*/_react.default.createElement(_RichTextEditor.RichTextEditor, Object.assign({
|
|
21
|
-
toolbar: /*#__PURE__*/_react.default.createElement(_HeadingToolbar.HeadingToolbar, null),
|
|
22
|
-
tag: tag !== null && tag !== void 0 ? tag : "h1",
|
|
23
|
-
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Enter your heading text here..."
|
|
24
|
-
}, rest), /*#__PURE__*/_react.default.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/_react.default.createElement(_ClickableLinkPlugin.ClickableLinkPlugin, null), /*#__PURE__*/_react.default.createElement(_FloatingLinkEditorPlugin.FloatingLinkEditorPlugin, {
|
|
25
|
-
anchorElem: document.body
|
|
26
|
-
}));
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { RichTextEditor } from "./RichTextEditor";
|
|
3
|
+
import { Toolbar } from "../Toolbar/Toolbar";
|
|
4
|
+
import { EnsureHeadingTagPlugin } from "./EnsureHeadingTagPlugin";
|
|
5
|
+
const styles = {
|
|
6
|
+
padding: 5
|
|
7
|
+
};
|
|
8
|
+
export const HeadingEditor = ({
|
|
9
|
+
tag,
|
|
10
|
+
placeholder,
|
|
11
|
+
...rest
|
|
12
|
+
}) => {
|
|
13
|
+
return /*#__PURE__*/React.createElement(RichTextEditor, Object.assign({
|
|
14
|
+
toolbar: /*#__PURE__*/React.createElement(Toolbar, null),
|
|
15
|
+
tag: tag ?? "h1",
|
|
16
|
+
placeholder: placeholder ?? "Enter your heading text here..."
|
|
17
|
+
}, rest, {
|
|
18
|
+
styles: styles
|
|
19
|
+
}), /*#__PURE__*/React.createElement(EnsureHeadingTagPlugin, null), rest?.children);
|
|
27
20
|
};
|
|
28
|
-
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=HeadingEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","RichTextEditor","Toolbar","EnsureHeadingTagPlugin","styles","padding","HeadingEditor","tag","placeholder","rest","createElement","Object","assign","toolbar","children"],"sources":["HeadingEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport type { RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\nimport { RichTextEditor } from \"~/components/Editor/RichTextEditor\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\nimport { EnsureHeadingTagPlugin } from \"~/components/Editor/EnsureHeadingTagPlugin\";\n\ninterface HeadingEditorProps extends RichTextEditorProps {\n tag?: \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n}\n\nconst styles = { padding: 5 };\n\nexport const HeadingEditor = ({ tag, placeholder, ...rest }: HeadingEditorProps) => {\n return (\n <RichTextEditor\n toolbar={<Toolbar />}\n tag={tag ?? \"h1\"}\n placeholder={placeholder ?? \"Enter your heading text here...\"}\n {...rest}\n styles={styles}\n >\n <EnsureHeadingTagPlugin />\n {rest?.children}\n </RichTextEditor>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,cAAc;AACvB,SAASC,OAAO;AAChB,SAASC,sBAAsB;AAM/B,MAAMC,MAAM,GAAG;EAAEC,OAAO,EAAE;AAAE,CAAC;AAE7B,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEC,GAAG;EAAEC,WAAW;EAAE,GAAGC;AAAyB,CAAC,KAAK;EAChF,oBACIT,KAAA,CAAAU,aAAA,CAACT,cAAc,EAAAU,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAEb,KAAA,CAAAU,aAAA,CAACR,OAAO,MAAE,CAAE;IACrBK,GAAG,EAAEA,GAAG,IAAI,IAAK;IACjBC,WAAW,EAAEA,WAAW,IAAI;EAAkC,GAC1DC,IAAI;IACRL,MAAM,EAAEA;EAAO,iBAEfJ,KAAA,CAAAU,aAAA,CAACP,sBAAsB,MAAE,CAAC,EACzBM,IAAI,EAAEK,QACK,CAAC;AAEzB,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { RichTextEditorProps } from "./RichTextEditor";
|
|
2
|
+
import type { RichTextEditorProps } from "./RichTextEditor";
|
|
3
3
|
interface ParagraphLexicalEditorProps extends RichTextEditorProps {
|
|
4
4
|
tag?: "p";
|
|
5
5
|
}
|
|
6
|
-
declare const ParagraphEditor: React.
|
|
6
|
+
declare const ParagraphEditor: ({ placeholder, tag, ...rest }: ParagraphLexicalEditorProps) => React.JSX.Element;
|
|
7
7
|
export { ParagraphEditor };
|
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var placeholder = _ref.placeholder,
|
|
20
|
-
tag = _ref.tag,
|
|
21
|
-
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
22
|
-
return /*#__PURE__*/_react.default.createElement(_RichTextEditor.RichTextEditor, Object.assign({
|
|
23
|
-
toolbar: /*#__PURE__*/_react.default.createElement(_ParagraphToolbar.ParagraphToolbar, null),
|
|
24
|
-
tag: tag !== null && tag !== void 0 ? tag : "p",
|
|
25
|
-
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "Enter your text here..."
|
|
26
|
-
}, rest), /*#__PURE__*/_react.default.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/_react.default.createElement(_CodeHighlightPlugin.CodeHighlightPlugin, null), /*#__PURE__*/_react.default.createElement(_ClickableLinkPlugin.ClickableLinkPlugin, null), /*#__PURE__*/_react.default.createElement(_FloatingLinkEditorPlugin.FloatingLinkEditorPlugin, {
|
|
27
|
-
anchorElem: document.body
|
|
28
|
-
}), /*#__PURE__*/_react.default.createElement(_LexicalListPlugin.ListPlugin, null));
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { RichTextEditor } from "./RichTextEditor";
|
|
3
|
+
import { Toolbar } from "../Toolbar/Toolbar";
|
|
4
|
+
const styles = {
|
|
5
|
+
padding: 5
|
|
6
|
+
};
|
|
7
|
+
const ParagraphEditor = ({
|
|
8
|
+
placeholder,
|
|
9
|
+
tag,
|
|
10
|
+
...rest
|
|
11
|
+
}) => {
|
|
12
|
+
return /*#__PURE__*/React.createElement(RichTextEditor, Object.assign({
|
|
13
|
+
toolbar: /*#__PURE__*/React.createElement(Toolbar, null),
|
|
14
|
+
tag: tag ?? "p",
|
|
15
|
+
placeholder: placeholder ?? "Enter your text here..."
|
|
16
|
+
}, rest, {
|
|
17
|
+
styles: styles
|
|
18
|
+
}), rest?.children);
|
|
29
19
|
};
|
|
30
|
-
|
|
20
|
+
export { ParagraphEditor };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=ParagraphEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","RichTextEditor","Toolbar","styles","padding","ParagraphEditor","placeholder","tag","rest","createElement","Object","assign","toolbar","children"],"sources":["ParagraphEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport type { RichTextEditorProps } from \"~/components/Editor/RichTextEditor\";\nimport { RichTextEditor } from \"~/components/Editor/RichTextEditor\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\n\ninterface ParagraphLexicalEditorProps extends RichTextEditorProps {\n tag?: \"p\";\n}\n\nconst styles = { padding: 5 };\n\nconst ParagraphEditor = ({ placeholder, tag, ...rest }: ParagraphLexicalEditorProps) => {\n return (\n <RichTextEditor\n toolbar={<Toolbar />}\n tag={tag ?? \"p\"}\n placeholder={placeholder ?? \"Enter your text here...\"}\n {...rest}\n styles={styles}\n >\n {rest?.children}\n </RichTextEditor>\n );\n};\n\nexport { ParagraphEditor };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,cAAc;AACvB,SAASC,OAAO;AAMhB,MAAMC,MAAM,GAAG;EAAEC,OAAO,EAAE;AAAE,CAAC;AAE7B,MAAMC,eAAe,GAAGA,CAAC;EAAEC,WAAW;EAAEC,GAAG;EAAE,GAAGC;AAAkC,CAAC,KAAK;EACpF,oBACIR,KAAA,CAAAS,aAAA,CAACR,cAAc,EAAAS,MAAA,CAAAC,MAAA;IACXC,OAAO,eAAEZ,KAAA,CAAAS,aAAA,CAACP,OAAO,MAAE,CAAE;IACrBK,GAAG,EAAEA,GAAG,IAAI,GAAI;IAChBD,WAAW,EAAEA,WAAW,IAAI;EAA0B,GAClDE,IAAI;IACRL,MAAM,EAAEA;EAAO,IAEdK,IAAI,EAAEK,QACK,CAAC;AAEzB,CAAC;AAED,SAASR,eAAe","ignoreList":[]}
|
|
@@ -1,23 +1,49 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { Klass, LexicalNode } from "lexical";
|
|
2
|
+
import type { CSSObject } from "@emotion/react";
|
|
3
|
+
import type { Klass, LexicalNode } from "lexical";
|
|
4
|
+
import type { EditorTheme, ThemeEmotionMap } from "@webiny/lexical-theme";
|
|
5
|
+
import type { LexicalValue, ToolbarActionPlugin } from "../../types";
|
|
4
6
|
export interface RichTextEditorProps {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
value: LexicalValue | null;
|
|
7
|
+
children?: React.ReactNode | React.ReactNode[];
|
|
8
|
+
classes?: string;
|
|
9
|
+
contentEditableStyles?: React.CSSProperties;
|
|
9
10
|
focus?: boolean;
|
|
10
|
-
|
|
11
|
+
height?: number | string;
|
|
11
12
|
nodes?: Klass<LexicalNode>[];
|
|
12
|
-
/**
|
|
13
|
-
* @description Lexical plugins
|
|
14
|
-
*/
|
|
15
|
-
children?: React.ReactNode | React.ReactNode[];
|
|
16
13
|
onBlur?: (editorState: LexicalValue) => void;
|
|
17
|
-
|
|
14
|
+
onChange?: (json: LexicalValue) => void;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
placeholderStyles?: React.CSSProperties;
|
|
17
|
+
staticToolbar?: React.ReactNode;
|
|
18
|
+
styles?: React.CSSProperties;
|
|
19
|
+
tag?: string;
|
|
20
|
+
theme: EditorTheme;
|
|
21
|
+
themeEmotionMap?: ThemeEmotionMap;
|
|
22
|
+
toolbarActionPlugins?: ToolbarActionPlugin[];
|
|
23
|
+
themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;
|
|
24
|
+
toolbar?: React.ReactNode;
|
|
25
|
+
value: LexicalValue | null | undefined;
|
|
18
26
|
width?: number | string;
|
|
19
27
|
}
|
|
20
28
|
/**
|
|
21
29
|
* @description Main editor container
|
|
22
30
|
*/
|
|
23
|
-
export declare const RichTextEditor:
|
|
31
|
+
export declare const RichTextEditor: ((props: RichTextEditorProps) => React.JSX.Element) & {
|
|
32
|
+
original: (props: RichTextEditorProps) => React.JSX.Element;
|
|
33
|
+
originalName: string;
|
|
34
|
+
displayName: string;
|
|
35
|
+
} & {
|
|
36
|
+
original: ((props: RichTextEditorProps) => React.JSX.Element) & {
|
|
37
|
+
original: (props: RichTextEditorProps) => React.JSX.Element;
|
|
38
|
+
originalName: string;
|
|
39
|
+
displayName: string;
|
|
40
|
+
};
|
|
41
|
+
originalName: string;
|
|
42
|
+
displayName: string;
|
|
43
|
+
} & {
|
|
44
|
+
createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<((props: RichTextEditorProps) => React.JSX.Element) & {
|
|
45
|
+
original: (props: RichTextEditorProps) => React.JSX.Element;
|
|
46
|
+
originalName: string;
|
|
47
|
+
displayName: string;
|
|
48
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
49
|
+
};
|
|
@@ -1,107 +1,133 @@
|
|
|
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
|
-
|
|
46
|
-
|
|
1
|
+
import React, { Fragment, useRef, useState } from "react";
|
|
2
|
+
import { css } from "emotion";
|
|
3
|
+
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
4
|
+
import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
5
|
+
import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
|
|
6
|
+
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
7
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
8
|
+
import { makeDecoratable } from "@webiny/react-composition";
|
|
9
|
+
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
10
|
+
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
11
|
+
import { createTheme, toTypographyEmotionMap } from "@webiny/lexical-theme";
|
|
12
|
+
import { allNodes } from "@webiny/lexical-nodes";
|
|
13
|
+
import { RichTextEditorProvider } from "../../context/RichTextEditorContext";
|
|
14
|
+
import { BlurEventPlugin } from "../../plugins/BlurEventPlugin/BlurEventPlugin";
|
|
15
|
+
import { Placeholder } from "../../ui/Placeholder";
|
|
16
|
+
import { SharedHistoryContext, useSharedHistoryContext } from "../../context/SharedHistoryContext";
|
|
17
|
+
import { LexicalEditorWithConfig, useLexicalEditorConfig } from "../LexicalEditorConfig/LexicalEditorConfig";
|
|
18
|
+
import { StateHandlingPlugin } from "../../plugins/StateHandlingPlugin";
|
|
19
|
+
const BaseRichTextEditor = ({
|
|
20
|
+
toolbar,
|
|
21
|
+
staticToolbar,
|
|
22
|
+
onChange,
|
|
23
|
+
nodes,
|
|
24
|
+
placeholder,
|
|
25
|
+
children,
|
|
26
|
+
onBlur,
|
|
27
|
+
focus,
|
|
28
|
+
styles,
|
|
29
|
+
width,
|
|
30
|
+
height,
|
|
31
|
+
contentEditableStyles,
|
|
32
|
+
placeholderStyles,
|
|
33
|
+
...props
|
|
34
|
+
}) => {
|
|
35
|
+
const themeEmotionMap = props.themeEmotionMap ?? toTypographyEmotionMap(css, props.theme, props.themeStylesTransformer);
|
|
36
|
+
const editorTheme = useRef(createTheme(props.theme));
|
|
37
|
+
const config = useLexicalEditorConfig();
|
|
38
|
+
const {
|
|
39
|
+
historyState
|
|
40
|
+
} = useSharedHistoryContext();
|
|
41
|
+
const placeholderElem = /*#__PURE__*/React.createElement(Placeholder, {
|
|
42
|
+
styles: placeholderStyles
|
|
43
|
+
}, placeholder || "Enter text...");
|
|
44
|
+
const scrollRef = useRef(null);
|
|
45
|
+
const [floatingAnchorElem, setFloatingAnchorElem] = useState(undefined);
|
|
46
|
+
const onRef = _floatingAnchorElem => {
|
|
47
47
|
if (_floatingAnchorElem !== null) {
|
|
48
48
|
setFloatingAnchorElem(_floatingAnchorElem);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
const sizeStyle = {
|
|
52
52
|
height: height || "",
|
|
53
53
|
width: width || ""
|
|
54
54
|
};
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const configNodes = config.nodes.map(node => node.node);
|
|
56
|
+
const configPlugins = config.plugins.map(plugin => /*#__PURE__*/React.createElement(Fragment, {
|
|
57
|
+
key: plugin.name
|
|
58
|
+
}, plugin.element));
|
|
59
|
+
const initialConfig = {
|
|
60
|
+
editorState: null,
|
|
57
61
|
namespace: "webiny",
|
|
58
|
-
onError:
|
|
59
|
-
|
|
62
|
+
onError: () => {
|
|
63
|
+
// Ignore errors. We don't want to break the app because of errors caused by config/value updates.
|
|
64
|
+
// These are usually resolved in the next component render cycle.
|
|
60
65
|
},
|
|
61
|
-
nodes: [
|
|
62
|
-
theme:
|
|
66
|
+
nodes: [...allNodes, ...configNodes, ...(nodes || [])],
|
|
67
|
+
theme: {
|
|
68
|
+
...editorTheme.current,
|
|
69
|
+
emotionMap: themeEmotionMap
|
|
70
|
+
}
|
|
63
71
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
return (
|
|
73
|
+
/*#__PURE__*/
|
|
74
|
+
/**
|
|
75
|
+
* Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future
|
|
76
|
+
* updates to the config will be ignored. This is a problem because we pull in Nodes from our config,
|
|
77
|
+
* and initially, there can be multiple re-renders, while the config object is settled.
|
|
78
|
+
*
|
|
79
|
+
* To bypass this issue, we generate a naive `key` based on the number of Nodes.
|
|
80
|
+
*/
|
|
81
|
+
React.createElement(SharedHistoryContext, null, /*#__PURE__*/React.createElement(LexicalComposer, {
|
|
82
|
+
initialConfig: initialConfig,
|
|
83
|
+
key: initialConfig.nodes.length
|
|
84
|
+
}, /*#__PURE__*/React.createElement(RichTextEditorProvider, {
|
|
85
|
+
theme: props.theme,
|
|
86
|
+
themeEmotionMap: themeEmotionMap,
|
|
87
|
+
toolbarActionPlugins: props.toolbarActionPlugins
|
|
88
|
+
}, staticToolbar ? staticToolbar : null, /*#__PURE__*/React.createElement("div", {
|
|
89
|
+
/* This className is necessary for targeting of editor container from CSS files. */
|
|
90
|
+
className: "editor-shell",
|
|
91
|
+
ref: scrollRef,
|
|
92
|
+
style: {
|
|
93
|
+
...styles,
|
|
94
|
+
...sizeStyle,
|
|
95
|
+
overflow: "auto",
|
|
96
|
+
position: "relative"
|
|
69
97
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
placeholder: placeholderElem,
|
|
97
|
-
ErrorBoundary: _LexicalErrorBoundary.default
|
|
98
|
-
}), floatingAnchorElem && toolbar));
|
|
98
|
+
}, /*#__PURE__*/React.createElement(StateHandlingPlugin, {
|
|
99
|
+
value: props.value,
|
|
100
|
+
onChange: onChange
|
|
101
|
+
}), /*#__PURE__*/React.createElement(ClearEditorPlugin, null), /*#__PURE__*/React.createElement(HistoryPlugin, {
|
|
102
|
+
externalHistoryState: historyState
|
|
103
|
+
}), onBlur && /*#__PURE__*/React.createElement(BlurEventPlugin, {
|
|
104
|
+
onBlur: onBlur
|
|
105
|
+
}), focus && /*#__PURE__*/React.createElement(AutoFocusPlugin, null), configPlugins, children, /*#__PURE__*/React.createElement(RichTextPlugin, {
|
|
106
|
+
contentEditable: /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: "editor-scroller",
|
|
108
|
+
style: {
|
|
109
|
+
...sizeStyle
|
|
110
|
+
}
|
|
111
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: "editor",
|
|
113
|
+
ref: onRef
|
|
114
|
+
}, /*#__PURE__*/React.createElement(ContentEditable, {
|
|
115
|
+
style: {
|
|
116
|
+
outline: 0,
|
|
117
|
+
...contentEditableStyles
|
|
118
|
+
}
|
|
119
|
+
}))),
|
|
120
|
+
placeholder: placeholderElem,
|
|
121
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
122
|
+
}), floatingAnchorElem && toolbar))))
|
|
123
|
+
);
|
|
99
124
|
};
|
|
100
125
|
|
|
101
126
|
/**
|
|
102
127
|
* @description Main editor container
|
|
103
128
|
*/
|
|
104
|
-
|
|
105
|
-
return /*#__PURE__*/
|
|
129
|
+
export const RichTextEditor = makeDecoratable("RichTextEditor", props => {
|
|
130
|
+
return /*#__PURE__*/React.createElement(LexicalEditorWithConfig, null, /*#__PURE__*/React.createElement(BaseRichTextEditor, props));
|
|
106
131
|
});
|
|
107
|
-
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=RichTextEditor.js.map
|