@webiny/lexical-nodes 5.44.1-beta.0 → 5.45.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 (83) hide show
  1. package/FontColorNode.d.ts +6 -6
  2. package/FontColorNode.js +102 -145
  3. package/FontColorNode.js.map +1 -1
  4. package/HeadingNode.d.ts +29 -17
  5. package/HeadingNode.js +184 -152
  6. package/HeadingNode.js.map +1 -1
  7. package/ImageNode.d.ts +1 -11
  8. package/ImageNode.js +119 -190
  9. package/ImageNode.js.map +1 -1
  10. package/LinkNode.d.ts +2 -2
  11. package/LinkNode.js +249 -346
  12. package/LinkNode.js.map +1 -1
  13. package/ListItemNode.d.ts +4 -3
  14. package/ListItemNode.js +275 -354
  15. package/ListItemNode.js.map +1 -1
  16. package/ListNode.d.ts +28 -14
  17. package/ListNode.js +170 -209
  18. package/ListNode.js.map +1 -1
  19. package/ParagraphNode.d.ts +28 -16
  20. package/ParagraphNode.js +143 -179
  21. package/ParagraphNode.js.map +1 -1
  22. package/QuoteNode.d.ts +26 -19
  23. package/QuoteNode.js +102 -188
  24. package/QuoteNode.js.map +1 -1
  25. package/README.md +9 -4
  26. package/components/ImageNode/ImageComponent.d.ts +2 -7
  27. package/components/ImageNode/ImageComponent.js +72 -166
  28. package/components/ImageNode/ImageComponent.js.map +1 -1
  29. package/components/ImageNode/ImageResizer.d.ts +1 -8
  30. package/components/ImageNode/ImageResizer.js +74 -89
  31. package/components/ImageNode/ImageResizer.js.map +1 -1
  32. package/generateInitialLexicalValue.d.ts +4 -0
  33. package/generateInitialLexicalValue.js +27 -0
  34. package/generateInitialLexicalValue.js.map +1 -0
  35. package/index.d.ts +19 -23
  36. package/index.js +50 -233
  37. package/index.js.map +1 -1
  38. package/package.json +16 -20
  39. package/prepareLexicalState.d.ts +2 -0
  40. package/prepareLexicalState.js +53 -0
  41. package/prepareLexicalState.js.map +1 -0
  42. package/types.d.ts +4 -5
  43. package/types.js +1 -5
  44. package/types.js.map +1 -1
  45. package/utils/clearNodeFormating.d.ts +1 -1
  46. package/utils/clearNodeFormating.js +12 -18
  47. package/utils/clearNodeFormating.js.map +1 -1
  48. package/utils/formatList.d.ts +4 -4
  49. package/utils/formatList.js +171 -208
  50. package/utils/formatList.js.map +1 -1
  51. package/utils/formatToHeading.d.ts +2 -2
  52. package/utils/formatToHeading.js +8 -15
  53. package/utils/formatToHeading.js.map +1 -1
  54. package/utils/formatToParagraph.d.ts +1 -1
  55. package/utils/formatToParagraph.js +8 -16
  56. package/utils/formatToParagraph.js.map +1 -1
  57. package/utils/formatToQuote.d.ts +1 -1
  58. package/utils/formatToQuote.js +8 -15
  59. package/utils/formatToQuote.js.map +1 -1
  60. package/utils/getStyleId.d.ts +11 -0
  61. package/utils/getStyleId.js +14 -0
  62. package/utils/getStyleId.js.map +1 -0
  63. package/utils/listNode.d.ts +2 -2
  64. package/utils/listNode.js +37 -50
  65. package/utils/listNode.js.map +1 -1
  66. package/utils/toggleLink.d.ts +1 -1
  67. package/utils/toggleLink.js +41 -45
  68. package/utils/toggleLink.js.map +1 -1
  69. package/TypographyNode.d.ts +0 -39
  70. package/TypographyNode.js +0 -146
  71. package/TypographyNode.js.map +0 -1
  72. package/components/ImageNode/ContentEditable.css +0 -22
  73. package/components/ImageNode/ContentEditable.d.ts +0 -12
  74. package/components/ImageNode/ContentEditable.js +0 -26
  75. package/components/ImageNode/ContentEditable.js.map +0 -1
  76. package/components/ImageNode/ImageComponent.css +0 -43
  77. package/components/ImageNode/Placeholder.css +0 -20
  78. package/components/ImageNode/Placeholder.d.ts +0 -15
  79. package/components/ImageNode/Placeholder.js +0 -30
  80. package/components/ImageNode/Placeholder.js.map +0 -1
  81. package/components/ImageNode/SharedHistoryContext.d.ts +0 -10
  82. package/components/ImageNode/SharedHistoryContext.js +0 -27
  83. package/components/ImageNode/SharedHistoryContext.js.map +0 -1
