@webiny/lexical-nodes 5.38.0-beta.0

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.
Files changed (72) hide show
  1. package/FontColorNode.d.ts +43 -0
  2. package/FontColorNode.js +125 -0
  3. package/FontColorNode.js.map +1 -0
  4. package/HeadingNode.d.ts +32 -0
  5. package/HeadingNode.js +193 -0
  6. package/HeadingNode.js.map +1 -0
  7. package/ImageNode.d.ts +58 -0
  8. package/ImageNode.js +217 -0
  9. package/ImageNode.js.map +1 -0
  10. package/LICENSE +21 -0
  11. package/LinkNode.d.ts +106 -0
  12. package/LinkNode.js +531 -0
  13. package/LinkNode.js.map +1 -0
  14. package/ListItemNode.d.ts +44 -0
  15. package/ListItemNode.js +442 -0
  16. package/ListItemNode.js.map +1 -0
  17. package/ListNode.d.ts +42 -0
  18. package/ListNode.js +290 -0
  19. package/ListNode.js.map +1 -0
  20. package/ParagraphNode.d.ts +31 -0
  21. package/ParagraphNode.js +220 -0
  22. package/ParagraphNode.js.map +1 -0
  23. package/QuoteNode.d.ts +33 -0
  24. package/QuoteNode.js +227 -0
  25. package/QuoteNode.js.map +1 -0
  26. package/README.md +6 -0
  27. package/TypographyNode.d.ts +41 -0
  28. package/TypographyNode.js +153 -0
  29. package/TypographyNode.js.map +1 -0
  30. package/components/ImageNode/ContentEditable.css +22 -0
  31. package/components/ImageNode/ContentEditable.d.ts +12 -0
  32. package/components/ImageNode/ContentEditable.js +26 -0
  33. package/components/ImageNode/ContentEditable.js.map +1 -0
  34. package/components/ImageNode/ImageComponent.css +43 -0
  35. package/components/ImageNode/ImageComponent.d.ts +16 -0
  36. package/components/ImageNode/ImageComponent.js +254 -0
  37. package/components/ImageNode/ImageComponent.js.map +1 -0
  38. package/components/ImageNode/ImageResizer.d.ts +26 -0
  39. package/components/ImageNode/ImageResizer.js +215 -0
  40. package/components/ImageNode/ImageResizer.js.map +1 -0
  41. package/components/ImageNode/Placeholder.css +20 -0
  42. package/components/ImageNode/Placeholder.d.ts +15 -0
  43. package/components/ImageNode/Placeholder.js +30 -0
  44. package/components/ImageNode/Placeholder.js.map +1 -0
  45. package/components/ImageNode/SharedHistoryContext.d.ts +11 -0
  46. package/components/ImageNode/SharedHistoryContext.js +28 -0
  47. package/components/ImageNode/SharedHistoryContext.js.map +1 -0
  48. package/index.d.ts +22 -0
  49. package/index.js +226 -0
  50. package/index.js.map +1 -0
  51. package/package.json +32 -0
  52. package/types.d.ts +15 -0
  53. package/types.js +7 -0
  54. package/types.js.map +1 -0
  55. package/utils/clearNodeFormating.d.ts +2 -0
  56. package/utils/clearNodeFormating.js +30 -0
  57. package/utils/clearNodeFormating.js.map +1 -0
  58. package/utils/formatList.d.ts +19 -0
  59. package/utils/formatList.js +449 -0
  60. package/utils/formatList.js.map +1 -0
  61. package/utils/formatToHeading.d.ts +3 -0
  62. package/utils/formatToHeading.js +27 -0
  63. package/utils/formatToHeading.js.map +1 -0
  64. package/utils/formatToParagraph.d.ts +2 -0
  65. package/utils/formatToParagraph.js +22 -0
  66. package/utils/formatToParagraph.js.map +1 -0
  67. package/utils/formatToQuote.d.ts +2 -0
  68. package/utils/formatToQuote.js +27 -0
  69. package/utils/formatToQuote.js.map +1 -0
  70. package/utils/listNode.d.ts +11 -0
  71. package/utils/listNode.js +109 -0
  72. package/utils/listNode.js.map +1 -0
