@webiny/lexical-nodes 5.43.3 → 6.0.0-alpha.1
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/FontColorNode.d.ts +4 -4
- package/FontColorNode.js +96 -145
- package/FontColorNode.js.map +1 -1
- package/HeadingNode.d.ts +29 -17
- package/HeadingNode.js +181 -152
- package/HeadingNode.js.map +1 -1
- package/ImageNode.js +143 -188
- package/ImageNode.js.map +1 -1
- package/LinkNode.d.ts +2 -2
- package/LinkNode.js +251 -346
- package/LinkNode.js.map +1 -1
- package/ListItemNode.d.ts +4 -3
- package/ListItemNode.js +276 -354
- package/ListItemNode.js.map +1 -1
- package/ListNode.d.ts +28 -14
- package/ListNode.js +174 -208
- package/ListNode.js.map +1 -1
- package/ParagraphNode.d.ts +28 -16
- package/ParagraphNode.js +141 -179
- package/ParagraphNode.js.map +1 -1
- package/QuoteNode.d.ts +26 -19
- package/QuoteNode.js +104 -186
- package/QuoteNode.js.map +1 -1
- package/components/ImageNode/ContentEditable.js +7 -14
- package/components/ImageNode/ContentEditable.js.map +1 -1
- package/components/ImageNode/ImageComponent.js +104 -124
- package/components/ImageNode/ImageComponent.js.map +1 -1
- package/components/ImageNode/ImageResizer.js +78 -83
- package/components/ImageNode/ImageResizer.js.map +1 -1
- package/components/ImageNode/Placeholder.d.ts +1 -1
- package/components/ImageNode/Placeholder.js +10 -16
- package/components/ImageNode/Placeholder.js.map +1 -1
- package/components/ImageNode/SharedHistoryContext.d.ts +2 -2
- package/components/ImageNode/SharedHistoryContext.js +12 -20
- package/components/ImageNode/SharedHistoryContext.js.map +1 -1
- package/generateInitialLexicalValue.d.ts +4 -0
- package/generateInitialLexicalValue.js +27 -0
- package/generateInitialLexicalValue.js.map +1 -0
- package/index.d.ts +4 -8
- package/index.js +44 -230
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/prepareLexicalState.d.ts +2 -0
- package/prepareLexicalState.js +53 -0
- package/prepareLexicalState.js.map +1 -0
- package/types.d.ts +4 -5
- package/types.js +1 -5
- package/types.js.map +1 -1
- package/utils/clearNodeFormating.d.ts +1 -1
- package/utils/clearNodeFormating.js +12 -18
- package/utils/clearNodeFormating.js.map +1 -1
- package/utils/formatList.d.ts +3 -3
- package/utils/formatList.js +171 -208
- package/utils/formatList.js.map +1 -1
- package/utils/formatToHeading.d.ts +2 -2
- package/utils/formatToHeading.js +8 -15
- package/utils/formatToHeading.js.map +1 -1
- package/utils/formatToParagraph.d.ts +1 -1
- package/utils/formatToParagraph.js +8 -16
- package/utils/formatToParagraph.js.map +1 -1
- package/utils/formatToQuote.d.ts +1 -1
- package/utils/formatToQuote.js +8 -15
- package/utils/formatToQuote.js.map +1 -1
- package/utils/getStyleId.d.ts +11 -0
- package/utils/getStyleId.js +14 -0
- package/utils/getStyleId.js.map +1 -0
- package/utils/listNode.d.ts +2 -2
- package/utils/listNode.js +37 -50
- package/utils/listNode.js.map +1 -1
- package/utils/toggleLink.d.ts +1 -1
- package/utils/toggleLink.js +41 -45
- package/utils/toggleLink.js.map +1 -1
- package/TypographyNode.d.ts +0 -39
- package/TypographyNode.js +0 -146
- package/TypographyNode.js.map +0 -1
package/ParagraphNode.js
CHANGED
|
@@ -1,194 +1,156 @@
|
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
import { ParagraphNode as BaseParagraphNode } from "lexical";
|
|
2
|
+
import { findTypographyStyleByHtmlTag } from "@webiny/lexical-theme";
|
|
3
|
+
import { addClassNamesToElement } from "@lexical/utils";
|
|
4
|
+
import { getStyleId } from "./utils/getStyleId";
|
|
5
|
+
function convertParagraphElement(element) {
|
|
6
|
+
const node = $createParagraphNode();
|
|
7
|
+
if (element.style) {
|
|
8
|
+
node.setFormat(element.style.textAlign);
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
node
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export class ParagraphNode extends BaseParagraphNode {
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
const {
|
|
17
|
+
styleId,
|
|
18
|
+
key,
|
|
19
|
+
className
|
|
20
|
+
} = options;
|
|
21
|
+
super(key);
|
|
22
|
+
this.__styleId = styleId;
|
|
23
|
+
this.__className = className;
|
|
24
|
+
}
|
|
25
|
+
getStyleId() {
|
|
26
|
+
return this.__styleId;
|
|
27
|
+
}
|
|
28
|
+
setStyleId(styleId) {
|
|
29
|
+
this.__styleId = styleId;
|
|
30
|
+
}
|
|
31
|
+
setClassName(className) {
|
|
32
|
+
this.__className = className;
|
|
33
|
+
}
|
|
34
|
+
getClassName() {
|
|
35
|
+
return this.__className;
|
|
36
|
+
}
|
|
37
|
+
static getType() {
|
|
38
|
+
return "wby-paragraph";
|
|
39
|
+
}
|
|
40
|
+
static clone(node) {
|
|
41
|
+
return new ParagraphNode({
|
|
42
|
+
styleId: node.getStyleId(),
|
|
43
|
+
className: node.getClassName(),
|
|
44
|
+
key: node.__key
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
insertNewAfter(rangeSelection, restoreSelection) {
|
|
48
|
+
const newElement = $createParagraphNode();
|
|
49
|
+
newElement.setTextFormat(rangeSelection.format);
|
|
50
|
+
newElement.setTextStyle(rangeSelection.style);
|
|
51
|
+
const direction = this.getDirection();
|
|
52
|
+
newElement.setDirection(direction);
|
|
53
|
+
newElement.setFormat(this.getFormatType());
|
|
54
|
+
newElement.setStyle(this.getStyle());
|
|
55
|
+
this.insertAfter(newElement, restoreSelection);
|
|
56
|
+
return newElement;
|
|
57
|
+
}
|
|
58
|
+
createDOM(config) {
|
|
59
|
+
const element = super.createDOM(config);
|
|
60
|
+
return this.updateElementWithThemeClasses(element, config.theme);
|
|
61
|
+
}
|
|
62
|
+
exportDOM(editor) {
|
|
63
|
+
const base = super.exportDOM(editor);
|
|
64
|
+
const element = base.element;
|
|
65
|
+
if (element && this.__className) {
|
|
66
|
+
element.classList.add(this.__className);
|
|
59
67
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
return {
|
|
69
|
+
...base,
|
|
70
|
+
element
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
updateDOM(prevNode, dom, config) {
|
|
74
|
+
const prevTypoStyleId = prevNode.getStyleId();
|
|
75
|
+
const nextTypoStyleId = this.getStyleId();
|
|
76
|
+
if (!nextTypoStyleId) {
|
|
77
|
+
this.updateElementWithThemeClasses(dom, config.theme);
|
|
78
|
+
return false;
|
|
67
79
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
value: function setThemeStyles(styles) {
|
|
71
|
-
// getWritable() creates a clone of the node
|
|
72
|
-
// if needed, to ensure we don't try and mutate
|
|
73
|
-
// a stale version of this node.
|
|
74
|
-
var self = (0, _superPropGet2.default)(ParagraphNode, "getWritable", this, 3)([]);
|
|
75
|
-
self.__styles = (0, _toConsumableArray2.default)(styles);
|
|
76
|
-
return self;
|
|
80
|
+
if (prevTypoStyleId !== nextTypoStyleId && nextTypoStyleId) {
|
|
81
|
+
this.updateElementWithThemeClasses(dom, config.theme);
|
|
77
82
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return element;
|
|
83
|
-
}
|
|
84
|
-
if (!this.hasTypographyStyle()) {
|
|
85
|
-
this.setDefaultTypography(theme.emotionMap);
|
|
86
|
-
}
|
|
87
|
-
var typoStyleId = this.getTypographyStyleId();
|
|
88
|
-
var themeClasses;
|
|
83
|
+
// Returning false tells Lexical that this node does not need its
|
|
84
|
+
// DOM element replacing with a new copy from createDOM.
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
89
87
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
}, {
|
|
103
|
-
key: "createDOM",
|
|
104
|
-
value: function createDOM(config) {
|
|
105
|
-
var element = (0, _superPropGet2.default)(ParagraphNode, "createDOM", this, 3)([config]);
|
|
106
|
-
return this.updateElementWithThemeClasses(element, config.theme);
|
|
107
|
-
}
|
|
108
|
-
}, {
|
|
109
|
-
key: "updateDOM",
|
|
110
|
-
value: function updateDOM(prevNode, dom, config) {
|
|
111
|
-
var prevTypoStyleId = prevNode.getTypographyStyleId();
|
|
112
|
-
var nextTypoStyleId = this.getTypographyStyleId();
|
|
113
|
-
if (!nextTypoStyleId) {
|
|
114
|
-
this.updateElementWithThemeClasses(dom, config.theme);
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
if (prevTypoStyleId !== nextTypoStyleId && nextTypoStyleId) {
|
|
118
|
-
this.updateElementWithThemeClasses(dom, config.theme);
|
|
119
|
-
}
|
|
120
|
-
// Returning false tells Lexical that this node does not need its
|
|
121
|
-
// DOM element replacing with a new copy from createDOM.
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
88
|
+
/*
|
|
89
|
+
* On copy/paste event this method will be executed in and create a node
|
|
90
|
+
* */
|
|
91
|
+
static importDOM() {
|
|
92
|
+
return {
|
|
93
|
+
p: () => ({
|
|
94
|
+
conversion: convertParagraphElement,
|
|
95
|
+
priority: 0
|
|
96
|
+
})
|
|
97
|
+
};
|
|
98
|
+
}
|
|
124
99
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
100
|
+
/*
|
|
101
|
+
* Serialize the JSON data back into a node
|
|
102
|
+
*/
|
|
103
|
+
static importJSON(serializedNode) {
|
|
104
|
+
const node = $createParagraphNode();
|
|
105
|
+
node.setFormat(serializedNode.format);
|
|
106
|
+
node.setIndent(serializedNode.indent);
|
|
107
|
+
node.setDirection(serializedNode.direction);
|
|
108
|
+
const styleId = getStyleId({
|
|
109
|
+
styleId: serializedNode.styleId,
|
|
110
|
+
styles: serializedNode.styles
|
|
111
|
+
});
|
|
112
|
+
node.setStyleId(styleId);
|
|
113
|
+
node.setClassName(serializedNode.className);
|
|
114
|
+
return node;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* Serialize the node to JSON data representation.
|
|
119
|
+
* */
|
|
120
|
+
exportJSON() {
|
|
121
|
+
return {
|
|
122
|
+
...super.exportJSON(),
|
|
123
|
+
styleId: this.__styleId,
|
|
124
|
+
className: this.__className,
|
|
125
|
+
type: "wby-paragraph"
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
updateElementWithThemeClasses(element, theme) {
|
|
129
|
+
if (!theme?.emotionMap) {
|
|
130
|
+
return element;
|
|
145
131
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
value: function clone(node) {
|
|
149
|
-
return new ParagraphNode(node.getTypographyStyleId(), node.__key);
|
|
132
|
+
if (!this.__styleId || !this.__className) {
|
|
133
|
+
this.setDefaultTypography(theme.emotionMap);
|
|
150
134
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
value: function importDOM() {
|
|
154
|
-
return {
|
|
155
|
-
p: function p() {
|
|
156
|
-
return {
|
|
157
|
-
conversion: convertParagraphElement,
|
|
158
|
-
priority: 0
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
};
|
|
135
|
+
if (this.__className) {
|
|
136
|
+
addClassNamesToElement(element, this.__className);
|
|
162
137
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
var node = $createParagraphNode();
|
|
171
|
-
node.setFormat(serializedNode.format);
|
|
172
|
-
node.setIndent(serializedNode.indent);
|
|
173
|
-
node.setDirection(serializedNode.direction);
|
|
174
|
-
node.setThemeStyles(serializedNode.styles);
|
|
175
|
-
return node;
|
|
138
|
+
return element;
|
|
139
|
+
}
|
|
140
|
+
setDefaultTypography(themeEmotionMap) {
|
|
141
|
+
const typographyStyle = findTypographyStyleByHtmlTag("p", themeEmotionMap);
|
|
142
|
+
if (typographyStyle) {
|
|
143
|
+
this.__styleId = typographyStyle.id;
|
|
144
|
+
this.__className = typographyStyle.className;
|
|
176
145
|
}
|
|
177
|
-
}]);
|
|
178
|
-
}(_lexical.ParagraphNode);
|
|
179
|
-
function convertParagraphElement(element) {
|
|
180
|
-
var node = $createParagraphNode();
|
|
181
|
-
if (element.style) {
|
|
182
|
-
node.setFormat(element.style.textAlign);
|
|
183
146
|
}
|
|
184
|
-
return {
|
|
185
|
-
node: node
|
|
186
|
-
};
|
|
187
147
|
}
|
|
188
|
-
function $createParagraphNode(
|
|
189
|
-
return
|
|
148
|
+
export function $createParagraphNode(styleId) {
|
|
149
|
+
return new ParagraphNode({
|
|
150
|
+
styleId
|
|
151
|
+
});
|
|
190
152
|
}
|
|
191
|
-
function $isParagraphNode(node) {
|
|
153
|
+
export function $isParagraphNode(node) {
|
|
192
154
|
return node instanceof ParagraphNode;
|
|
193
155
|
}
|
|
194
156
|
|
package/ParagraphNode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_lexical","require","_lexicalTheme","_utils","ParagraphNode","exports","_BaseParagraphNode","typographyStyleId","key","_this","_classCallCheck2","default","_callSuper2","_defineProperty2","__styles","push","styleId","type","_inherits2","_createClass2","value","setDefaultTypography","themeEmotionMap","typographyStyle","findTypographyStyleByHtmlTag","id","getTypographyStyleId","style","find","x","undefined","hasTypographyStyle","getThemeStyles","self","_superPropGet2","setThemeStyles","styles","_toConsumableArray2","updateElementWithThemeClasses","element","theme","emotionMap","typoStyleId","themeClasses","className","addClassNamesToElement","createDOM","config","updateDOM","prevNode","dom","prevTypoStyleId","nextTypoStyleId","exportJSON","_objectSpread2","version","getType","clone","node","__key","importDOM","p","conversion","convertParagraphElement","priority","importJSON","serializedNode","$createParagraphNode","setFormat","format","setIndent","indent","setDirection","direction","BaseParagraphNode","textAlign","$applyNodeReplacement","$isParagraphNode"],"sources":["ParagraphNode.ts"],"sourcesContent":["import {\n $applyNodeReplacement,\n DOMConversionMap,\n DOMConversionOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n ParagraphNode as BaseParagraphNode,\n SerializedParagraphNode as SerializedBaseParagraphNode,\n Spread\n} from \"lexical\";\nimport { EditorConfig } from \"lexical\";\nimport { EditorTheme, ThemeEmotionMap, findTypographyStyleByHtmlTag } from \"@webiny/lexical-theme\";\nimport { addClassNamesToElement } from \"@lexical/utils\";\nimport { TypographyStylesNode, ThemeStyleValue, TextNodeThemeStyles } from \"~/types\";\n\nexport type SerializeParagraphNode = Spread<\n {\n styles: ThemeStyleValue[];\n type: \"paragraph-element\";\n },\n SerializedBaseParagraphNode\n>;\n\nexport class ParagraphNode\n extends BaseParagraphNode\n implements TextNodeThemeStyles, TypographyStylesNode\n{\n __styles: ThemeStyleValue[] = [];\n\n constructor(typographyStyleId?: string, key?: NodeKey) {\n super(key);\n\n if (typographyStyleId) {\n this.__styles.push({ styleId: typographyStyleId, type: \"typography\" });\n }\n }\n\n protected setDefaultTypography(themeEmotionMap: ThemeEmotionMap) {\n const typographyStyle = findTypographyStyleByHtmlTag(\"p\", themeEmotionMap);\n if (typographyStyle) {\n this.__styles.push({ styleId: typographyStyle.id, type: \"typography\" });\n }\n }\n\n getTypographyStyleId(): string | undefined {\n const style = this.__styles.find(x => x.type === \"typography\");\n return style?.styleId || undefined;\n }\n\n private hasTypographyStyle(): boolean {\n return !!this.getTypographyStyleId();\n }\n\n getThemeStyles(): ThemeStyleValue[] {\n // getLatest() ensures we are getting the most\n // up-to-date value from the EditorState.\n const self = super.getLatest();\n return self.__styles;\n }\n\n setThemeStyles(styles: ThemeStyleValue[]) {\n // getWritable() creates a clone of the node\n // if needed, to ensure we don't try and mutate\n // a stale version of this node.\n const self = super.getWritable();\n self.__styles = [...styles];\n return self;\n }\n\n static override getType(): string {\n return \"paragraph-element\";\n }\n\n static override clone(node: ParagraphNode): ParagraphNode {\n return new ParagraphNode(node.getTypographyStyleId(), node.__key);\n }\n\n private updateElementWithThemeClasses(element: HTMLElement, theme: EditorTheme): HTMLElement {\n if (!theme?.emotionMap) {\n return element;\n }\n\n if (!this.hasTypographyStyle()) {\n this.setDefaultTypography(theme.emotionMap);\n }\n\n const typoStyleId = this.getTypographyStyleId();\n\n let themeClasses;\n\n // Typography css class\n if (typoStyleId) {\n const typographyStyle = theme.emotionMap[typoStyleId];\n if (typographyStyle) {\n themeClasses = typographyStyle.className;\n }\n }\n\n if (themeClasses) {\n addClassNamesToElement(element, themeClasses);\n }\n\n return element;\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n return this.updateElementWithThemeClasses(element, config.theme as EditorTheme);\n }\n\n override updateDOM(prevNode: ParagraphNode, dom: HTMLElement, config: EditorConfig): boolean {\n const prevTypoStyleId = prevNode.getTypographyStyleId();\n const nextTypoStyleId = this.getTypographyStyleId();\n\n if (!nextTypoStyleId) {\n this.updateElementWithThemeClasses(dom, config.theme as EditorTheme);\n return false;\n }\n\n if (prevTypoStyleId !== nextTypoStyleId && nextTypoStyleId) {\n this.updateElementWithThemeClasses(dom, config.theme as EditorTheme);\n }\n // Returning false tells Lexical that this node does not need its\n // DOM element replacing with a new copy from createDOM.\n return false;\n }\n\n /*\n * On copy/paste event this method will be executed in and create a node\n * */\n static override importDOM(): DOMConversionMap | null {\n return {\n p: () => ({\n conversion: convertParagraphElement,\n priority: 0\n })\n };\n }\n\n /*\n * Serialize the JSON data back into a node\n */\n static override importJSON(serializedNode: SerializeParagraphNode): BaseParagraphNode {\n const node = $createParagraphNode();\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n node.setThemeStyles(serializedNode.styles);\n return node;\n }\n\n /*\n * Serialize the node to JSON data representation.\n * */\n override exportJSON(): SerializeParagraphNode {\n return {\n ...super.exportJSON(),\n styles: this.__styles,\n type: \"paragraph-element\",\n version: 1\n };\n }\n}\n\nfunction convertParagraphElement(element: HTMLElement): DOMConversionOutput {\n const node = $createParagraphNode();\n if (element.style) {\n node.setFormat(element.style.textAlign as ElementFormatType);\n }\n\n return { node };\n}\n\nexport function $createParagraphNode(typographyStyleId?: string): ParagraphNode {\n return $applyNodeReplacement(new ParagraphNode(typographyStyleId));\n}\n\nexport function $isParagraphNode(node: LexicalNode | null | undefined): node is ParagraphNode {\n return node instanceof ParagraphNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAYA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAAwD,IAW3CG,aAAa,G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AAY,KAAA,EAuDD,SAAgBwC,SAASA,CAAA,EAA4B;MACjD,OAAO;QACHC,CAAC,EAAE,SAAHA,CAACA,CAAA;UAAA,OAAS;YACNC,UAAU,EAAEC,uBAAuB;YACnCC,QAAQ,EAAE;UACd,CAAC;QAAA;MACL,CAAC;IACL;;IAEA;AACJ;AACA;EAFI;IAAAxD,GAAA;IAAAY,KAAA,EAGA,SAAgB6C,UAAUA,CAACC,cAAsC,EAAqB;MAClF,IAAMR,IAAI,GAAGS,oBAAoB,CAAC,CAAC;MACnCT,IAAI,CAACU,SAAS,CAACF,cAAc,CAACG,MAAM,CAAC;MACrCX,IAAI,CAACY,SAAS,CAACJ,cAAc,CAACK,MAAM,CAAC;MACrCb,IAAI,CAACc,YAAY,CAACN,cAAc,CAACO,SAAS,CAAC;MAC3Cf,IAAI,CAACvB,cAAc,CAAC+B,cAAc,CAAC9B,MAAM,CAAC;MAC1C,OAAOsB,IAAI;IACf;EAAC;AAAA,EA7HOgB,sBAAiB;AA4I7B,SAASX,uBAAuBA,CAACxB,OAAoB,EAAuB;EACxE,IAAMmB,IAAI,GAAGS,oBAAoB,CAAC,CAAC;EACnC,IAAI5B,OAAO,CAACZ,KAAK,EAAE;IACf+B,IAAI,CAACU,SAAS,CAAC7B,OAAO,CAACZ,KAAK,CAACgD,SAA8B,CAAC;EAChE;EAEA,OAAO;IAAEjB,IAAI,EAAJA;EAAK,CAAC;AACnB;AAEO,SAASS,oBAAoBA,CAAC5D,iBAA0B,EAAiB;EAC5E,OAAO,IAAAqE,8BAAqB,EAAC,IAAIxE,aAAa,CAACG,iBAAiB,CAAC,CAAC;AACtE;AAEO,SAASsE,gBAAgBA,CAACnB,IAAoC,EAAyB;EAC1F,OAAOA,IAAI,YAAYtD,aAAa;AACxC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["ParagraphNode","BaseParagraphNode","findTypographyStyleByHtmlTag","addClassNamesToElement","getStyleId","convertParagraphElement","element","node","$createParagraphNode","style","setFormat","textAlign","constructor","options","styleId","key","className","__styleId","__className","setStyleId","setClassName","getClassName","getType","clone","__key","insertNewAfter","rangeSelection","restoreSelection","newElement","setTextFormat","format","setTextStyle","direction","getDirection","setDirection","getFormatType","setStyle","getStyle","insertAfter","createDOM","config","updateElementWithThemeClasses","theme","exportDOM","editor","base","classList","add","updateDOM","prevNode","dom","prevTypoStyleId","nextTypoStyleId","importDOM","p","conversion","priority","importJSON","serializedNode","setIndent","indent","styles","exportJSON","type","emotionMap","setDefaultTypography","themeEmotionMap","typographyStyle","id","$isParagraphNode"],"sources":["ParagraphNode.ts"],"sourcesContent":["import type {\n DOMConversionMap,\n DOMConversionOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n SerializedParagraphNode as SerializedBaseParagraphNode,\n Spread,\n LexicalEditor,\n DOMExportOutput,\n RangeSelection\n} from \"lexical\";\nimport { ParagraphNode as BaseParagraphNode } from \"lexical\";\nimport type { EditorConfig } from \"lexical\";\nimport type { EditorTheme, ThemeEmotionMap } from \"@webiny/lexical-theme\";\nimport { findTypographyStyleByHtmlTag } from \"@webiny/lexical-theme\";\nimport { addClassNamesToElement } from \"@lexical/utils\";\nimport type { TypographyStylesNode, ThemeStyleValue } from \"~/types\";\nimport { getStyleId } from \"./utils/getStyleId\";\n\nfunction convertParagraphElement(element: HTMLElement): DOMConversionOutput {\n const node = $createParagraphNode();\n if (element.style) {\n node.setFormat(element.style.textAlign as ElementFormatType);\n }\n\n return { node };\n}\n\nexport type SerializeParagraphNode = Spread<\n {\n styles?: ThemeStyleValue[];\n styleId?: string;\n className?: string;\n type: \"wby-paragraph\";\n },\n SerializedBaseParagraphNode\n>;\n\ninterface ParagraphNodeOptions {\n className?: string;\n styleId?: string;\n key?: NodeKey;\n}\n\nexport class ParagraphNode extends BaseParagraphNode implements TypographyStylesNode {\n private __styleId: string | undefined;\n private __className: string | undefined;\n\n constructor(options: ParagraphNodeOptions = {}) {\n const { styleId, key, className } = options;\n super(key);\n\n this.__styleId = styleId;\n this.__className = className;\n }\n\n getStyleId(): string | undefined {\n return this.__styleId;\n }\n\n setStyleId(styleId: string | undefined) {\n this.__styleId = styleId;\n }\n\n setClassName(className: string | undefined) {\n this.__className = className;\n }\n\n getClassName(): string | undefined {\n return this.__className;\n }\n\n static override getType(): string {\n return \"wby-paragraph\";\n }\n\n static override clone(node: ParagraphNode): ParagraphNode {\n return new ParagraphNode({\n styleId: node.getStyleId(),\n className: node.getClassName(),\n key: node.__key\n });\n }\n\n override insertNewAfter(\n rangeSelection: RangeSelection,\n restoreSelection: boolean\n ): ParagraphNode {\n const newElement = $createParagraphNode();\n newElement.setTextFormat(rangeSelection.format);\n newElement.setTextStyle(rangeSelection.style);\n const direction = this.getDirection();\n newElement.setDirection(direction);\n newElement.setFormat(this.getFormatType());\n newElement.setStyle(this.getStyle());\n this.insertAfter(newElement, restoreSelection);\n return newElement;\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n return this.updateElementWithThemeClasses(element, config.theme as EditorTheme);\n }\n\n override exportDOM(editor: LexicalEditor): DOMExportOutput {\n const base = super.exportDOM(editor);\n\n const element = base.element as HTMLElement;\n if (element && this.__className) {\n element.classList.add(this.__className);\n }\n\n return { ...base, element };\n }\n\n override updateDOM(prevNode: ParagraphNode, dom: HTMLElement, config: EditorConfig): boolean {\n const prevTypoStyleId = prevNode.getStyleId();\n const nextTypoStyleId = this.getStyleId();\n\n if (!nextTypoStyleId) {\n this.updateElementWithThemeClasses(dom, config.theme as EditorTheme);\n return false;\n }\n\n if (prevTypoStyleId !== nextTypoStyleId && nextTypoStyleId) {\n this.updateElementWithThemeClasses(dom, config.theme as EditorTheme);\n }\n // Returning false tells Lexical that this node does not need its\n // DOM element replacing with a new copy from createDOM.\n return false;\n }\n\n /*\n * On copy/paste event this method will be executed in and create a node\n * */\n static override importDOM(): DOMConversionMap | null {\n return {\n p: () => ({\n conversion: convertParagraphElement,\n priority: 0\n })\n };\n }\n\n /*\n * Serialize the JSON data back into a node\n */\n static override importJSON(serializedNode: SerializeParagraphNode): BaseParagraphNode {\n const node = $createParagraphNode();\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n\n const styleId = getStyleId({\n styleId: serializedNode.styleId,\n styles: serializedNode.styles\n });\n\n node.setStyleId(styleId);\n node.setClassName(serializedNode.className);\n return node;\n }\n\n /*\n * Serialize the node to JSON data representation.\n * */\n override exportJSON(): SerializeParagraphNode {\n return {\n ...super.exportJSON(),\n styleId: this.__styleId,\n className: this.__className,\n type: \"wby-paragraph\"\n };\n }\n\n protected updateElementWithThemeClasses(element: HTMLElement, theme: EditorTheme): HTMLElement {\n if (!theme?.emotionMap) {\n return element;\n }\n\n if (!this.__styleId || !this.__className) {\n this.setDefaultTypography(theme.emotionMap);\n }\n\n if (this.__className) {\n addClassNamesToElement(element, this.__className);\n }\n\n return element;\n }\n\n private setDefaultTypography(themeEmotionMap: ThemeEmotionMap) {\n const typographyStyle = findTypographyStyleByHtmlTag(\"p\", themeEmotionMap);\n if (typographyStyle) {\n this.__styleId = typographyStyle.id;\n this.__className = typographyStyle.className;\n }\n }\n}\n\nexport function $createParagraphNode(styleId?: string): ParagraphNode {\n return new ParagraphNode({ styleId });\n}\n\nexport function $isParagraphNode(node: LexicalNode | null | undefined): node is ParagraphNode {\n return node instanceof ParagraphNode;\n}\n"],"mappings":"AAYA,SAASA,aAAa,IAAIC,iBAAiB,QAAQ,SAAS;AAG5D,SAASC,4BAA4B,QAAQ,uBAAuB;AACpE,SAASC,sBAAsB,QAAQ,gBAAgB;AAEvD,SAASC,UAAU;AAEnB,SAASC,uBAAuBA,CAACC,OAAoB,EAAuB;EACxE,MAAMC,IAAI,GAAGC,oBAAoB,CAAC,CAAC;EACnC,IAAIF,OAAO,CAACG,KAAK,EAAE;IACfF,IAAI,CAACG,SAAS,CAACJ,OAAO,CAACG,KAAK,CAACE,SAA8B,CAAC;EAChE;EAEA,OAAO;IAAEJ;EAAK,CAAC;AACn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IAEA,OAAOZ,OAAO;EAClB;EAEQ2D,oBAAoBA,CAACC,eAAgC,EAAE;IAC3D,MAAMC,eAAe,GAAGjE,4BAA4B,CAAC,GAAG,EAAEgE,eAAe,CAAC;IAC1E,IAAIC,eAAe,EAAE;MACjB,IAAI,CAAClD,SAAS,GAAGkD,eAAe,CAACC,EAAE;MACnC,IAAI,CAAClD,WAAW,GAAGiD,eAAe,CAACnD,SAAS;IAChD;EACJ;AACJ;AAEA,OAAO,SAASR,oBAAoBA,CAACM,OAAgB,EAAiB;EAClE,OAAO,IAAId,aAAa,CAAC;IAAEc;EAAQ,CAAC,CAAC;AACzC;AAEA,OAAO,SAASuD,gBAAgBA,CAAC9D,IAAoC,EAAyB;EAC1F,OAAOA,IAAI,YAAYP,aAAa;AACxC","ignoreList":[]}
|
package/QuoteNode.d.ts
CHANGED
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
import { DOMConversion, DOMConversionMap, EditorConfig, LexicalNode, NodeKey, Spread } from "lexical";
|
|
2
|
-
import { EditorTheme
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { DOMConversion, DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, Spread } from "lexical";
|
|
2
|
+
import type { EditorTheme } from "@webiny/lexical-theme";
|
|
3
|
+
import type { SerializedQuoteNode as BaseSerializedQuoteNode } from "@lexical/rich-text";
|
|
4
|
+
import { QuoteNode as BaseQuoteNode } from "@lexical/rich-text";
|
|
5
|
+
import type { ThemeStyleValue, TypographyStylesNode } from "./types";
|
|
5
6
|
export type SerializedQuoteNode = Spread<{
|
|
6
7
|
styleId?: string;
|
|
7
|
-
styles
|
|
8
|
-
|
|
8
|
+
styles?: ThemeStyleValue[];
|
|
9
|
+
className?: string;
|
|
10
|
+
type: "wby-quote";
|
|
9
11
|
}, BaseSerializedQuoteNode>;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
interface QuoteNodeOptions {
|
|
13
|
+
className?: string;
|
|
14
|
+
styleId?: string;
|
|
15
|
+
key?: NodeKey;
|
|
16
|
+
}
|
|
17
|
+
export declare class QuoteNode extends BaseQuoteNode implements TypographyStylesNode {
|
|
18
|
+
private __styleId;
|
|
19
|
+
private __className;
|
|
20
|
+
constructor(options?: QuoteNodeOptions);
|
|
21
|
+
getStyleId(): string | undefined;
|
|
22
|
+
setStyleId(styleId: string | undefined): void;
|
|
23
|
+
setClassName(className: string | undefined): void;
|
|
24
|
+
getClassName(): string | undefined;
|
|
25
|
+
private setDefaultTypography;
|
|
21
26
|
static getType(): string;
|
|
22
27
|
static clone(node: QuoteNode): QuoteNode;
|
|
23
|
-
addThemeStylesToHTMLElement(element: HTMLElement, theme: EditorTheme): HTMLElement;
|
|
24
28
|
createDOM(config: EditorConfig): HTMLElement;
|
|
29
|
+
exportDOM(editor: LexicalEditor): DOMExportOutput;
|
|
25
30
|
static importDomConversionMap(): DOMConversion<HTMLElement> | null;
|
|
26
31
|
static importDOM(): DOMConversionMap | null;
|
|
27
32
|
static importJSON(serializedNode: SerializedQuoteNode): QuoteNode;
|
|
28
33
|
exportJSON(): SerializedQuoteNode;
|
|
34
|
+
protected updateElementWithThemeClasses(element: HTMLElement, theme: EditorTheme): HTMLElement;
|
|
29
35
|
}
|
|
30
|
-
export declare function $createQuoteNode(
|
|
36
|
+
export declare function $createQuoteNode(styleId?: string, key?: NodeKey): QuoteNode;
|
|
31
37
|
export declare function $isQuoteNode(node: LexicalNode | null | undefined): node is QuoteNode;
|
|
38
|
+
export {};
|