package/index.js CHANGED
@@ -1,237 +1,54 @@
1
- "use strict";
1
+ import { ParagraphNode as BaseParagraphNode } from "lexical";
2
+ import { HeadingNode as BaseHeadingNode, QuoteNode as BaseQuoteNode } from "@lexical/rich-text";
3
+ import { CodeHighlightNode, CodeNode } from "@lexical/code";
4
+ import { HashtagNode } from "@lexical/hashtag";
5
+ import { MarkNode } from "@lexical/mark";
6
+ import { OverflowNode } from "@lexical/overflow";
7
+ import { AutoLinkNode, LinkNode } from "./LinkNode.js";
8
+ import { FontColorNode } from "./FontColorNode.js";
9
+ import { ListNode } from "./ListNode.js";
10
+ import { ListItemNode } from "./ListItemNode.js";
11
+ import { HeadingNode } from "./HeadingNode.js";
12
+ import { ParagraphNode } from "./ParagraphNode.js";
13
+ import { QuoteNode } from "./QuoteNode.js";
14
+ import { ImageNode } from "./ImageNode.js";
15
+ export * from "./FontColorNode.js";
16
+ export * from "./ListNode.js";
17
+ export * from "./ListItemNode.js";
18
+ export * from "./HeadingNode.js";
19
+ export * from "./ParagraphNode.js";
20
+ export * from "./QuoteNode.js";
21
+ export * from "./ImageNode.js";
22
+ export * from "./LinkNode.js";
23
+ export * from "./utils/formatList.js";
24
+ export * from "./utils/listNode.js";
25
+ export * from "./utils/formatToQuote.js";
26
+ export * from "./utils/formatToHeading.js";
27
+ export * from "./utils/formatToParagraph.js";
28
+ export * from "./utils/clearNodeFormating.js";
29
+ export * from "./utils/toggleLink.js";
30
+ export * from "./prepareLexicalState.js";
31
+ export * from "./generateInitialLexicalValue.js";
2
32
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- allNodes: true
8
- };
9
- exports.allNodes = void 0;
10
- var _lexical = require("lexical");
11
- var _code = require("@lexical/code");
12
- var _hashtag = require("@lexical/hashtag");
13
- var _mark = require("@lexical/mark");
14
- var _richText = require("@lexical/rich-text");
15
- var _overflow = require("@lexical/overflow");
16
- var _LinkNode = require("./LinkNode");
17
- Object.keys(_LinkNode).forEach(function (key) {
18
- if (key === "default" || key === "__esModule") return;
19
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
20
- if (key in exports && exports[key] === _LinkNode[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function get() {
24
- return _LinkNode[key];
25
- }
26
- });
27
- });
28
- var _FontColorNode = require("./FontColorNode");
29
- Object.keys(_FontColorNode).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
32
- if (key in exports && exports[key] === _FontColorNode[key]) return;
33
- Object.defineProperty(exports, key, {
34
- enumerable: true,
35
- get: function get() {
36
- return _FontColorNode[key];
37
- }
38
- });
39
- });
40
- var _TypographyNode = require("./TypographyNode");
41
- Object.keys(_TypographyNode).forEach(function (key) {
42
- if (key === "default" || key === "__esModule") return;
43
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
44
- if (key in exports && exports[key] === _TypographyNode[key]) return;
45
- Object.defineProperty(exports, key, {
46
- enumerable: true,
47
- get: function get() {
48
- return _TypographyNode[key];
49
- }
50
- });
51
- });
52
- var _ListNode = require("./ListNode");
53
- Object.keys(_ListNode).forEach(function (key) {
54
- if (key === "default" || key === "__esModule") return;
55
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
56
- if (key in exports && exports[key] === _ListNode[key]) return;
57
- Object.defineProperty(exports, key, {
58
- enumerable: true,
59
- get: function get() {
60
- return _ListNode[key];
61
- }
62
- });
63
- });
64
- var _ListItemNode = require("./ListItemNode");
65
- Object.keys(_ListItemNode).forEach(function (key) {
66
- if (key === "default" || key === "__esModule") return;
67
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
68
- if (key in exports && exports[key] === _ListItemNode[key]) return;
69
- Object.defineProperty(exports, key, {
70
- enumerable: true,
71
- get: function get() {
72
- return _ListItemNode[key];
73
- }
74
- });
75
- });
76
- var _HeadingNode = require("./HeadingNode");
77
- Object.keys(_HeadingNode).forEach(function (key) {
78
- if (key === "default" || key === "__esModule") return;
79
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
80
- if (key in exports && exports[key] === _HeadingNode[key]) return;
81
- Object.defineProperty(exports, key, {
82
- enumerable: true,
83
- get: function get() {
84
- return _HeadingNode[key];
85
- }
86
- });
87
- });
88
- var _ParagraphNode = require("./ParagraphNode");
89
- Object.keys(_ParagraphNode).forEach(function (key) {
90
- if (key === "default" || key === "__esModule") return;
91
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
92
- if (key in exports && exports[key] === _ParagraphNode[key]) return;
93
- Object.defineProperty(exports, key, {
94
- enumerable: true,
95
- get: function get() {
96
- return _ParagraphNode[key];
97
- }
98
- });
99
- });
100
- var _QuoteNode = require("./QuoteNode");
101
- Object.keys(_QuoteNode).forEach(function (key) {
102
- if (key === "default" || key === "__esModule") return;
103
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
104
- if (key in exports && exports[key] === _QuoteNode[key]) return;
105
- Object.defineProperty(exports, key, {
106
- enumerable: true,
107
- get: function get() {
108
- return _QuoteNode[key];
109
- }
110
- });
111
- });
112
- var _ImageNode = require("./ImageNode");
113
- Object.keys(_ImageNode).forEach(function (key) {
114
- if (key === "default" || key === "__esModule") return;
115
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
116
- if (key in exports && exports[key] === _ImageNode[key]) return;
117
- Object.defineProperty(exports, key, {
118
- enumerable: true,
119
- get: function get() {
120
- return _ImageNode[key];
121
- }
122
- });
123
- });
124
- var _formatList = require("./utils/formatList");
125
- Object.keys(_formatList).forEach(function (key) {
126
- if (key === "default" || key === "__esModule") return;
127
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
128
- if (key in exports && exports[key] === _formatList[key]) return;
129
- Object.defineProperty(exports, key, {
130
- enumerable: true,
131
- get: function get() {
132
- return _formatList[key];
133
- }
134
- });
135
- });
136
- var _listNode = require("./utils/listNode");
137
- Object.keys(_listNode).forEach(function (key) {
138
- if (key === "default" || key === "__esModule") return;
139
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
140
- if (key in exports && exports[key] === _listNode[key]) return;
141
- Object.defineProperty(exports, key, {
142
- enumerable: true,
143
- get: function get() {
144
- return _listNode[key];
145
- }
146
- });
147
- });
148
- var _formatToQuote = require("./utils/formatToQuote");
149
- Object.keys(_formatToQuote).forEach(function (key) {
150
- if (key === "default" || key === "__esModule") return;
151
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
152
- if (key in exports && exports[key] === _formatToQuote[key]) return;
153
- Object.defineProperty(exports, key, {
154
- enumerable: true,
155
- get: function get() {
156
- return _formatToQuote[key];
157
- }
158
- });
159
- });
160
- var _formatToHeading = require("./utils/formatToHeading");
161
- Object.keys(_formatToHeading).forEach(function (key) {
162
- if (key === "default" || key === "__esModule") return;
163
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
164
- if (key in exports && exports[key] === _formatToHeading[key]) return;
165
- Object.defineProperty(exports, key, {
166
- enumerable: true,
167
- get: function get() {
168
- return _formatToHeading[key];
169
- }
170
- });
171
- });
172
- var _formatToParagraph = require("./utils/formatToParagraph");
173
- Object.keys(_formatToParagraph).forEach(function (key) {
174
- if (key === "default" || key === "__esModule") return;
175
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
176
- if (key in exports && exports[key] === _formatToParagraph[key]) return;
177
- Object.defineProperty(exports, key, {
178
- enumerable: true,
179
- get: function get() {
180
- return _formatToParagraph[key];
181
- }
182
- });
183
- });
184
- var _clearNodeFormating = require("./utils/clearNodeFormating");
185
- Object.keys(_clearNodeFormating).forEach(function (key) {
186
- if (key === "default" || key === "__esModule") return;
187
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
188
- if (key in exports && exports[key] === _clearNodeFormating[key]) return;
189
- Object.defineProperty(exports, key, {
190
- enumerable: true,
191
- get: function get() {
192
- return _clearNodeFormating[key];
193
- }
194
- });
195
- });
196
- var _toggleLink = require("./utils/toggleLink");
197
- Object.keys(_toggleLink).forEach(function (key) {
198
- if (key === "default" || key === "__esModule") return;
199
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
200
- if (key in exports && exports[key] === _toggleLink[key]) return;
201
- Object.defineProperty(exports, key, {
202
- enumerable: true,
203
- get: function get() {
204
- return _toggleLink[key];
205
- }
206
- });
207
- });
208
33
  // This is a list of all the nodes that our Lexical implementation supports OOTB.
