@webiny/lexical-editor 0.0.0-unstable.085ff6572f
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/LICENSE +21 -0
- package/README.md +17 -0
- package/commands/webiny-list.d.ts +7 -0
- package/commands/webiny-list.js +13 -0
- package/commands/webiny-list.js.map +1 -0
- package/commands/webiny-quote.d.ts +5 -0
- package/commands/webiny-quote.js +9 -0
- package/commands/webiny-quote.js.map +1 -0
- package/components/AddRichTextEditorNodeType.d.ts +6 -0
- package/components/AddRichTextEditorNodeType.js +28 -0
- package/components/AddRichTextEditorNodeType.js.map +1 -0
- package/components/AddRichTextEditorPlugin.d.ts +12 -0
- package/components/AddRichTextEditorPlugin.js +33 -0
- package/components/AddRichTextEditorPlugin.js.map +1 -0
- package/components/AddToolbarAction.d.ts +7 -0
- package/components/AddToolbarAction.js +33 -0
- package/components/AddToolbarAction.js.map +1 -0
- package/components/Editor/HeadingEditor.d.ts +7 -0
- package/components/Editor/HeadingEditor.js +29 -0
- package/components/Editor/HeadingEditor.js.map +1 -0
- package/components/Editor/ParagraphEditor.d.ts +7 -0
- package/components/Editor/ParagraphEditor.js +30 -0
- package/components/Editor/ParagraphEditor.js.map +1 -0
- package/components/Editor/RichTextEditor.d.ts +26 -0
- package/components/Editor/RichTextEditor.js +138 -0
- package/components/Editor/RichTextEditor.js.map +1 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +11 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +19 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
- package/components/LexicalHtmlRenderer.d.ts +16 -0
- package/components/LexicalHtmlRenderer.js +67 -0
- package/components/LexicalHtmlRenderer.js.map +1 -0
- package/components/Toolbar/HeadingToolbar.d.ts +12 -0
- package/components/Toolbar/HeadingToolbar.js +23 -0
- package/components/Toolbar/HeadingToolbar.js.map +1 -0
- package/components/Toolbar/ParagraphToolbar.d.ts +12 -0
- package/components/Toolbar/ParagraphToolbar.js +23 -0
- package/components/Toolbar/ParagraphToolbar.js.map +1 -0
- package/components/Toolbar/Toolbar.css +435 -0
- package/components/Toolbar/Toolbar.d.ts +13 -0
- package/components/Toolbar/Toolbar.js +215 -0
- package/components/Toolbar/Toolbar.js.map +1 -0
- package/components/ToolbarActions/BoldAction.d.ts +2 -0
- package/components/ToolbarActions/BoldAction.js +43 -0
- package/components/ToolbarActions/BoldAction.js.map +1 -0
- package/components/ToolbarActions/BulletListAction.d.ts +2 -0
- package/components/ToolbarActions/BulletListAction.js +56 -0
- package/components/ToolbarActions/BulletListAction.js.map +1 -0
- package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -0
- package/components/ToolbarActions/CodeHighlightAction.js +43 -0
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -0
- package/components/ToolbarActions/FontColorAction.d.ts +11 -0
- package/components/ToolbarActions/FontColorAction.js +83 -0
- package/components/ToolbarActions/FontColorAction.js.map +1 -0
- package/components/ToolbarActions/FontSizeAction.d.ts +2 -0
- package/components/ToolbarActions/FontSizeAction.js +101 -0
- package/components/ToolbarActions/FontSizeAction.js.map +1 -0
- package/components/ToolbarActions/ItalicAction.d.ts +2 -0
- package/components/ToolbarActions/ItalicAction.js +43 -0
- package/components/ToolbarActions/ItalicAction.js.map +1 -0
- package/components/ToolbarActions/LinkAction.d.ts +2 -0
- package/components/ToolbarActions/LinkAction.js +64 -0
- package/components/ToolbarActions/LinkAction.js.map +1 -0
- package/components/ToolbarActions/NumberedListAction.d.ts +2 -0
- package/components/ToolbarActions/NumberedListAction.js +58 -0
- package/components/ToolbarActions/NumberedListAction.js.map +1 -0
- package/components/ToolbarActions/QuoteAction.d.ts +2 -0
- package/components/ToolbarActions/QuoteAction.js +52 -0
- package/components/ToolbarActions/QuoteAction.js.map +1 -0
- package/components/ToolbarActions/TextAlignmentAction.d.ts +11 -0
- package/components/ToolbarActions/TextAlignmentAction.js +70 -0
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -0
- package/components/ToolbarActions/TypographyAction.d.ts +11 -0
- package/components/ToolbarActions/TypographyAction.js +145 -0
- package/components/ToolbarActions/TypographyAction.js.map +1 -0
- package/components/ToolbarActions/UnderlineAction.d.ts +2 -0
- package/components/ToolbarActions/UnderlineAction.js +43 -0
- package/components/ToolbarActions/UnderlineAction.js.map +1 -0
- package/components/ToolbarPresets/HeadingToolbarPreset.d.ts +2 -0
- package/components/ToolbarPresets/HeadingToolbarPreset.js +56 -0
- package/components/ToolbarPresets/HeadingToolbarPreset.js.map +1 -0
- package/components/ToolbarPresets/ParagraphToolbarPreset.d.ts +2 -0
- package/components/ToolbarPresets/ParagraphToolbarPreset.js +71 -0
- package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +1 -0
- package/context/FontColorActionContext.d.ts +6 -0
- package/context/FontColorActionContext.js +10 -0
- package/context/FontColorActionContext.js.map +1 -0
- package/context/RichTextEditorContext.d.ts +26 -0
- package/context/RichTextEditorContext.js +68 -0
- package/context/RichTextEditorContext.js.map +1 -0
- package/context/SharedHistoryContext.d.ts +11 -0
- package/context/SharedHistoryContext.js +26 -0
- package/context/SharedHistoryContext.js.map +1 -0
- package/context/TextAlignmentActionContextProps.d.ts +9 -0
- package/context/TextAlignmentActionContextProps.js +10 -0
- package/context/TextAlignmentActionContextProps.js.map +1 -0
- package/context/TypographyActionContext.d.ts +7 -0
- package/context/TypographyActionContext.js +10 -0
- package/context/TypographyActionContext.js.map +1 -0
- package/hooks/useFontColorPicker.d.ts +2 -0
- package/hooks/useFontColorPicker.js +15 -0
- package/hooks/useFontColorPicker.js.map +1 -0
- package/hooks/useList.d.ts +2 -0
- package/hooks/useList.js +39 -0
- package/hooks/useList.js.map +1 -0
- package/hooks/useQuote.d.ts +2 -0
- package/hooks/useQuote.js +20 -0
- package/hooks/useQuote.js.map +1 -0
- package/hooks/useRichTextEditor.d.ts +2 -0
- package/hooks/useRichTextEditor.js +15 -0
- package/hooks/useRichTextEditor.js.map +1 -0
- package/hooks/useTextAlignmentAction.d.ts +1 -0
- package/hooks/useTextAlignmentAction.js +15 -0
- package/hooks/useTextAlignmentAction.js.map +1 -0
- package/hooks/useTypographyAction.d.ts +1 -0
- package/hooks/useTypographyAction.js +15 -0
- package/hooks/useTypographyAction.js.map +1 -0
- package/images/icons/LICENSE.md +5 -0
- package/images/icons/chat-square-quote.svg +1 -0
- package/images/icons/chevron-down.svg +1 -0
- package/images/icons/code.svg +1 -0
- package/images/icons/font-color.svg +1 -0
- package/images/icons/indent.svg +3 -0
- package/images/icons/justify.svg +3 -0
- package/images/icons/link.svg +1 -0
- package/images/icons/list-ol.svg +1 -0
- package/images/icons/list-ul.svg +1 -0
- package/images/icons/outdent.svg +3 -0
- package/images/icons/pencil-fill.svg +1 -0
- package/images/icons/text-center.svg +1 -0
- package/images/icons/text-left.svg +1 -0
- package/images/icons/text-paragraph.svg +1 -0
- package/images/icons/text-right.svg +1 -0
- package/images/icons/type-bold.svg +1 -0
- package/images/icons/type-h1.svg +1 -0
- package/images/icons/type-h2.svg +1 -0
- package/images/icons/type-h3.svg +1 -0
- package/images/icons/type-h4.svg +1 -0
- package/images/icons/type-h5.svg +1 -0
- package/images/icons/type-h6.svg +1 -0
- package/images/icons/type-italic.svg +1 -0
- package/images/icons/type-strikethrough.svg +1 -0
- package/images/icons/type-underline.svg +1 -0
- package/images/icons/unlink_icon.svg +1 -0
- package/index.d.ts +42 -0
- package/index.js +295 -0
- package/index.js.map +1 -0
- package/nodes/FontColorNode.d.ts +43 -0
- package/nodes/FontColorNode.js +127 -0
- package/nodes/FontColorNode.js.map +1 -0
- package/nodes/HeadingNode.d.ts +34 -0
- package/nodes/HeadingNode.js +192 -0
- package/nodes/HeadingNode.js.map +1 -0
- package/nodes/ListItemNode.d.ts +46 -0
- package/nodes/ListItemNode.js +441 -0
- package/nodes/ListItemNode.js.map +1 -0
- package/nodes/ListNode/formatList.d.ts +12 -0
- package/nodes/ListNode/formatList.js +424 -0
- package/nodes/ListNode/formatList.js.map +1 -0
- package/nodes/ListNode.d.ts +42 -0
- package/nodes/ListNode.js +294 -0
- package/nodes/ListNode.js.map +1 -0
- package/nodes/ParagraphNode.d.ts +32 -0
- package/nodes/ParagraphNode.js +218 -0
- package/nodes/ParagraphNode.js.map +1 -0
- package/nodes/QuoteNode.d.ts +34 -0
- package/nodes/QuoteNode.js +225 -0
- package/nodes/QuoteNode.js.map +1 -0
- package/nodes/TypographyElementNode.d.ts +42 -0
- package/nodes/TypographyElementNode.js +155 -0
- package/nodes/TypographyElementNode.js.map +1 -0
- package/nodes/types.d.ts +15 -0
- package/nodes/types.js +5 -0
- package/nodes/types.js.map +1 -0
- package/nodes/webinyNodes.d.ts +7 -0
- package/nodes/webinyNodes.js +45 -0
- package/nodes/webinyNodes.js.map +1 -0
- package/package.json +41 -0
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.d.ts +11 -0
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.js +46 -0
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.js.map +1 -0
- package/plugins/AutoLinkPlugin/index.d.ts +1 -0
- package/plugins/AutoLinkPlugin/index.js +16 -0
- package/plugins/AutoLinkPlugin/index.js.map +1 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +7 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +28 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -0
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.d.ts +17 -0
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js +88 -0
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js.map +1 -0
- package/plugins/ClickableLinkPlugin/index.d.ts +1 -0
- package/plugins/ClickableLinkPlugin/index.js +16 -0
- package/plugins/ClickableLinkPlugin/index.js.map +1 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.d.ts +1 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +20 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -0
- package/plugins/CodeHighlightPlugin/index.d.ts +1 -0
- package/plugins/CodeHighlightPlugin/index.js +16 -0
- package/plugins/CodeHighlightPlugin/index.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +118 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +7 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +222 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -0
- package/plugins/FloatingLinkEditorPlugin/index.js +16 -0
- package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
- package/plugins/FontColorPlugin/FontColorPlugin.d.ts +2 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js +39 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.d.ts +8 -0
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js +34 -0
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +1 -0
- package/plugins/LexicalUpdateStatePlugin/index.d.ts +1 -0
- package/plugins/LexicalUpdateStatePlugin/index.js +16 -0
- package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -0
- package/plugins/TypographyPlugin/TypographyPlugin.d.ts +2 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js +35 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.d.ts +1 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.js +25 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.js.map +1 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.d.ts +1 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js +24 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js.map +1 -0
- package/themes/webinyLexicalTheme.css +429 -0
- package/themes/webinyLexicalTheme.d.ts +9 -0
- package/themes/webinyLexicalTheme.js +87 -0
- package/themes/webinyLexicalTheme.js.map +1 -0
- package/types.d.ts +63 -0
- package/types.js +25 -0
- package/types.js.map +1 -0
- package/ui/Divider.d.ts +2 -0
- package/ui/Divider.js +13 -0
- package/ui/Divider.js.map +1 -0
- package/ui/DropDown.d.ts +26 -0
- package/ui/DropDown.js +206 -0
- package/ui/DropDown.js.map +1 -0
- package/ui/Input.css +32 -0
- package/ui/LinkPreview.css +69 -0
- package/ui/LinkPreview.d.ts +12 -0
- package/ui/LinkPreview.js +101 -0
- package/ui/LinkPreview.js.map +1 -0
- package/ui/Placeholder.css +23 -0
- package/ui/Placeholder.d.ts +13 -0
- package/ui/Placeholder.js +24 -0
- package/ui/Placeholder.js.map +1 -0
- package/ui/TextInput.d.ts +18 -0
- package/ui/TextInput.js +39 -0
- package/ui/TextInput.js.map +1 -0
- package/ui/ToolbarActionDialog.d.ts +12 -0
- package/ui/ToolbarActionDialog.js +106 -0
- package/ui/ToolbarActionDialog.js.map +1 -0
- package/utils/findTypographyStyleByHtmlTag.d.ts +8 -0
- package/utils/findTypographyStyleByHtmlTag.js +16 -0
- package/utils/findTypographyStyleByHtmlTag.js.map +1 -0
- package/utils/generateInitialLexicalValue.d.ts +5 -0
- package/utils/generateInitialLexicalValue.js +30 -0
- package/utils/generateInitialLexicalValue.js.map +1 -0
- package/utils/getDOMRangeRect.d.ts +10 -0
- package/utils/getDOMRangeRect.js +27 -0
- package/utils/getDOMRangeRect.js.map +1 -0
- package/utils/getLexicalTextSelectionState.d.ts +5 -0
- package/utils/getLexicalTextSelectionState.js +163 -0
- package/utils/getLexicalTextSelectionState.js.map +1 -0
- package/utils/getSelectedNode.d.ts +2 -0
- package/utils/getSelectedNode.js +30 -0
- package/utils/getSelectedNode.js.map +1 -0
- package/utils/isValidJSON.d.ts +1 -0
- package/utils/isValidJSON.js +18 -0
- package/utils/isValidJSON.js.map +1 -0
- package/utils/isValidLexicalData.d.ts +2 -0
- package/utils/isValidLexicalData.js +24 -0
- package/utils/isValidLexicalData.js.map +1 -0
- package/utils/nodes/clearNodeFormating.d.ts +2 -0
- package/utils/nodes/clearNodeFormating.js +28 -0
- package/utils/nodes/clearNodeFormating.js.map +1 -0
- package/utils/nodes/formatToHeading.d.ts +3 -0
- package/utils/nodes/formatToHeading.js +25 -0
- package/utils/nodes/formatToHeading.js.map +1 -0
- package/utils/nodes/formatToParagraph.d.ts +2 -0
- package/utils/nodes/formatToParagraph.js +20 -0
- package/utils/nodes/formatToParagraph.js.map +1 -0
- package/utils/nodes/formatToQuote.d.ts +2 -0
- package/utils/nodes/formatToQuote.js +25 -0
- package/utils/nodes/formatToQuote.js.map +1 -0
- package/utils/nodes/listNode.d.ts +11 -0
- package/utils/nodes/listNode.js +107 -0
- package/utils/nodes/listNode.js.map +1 -0
- package/utils/point.d.ts +21 -0
- package/utils/point.js +77 -0
- package/utils/point.js.map +1 -0
- package/utils/rect.d.ts +47 -0
- package/utils/rect.js +169 -0
- package/utils/rect.js.map +1 -0
- package/utils/sanitizeUrl.d.ts +8 -0
- package/utils/sanitizeUrl.js +27 -0
- package/utils/sanitizeUrl.js.map +1 -0
- package/utils/setFloatingElemPosition.d.ts +3 -0
- package/utils/setFloatingElemPosition.js +40 -0
- package/utils/setFloatingElemPosition.js.map +1 -0
- package/utils/styleObjectToString.d.ts +2 -0
- package/utils/styleObjectToString.js +22 -0
- package/utils/styleObjectToString.js.map +1 -0
- package/utils/toTypographyEmotionMap.d.ts +3 -0
- package/utils/toTypographyEmotionMap.js +36 -0
- package/utils/toTypographyEmotionMap.js.map +1 -0
package/index.js
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "AddRichTextEditorNodeType", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _AddRichTextEditorNodeType.AddRichTextEditorNodeType;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "AddRichTextEditorPlugin", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _AddRichTextEditorPlugin.AddRichTextEditorPlugin;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "AddToolbarAction", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _AddToolbarAction.AddToolbarAction;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "BlurEventPlugin", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _BlurEventPlugin.BlurEventPlugin;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "BoldAction", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _BoldAction.BoldAction;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "BulletListAction", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function get() {
|
|
40
|
+
return _BulletListAction.BulletListAction;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "ClickableLinkPlugin", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _ClickableLinkPlugin.ClickableLinkPlugin;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "CodeHighlightAction", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function get() {
|
|
52
|
+
return _CodeHighlightAction.CodeHighlightAction;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, "CodeHighlightPlugin", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function get() {
|
|
58
|
+
return _CodeHighlightPlugin.CodeHighlightPlugin;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, "Divider", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function get() {
|
|
64
|
+
return _Divider.Divider;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, "DropDown", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function get() {
|
|
70
|
+
return _DropDown.DropDown;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, "DropDownItem", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function get() {
|
|
76
|
+
return _DropDown.DropDownItem;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, "FloatingLinkEditorPlugin", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function get() {
|
|
82
|
+
return _FloatingLinkEditorPlugin.FloatingLinkEditorPlugin;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(exports, "FontColorAction", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function get() {
|
|
88
|
+
return _FontColorAction.FontColorAction;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(exports, "FontSizeAction", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function get() {
|
|
94
|
+
return _FontSizeAction.FontSizeAction;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, "HeadingEditor", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function get() {
|
|
100
|
+
return _HeadingEditor.HeadingEditor;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(exports, "HeadingToolbar", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function get() {
|
|
106
|
+
return _HeadingToolbar.HeadingToolbar;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(exports, "HeadingToolbarPreset", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function get() {
|
|
112
|
+
return _HeadingToolbarPreset.HeadingToolbarPreset;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(exports, "ItalicAction", {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function get() {
|
|
118
|
+
return _ItalicAction.ItalicAction;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(exports, "LexicalEditorConfig", {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: function get() {
|
|
124
|
+
return _LexicalEditorConfig.LexicalEditorConfig;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
Object.defineProperty(exports, "LexicalHtmlRenderer", {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
get: function get() {
|
|
130
|
+
return _LexicalHtmlRenderer.LexicalHtmlRenderer;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(exports, "LexicalUpdateStatePlugin", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get: function get() {
|
|
136
|
+
return _LexicalUpdateStatePlugin.LexicalUpdateStatePlugin;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(exports, "LinkAction", {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function get() {
|
|
142
|
+
return _LinkAction.LinkAction;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(exports, "LinkPlugin", {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function get() {
|
|
148
|
+
return _LexicalLinkPlugin.LinkPlugin;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
Object.defineProperty(exports, "NumberedListAction", {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
get: function get() {
|
|
154
|
+
return _NumberedListAction.NumberedListAction;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
Object.defineProperty(exports, "ParagraphEditor", {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
get: function get() {
|
|
160
|
+
return _ParagraphEditor.ParagraphEditor;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
Object.defineProperty(exports, "ParagraphToolbar", {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
get: function get() {
|
|
166
|
+
return _ParagraphToolbar.ParagraphToolbar;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
Object.defineProperty(exports, "ParagraphToolbarPreset", {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
get: function get() {
|
|
172
|
+
return _ParagraphToolbarPreset.ParagraphToolbarPreset;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
Object.defineProperty(exports, "QuoteAction", {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function get() {
|
|
178
|
+
return _QuoteAction.QuoteAction;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
Object.defineProperty(exports, "RichTextEditor", {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
get: function get() {
|
|
184
|
+
return _RichTextEditor.RichTextEditor;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
Object.defineProperty(exports, "TextAlignmentAction", {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
get: function get() {
|
|
190
|
+
return _TextAlignmentAction.TextAlignmentAction;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
Object.defineProperty(exports, "Toolbar", {
|
|
194
|
+
enumerable: true,
|
|
195
|
+
get: function get() {
|
|
196
|
+
return _Toolbar.Toolbar;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
Object.defineProperty(exports, "TypographyAction", {
|
|
200
|
+
enumerable: true,
|
|
201
|
+
get: function get() {
|
|
202
|
+
return _TypographyAction.TypographyAction;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
Object.defineProperty(exports, "UnderlineAction", {
|
|
206
|
+
enumerable: true,
|
|
207
|
+
get: function get() {
|
|
208
|
+
return _UnderlineAction.UnderlineAction;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
Object.defineProperty(exports, "clearNodeFormatting", {
|
|
212
|
+
enumerable: true,
|
|
213
|
+
get: function get() {
|
|
214
|
+
return _clearNodeFormating.clearNodeFormatting;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
Object.defineProperty(exports, "generateInitialLexicalValue", {
|
|
218
|
+
enumerable: true,
|
|
219
|
+
get: function get() {
|
|
220
|
+
return _generateInitialLexicalValue.generateInitialLexicalValue;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
Object.defineProperty(exports, "isValidLexicalData", {
|
|
224
|
+
enumerable: true,
|
|
225
|
+
get: function get() {
|
|
226
|
+
return _isValidLexicalData.isValidLexicalData;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
exports.types = void 0;
|
|
230
|
+
Object.defineProperty(exports, "useFontColorPicker", {
|
|
231
|
+
enumerable: true,
|
|
232
|
+
get: function get() {
|
|
233
|
+
return _useFontColorPicker.useFontColorPicker;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(exports, "useRichTextEditor", {
|
|
237
|
+
enumerable: true,
|
|
238
|
+
get: function get() {
|
|
239
|
+
return _useRichTextEditor.useRichTextEditor;
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
Object.defineProperty(exports, "useTextAlignmentAction", {
|
|
243
|
+
enumerable: true,
|
|
244
|
+
get: function get() {
|
|
245
|
+
return _useTextAlignmentAction.useTextAlignmentAction;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
Object.defineProperty(exports, "useTypographyAction", {
|
|
249
|
+
enumerable: true,
|
|
250
|
+
get: function get() {
|
|
251
|
+
return _useTypographyAction.useTypographyAction;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
var _LexicalHtmlRenderer = require("./components/LexicalHtmlRenderer");
|
|
255
|
+
var _useRichTextEditor = require("./hooks/useRichTextEditor");
|
|
256
|
+
var _useFontColorPicker = require("./hooks/useFontColorPicker");
|
|
257
|
+
var _useTypographyAction = require("./hooks/useTypographyAction");
|
|
258
|
+
var _useTextAlignmentAction = require("./hooks/useTextAlignmentAction");
|
|
259
|
+
var _Divider = require("./ui/Divider");
|
|
260
|
+
var _DropDown = require("./ui/DropDown");
|
|
261
|
+
var _BoldAction = require("./components/ToolbarActions/BoldAction");
|
|
262
|
+
var _BulletListAction = require("./components/ToolbarActions/BulletListAction");
|
|
263
|
+
var _CodeHighlightAction = require("./components/ToolbarActions/CodeHighlightAction");
|
|
264
|
+
var _FontSizeAction = require("./components/ToolbarActions/FontSizeAction");
|
|
265
|
+
var _FontColorAction = require("./components/ToolbarActions/FontColorAction");
|
|
266
|
+
var _ItalicAction = require("./components/ToolbarActions/ItalicAction");
|
|
267
|
+
var _LinkAction = require("./components/ToolbarActions/LinkAction");
|
|
268
|
+
var _NumberedListAction = require("./components/ToolbarActions/NumberedListAction");
|
|
269
|
+
var _QuoteAction = require("./components/ToolbarActions/QuoteAction");
|
|
270
|
+
var _UnderlineAction = require("./components/ToolbarActions/UnderlineAction");
|
|
271
|
+
var _TypographyAction = require("./components/ToolbarActions/TypographyAction");
|
|
272
|
+
var _TextAlignmentAction = require("./components/ToolbarActions/TextAlignmentAction");
|
|
273
|
+
var _HeadingToolbar = require("./components/Toolbar/HeadingToolbar");
|
|
274
|
+
var _ParagraphToolbar = require("./components/Toolbar/ParagraphToolbar");
|
|
275
|
+
var _Toolbar = require("./components/Toolbar/Toolbar");
|
|
276
|
+
var _ParagraphToolbarPreset = require("./components/ToolbarPresets/ParagraphToolbarPreset");
|
|
277
|
+
var _HeadingToolbarPreset = require("./components/ToolbarPresets/HeadingToolbarPreset");
|
|
278
|
+
var _RichTextEditor = require("./components/Editor/RichTextEditor");
|
|
279
|
+
var _HeadingEditor = require("./components/Editor/HeadingEditor");
|
|
280
|
+
var _ParagraphEditor = require("./components/Editor/ParagraphEditor");
|
|
281
|
+
var _LexicalLinkPlugin = require("@lexical/react/LexicalLinkPlugin");
|
|
282
|
+
var _FloatingLinkEditorPlugin = require("./plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin");
|
|
283
|
+
var _CodeHighlightPlugin = require("./plugins/CodeHighlightPlugin/CodeHighlightPlugin");
|
|
284
|
+
var _ClickableLinkPlugin = require("./plugins/ClickableLinkPlugin/ClickableLinkPlugin");
|
|
285
|
+
var _BlurEventPlugin = require("./plugins/BlurEventPlugin/BlurEventPlugin");
|
|
286
|
+
var _LexicalUpdateStatePlugin = require("./plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin");
|
|
287
|
+
var _AddToolbarAction = require("./components/AddToolbarAction");
|
|
288
|
+
var _AddRichTextEditorPlugin = require("./components/AddRichTextEditorPlugin");
|
|
289
|
+
var _AddRichTextEditorNodeType = require("./components/AddRichTextEditorNodeType");
|
|
290
|
+
var _generateInitialLexicalValue = require("./utils/generateInitialLexicalValue");
|
|
291
|
+
var _isValidLexicalData = require("./utils/isValidLexicalData");
|
|
292
|
+
var _clearNodeFormating = require("./utils/nodes/clearNodeFormating");
|
|
293
|
+
var _types = _interopRequireWildcard(require("./types"));
|
|
294
|
+
exports.types = _types;
|
|
295
|
+
var _LexicalEditorConfig = require("./components/LexicalEditorConfig/LexicalEditorConfig");
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.tsx"],"sourcesContent":["// render\nexport { LexicalHtmlRenderer } from \"~/components/LexicalHtmlRenderer\";\n// hooks\nexport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\nexport { useFontColorPicker } from \"~/hooks/useFontColorPicker\";\nexport { useTypographyAction } from \"~/hooks/useTypographyAction\";\nexport { useTextAlignmentAction } from \"~/hooks/useTextAlignmentAction\";\n// UI elements\nexport { Divider } from \"~/ui/Divider\";\nexport { DropDownItem } from \"~/ui/DropDown\";\nexport { DropDown } from \"~/ui/DropDown\";\n// actions\nexport { BoldAction } from \"~/components/ToolbarActions/BoldAction\";\nexport { BulletListAction } from \"~/components/ToolbarActions/BulletListAction\";\nexport { CodeHighlightAction } from \"~/components/ToolbarActions/CodeHighlightAction\";\nexport { FontSizeAction } from \"~/components/ToolbarActions/FontSizeAction\";\nexport { FontColorAction } from \"~/components/ToolbarActions/FontColorAction\";\nexport { ItalicAction } from \"~/components/ToolbarActions/ItalicAction\";\nexport { LinkAction } from \"~/components/ToolbarActions/LinkAction\";\nexport { NumberedListAction } from \"~/components/ToolbarActions/NumberedListAction\";\nexport { QuoteAction } from \"~/components/ToolbarActions/QuoteAction\";\nexport { UnderlineAction } from \"~/components/ToolbarActions/UnderlineAction\";\nexport { TypographyAction } from \"~/components/ToolbarActions/TypographyAction\";\nexport { TextAlignmentAction } from \"~/components/ToolbarActions/TextAlignmentAction\";\n// toolbars\nexport { HeadingToolbar } from \"~/components/Toolbar/HeadingToolbar\";\nexport { ParagraphToolbar } from \"~/components/Toolbar/ParagraphToolbar\";\nexport { Toolbar } from \"~/components/Toolbar/Toolbar\";\n// presets\nexport { ParagraphToolbarPreset } from \"~/components/ToolbarPresets/ParagraphToolbarPreset\";\nexport { HeadingToolbarPreset } from \"./components/ToolbarPresets/HeadingToolbarPreset\";\n// editor\nexport { RichTextEditor } from \"~/components/Editor/RichTextEditor\";\nexport { HeadingEditor } from \"~/components/Editor/HeadingEditor\";\nexport { ParagraphEditor } from \"~/components/Editor/ParagraphEditor\";\n// plugins\nexport { LinkPlugin } from \"@lexical/react/LexicalLinkPlugin\";\nexport { FloatingLinkEditorPlugin } from \"~/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin\";\nexport { CodeHighlightPlugin } from \"~/plugins/CodeHighlightPlugin/CodeHighlightPlugin\";\nexport { ClickableLinkPlugin } from \"~/plugins/ClickableLinkPlugin/ClickableLinkPlugin\";\nexport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin\";\nexport { LexicalUpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin\";\n// composition\nexport { AddToolbarAction } from \"~/components/AddToolbarAction\";\nexport { AddRichTextEditorPlugin } from \"~/components/AddRichTextEditorPlugin\";\nexport { AddRichTextEditorNodeType } from \"~/components/AddRichTextEditorNodeType\";\n// utils\nexport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nexport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nexport { clearNodeFormatting } from \"~/utils/nodes/clearNodeFormating\";\n// types\nexport * as types from \"./types\";\n// config\nexport { LexicalEditorConfig } from \"~/components/LexicalEditorConfig/LexicalEditorConfig\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAAuE;AAAA;AAIvE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/// <reference types="web" />
|
|
3
|
+
import { EditorConfig, LexicalCommand, LexicalEditor, LexicalNode, NodeKey, RangeSelection, SerializedTextNode, Spread, TextNode } from "lexical";
|
|
4
|
+
import { WebinyEditorTheme } from "../themes/webinyLexicalTheme";
|
|
5
|
+
export declare const ADD_FONT_COLOR_COMMAND: LexicalCommand<FontColorPayload>;
|
|
6
|
+
export interface FontColorPayload {
|
|
7
|
+
color: string;
|
|
8
|
+
themeColorName: string | undefined;
|
|
9
|
+
caption?: LexicalEditor;
|
|
10
|
+
key?: NodeKey;
|
|
11
|
+
}
|
|
12
|
+
declare type ThemeStyleColorName = string;
|
|
13
|
+
declare type ThemeColor = "custom" | ThemeStyleColorName;
|
|
14
|
+
export declare type SerializedFontColorNode = Spread<{
|
|
15
|
+
themeColor: ThemeColor;
|
|
16
|
+
color: string;
|
|
17
|
+
type: "font-color-node";
|
|
18
|
+
version: 1;
|
|
19
|
+
}, SerializedTextNode>;
|
|
20
|
+
/**
|
|
21
|
+
* Main responsibility of this node is to apply custom or Webiny theme color to selected text.
|
|
22
|
+
* Extends the original TextNode node to add additional transformation and support for webiny theme font color.
|
|
23
|
+
*/
|
|
24
|
+
export declare class FontColorNode extends TextNode {
|
|
25
|
+
__themeColor: ThemeColor;
|
|
26
|
+
__color: string;
|
|
27
|
+
constructor(text: string, color: string, themeColor?: ThemeColor, key?: NodeKey);
|
|
28
|
+
static getType(): string;
|
|
29
|
+
static clone(node: FontColorNode): FontColorNode;
|
|
30
|
+
static importJSON(serializedNode: SerializedFontColorNode): TextNode;
|
|
31
|
+
exportJSON(): SerializedFontColorNode;
|
|
32
|
+
addColorValueToHTMLElement(element: HTMLElement, theme: WebinyEditorTheme): HTMLElement;
|
|
33
|
+
updateDOM(prevNode: FontColorNode, dom: HTMLElement, config: EditorConfig): boolean;
|
|
34
|
+
getColorStyle(): {
|
|
35
|
+
color: string;
|
|
36
|
+
themeColor: ThemeColor;
|
|
37
|
+
};
|
|
38
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
39
|
+
}
|
|
40
|
+
export declare const $createFontColorNode: (text: string, color: string, themeColor?: ThemeColor, key?: NodeKey) => FontColorNode;
|
|
41
|
+
export declare const $isFontColorNode: (node: LexicalNode) => boolean;
|
|
42
|
+
export declare function $applyStylesToNode(node: FontColorNode, nodeStyleProvider: RangeSelection): void;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.$applyStylesToNode = $applyStylesToNode;
|
|
8
|
+
exports.FontColorNode = exports.ADD_FONT_COLOR_COMMAND = exports.$isFontColorNode = exports.$createFontColorNode = void 0;
|
|
9
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
13
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
14
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
16
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
17
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
|
+
var _lexical = require("lexical");
|
|
19
|
+
var ADD_FONT_COLOR_COMMAND = (0, _lexical.createCommand)("ADD_FONT_COLOR_COMMAND");
|
|
20
|
+
exports.ADD_FONT_COLOR_COMMAND = ADD_FONT_COLOR_COMMAND;
|
|
21
|
+
var FontColorNodeAttrName = "data-theme-font-color-name";
|
|
22
|
+
/**
|
|
23
|
+
* Main responsibility of this node is to apply custom or Webiny theme color to selected text.
|
|
24
|
+
* Extends the original TextNode node to add additional transformation and support for webiny theme font color.
|
|
25
|
+
*/
|
|
26
|
+
var FontColorNode = /*#__PURE__*/function (_TextNode) {
|
|
27
|
+
(0, _inherits2.default)(FontColorNode, _TextNode);
|
|
28
|
+
var _super = (0, _createSuper2.default)(FontColorNode);
|
|
29
|
+
function FontColorNode(text, color, themeColor, key) {
|
|
30
|
+
var _this;
|
|
31
|
+
(0, _classCallCheck2.default)(this, FontColorNode);
|
|
32
|
+
_this = _super.call(this, text, key);
|
|
33
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "__themeColor", void 0);
|
|
34
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "__color", void 0);
|
|
35
|
+
_this.__themeColor = themeColor || "custom";
|
|
36
|
+
_this.__color = color;
|
|
37
|
+
return _this;
|
|
38
|
+
}
|
|
39
|
+
(0, _createClass2.default)(FontColorNode, [{
|
|
40
|
+
key: "exportJSON",
|
|
41
|
+
value: function exportJSON() {
|
|
42
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(FontColorNode.prototype), "exportJSON", this).call(this)), {}, {
|
|
43
|
+
themeColor: this.__themeColor,
|
|
44
|
+
color: this.__color,
|
|
45
|
+
type: "font-color-node",
|
|
46
|
+
version: 1
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "addColorValueToHTMLElement",
|
|
51
|
+
value: function addColorValueToHTMLElement(element, theme) {
|
|
52
|
+
var _theme$styles;
|
|
53
|
+
var hasThemeColor = this.__themeColor !== "custom";
|
|
54
|
+
// get the updated color from webiny theme
|
|
55
|
+
if (hasThemeColor && theme !== null && theme !== void 0 && (_theme$styles = theme.styles) !== null && _theme$styles !== void 0 && _theme$styles.colors) {
|
|
56
|
+
this.__color = theme.styles.colors[this.__themeColor];
|
|
57
|
+
}
|
|
58
|
+
element.setAttribute(FontColorNodeAttrName, this.__themeColor);
|
|
59
|
+
element.style.color = this.__color;
|
|
60
|
+
return element;
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
key: "updateDOM",
|
|
64
|
+
value: function updateDOM(prevNode, dom, config) {
|
|
65
|
+
var _theme$styles2;
|
|
66
|
+
var theme = config.theme;
|
|
67
|
+
var isUpdated = (0, _get2.default)((0, _getPrototypeOf2.default)(FontColorNode.prototype), "updateDOM", this).call(this, prevNode, dom, config);
|
|
68
|
+
var hasThemeColor = this.__themeColor !== "custom";
|
|
69
|
+
// get the updated color from webiny theme
|
|
70
|
+
if (hasThemeColor && theme !== null && theme !== void 0 && (_theme$styles2 = theme.styles) !== null && _theme$styles2 !== void 0 && _theme$styles2.colors) {
|
|
71
|
+
this.__color = theme.styles.colors[this.__themeColor];
|
|
72
|
+
}
|
|
73
|
+
dom.setAttribute(FontColorNodeAttrName, this.__themeColor);
|
|
74
|
+
dom.style.color = this.__color;
|
|
75
|
+
return isUpdated;
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "getColorStyle",
|
|
79
|
+
value: function getColorStyle() {
|
|
80
|
+
return {
|
|
81
|
+
color: this.__color,
|
|
82
|
+
themeColor: this.__themeColor
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "createDOM",
|
|
87
|
+
value: function createDOM(config) {
|
|
88
|
+
var element = (0, _get2.default)((0, _getPrototypeOf2.default)(FontColorNode.prototype), "createDOM", this).call(this, config);
|
|
89
|
+
return this.addColorValueToHTMLElement(element, config.theme);
|
|
90
|
+
}
|
|
91
|
+
}], [{
|
|
92
|
+
key: "getType",
|
|
93
|
+
value: function getType() {
|
|
94
|
+
return "font-color-node";
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "clone",
|
|
98
|
+
value: function clone(node) {
|
|
99
|
+
return new FontColorNode(node.__text, node.__color, node.__themeColor, node.__key);
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "importJSON",
|
|
103
|
+
value: function importJSON(serializedNode) {
|
|
104
|
+
var node = new FontColorNode(serializedNode.text, serializedNode.color, serializedNode.themeColor);
|
|
105
|
+
node.setTextContent(serializedNode.text);
|
|
106
|
+
node.setFormat(serializedNode.format);
|
|
107
|
+
node.setDetail(serializedNode.detail);
|
|
108
|
+
node.setMode(serializedNode.mode);
|
|
109
|
+
node.setStyle(serializedNode.style);
|
|
110
|
+
return node;
|
|
111
|
+
}
|
|
112
|
+
}]);
|
|
113
|
+
return FontColorNode;
|
|
114
|
+
}(_lexical.TextNode);
|
|
115
|
+
exports.FontColorNode = FontColorNode;
|
|
116
|
+
var $createFontColorNode = function $createFontColorNode(text, color, themeColor, key) {
|
|
117
|
+
return new FontColorNode(text, color, themeColor, key);
|
|
118
|
+
};
|
|
119
|
+
exports.$createFontColorNode = $createFontColorNode;
|
|
120
|
+
var $isFontColorNode = function $isFontColorNode(node) {
|
|
121
|
+
return node instanceof FontColorNode;
|
|
122
|
+
};
|
|
123
|
+
exports.$isFontColorNode = $isFontColorNode;
|
|
124
|
+
function $applyStylesToNode(node, nodeStyleProvider) {
|
|
125
|
+
node.setFormat(nodeStyleProvider.format);
|
|
126
|
+
node.setStyle(nodeStyleProvider.style);
|
|
127
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ADD_FONT_COLOR_COMMAND","createCommand","FontColorNodeAttrName","FontColorNode","text","color","themeColor","key","__themeColor","__color","type","version","element","theme","hasThemeColor","styles","colors","setAttribute","style","prevNode","dom","config","isUpdated","addColorValueToHTMLElement","node","__text","__key","serializedNode","setTextContent","setFormat","format","setDetail","detail","setMode","mode","setStyle","TextNode","$createFontColorNode","$isFontColorNode","$applyStylesToNode","nodeStyleProvider"],"sources":["FontColorNode.ts"],"sourcesContent":["import {\n createCommand,\n EditorConfig,\n LexicalCommand,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n RangeSelection,\n SerializedTextNode,\n Spread,\n TextNode\n} from \"lexical\";\nimport { WebinyEditorTheme } from \"~/themes/webinyLexicalTheme\";\n\nexport const ADD_FONT_COLOR_COMMAND: LexicalCommand<FontColorPayload> =\n createCommand(\"ADD_FONT_COLOR_COMMAND\");\nconst FontColorNodeAttrName = \"data-theme-font-color-name\";\n\nexport interface FontColorPayload {\n // This color can be hex string\n color: string;\n // webiny theme color variable like color1, color2...\n themeColorName: string | undefined;\n caption?: LexicalEditor;\n key?: NodeKey;\n}\n\ntype ThemeStyleColorName = string;\ntype ThemeColor = \"custom\" | ThemeStyleColorName;\n\nexport type SerializedFontColorNode = Spread<\n {\n themeColor: ThemeColor;\n color: string;\n type: \"font-color-node\";\n version: 1;\n },\n SerializedTextNode\n>;\n\n/**\n * Main responsibility of this node is to apply custom or Webiny theme color to selected text.\n * Extends the original TextNode node to add additional transformation and support for webiny theme font color.\n */\nexport class FontColorNode extends TextNode {\n __themeColor: ThemeColor;\n __color: string;\n\n constructor(text: string, color: string, themeColor?: ThemeColor, key?: NodeKey) {\n super(text, key);\n this.__themeColor = themeColor || \"custom\";\n this.__color = color;\n }\n\n static override getType(): string {\n return \"font-color-node\";\n }\n\n static override clone(node: FontColorNode): FontColorNode {\n return new FontColorNode(node.__text, node.__color, node.__themeColor, node.__key);\n }\n\n static override importJSON(serializedNode: SerializedFontColorNode): TextNode {\n const node = new FontColorNode(\n serializedNode.text,\n serializedNode.color,\n serializedNode.themeColor\n );\n node.setTextContent(serializedNode.text);\n node.setFormat(serializedNode.format);\n node.setDetail(serializedNode.detail);\n node.setMode(serializedNode.mode);\n node.setStyle(serializedNode.style);\n return node;\n }\n\n override exportJSON(): SerializedFontColorNode {\n return {\n ...super.exportJSON(),\n themeColor: this.__themeColor,\n color: this.__color,\n type: \"font-color-node\",\n version: 1\n };\n }\n\n addColorValueToHTMLElement(element: HTMLElement, theme: WebinyEditorTheme): HTMLElement {\n const hasThemeColor = this.__themeColor !== \"custom\";\n // get the updated color from webiny theme\n if (hasThemeColor && theme?.styles?.colors) {\n this.__color = theme.styles.colors[this.__themeColor];\n }\n\n element.setAttribute(FontColorNodeAttrName, this.__themeColor);\n element.style.color = this.__color;\n return element;\n }\n\n override updateDOM(prevNode: FontColorNode, dom: HTMLElement, config: EditorConfig): boolean {\n const theme = config.theme;\n const isUpdated = super.updateDOM(prevNode, dom, config);\n const hasThemeColor = this.__themeColor !== \"custom\";\n // get the updated color from webiny theme\n if (hasThemeColor && theme?.styles?.colors) {\n this.__color = theme.styles.colors[this.__themeColor];\n }\n\n dom.setAttribute(FontColorNodeAttrName, this.__themeColor);\n dom.style.color = this.__color;\n return isUpdated;\n }\n\n getColorStyle(): { color: string; themeColor: ThemeColor } {\n return {\n color: this.__color,\n themeColor: this.__themeColor\n };\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n return this.addColorValueToHTMLElement(element, config.theme);\n }\n}\n\nexport const $createFontColorNode = (\n text: string,\n color: string,\n themeColor?: ThemeColor,\n key?: NodeKey\n): FontColorNode => {\n return new FontColorNode(text, color, themeColor, key);\n};\n\nexport const $isFontColorNode = (node: LexicalNode): boolean => {\n return node instanceof FontColorNode;\n};\n\nexport function $applyStylesToNode(node: FontColorNode, nodeStyleProvider: RangeSelection) {\n node.setFormat(nodeStyleProvider.format);\n node.setStyle(nodeStyleProvider.style);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/// <reference types="web" />
|
|
3
|
+
import { LexicalNode, NodeKey, RangeSelection, Spread } from "lexical";
|
|
4
|
+
import { EditorConfig } from "lexical";
|
|
5
|
+
import { TypographyStylesNode, ThemeStyleValue, TextNodeThemeStyles } from "./types";
|
|
6
|
+
import { WebinyTheme } from "../themes/webinyLexicalTheme";
|
|
7
|
+
import { ThemeEmotionMap } from "../types";
|
|
8
|
+
import { HeadingNode as BaseHeadingNode, HeadingTagType, SerializedHeadingNode as BaseSerializedHeadingNode } from "@lexical/rich-text";
|
|
9
|
+
import { ParagraphNode } from "./ParagraphNode";
|
|
10
|
+
export declare type SerializeHeadingNode = Spread<{
|
|
11
|
+
styles: ThemeStyleValue[];
|
|
12
|
+
type: "heading-element";
|
|
13
|
+
}, BaseSerializedHeadingNode>;
|
|
14
|
+
export declare class HeadingNode extends BaseHeadingNode implements TextNodeThemeStyles, TypographyStylesNode {
|
|
15
|
+
__styles: ThemeStyleValue[];
|
|
16
|
+
constructor(tag: HeadingTagType, typographyStyleId?: string, key?: NodeKey);
|
|
17
|
+
protected setDefaultTypography(themeEmotionMap: ThemeEmotionMap): void;
|
|
18
|
+
setTypography(typographyStyleId: string): this;
|
|
19
|
+
getTypographyStyleId(): string | undefined;
|
|
20
|
+
clearTypographyStyle(): this;
|
|
21
|
+
hasTypographyStyle(): boolean;
|
|
22
|
+
getThemeStyles(): ThemeStyleValue[];
|
|
23
|
+
setThemeStyles(styles: ThemeStyleValue[]): this;
|
|
24
|
+
static getType(): string;
|
|
25
|
+
static clone(node: HeadingNode): HeadingNode;
|
|
26
|
+
protected updateElementWithThemeClasses(element: HTMLElement, theme: WebinyTheme): HTMLElement;
|
|
27
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
28
|
+
static importJSON(serializedNode: SerializeHeadingNode): BaseHeadingNode;
|
|
29
|
+
exportJSON(): SerializeHeadingNode;
|
|
30
|
+
insertNewAfter(selection?: RangeSelection, restoreSelection?: boolean): ParagraphNode | HeadingNode;
|
|
31
|
+
collapseAtStart(): true;
|
|
32
|
+
}
|
|
33
|
+
export declare function $createHeadingNode(tag: HeadingTagType, typographyStyleId?: string): HeadingNode;
|
|
34
|
+
export declare function $isHeadingNode(node: LexicalNode | null | undefined): node is HeadingNode;
|