package/ListNode.js ADDED
@@ -0,0 +1,290 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.$createListNode = $createListNode;
8
+ exports.$isListNode = $isListNode;
9
+ exports.ListNode = void 0;
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
15
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
18
+ var _lexical = require("lexical");
19
+ var _lexicalTheme = require("@webiny/lexical-theme");
20
+ var _utils = require("@lexical/utils");
21
+ var _listNode = require("./utils/listNode");
22
+ var _ListItemNode = require("./ListItemNode");
23
+ var TypographyStyleAttrName = "data-theme-list-style-id";
24
+ var ListNode = /*#__PURE__*/function (_ElementNode) {
25
+ (0, _inherits2.default)(ListNode, _ElementNode);
26
+ var _super = (0, _createSuper2.default)(ListNode);
27
+ /** @internal */
28
+
29
+ /** @internal */
30
+
31
+ /** @internal */
32
+
33
+ function ListNode(listType, themeStyleId, start, key) {
34
+ var _this;
35
+ (0, _classCallCheck2.default)(this, ListNode);
36
+ _this = _super.call(this, key);
37
+ _this.__themeStyleId = themeStyleId || "";
38
+ var _listType = TAG_TO_WEBINY_LIST_TYPE[listType] || listType;
39
+ _this.__listType = _listType;
40
+ _this.__tag = _listType === "number" ? "ol" : "ul";
41
+ _this.__start = start || 1;
42
+ return _this;
43
+ }
44
+ (0, _createClass2.default)(ListNode, [{
45
+ key: "isStyleExistInTheme",
46
+ value: function isStyleExistInTheme(theme) {
47
+ return theme !== null && theme !== void 0 && theme.emotionMap ? !!(theme !== null && theme !== void 0 && theme.emotionMap[this.__themeStyleId]) : false;
48
+ }
49
+ }, {
50
+ key: "createDOM",
51
+ value: function createDOM(config) {
52
+ var tag = this.__tag;
53
+ var dom = document.createElement(tag);
54
+ var wTheme = config.theme;
55
+ if (this.__start !== 1) {
56
+ dom.setAttribute("start", String(this.__start));
57
+ }
58
+
59
+ // If styleId is not set or user removed from theme, set default style
60
+ if (!this.hasThemeStyle() || !this.isStyleExistInTheme(wTheme)) {
61
+ this.setDefaultThemeListStyleByTag(this.__tag, wTheme);
62
+ }
63
+
64
+ // @ts-expect-error Internal field.
65
+ dom.__lexicalListType = this.__listType;
66
+ var theme = config.theme;
67
+ setListThemeClassNames(dom, theme, this, this.__themeStyleId);
68
+ dom.setAttribute(TypographyStyleAttrName, this.__themeStyleId);
69
+ return dom;
70
+ }
71
+ }, {
72
+ key: "getTag",
73
+ value: function getTag() {
74
+ return this.__tag;
75
+ }
76
+ }, {
77
+ key: "getListType",
78
+ value: function getListType() {
79
+ return this.__listType;
80
+ }
81
+ }, {
82
+ key: "getStart",
83
+ value: function getStart() {
84
+ return this.__start;
85
+ }
86
+ }, {
87
+ key: "getStyleId",
88
+ value: function getStyleId() {
89
+ return this.__themeStyleId;
90
+ }
91
+ }, {
92
+ key: "exportJSON",
93
+ value:
94
+ // @ts-ignore
95
+ function exportJSON() {
96
+ var _this$__themeStyleId;
97
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(ListNode.prototype), "exportJSON", this).call(this)), {}, {
98
+ themeStyleId: (_this$__themeStyleId = this.__themeStyleId) !== null && _this$__themeStyleId !== void 0 ? _this$__themeStyleId : "",
99
+ listType: this.getListType(),
100
+ start: this.getStart(),
101
+ tag: this.getTag(),
102
+ type: "webiny-list",
103
+ version: 1
104
+ });
105
+ }
106
+ }, {
107
+ key: "setDefaultThemeListStyleByTag",
108
+ value:
109
+ /*
110
+ * Set default styleId from first style that is found in the theme that contains current ul or ol tag
111
+ */
112
+ function setDefaultThemeListStyleByTag(tag, theme) {
113
+ if (!tag) {
114
+ return;
115
+ }
116
+ var themeEmotionMap = theme === null || theme === void 0 ? void 0 : theme.emotionMap;
117
+ if (!themeEmotionMap) {
118
+ return;
119
+ }
120
+ var style = (0, _lexicalTheme.findTypographyStyleByHtmlTag)(tag, themeEmotionMap);
121
+ if (style) {
122
+ this.__themeStyleId = style.id;
123
+ }
124
+ }
125
+ }, {
126
+ key: "hasThemeStyle",
127
+ value: function hasThemeStyle() {
128
+ return !!this.__themeStyleId;
129
+ }
130
+ }, {
131
+ key: "updateDOM",
132
+ value: function updateDOM(prevNode, dom, config) {
133
+ var wTheme = config.theme;
134
+ if (prevNode.__tag !== this.__tag) {
135
+ return true;
136
+ }
137
+
138
+ // if styleId is not set or user removed from theme, set default style.
139
+ if (!this.hasThemeStyle() || !this.isStyleExistInTheme(wTheme)) {
140
+ this.setDefaultThemeListStyleByTag(this.__tag, wTheme);
141
+ }
142
+ setListThemeClassNames(dom, config.theme, this, this.__themeStyleId);
143
+ dom.setAttribute(TypographyStyleAttrName, this.__themeStyleId);
144
+ return false;
145
+ }
146
+ }, {
147
+ key: "extractWithChild",
148
+ value: function extractWithChild(child) {
149
+ return (0, _ListItemNode.$isListItemNode)(child);
150
+ }
151
+ }], [{
152
+ key: "getType",
153
+ value: function getType() {
154
+ return "webiny-list";
155
+ }
156
+ }, {
157
+ key: "clone",
158
+ value: function clone(node) {
159
+ return new ListNode(node.getListType(), node.getStyleId(), node.getStart(), node.__key);
160
+ }
161
+ }, {
162
+ key: "importJSON",
163
+ value: function importJSON(serializedNode) {
164
+ var node = $createListNode(serializedNode.listType, serializedNode.themeStyleId, serializedNode.start);
165
+ node.setFormat(serializedNode.format);
166
+ node.setIndent(serializedNode.indent);
167
+ node.setDirection(serializedNode.direction);
168
+ return node;
169
+ }
170
+ }, {
171
+ key: "importDomConversionMap",
172
+ value: function importDomConversionMap() {
173
+ return {
174
+ conversion: convertListNode,
175
+ priority: 0
176
+ };
177
+ }
178
+ }, {
179
+ key: "importDOM",
180
+ value: function importDOM() {
181
+ var _this2 = this;
182
+ return {
183
+ ol: function ol() {
184
+ return _this2.importDomConversionMap();
185
+ },
186
+ ul: function ul() {
187
+ return _this2.importDomConversionMap();
188
+ }
189
+ };
190
+ }
191
+ }]);
192
+ return ListNode;
193
+ }(_lexical.ElementNode);
194
+ exports.ListNode = ListNode;
195
+ function setListThemeClassNames(dom, editorTheme, node, themeStyleId) {
196
+ var editorThemeClasses = editorTheme;
197
+ var classesToAdd = [];
198
+ var classesToRemove = [];
199
+ var listTheme = editorThemeClasses.list;
200
+ var emotionMap = (editorTheme === null || editorTheme === void 0 ? void 0 : editorTheme.emotionMap) || {};
201
+ if (listTheme !== undefined) {
202
+ var _emotionMap$themeStyl, _emotionMap$themeStyl2;
203
+ var listLevelsClassNames = listTheme["".concat(node.__tag, "Depth")] || [];
204
+ var listDepth = (0, _listNode.$getListDepth)(node) - 1;
205
+ var normalizedListDepth = listDepth % listLevelsClassNames.length;
206
+ var listLevelClassName = listLevelsClassNames[normalizedListDepth];
207
+ var listClassName = "".concat(listTheme[node.__tag], " ").concat((_emotionMap$themeStyl = (_emotionMap$themeStyl2 = emotionMap[themeStyleId]) === null || _emotionMap$themeStyl2 === void 0 ? void 0 : _emotionMap$themeStyl2.className) !== null && _emotionMap$themeStyl !== void 0 ? _emotionMap$themeStyl : "");
208
+ var nestedListClassName;
209
+ var nestedListTheme = listTheme.nested;
210
+ if (nestedListTheme !== undefined && nestedListTheme.list) {
211
+ nestedListClassName = nestedListTheme.list;
212
+ }
213
+ if (listClassName) {
214
+ classesToAdd.push(listClassName);
215
+ }
216
+ if (listLevelClassName !== undefined) {
217
+ var listItemClasses = listLevelClassName.split(" ");
218
+ classesToAdd.push.apply(classesToAdd, (0, _toConsumableArray2.default)(listItemClasses));
219
+ for (var i = 0; i < listLevelsClassNames.length; i++) {
220
+ if (i !== normalizedListDepth) {
221
+ classesToRemove.push(node.__tag + i);
222
+ }
223
+ }
224
+ }
225
+ if (nestedListClassName !== undefined) {
226
+ var nestedListItemClasses = nestedListClassName.split(" ");
227
+ if (listDepth > 1) {
228
+ classesToAdd.push.apply(classesToAdd, (0, _toConsumableArray2.default)(nestedListItemClasses));
229
+ } else {
230
+ classesToRemove.push.apply(classesToRemove, (0, _toConsumableArray2.default)(nestedListItemClasses));
231
+ }
232
+ }
233
+ }
234
+ if (classesToRemove.length > 0) {
235
+ _utils.removeClassNamesFromElement.apply(void 0, [dom].concat(classesToRemove));
236
+ }
237
+ if (classesToAdd.length > 0) {
238
+ _utils.addClassNamesToElement.apply(void 0, [dom].concat(classesToAdd));
239
+ }
240
+ }
241
+
242
+ /*
243
+ * This function normalizes the children of a ListNode after the conversion from HTML,
244
+ * ensuring that they are all ListItemNodes and contain either a single nested ListNode
245
+ * or some other inline content.
246
+ */
247
+ function normalizeChildren(nodes) {
248
+ var normalizedListItems = [];
249
+ for (var i = 0; i < nodes.length; i++) {
250
+ var node = nodes[i];
251
+ if ((0, _ListItemNode.$isListItemNode)(node)) {
252
+ normalizedListItems.push(node);
253
+ node.getChildren().forEach(function (child) {
254
+ if ($isListNode(child)) {
255
+ normalizedListItems.push((0, _listNode.wrapInListItem)(child));
256
+ }
257
+ });
258
+ } else {
259
+ normalizedListItems.push((0, _listNode.wrapInListItem)(node));
260
+ }
261
+ }
262
+ return normalizedListItems;
263
+ }
264
+ function convertListNode(domNode) {
265
+ var nodeName = domNode.nodeName.toLowerCase();
266
+ var node = null;
267
+ if (nodeName === "ol") {
268
+ node = $createListNode("number");
269
+ } else if (nodeName === "ul") {
270
+ node = $createListNode("bullet");
271
+ }
272
+ return {
273
+ // @ts-ignore
274
+ after: normalizeChildren,
275
+ node: node
276
+ };
277
+ }
278
+ var TAG_TO_WEBINY_LIST_TYPE = {
279
+ ol: "number",
280
+ ul: "bullet"
281
+ };
282
+ function $createListNode(listType, themeStyleId) {
283
+ var start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
284
+ return new ListNode(listType, themeStyleId, start);
285
+ }
286
+ function $isListNode(node) {
287
+ return node instanceof ListNode;
288
+ }
289
+
290
+ //# sourceMappingURL=ListNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lexical","require","_lexicalTheme","_utils","_listNode","_ListItemNode","TypographyStyleAttrName","ListNode","_ElementNode","_inherits2","default","_super","_createSuper2","listType","themeStyleId","start","key","_this","_classCallCheck2","call","__themeStyleId","_listType","TAG_TO_WEBINY_LIST_TYPE","__listType","__tag","__start","_createClass2","value","isStyleExistInTheme","theme","emotionMap","createDOM","config","tag","dom","document","createElement","wTheme","setAttribute","String","hasThemeStyle","setDefaultThemeListStyleByTag","__lexicalListType","setListThemeClassNames","getTag","getListType","getStart","getStyleId","exportJSON","_this$__themeStyleId","_objectSpread2","_get2","_getPrototypeOf2","prototype","type","version","themeEmotionMap","style","findTypographyStyleByHtmlTag","id","updateDOM","prevNode","extractWithChild","child","$isListItemNode","getType","clone","node","__key","importJSON","serializedNode","$createListNode","setFormat","format","setIndent","indent","setDirection","direction","importDomConversionMap","conversion","convertListNode","priority","importDOM","_this2","ol","ul","ElementNode","exports","editorTheme","editorThemeClasses","classesToAdd","classesToRemove","listTheme","list","undefined","_emotionMap$themeStyl","_emotionMap$themeStyl2","listLevelsClassNames","concat","listDepth","$getListDepth","normalizedListDepth","length","listLevelClassName","listClassName","className","nestedListClassName","nestedListTheme","nested","push","listItemClasses","split","apply","_toConsumableArray2","i","nestedListItemClasses","removeClassNamesFromElement","addClassNamesToElement","normalizeChildren","nodes","normalizedListItems","getChildren","forEach","$isListNode","wrapInListItem","domNode","nodeName","toLowerCase","after","arguments"],"sources":["ListNode.ts"],"sourcesContent":["import {\n DOMConversion,\n DOMConversionMap,\n DOMConversionOutput,\n EditorConfig,\n ElementNode,\n LexicalNode,\n NodeKey,\n SerializedElementNode,\n Spread\n} from \"lexical\";\nimport { EditorTheme, WebinyTheme, findTypographyStyleByHtmlTag } from \"@webiny/lexical-theme\";\nimport { addClassNamesToElement, removeClassNamesFromElement } from \"@lexical/utils\";\nimport { ListNodeTagType } from \"@lexical/list/LexicalListNode\";\nimport { $getListDepth, wrapInListItem } from \"~/utils/listNode\";\nimport { $isListItemNode, ListItemNode } from \"./ListItemNode\";\nimport { ListType } from \"@lexical/list\";\n\nconst TypographyStyleAttrName = \"data-theme-list-style-id\";\n\nexport type SerializedWebinyListNode = Spread<\n {\n themeStyleId: string;\n listType: ListType;\n start: number;\n tag: ListNodeTagType;\n type: \"webiny-list\";\n version: 1;\n },\n SerializedElementNode\n>;\n\nexport class ListNode extends ElementNode {\n /** @internal */\n __tag: ListNodeTagType;\n /** @internal */\n __start: number;\n /** @internal */\n __listType: ListType;\n\n __themeStyleId: string;\n\n constructor(listType: ListType, themeStyleId?: string, start?: number, key?: NodeKey) {\n super(key);\n this.__themeStyleId = themeStyleId || \"\";\n const _listType = TAG_TO_WEBINY_LIST_TYPE[listType] || listType;\n this.__listType = _listType;\n this.__tag = _listType === \"number\" ? \"ol\" : \"ul\";\n this.__start = start || 1;\n }\n\n static override getType() {\n return \"webiny-list\";\n }\n\n isStyleExistInTheme(theme: WebinyTheme): boolean {\n return theme?.emotionMap ? !!theme?.emotionMap[this.__themeStyleId] : false;\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const tag = this.__tag;\n const dom = document.createElement(tag);\n const wTheme = config.theme as WebinyTheme;\n\n if (this.__start !== 1) {\n dom.setAttribute(\"start\", String(this.__start));\n }\n\n // If styleId is not set or user removed from theme, set default style\n if (!this.hasThemeStyle() || !this.isStyleExistInTheme(wTheme)) {\n this.setDefaultThemeListStyleByTag(this.__tag, wTheme);\n }\n\n // @ts-expect-error Internal field.\n dom.__lexicalListType = this.__listType;\n const theme = config.theme as EditorTheme;\n setListThemeClassNames(dom, theme, this, this.__themeStyleId);\n dom.setAttribute(TypographyStyleAttrName, this.__themeStyleId);\n return dom;\n }\n\n static override clone(node: ListNode): ListNode {\n return new ListNode(node.getListType(), node.getStyleId(), node.getStart(), node.__key);\n }\n\n getTag(): ListNodeTagType {\n return this.__tag;\n }\n\n getListType(): ListType {\n return this.__listType;\n }\n\n getStart(): number {\n return this.__start;\n }\n\n getStyleId(): string {\n return this.__themeStyleId;\n }\n\n static override importJSON(serializedNode: SerializedWebinyListNode): ListNode {\n const node = $createListNode(\n serializedNode.listType,\n serializedNode.themeStyleId,\n serializedNode.start\n );\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n return node;\n }\n\n // @ts-ignore\n override exportJSON(): SerializedWebinyListNode {\n return {\n ...super.exportJSON(),\n themeStyleId: this.__themeStyleId ?? \"\",\n listType: this.getListType(),\n start: this.getStart(),\n tag: this.getTag(),\n type: \"webiny-list\",\n version: 1\n };\n }\n\n static importDomConversionMap(): DOMConversion<HTMLElement> | null {\n return {\n conversion: convertListNode,\n priority: 0\n };\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n ol: () => {\n return this.importDomConversionMap();\n },\n ul: () => {\n return this.importDomConversionMap();\n }\n };\n }\n\n /*\n * Set default styleId from first style that is found in the theme that contains current ul or ol tag\n */\n setDefaultThemeListStyleByTag(tag: string, theme: WebinyTheme) {\n if (!tag) {\n return;\n }\n\n const themeEmotionMap = theme?.emotionMap;\n if (!themeEmotionMap) {\n return;\n }\n\n const style = findTypographyStyleByHtmlTag(tag, themeEmotionMap);\n\n if (style) {\n this.__themeStyleId = style.id;\n }\n }\n\n hasThemeStyle(): boolean {\n return !!this.__themeStyleId;\n }\n\n override updateDOM(prevNode: ListNode, dom: HTMLElement, config: EditorConfig): boolean {\n const wTheme = config.theme as WebinyTheme;\n\n if (prevNode.__tag !== this.__tag) {\n return true;\n }\n\n // if styleId is not set or user removed from theme, set default style.\n if (!this.hasThemeStyle() || !this.isStyleExistInTheme(wTheme)) {\n this.setDefaultThemeListStyleByTag(this.__tag, wTheme);\n }\n\n setListThemeClassNames(dom, config.theme, this, this.__themeStyleId);\n dom.setAttribute(TypographyStyleAttrName, this.__themeStyleId);\n return false;\n }\n\n override extractWithChild(child: LexicalNode): boolean {\n return $isListItemNode(child);\n }\n}\n\nfunction setListThemeClassNames(\n dom: HTMLElement,\n editorTheme: EditorTheme,\n node: ListNode,\n themeStyleId: string\n): void {\n const editorThemeClasses = editorTheme;\n const classesToAdd = [];\n const classesToRemove = [];\n const listTheme = editorThemeClasses.list;\n const emotionMap = editorTheme?.emotionMap || {};\n if (listTheme !== undefined) {\n const listLevelsClassNames = listTheme[`${node.__tag}Depth`] || [];\n const listDepth = $getListDepth(node) - 1;\n const normalizedListDepth = listDepth % listLevelsClassNames.length;\n const listLevelClassName = listLevelsClassNames[normalizedListDepth];\n const listClassName = `${listTheme[node.__tag]} ${\n emotionMap[themeStyleId]?.className ?? \"\"\n }`;\n let nestedListClassName;\n const nestedListTheme = listTheme.nested;\n\n if (nestedListTheme !== undefined && nestedListTheme.list) {\n nestedListClassName = nestedListTheme.list;\n }\n\n if (listClassName) {\n classesToAdd.push(listClassName);\n }\n\n if (listLevelClassName !== undefined) {\n const listItemClasses = listLevelClassName.split(\" \");\n classesToAdd.push(...listItemClasses);\n for (let i = 0; i < listLevelsClassNames.length; i++) {\n if (i !== normalizedListDepth) {\n classesToRemove.push(node.__tag + i);\n }\n }\n }\n\n if (nestedListClassName !== undefined) {\n const nestedListItemClasses = nestedListClassName.split(\" \");\n\n if (listDepth > 1) {\n classesToAdd.push(...nestedListItemClasses);\n } else {\n classesToRemove.push(...nestedListItemClasses);\n }\n }\n }\n\n if (classesToRemove.length > 0) {\n removeClassNamesFromElement(dom, ...classesToRemove);\n }\n\n if (classesToAdd.length > 0) {\n addClassNamesToElement(dom, ...classesToAdd);\n }\n}\n\n/*\n * This function normalizes the children of a ListNode after the conversion from HTML,\n * ensuring that they are all ListItemNodes and contain either a single nested ListNode\n * or some other inline content.\n */\nfunction normalizeChildren(nodes: Array<ListNode>): Array<ListItemNode> {\n const normalizedListItems: Array<ListItemNode> = [];\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if ($isListItemNode(node)) {\n normalizedListItems.push(node);\n node.getChildren().forEach(child => {\n if ($isListNode(child)) {\n normalizedListItems.push(wrapInListItem(child));\n }\n });\n } else {\n normalizedListItems.push(wrapInListItem(node));\n }\n }\n return normalizedListItems;\n}\n\nfunction convertListNode(domNode: Node): DOMConversionOutput {\n const nodeName = domNode.nodeName.toLowerCase();\n let node = null;\n\n if (nodeName === \"ol\") {\n node = $createListNode(\"number\");\n } else if (nodeName === \"ul\") {\n node = $createListNode(\"bullet\");\n }\n\n return {\n // @ts-ignore\n after: normalizeChildren,\n node\n };\n}\n\nconst TAG_TO_WEBINY_LIST_TYPE: Record<string, ListType> = {\n ol: \"number\",\n ul: \"bullet\"\n};\n\nexport function $createListNode(listType: ListType, themeStyleId?: string, start = 1): ListNode {\n return new ListNode(listType, themeStyleId, start);\n}\n\nexport function $isListNode(node: LexicalNode | null | undefined): node is ListNode {\n return node instanceof ListNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAWA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAGA,IAAMK,uBAAuB,GAAG,0BAA0B;AAAC,IAc9CC,QAAQ,0BAAAC,YAAA;EAAA,IAAAC,UAAA,CAAAC,OAAA,EAAAH,QAAA,EAAAC,YAAA;EAAA,IAAAG,MAAA,OAAAC,aAAA,CAAAF,OAAA,EAAAH,QAAA;EACjB;;EAEA;;EAEA;;EAKA,SAAAA,SAAYM,QAAkB,EAAEC,YAAqB,EAAEC,KAAc,EAAEC,GAAa,EAAE;IAAA,IAAAC,KAAA;IAAA,IAAAC,gBAAA,CAAAR,OAAA,QAAAH,QAAA;IAClFU,KAAA,GAAAN,MAAA,CAAAQ,IAAA,OAAMH,GAAG;IACTC,KAAA,CAAKG,cAAc,GAAGN,YAAY,IAAI,EAAE;IACxC,IAAMO,SAAS,GAAGC,uBAAuB,CAACT,QAAQ,CAAC,IAAIA,QAAQ;IAC/DI,KAAA,CAAKM,UAAU,GAAGF,SAAS;IAC3BJ,KAAA,CAAKO,KAAK,GAAGH,SAAS,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI;IACjDJ,KAAA,CAAKQ,OAAO,GAAGV,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ParagraphNode, SerializedParagraphNode as SerializedBaseParagraphNode, Spread } from "lexical";
4
+ import { EditorConfig } from "lexical";
5
+ import { WebinyTheme, ThemeEmotionMap } from "@webiny/lexical-theme";
6
+ import { TypographyStylesNode, ThemeStyleValue, TextNodeThemeStyles } from "./types";
7
+ export declare type SerializeParagraphNode = Spread<{
8
+ styles: ThemeStyleValue[];
9
+ type: "paragraph-element";
10
+ }, SerializedBaseParagraphNode>;
11
+ export declare class ParagraphNode extends BaseParagraphNode implements TextNodeThemeStyles, TypographyStylesNode {
12
+ __styles: ThemeStyleValue[];
13
+ constructor(typographyStyleId?: string, key?: NodeKey);
14
+ protected setDefaultTypography(themeEmotionMap: ThemeEmotionMap): void;
15
+ setTypography(typographyStyleId: string): this;
16
+ getTypographyStyleId(): string | undefined;
17
+ clearTypographyStyle(): this;
18
+ hasTypographyStyle(): boolean;
19
+ getThemeStyles(): ThemeStyleValue[];
20
+ setThemeStyles(styles: ThemeStyleValue[]): this;
21
+ static getType(): string;
22
+ static clone(node: ParagraphNode): ParagraphNode;
23
+ protected updateElementWithThemeClasses(element: HTMLElement, theme: WebinyTheme): HTMLElement;
24
+ createDOM(config: EditorConfig): HTMLElement;
25
+ updateDOM(prevNode: BaseParagraphNode, dom: HTMLElement, config: EditorConfig): boolean;
26
+ static importDOM(): DOMConversionMap | null;
27
+ static importJSON(serializedNode: SerializeParagraphNode): BaseParagraphNode;
28
+ exportJSON(): SerializeParagraphNode;
29
+ }
30
+ export declare function $createParagraphNode(typographyStyleId?: string): ParagraphNode;
31
+ export declare function $isParagraphNode(node: LexicalNode | null | undefined): node is ParagraphNode;
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.$createParagraphNode = $createParagraphNode;
8
+ exports.$isParagraphNode = $isParagraphNode;
9
+ exports.ParagraphNode = void 0;
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
16
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
17
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
18
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
19
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
20
+ var _lexical = require("lexical");
21
+ var _lexicalTheme = require("@webiny/lexical-theme");
22
+ var _utils = require("@lexical/utils");
23
+ var ParagraphNode = /*#__PURE__*/function (_BaseParagraphNode) {
24
+ (0, _inherits2.default)(ParagraphNode, _BaseParagraphNode);
25
+ var _super = (0, _createSuper2.default)(ParagraphNode);
26
+ function ParagraphNode(typographyStyleId, key) {
27
+ var _this;
28
+ (0, _classCallCheck2.default)(this, ParagraphNode);
29
+ _this = _super.call(this, key);
30
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "__styles", []);
31
+ if (typographyStyleId) {
32
+ _this.__styles.push({
33
+ styleId: typographyStyleId,
34
+ type: "typography"
35
+ });
36
+ }
37
+ return _this;
38
+ }
39
+ (0, _createClass2.default)(ParagraphNode, [{
40
+ key: "setDefaultTypography",
41
+ value: function setDefaultTypography(themeEmotionMap) {
42
+ var typographyStyle = (0, _lexicalTheme.findTypographyStyleByHtmlTag)("p", themeEmotionMap);
43
+ if (typographyStyle) {
44
+ this.__styles.push({
45
+ styleId: typographyStyle.id,
46
+ type: "typography"
47
+ });
48
+ }
49
+ }
50
+ }, {
51
+ key: "setTypography",
52
+ value: function setTypography(typographyStyleId) {
53
+ var self = (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "getWritable", this).call(this);
54
+ var themeStyle = {
55
+ styleId: typographyStyleId,
56
+ type: "typography"
57
+ };
58
+ self.__styles.push(themeStyle);
59
+ return self;
60
+ }
61
+ }, {
62
+ key: "getTypographyStyleId",
63
+ value: function getTypographyStyleId() {
64
+ var style = this.__styles.find(function (x) {
65
+ return x.type === "typography";
66
+ });
67
+ return (style === null || style === void 0 ? void 0 : style.styleId) || undefined;
68
+ }
69
+ }, {
70
+ key: "clearTypographyStyle",
71
+ value: function clearTypographyStyle() {
72
+ var self = (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "getWritable", this).call(this);
73
+ self.__styles = self.__styles.filter(function (s) {
74
+ return s.type !== "typography";
75
+ });
76
+ return self;
77
+ }
78
+ }, {
79
+ key: "hasTypographyStyle",
80
+ value: function hasTypographyStyle() {
81
+ return !!this.getTypographyStyleId();
82
+ }
83
+ }, {
84
+ key: "getThemeStyles",
85
+ value: function getThemeStyles() {
86
+ // getLatest() ensures we are getting the most
87
+ // up-to-date value from the EditorState.
88
+ var self = (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "getLatest", this).call(this);
89
+ return self.__styles;
90
+ }
91
+ }, {
92
+ key: "setThemeStyles",
93
+ value: function setThemeStyles(styles) {
94
+ // getWritable() creates a clone of the node
95
+ // if needed, to ensure we don't try and mutate
96
+ // a stale version of this node.
97
+ var self = (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "getWritable", this).call(this);
98
+ self.__styles = (0, _toConsumableArray2.default)(styles);
99
+ return self;
100
+ }
101
+ }, {
102
+ key: "updateElementWithThemeClasses",
103
+ value: function updateElementWithThemeClasses(element, theme) {
104
+ if (!(theme !== null && theme !== void 0 && theme.emotionMap)) {
105
+ return element;
106
+ }
107
+ if (!this.hasTypographyStyle()) {
108
+ this.setDefaultTypography(theme.emotionMap);
109
+ }
110
+ var typoStyleId = this.getTypographyStyleId();
111
+ var themeClasses;
112
+
113
+ // Typography css class
114
+ if (typoStyleId) {
115
+ var typographyStyle = theme.emotionMap[typoStyleId];
116
+ if (typographyStyle) {
117
+ themeClasses = typographyStyle.className;
118
+ }
119
+ }
120
+ if (themeClasses) {
121
+ (0, _utils.addClassNamesToElement)(element, themeClasses);
122
+ }
123
+ return element;
124
+ }
125
+ }, {
126
+ key: "createDOM",
127
+ value: function createDOM(config) {
128
+ var element = (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "createDOM", this).call(this, config);
129
+ return this.updateElementWithThemeClasses(element, config.theme);
130
+ }
131
+ }, {
132
+ key: "updateDOM",
133
+ value: function updateDOM(prevNode, dom, config) {
134
+ var prevTypoStyleId = prevNode.getTypographyStyleId();
135
+ var nextTypoStyleId = this.getTypographyStyleId();
136
+ if (!nextTypoStyleId) {
137
+ this.updateElementWithThemeClasses(dom, config.theme);
138
+ return false;
139
+ }
140
+ if (prevTypoStyleId !== nextTypoStyleId && nextTypoStyleId) {
141
+ this.updateElementWithThemeClasses(dom, config.theme);
142
+ }
143
+ // Returning false tells Lexical that this node does not need its
144
+ // DOM element replacing with a new copy from createDOM.
145
+ return false;
146
+ }
147
+
148
+ /*
149
+ * On copy/paste event this method will be executed in and create a node
150
+ * */
151
+ }, {
152
+ key: "exportJSON",
153
+ value:
154
+ /*
155
+ * Serialize the node to JSON data representation.
156
+ * */
157
+ function exportJSON() {
158
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "exportJSON", this).call(this)), {}, {
159
+ styles: this.__styles,
160
+ type: "paragraph-element",
161
+ version: 1
162
+ });
163
+ }
164
+ }], [{
165
+ key: "getType",
166
+ value: function getType() {
167
+ return "paragraph-element";
168
+ }
169
+ }, {
170
+ key: "clone",
171
+ value: function clone(node) {
172
+ return new ParagraphNode(node.getTypographyStyleId(), node.__key);
173
+ }
174
+ }, {
175
+ key: "importDOM",
176
+ value: function importDOM() {
177
+ return {
178
+ p: function p() {
179
+ return {
180
+ conversion: convertParagraphElement,
181
+ priority: 0
182
+ };
183
+ }
184
+ };
185
+ }
186
+
187
+ /*
188
+ * Serialize the JSON data back into a node
189
+ */
190
+ }, {
191
+ key: "importJSON",
192
+ value: function importJSON(serializedNode) {
193
+ var node = $createParagraphNode();
194
+ node.setFormat(serializedNode.format);
195
+ node.setIndent(serializedNode.indent);
196
+ node.setDirection(serializedNode.direction);
197
+ node.setThemeStyles(serializedNode.styles);
198
+ return node;
199
+ }
200
+ }]);
201
+ return ParagraphNode;
202
+ }(_lexical.ParagraphNode);
203
+ exports.ParagraphNode = ParagraphNode;
204
+ function convertParagraphElement(element) {
205
+ var node = $createParagraphNode();
206
+ if (element.style) {
207
+ node.setFormat(element.style.textAlign);
208
+ }
209
+ return {
210
+ node: node
211
+ };
212
+ }
213
+ function $createParagraphNode(typographyStyleId) {
214
+ return (0, _lexical.$applyNodeReplacement)(new ParagraphNode(typographyStyleId));
215
+ }
216
+ function $isParagraphNode(node) {
217
+ return node instanceof ParagraphNode;
218
+ }
219
+
220
+ //# sourceMappingURL=ParagraphNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lexical","require","_lexicalTheme","_utils","ParagraphNode","_BaseParagraphNode","_inherits2","default","_super","_createSuper2","typographyStyleId","key","_this","_classCallCheck2","call","_defineProperty2","_assertThisInitialized2","__styles","push","styleId","type","_createClass2","value","setDefaultTypography","themeEmotionMap","typographyStyle","findTypographyStyleByHtmlTag","id","setTypography","self","_get2","_getPrototypeOf2","prototype","themeStyle","getTypographyStyleId","style","find","x","undefined","clearTypographyStyle","filter","s","hasTypographyStyle","getThemeStyles","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","exports","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 { WebinyTheme, 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 setTypography(typographyStyleId: string): this {\n const self = super.getWritable();\n const themeStyle = {\n styleId: typographyStyleId,\n type: \"typography\"\n } as ThemeStyleValue;\n self.__styles.push(themeStyle);\n return self;\n }\n\n getTypographyStyleId(): string | undefined {\n const style = this.__styles.find(x => x.type === \"typography\");\n return style?.styleId || undefined;\n }\n\n clearTypographyStyle(): this {\n const self = super.getWritable();\n self.__styles = self.__styles.filter(s => s.type !== \"typography\");\n return self;\n }\n\n 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 protected updateElementWithThemeClasses(element: HTMLElement, theme: WebinyTheme): 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 WebinyTheme);\n }\n\n override updateDOM(\n prevNode: BaseParagraphNode,\n dom: HTMLElement,\n config: EditorConfig\n ): boolean {\n const prevTypoStyleId = prevNode.getTypographyStyleId();\n const nextTypoStyleId = this.getTypographyStyleId();\n\n if (!nextTypoStyleId) {\n this.updateElementWithThemeClasses(dom, config.theme as WebinyTheme);\n return false;\n }\n\n if (prevTypoStyleId !== nextTypoStyleId && nextTypoStyleId) {\n this.updateElementWithThemeClasses(dom, config.theme as WebinyTheme);\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,0BAAAC,kBAAA;EAAA,IAAAC,UAAA,CAAAC,OAAA,EAAAH,aAAA,EAAAC,kBAAA;EAAA,IAAAG,MAAA,OAAAC,aAAA,CAAAF,OAAA,EAAAH,aAAA;EAMtB,SAAAA,cAAYM,iBAA0B,EAAEC,GAAa,EAAE;IAAA,IAAAC,KAAA;IAAA,IAAAC,gBAAA,CAAAN,OAAA,QAAAH,aAAA;IACnDQ,KAAA,GAAAJ,MAAA,CAAAM,IAAA,OAAMH,GAAG;IAAE,IAAAI,gBAAA,CAAAR,OAAA,MAAAS,uBAAA,CAAAT,OAAA,EAAAK,KAAA,eAHe,EAAE;IAK5B,IAAIF,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AC,OAAA,CAAAhF,aAAA,GAAAA,aAAA;AAgK7B,SAASoE,uBAAuBA,CAACxB,OAAoB,EAAuB;EACxE,IAAMmB,IAAI,GAAGS,oBAAoB,CAAC,CAAC;EACnC,IAAI5B,OAAO,CAACb,KAAK,EAAE;IACfgC,IAAI,CAACU,SAAS,CAAC7B,OAAO,CAACb,KAAK,CAACkD,SAA8B,CAAC;EAChE;EAEA,OAAO;IAAElB,IAAI,EAAJA;EAAK,CAAC;AACnB;AAEO,SAASS,oBAAoBA,CAAClE,iBAA0B,EAAiB;EAC5E,OAAO,IAAA4E,8BAAqB,EAAC,IAAIlF,aAAa,CAACM,iBAAiB,CAAC,CAAC;AACtE;AAEO,SAAS6E,gBAAgBA,CAACpB,IAAoC,EAAyB;EAC1F,OAAOA,IAAI,YAAY/D,aAAa;AACxC"}
package/QuoteNode.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ /// <reference types="react" />
2
+ /// <reference types="web" />
3
+ import { DOMConversion, DOMConversionMap, EditorConfig, LexicalNode, NodeKey, Spread } from "lexical";
4
+ import { EditorTheme, ThemeEmotionMap } from "@webiny/lexical-theme";
5
+ import { QuoteNode as BaseQuoteNode, SerializedQuoteNode as BaseSerializedQuoteNode } from "@lexical/rich-text";
6
+ import { TextNodeThemeStyles, ThemeStyleValue, TypographyStylesNode } from "./types";
7
+ export declare type SerializedQuoteNode = Spread<{
8
+ styleId?: string;
9
+ styles: ThemeStyleValue[];
10
+ type: "webiny-quote";
11
+ }, BaseSerializedQuoteNode>;
12
+ export declare class QuoteNode extends BaseQuoteNode implements TextNodeThemeStyles, TypographyStylesNode {
13
+ __styles: ThemeStyleValue[];
14
+ constructor(themeStyleId?: string, key?: NodeKey);
15
+ protected setDefaultTypography(themeEmotionMap: ThemeEmotionMap): void;
16
+ protected typographyStyleExist(themeEmotionMap: ThemeEmotionMap): boolean;
17
+ setTypography(typographyStyleId: string): this;
18
+ getTypographyStyleId(): string | undefined;
19
+ clearTypographyStyle(): this;
20
+ hasTypographyStyle(): boolean;
21
+ getThemeStyles(): ThemeStyleValue[];
22
+ setThemeStyles(styles: ThemeStyleValue[]): this;
23
+ static getType(): string;
24
+ static clone(node: QuoteNode): QuoteNode;
25
+ addThemeStylesToHTMLElement(element: HTMLElement, theme: EditorTheme): HTMLElement;
26
+ createDOM(config: EditorConfig): HTMLElement;
27
+ static importDomConversionMap(): DOMConversion<HTMLElement> | null;
28
+ static importDOM(): DOMConversionMap | null;
29
+ static importJSON(serializedNode: SerializedQuoteNode): QuoteNode;
30
+ exportJSON(): SerializedQuoteNode;
31
+ }
32
+ export declare function $createQuoteNode(themeStyleId?: string, key?: NodeKey): QuoteNode;
33
+ export declare function $isQuoteNode(node: LexicalNode | null | undefined): node is QuoteNode;