209
- var allNodes = exports.allNodes = [
210
- // These nodes are copy-pasted from Lexical and modified to fit our needs.
211
- // https://github.com/facebook/lexical/tree/main/packages/lexical-playground/src/nodes
212
- // https://github.com/facebook/lexical/tree/main/packages
213
- _ImageNode.ImageNode, _ListNode.ListNode, _ListItemNode.ListItemNode,
214
- // These nodes are directly imported from Lexical.
215
- _code.CodeNode, _hashtag.HashtagNode, _code.CodeHighlightNode, _LinkNode.AutoLinkNode, _overflow.OverflowNode, _mark.MarkNode,
216
- // Our custom nodes.
217
- _FontColorNode.FontColorNode, _TypographyNode.TypographyNode,
218
- // The following code replaces the built-in Lexical nodes with our custom ones.
219
- // https://lexical.dev/docs/concepts/node-replacement
220
- _ParagraphNode.ParagraphNode, {
221
- replace: _lexical.ParagraphNode,
222
- with: function _with() {
223
- return new _ParagraphNode.ParagraphNode();
224
- }
225
- }, _HeadingNode.HeadingNode, {
226
- replace: _richText.HeadingNode,
227
- with: function _with(node) {
228
- return new _HeadingNode.HeadingNode(node.getTag());
229
- }
230
- }, _QuoteNode.QuoteNode, {
231
- replace: _richText.QuoteNode,
232
- with: function _with() {
233
- return new _QuoteNode.QuoteNode();
234
- }
235
- }, _LinkNode.LinkNode];
34
+ export const allNodes = [ParagraphNode, {
35
+ replace: BaseParagraphNode,
36
+ with: () => {
37
+ return new ParagraphNode();
38
+ },
39
+ withKlass: ParagraphNode
40
+ }, HeadingNode, {
41
+ replace: BaseHeadingNode,
42
+ with: node => {
43
+ return new HeadingNode(node.getTag());
44
+ },
45
+ withKlass: HeadingNode
46
+ }, QuoteNode, {
47
+ replace: BaseQuoteNode,
48
+ with: () => {
49
+ return new QuoteNode();
50
+ },
51
+ withKlass: QuoteNode
52
+ }, ImageNode, ListNode, ListItemNode, CodeNode, HashtagNode, CodeHighlightNode, AutoLinkNode, OverflowNode, MarkNode, FontColorNode, QuoteNode, LinkNode];
236
53
 
237
54
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_lexical","require","_code","_hashtag","_mark","_richText","_overflow","_LinkNode","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_FontColorNode","_TypographyNode","_ListNode","_ListItemNode","_HeadingNode","_ParagraphNode","_QuoteNode","_ImageNode","_formatList","_listNode","_formatToQuote","_formatToHeading","_formatToParagraph","_clearNodeFormating","_toggleLink","allNodes","ImageNode","ListNode","ListItemNode","CodeNode","HashtagNode","CodeHighlightNode","AutoLinkNode","OverflowNode","MarkNode","FontColorNode","TypographyNode","ParagraphNode","replace","BaseParagraphNode","with","HeadingNode","BaseHeadingNode","node","getTag","QuoteNode","BaseQuoteNode","LinkNode"],"sources":["index.ts"],"sourcesContent":["import type { Klass, LexicalNode } from \"lexical\";\nimport { ParagraphNode as BaseParagraphNode } from \"lexical\";\nimport { CodeHighlightNode, CodeNode } from \"@lexical/code\";\nimport { HashtagNode } from \"@lexical/hashtag\";\nimport { MarkNode } from \"@lexical/mark\";\nimport { HeadingNode as BaseHeadingNode, QuoteNode as BaseQuoteNode } from \"@lexical/rich-text\";\nimport { OverflowNode } from \"@lexical/overflow\";\n\nimport { AutoLinkNode, LinkNode } from \"./LinkNode\";\nimport { FontColorNode } from \"./FontColorNode\";\nimport { TypographyNode } from \"./TypographyNode\";\nimport { ListNode } from \"./ListNode\";\nimport { ListItemNode } from \"./ListItemNode\";\nimport { HeadingNode } from \"./HeadingNode\";\nimport { ParagraphNode } from \"./ParagraphNode\";\nimport { QuoteNode } from \"./QuoteNode\";\nimport { ImageNode } from \"./ImageNode\";\n\nexport * from \"./FontColorNode\";\nexport * from \"./TypographyNode\";\nexport * from \"./ListNode\";\nexport * from \"./ListItemNode\";\nexport * from \"./HeadingNode\";\nexport * from \"./ParagraphNode\";\nexport * from \"./QuoteNode\";\nexport * from \"./ImageNode\";\nexport * from \"./LinkNode\";\n\nexport * from \"./utils/formatList\";\nexport * from \"./utils/listNode\";\nexport * from \"./utils/formatToQuote\";\nexport * from \"./utils/formatToHeading\";\nexport * from \"./utils/formatToParagraph\";\nexport * from \"./utils/clearNodeFormating\";\nexport * from \"./utils/toggleLink\";\n\n// This is a list of all the nodes that our Lexical implementation supports OOTB.\nexport const allNodes: ReadonlyArray<\n | Klass<LexicalNode>\n | {\n replace: Klass<LexicalNode>;\n with: <T extends { new (...args: any): any }>(node: InstanceType<T>) => LexicalNode;\n }\n> = [\n // These nodes are copy-pasted from Lexical and modified to fit our needs.\n // https://github.com/facebook/lexical/tree/main/packages/lexical-playground/src/nodes\n // https://github.com/facebook/lexical/tree/main/packages\n ImageNode,\n ListNode,\n ListItemNode,\n\n // These nodes are directly imported from Lexical.\n CodeNode,\n HashtagNode,\n CodeHighlightNode,\n AutoLinkNode,\n OverflowNode,\n MarkNode,\n\n // Our custom nodes.\n FontColorNode,\n TypographyNode,\n\n // The following code replaces the built-in Lexical nodes with our custom ones.\n // https://lexical.dev/docs/concepts/node-replacement\n ParagraphNode,\n {\n replace: BaseParagraphNode,\n with: () => {\n return new ParagraphNode();\n }\n },\n HeadingNode,\n {\n replace: BaseHeadingNode,\n with: (node: BaseHeadingNode) => {\n return new HeadingNode(node.getTag());\n }\n },\n QuoteNode,\n {\n replace: BaseQuoteNode,\n with: () => {\n return new QuoteNode();\n }\n },\n LinkNode\n];\n"],"mappings":";;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,IAAAM,SAAA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ACZC,sBAAY,EACZC,cAAQ;AAER;AACAC,4BAAa,EACbC,8BAAc;AAEd;AACA;AACAC,4BAAa,EACb;EACIC,OAAO,EAAEC,sBAAiB;EAC1BC,IAAI,EAAE,SAANA,KAAIA,CAAA,EAAQ;IACR,OAAO,IAAIH,4BAAa,CAAC,CAAC;EAC9B;AACJ,CAAC,EACDI,wBAAW,EACX;EACIH,OAAO,EAAEI,qBAAe;EACxBF,IAAI,EAAE,SAANA,KAAIA,CAAGG,IAAqB,EAAK;IAC7B,OAAO,IAAIF,wBAAW,CAACE,IAAI,CAACC,MAAM,CAAC,CAAC,CAAC;EACzC;AACJ,CAAC,EACDC,oBAAS,EACT;EACIP,OAAO,EAAEQ,mBAAa;EACtBN,IAAI,EAAE,SAANA,KAAIA,CAAA,EAAQ;IACR,OAAO,IAAIK,oBAAS,CAAC,CAAC;EAC1B;AACJ,CAAC,EACDE,kBAAQ,CACX","ignoreList":[]}
1
+ {"version":3,"names":["ParagraphNode","BaseParagraphNode","HeadingNode","BaseHeadingNode","QuoteNode","BaseQuoteNode","CodeHighlightNode","CodeNode","HashtagNode","MarkNode","OverflowNode","AutoLinkNode","LinkNode","FontColorNode","ListNode","ListItemNode","ImageNode","allNodes","replace","with","withKlass","node","getTag"],"sources":["index.ts"],"sourcesContent":["import {\n type Klass,\n type LexicalNode,\n type LexicalNodeReplacement,\n ParagraphNode as BaseParagraphNode\n} from \"lexical\";\nimport { HeadingNode as BaseHeadingNode, QuoteNode as BaseQuoteNode } from \"@lexical/rich-text\";\nimport { CodeHighlightNode, CodeNode } from \"@lexical/code\";\nimport { HashtagNode } from \"@lexical/hashtag\";\nimport { MarkNode } from \"@lexical/mark\";\nimport { OverflowNode } from \"@lexical/overflow\";\n\nimport { AutoLinkNode, LinkNode } from \"./LinkNode.js\";\nimport { FontColorNode } from \"./FontColorNode.js\";\nimport { ListNode } from \"./ListNode.js\";\nimport { ListItemNode } from \"./ListItemNode.js\";\nimport { HeadingNode } from \"./HeadingNode.js\";\nimport { ParagraphNode } from \"./ParagraphNode.js\";\nimport { QuoteNode } from \"./QuoteNode.js\";\nimport { ImageNode } from \"./ImageNode.js\";\n\nexport * from \"./FontColorNode.js\";\nexport * from \"./ListNode.js\";\nexport * from \"./ListItemNode.js\";\nexport * from \"./HeadingNode.js\";\nexport * from \"./ParagraphNode.js\";\nexport * from \"./QuoteNode.js\";\nexport * from \"./ImageNode.js\";\nexport * from \"./LinkNode.js\";\n\nexport * from \"./utils/formatList.js\";\nexport * from \"./utils/listNode.js\";\nexport * from \"./utils/formatToQuote.js\";\nexport * from \"./utils/formatToHeading.js\";\nexport * from \"./utils/formatToParagraph.js\";\nexport * from \"./utils/clearNodeFormating.js\";\nexport * from \"./utils/toggleLink.js\";\nexport * from \"./prepareLexicalState.js\";\nexport * from \"./generateInitialLexicalValue.js\";\n\n// This is a list of all the nodes that our Lexical implementation supports OOTB.\nexport const allNodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement> = [\n ParagraphNode,\n {\n replace: BaseParagraphNode,\n with: () => {\n return new ParagraphNode();\n },\n withKlass: ParagraphNode\n },\n HeadingNode,\n {\n replace: BaseHeadingNode,\n with: (node: BaseHeadingNode) => {\n return new HeadingNode(node.getTag());\n },\n withKlass: HeadingNode\n },\n QuoteNode,\n {\n replace: BaseQuoteNode,\n with: () => {\n return new QuoteNode();\n },\n withKlass: QuoteNode\n },\n ImageNode,\n ListNode,\n ListItemNode,\n CodeNode,\n HashtagNode,\n CodeHighlightNode,\n AutoLinkNode,\n OverflowNode,\n MarkNode,\n FontColorNode,\n QuoteNode,\n LinkNode\n];\n"],"mappings":"AAAA,SAIIA,aAAa,IAAIC,iBAAiB,QAC/B,SAAS;AAChB,SAASC,WAAW,IAAIC,eAAe,EAAEC,SAAS,IAAIC,aAAa,QAAQ,oBAAoB;AAC/F,SAASC,iBAAiB,EAAEC,QAAQ,QAAQ,eAAe;AAC3D,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASC,QAAQ,QAAQ,eAAe;AACxC,SAASC,YAAY,QAAQ,mBAAmB;AAEhD,SAASC,YAAY,EAAEC,QAAQ;AAC/B,SAASC,aAAa;AACtB,SAASC,QAAQ;AACjB,SAASC,YAAY;AACrB,SAASb,WAAW;AACpB,SAASF,aAAa;AACtB,SAASI,SAAS;AAClB,SAASY,SAAS;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,MAAMC,QAAoE,GAAG,CAChFjB,aAAa,EACb;EACIkB,OAAO,EAAEjB,iBAAiB;EAC1BkB,IAAI,EAAEA,CAAA,KAAM;IACR,OAAO,IAAInB,aAAa,CAAC,CAAC;EAC9B,CAAC;EACDoB,SAAS,EAAEpB;AACf,CAAC,EACDE,WAAW,EACX;EACIgB,OAAO,EAAEf,eAAe;EACxBgB,IAAI,EAAGE,IAAqB,IAAK;IAC7B,OAAO,IAAInB,WAAW,CAACmB,IAAI,CAACC,MAAM,CAAC,CAAC,CAAC;EACzC,CAAC;EACDF,SAAS,EAAElB;AACf,CAAC,EACDE,SAAS,EACT;EACIc,OAAO,EAAEb,aAAa;EACtBc,IAAI,EAAEA,CAAA,KAAM;IACR,OAAO,IAAIf,SAAS,CAAC,CAAC;EAC1B,CAAC;EACDgB,SAAS,EAAEhB;AACf,CAAC,EACDY,SAAS,EACTF,QAAQ,EACRC,YAAY,EACZR,QAAQ,EACRC,WAAW,EACXF,iBAAiB,EACjBK,YAAY,EACZD,YAAY,EACZD,QAAQ,EACRI,aAAa,EACbT,SAAS,EACTQ,QAAQ,CACX","ignoreList":[]}
package/package.json CHANGED
@@ -1,33 +1,29 @@
1
1
  {
2
2
  "name": "@webiny/lexical-nodes",
3
- "version": "5.44.1-beta.0",
3
+ "version": "5.45.0-beta.0",
4
+ "type": "module",
4
5
  "dependencies": {
5
- "@lexical/code": "0.23.1",
6
- "@lexical/hashtag": "0.23.1",
7
- "@lexical/history": "0.23.1",
8
- "@lexical/list": "0.23.1",
9
- "@lexical/mark": "0.23.1",
10
- "@lexical/overflow": "0.23.1",
11
- "@lexical/react": "0.23.1",
12
- "@lexical/rich-text": "0.23.1",
13
- "@lexical/selection": "0.23.1",
14
- "@lexical/utils": "0.23.1",
15
- "@types/prismjs": "1.26.4",
16
- "@webiny/lexical-theme": "5.44.1-beta.0",
17
- "lexical": "0.23.1"
6
+ "@lexical/code": "0.40.0",
7
+ "@lexical/hashtag": "0.40.0",
8
+ "@lexical/list": "0.40.0",
9
+ "@lexical/mark": "0.40.0",
10
+ "@lexical/overflow": "0.40.0",
11
+ "@lexical/react": "0.40.0",
12
+ "@lexical/rich-text": "0.40.0",
13
+ "@lexical/selection": "0.40.0",
14
+ "@lexical/utils": "0.40.0",
15
+ "@types/prismjs": "1.26.6",
16
+ "@webiny/lexical-theme": "5.45.0-beta.0",
17
+ "lexical": "0.40.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@webiny/project-utils": "5.44.1-beta.0",
20
+ "@webiny/build-tools": "5.45.0-beta.0",
21
21
  "react": "18.2.0"
22
22
  },
23
23
  "publishConfig": {
24
24
  "access": "public",
25
25
  "directory": "dist"
26
26
  },
27
- "scripts": {
28
- "build": "node ../cli/bin.js run build",
29
- "watch": "node ../cli/bin.js run watch"
30
- },
31
27
  "adio": {
32
28
  "ignore": {
33
29
  "dependencies": [
@@ -35,5 +31,5 @@
35
31
  ]
36
32
  }
37
33
  },
38
- "gitHead": "c80e6d88501ac84229f6577dee7b30163a906379"
34
+ "gitHead": "b85c33cfbe7c02c130445c918d913ef4b2c09cb2"
39
35
  }
@@ -0,0 +1,2 @@
1
+ import type { SerializedEditorState } from "lexical";
2
+ export declare const prepareLexicalState: (value: string | SerializedEditorState | null | undefined) => string;
@@ -0,0 +1,53 @@
1
+ import { generateInitialLexicalValue } from "./generateInitialLexicalValue.js";
2
+
3
+ /**
4
+ * Remap various node types to their latest form.
5
+ */
6
+ const nodeTypeMap = {
7
+ "webiny-list": "wby-list",
8
+ list: "wby-list",
9
+ "webiny-listitem": "wby-list-item",
10
+ "list-item": "wby-list-item",
11
+ "font-color-node": "wby-font-color",
12
+ "font-color": "wby-font-color",
13
+ "heading-element": "wby-heading",
14
+ heading: "wby-heading",
15
+ "paragraph-element": "wby-paragraph",
16
+ paragraph: "wby-paragraph",
17
+ "webiny-quote": "wby-quote",
18
+ quote: "wby-quote",
19
+ image: "wby-image",
20
+ link: "wby-link"
21
+ };
22
+
23
+ // Migrate old node types
24
+ function deepReplaceType(node) {
25
+ if (nodeTypeMap.hasOwnProperty(node.type)) {
26
+ node.type = nodeTypeMap[node.type];
27
+ }
28
+ if (node.children) {
29
+ node.children.forEach(deepReplaceType);
30
+ }
31
+ }
32
+ export const prepareLexicalState = value => {
33
+ if (!value) {
34
+ return generateInitialLexicalValue();
35
+ }
36
+ if (typeof value === "string") {
37
+ try {
38
+ const stateAsObject = JSON.parse(value);
39
+ deepReplaceType(stateAsObject.root);
40
+ return JSON.stringify(stateAsObject);
41
+ } catch {
42
+ return generateInitialLexicalValue();
43
+ }
44
+ }
45
+ try {
46
+ deepReplaceType(value.root);
47
+ return JSON.stringify(value);
48
+ } catch {
49
+ return generateInitialLexicalValue();
50
+ }
51
+ };
52
+
53
+ //# sourceMappingURL=prepareLexicalState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["generateInitialLexicalValue","nodeTypeMap","list","heading","paragraph","quote","image","link","deepReplaceType","node","hasOwnProperty","type","children","forEach","prepareLexicalState","value","stateAsObject","JSON","parse","root","stringify"],"sources":["prepareLexicalState.ts"],"sourcesContent":["import type { SerializedEditorState } from \"lexical\";\nimport { generateInitialLexicalValue } from \"./generateInitialLexicalValue.js\";\n\n/**\n * Remap various node types to their latest form.\n */\nconst nodeTypeMap: Record<string, string> = {\n \"webiny-list\": \"wby-list\",\n list: \"wby-list\",\n \"webiny-listitem\": \"wby-list-item\",\n \"list-item\": \"wby-list-item\",\n \"font-color-node\": \"wby-font-color\",\n \"font-color\": \"wby-font-color\",\n \"heading-element\": \"wby-heading\",\n heading: \"wby-heading\",\n \"paragraph-element\": \"wby-paragraph\",\n paragraph: \"wby-paragraph\",\n \"webiny-quote\": \"wby-quote\",\n quote: \"wby-quote\",\n image: \"wby-image\",\n link: \"wby-link\"\n};\n\n// Migrate old node types\nfunction deepReplaceType(node: any): void {\n if (nodeTypeMap.hasOwnProperty(node.type)) {\n node.type = nodeTypeMap[node.type];\n }\n\n if (node.children) {\n node.children.forEach(deepReplaceType);\n }\n}\n\nexport const prepareLexicalState = (\n value: string | SerializedEditorState | null | undefined\n): string => {\n if (!value) {\n return generateInitialLexicalValue();\n }\n\n if (typeof value === \"string\") {\n try {\n const stateAsObject = JSON.parse(value) as SerializedEditorState;\n deepReplaceType(stateAsObject.root);\n return JSON.stringify(stateAsObject);\n } catch {\n return generateInitialLexicalValue();\n }\n }\n\n try {\n deepReplaceType(value.root);\n return JSON.stringify(value);\n } catch {\n return generateInitialLexicalValue();\n }\n};\n"],"mappings":"AACA,SAASA,2BAA2B;;AAEpC;AACA;AACA;AACA,MAAMC,WAAmC,GAAG;EACxC,aAAa,EAAE,UAAU;EACzBC,IAAI,EAAE,UAAU;EAChB,iBAAiB,EAAE,eAAe;EAClC,WAAW,EAAE,eAAe;EAC5B,iBAAiB,EAAE,gBAAgB;EACnC,YAAY,EAAE,gBAAgB;EAC9B,iBAAiB,EAAE,aAAa;EAChCC,OAAO,EAAE,aAAa;EACtB,mBAAmB,EAAE,eAAe;EACpCC,SAAS,EAAE,eAAe;EAC1B,cAAc,EAAE,WAAW;EAC3BC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE;AACV,CAAC;;AAED;AACA,SAASC,eAAeA,CAACC,IAAS,EAAQ;EACtC,IAAIR,WAAW,CAACS,cAAc,CAACD,IAAI,CAACE,IAAI,CAAC,EAAE;IACvCF,IAAI,CAACE,IAAI,GAAGV,WAAW,CAACQ,IAAI,CAACE,IAAI,CAAC;EACtC;EAEA,IAAIF,IAAI,CAACG,QAAQ,EAAE;IACfH,IAAI,CAACG,QAAQ,CAACC,OAAO,CAACL,eAAe,CAAC;EAC1C;AACJ;AAEA,OAAO,MAAMM,mBAAmB,GAC5BC,KAAwD,IAC/C;EACT,IAAI,CAACA,KAAK,EAAE;IACR,OAAOf,2BAA2B,CAAC,CAAC;EACxC;EAEA,IAAI,OAAOe,KAAK,KAAK,QAAQ,EAAE;IAC3B,IAAI;MACA,MAAMC,aAAa,GAAGC,IAAI,CAACC,KAAK,CAACH,KAAK,CAA0B;MAChEP,eAAe,CAACQ,aAAa,CAACG,IAAI,CAAC;MACnC,OAAOF,IAAI,CAACG,SAAS,CAACJ,aAAa,CAAC;IACxC,CAAC,CAAC,MAAM;MACJ,OAAOhB,2BAA2B,CAAC,CAAC;IACxC;EACJ;EAEA,IAAI;IACAQ,eAAe,CAACO,KAAK,CAACI,IAAI,CAAC;IAC3B,OAAOF,IAAI,CAACG,SAAS,CAACL,KAAK,CAAC;EAChC,CAAC,CAAC,MAAM;IACJ,OAAOf,2BAA2B,CAAC,CAAC;EACxC;AACJ,CAAC","ignoreList":[]}
package/types.d.ts CHANGED
@@ -3,10 +3,9 @@ export interface ThemeStyleValue {
3
3
  styleId: string;
4
4
  type: ThemeStyleType;
5
5
  }
6
- export interface TextNodeThemeStyles {
7
- getThemeStyles: () => ThemeStyleValue[];
8
- setThemeStyles: (styles: ThemeStyleValue[]) => void;
9
- }
10
6
  export interface TypographyStylesNode {
11
- getTypographyStyleId: () => string | undefined;
7
+ getStyleId: () => string | undefined;
8
+ setStyleId: (id: string) => void;
9
+ getClassName: () => string | undefined;
10
+ setClassName: (className: string) => void;
12
11
  }
package/types.js CHANGED
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export type ThemeStyleType = \"typography\" | \"colors\" | \"fonts\";\n\nexport interface ThemeStyleValue {\n styleId: string;\n type: ThemeStyleType;\n}\n\nexport interface TextNodeThemeStyles {\n getThemeStyles: () => ThemeStyleValue[];\n setThemeStyles: (styles: ThemeStyleValue[]) => void;\n}\n\n/*\n * Indicates that the node is implementing the typography styles\n */\nexport interface TypographyStylesNode {\n getTypographyStyleId: () => string | undefined;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export type ThemeStyleType = \"typography\" | \"colors\" | \"fonts\";\n\nexport interface ThemeStyleValue {\n styleId: string;\n type: ThemeStyleType;\n}\n\nexport interface TypographyStylesNode {\n getStyleId: () => string | undefined;\n setStyleId: (id: string) => void;\n getClassName: () => string | undefined;\n setClassName: (className: string) => void;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { LexicalEditor, RangeSelection } from "lexical";
1
+ import type { LexicalEditor, RangeSelection } from "lexical";
2
2
  export declare const clearNodeFormatting: (activeEditor: LexicalEditor, selection: RangeSelection | null) => void;
@@ -1,24 +1,18 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.clearNodeFormatting = void 0;
7
- var _lexical = require("lexical");
8
- var _selection = require("@lexical/selection");
9
- var _utils = require("@lexical/utils");
10
- var _LexicalDecoratorBlockNode = require("@lexical/react/LexicalDecoratorBlockNode");
11
- var clearNodeFormatting = exports.clearNodeFormatting = function clearNodeFormatting(activeEditor, selection) {
12
- activeEditor.update(function () {
13
- if ((0, _lexical.$isRangeSelection)(selection)) {
14
- (0, _selection.$selectAll)(selection);
15
- selection.getNodes().forEach(function (node) {
16
- if ((0, _lexical.$isTextNode)(node)) {
1
+ import { $isRangeSelection, $isTextNode } from "lexical";
2
+ import { $selectAll } from "@lexical/selection";
3
+ import { $getNearestBlockElementAncestorOrThrow } from "@lexical/utils";
4
+ import { $isDecoratorBlockNode } from "@lexical/react/LexicalDecoratorBlockNode";
5
+ export const clearNodeFormatting = (activeEditor, selection) => {
6
+ activeEditor.update(() => {
7
+ if ($isRangeSelection(selection)) {
8
+ $selectAll(selection);
9
+ selection.getNodes().forEach(node => {
10
+ if ($isTextNode(node)) {
17
11
  node.setFormat(0);
18
12
  node.setStyle("");
19
- (0, _utils.$getNearestBlockElementAncestorOrThrow)(node).setFormat("");
13
+ $getNearestBlockElementAncestorOrThrow(node).setFormat("");
20
14
  }
21
- if ((0, _LexicalDecoratorBlockNode.$isDecoratorBlockNode)(node)) {
15
+ if ($isDecoratorBlockNode(node)) {
22
16
  node.setFormat("");
23
17
  }
24
18
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_lexical","require","_selection","_utils","_LexicalDecoratorBlockNode","clearNodeFormatting","exports","activeEditor","selection","update","$isRangeSelection","$selectAll","getNodes","forEach","node","$isTextNode","setFormat","setStyle","$getNearestBlockElementAncestorOrThrow","$isDecoratorBlockNode"],"sources":["clearNodeFormating.ts"],"sourcesContent":["import { $isRangeSelection, $isTextNode, LexicalEditor, RangeSelection } from \"lexical\";\nimport { $selectAll } from \"@lexical/selection\";\nimport { $getNearestBlockElementAncestorOrThrow } from \"@lexical/utils\";\nimport { $isDecoratorBlockNode } from \"@lexical/react/LexicalDecoratorBlockNode\";\n\nexport const clearNodeFormatting = (\n activeEditor: LexicalEditor,\n selection: RangeSelection | null\n) => {\n activeEditor.update(() => {\n if ($isRangeSelection(selection)) {\n $selectAll(selection);\n selection.getNodes().forEach(node => {\n if ($isTextNode(node)) {\n node.setFormat(0);\n node.setStyle(\"\");\n $getNearestBlockElementAncestorOrThrow(node).setFormat(\"\");\n }\n if ($isDecoratorBlockNode(node)) {\n node.setFormat(\"\");\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AAEO,IAAMI,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,SAAtBA,mBAAmBA,CAC5BE,YAA2B,EAC3BC,SAAgC,EAC/B;EACDD,YAAY,CAACE,MAAM,CAAC,YAAM;IACtB,IAAI,IAAAC,0BAAiB,EAACF,SAAS,CAAC,EAAE;MAC9B,IAAAG,qBAAU,EAACH,SAAS,CAAC;MACrBA,SAAS,CAACI,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,UAAAC,IAAI,EAAI;QACjC,IAAI,IAAAC,oBAAW,EAACD,IAAI,CAAC,EAAE;UACnBA,IAAI,CAACE,SAAS,CAAC,CAAC,CAAC;UACjBF,IAAI,CAACG,QAAQ,CAAC,EAAE,CAAC;UACjB,IAAAC,6CAAsC,EAACJ,IAAI,CAAC,CAACE,SAAS,CAAC,EAAE,CAAC;QAC9D;QACA,IAAI,IAAAG,gDAAqB,EAACL,IAAI,CAAC,EAAE;UAC7BA,IAAI,CAACE,SAAS,CAAC,EAAE,CAAC;QACtB;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["$isRangeSelection","$isTextNode","$selectAll","$getNearestBlockElementAncestorOrThrow","$isDecoratorBlockNode","clearNodeFormatting","activeEditor","selection","update","getNodes","forEach","node","setFormat","setStyle"],"sources":["clearNodeFormating.ts"],"sourcesContent":["import type { LexicalEditor, RangeSelection } from \"lexical\";\nimport { $isRangeSelection, $isTextNode } from \"lexical\";\nimport { $selectAll } from \"@lexical/selection\";\nimport { $getNearestBlockElementAncestorOrThrow } from \"@lexical/utils\";\nimport { $isDecoratorBlockNode } from \"@lexical/react/LexicalDecoratorBlockNode\";\n\nexport const clearNodeFormatting = (\n activeEditor: LexicalEditor,\n selection: RangeSelection | null\n) => {\n activeEditor.update(() => {\n if ($isRangeSelection(selection)) {\n $selectAll(selection);\n selection.getNodes().forEach(node => {\n if ($isTextNode(node)) {\n node.setFormat(0);\n node.setStyle(\"\");\n $getNearestBlockElementAncestorOrThrow(node).setFormat(\"\");\n }\n if ($isDecoratorBlockNode(node)) {\n node.setFormat(\"\");\n }\n });\n }\n });\n};\n"],"mappings":"AACA,SAASA,iBAAiB,EAAEC,WAAW,QAAQ,SAAS;AACxD,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,sCAAsC,QAAQ,gBAAgB;AACvE,SAASC,qBAAqB,QAAQ,0CAA0C;AAEhF,OAAO,MAAMC,mBAAmB,GAAGA,CAC/BC,YAA2B,EAC3BC,SAAgC,KAC/B;EACDD,YAAY,CAACE,MAAM,CAAC,MAAM;IACtB,IAAIR,iBAAiB,CAACO,SAAS,CAAC,EAAE;MAC9BL,UAAU,CAACK,SAAS,CAAC;MACrBA,SAAS,CAACE,QAAQ,CAAC,CAAC,CAACC,OAAO,CAACC,IAAI,IAAI;QACjC,IAAIV,WAAW,CAACU,IAAI,CAAC,EAAE;UACnBA,IAAI,CAACC,SAAS,CAAC,CAAC,CAAC;UACjBD,IAAI,CAACE,QAAQ,CAAC,EAAE,CAAC;UACjBV,sCAAsC,CAACQ,IAAI,CAAC,CAACC,SAAS,CAAC,EAAE,CAAC;QAC9D;QACA,IAAIR,qBAAqB,CAACO,IAAI,CAAC,EAAE;UAC7BA,IAAI,CAACC,SAAS,CAAC,EAAE,CAAC;QACtB;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import { LexicalEditor, LexicalNode } from "lexical";
2
- import { ListNode } from "../ListNode";
3
- import { ListItemNode } from "../ListItemNode";
4
- import { ListType } from "@lexical/list";
1
+ import type { LexicalEditor, LexicalNode } from "lexical";
2
+ import type { ListNode } from "../ListNode.js";
3
+ import { ListItemNode } from "../ListItemNode.js";
4
+ import type { ListType } from "@lexical/list";
5
5
  export declare function insertList(editor: LexicalEditor, listType: ListType, styleId?: string): void;
6
6
  /**
7
7
  * A recursive function that goes through each list and their children, including nested lists,