@webiny/lexical-nodes 6.3.0-beta.4 → 6.4.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 (45) hide show
  1. package/FontColorNode.js +94 -119
  2. package/FontColorNode.js.map +1 -1
  3. package/HeadingNode.js +160 -183
  4. package/HeadingNode.js.map +1 -1
  5. package/ImageNode.js +101 -131
  6. package/ImageNode.js.map +1 -1
  7. package/LinkNode.js +228 -315
  8. package/LinkNode.js.map +1 -1
  9. package/ListItemNode.js +249 -320
  10. package/ListItemNode.js.map +1 -1
  11. package/ListNode.js +174 -223
  12. package/ListNode.js.map +1 -1
  13. package/ParagraphNode.js +119 -148
  14. package/ParagraphNode.js.map +1 -1
  15. package/QuoteNode.js +97 -102
  16. package/QuoteNode.js.map +1 -1
  17. package/components/ImageNode/ImageComponent.js +117 -147
  18. package/components/ImageNode/ImageComponent.js.map +1 -1
  19. package/components/ImageNode/ImageResizer.js +167 -194
  20. package/components/ImageNode/ImageResizer.js.map +1 -1
  21. package/generateInitialLexicalValue.js +20 -23
  22. package/generateInitialLexicalValue.js.map +1 -1
  23. package/index.js +38 -26
  24. package/index.js.map +1 -1
  25. package/package.json +4 -4
  26. package/prepareLexicalState.js +30 -43
  27. package/prepareLexicalState.js.map +1 -1
  28. package/types.js +0 -3
  29. package/utils/clearNodeFormating.js +14 -15
  30. package/utils/clearNodeFormating.js.map +1 -1
  31. package/utils/formatList.js +277 -368
  32. package/utils/formatList.js.map +1 -1
  33. package/utils/formatToHeading.js +6 -13
  34. package/utils/formatToHeading.js.map +1 -1
  35. package/utils/formatToParagraph.js +6 -7
  36. package/utils/formatToParagraph.js.map +1 -1
  37. package/utils/formatToQuote.js +6 -13
  38. package/utils/formatToQuote.js.map +1 -1
  39. package/utils/getStyleId.js +6 -11
  40. package/utils/getStyleId.js.map +1 -1
  41. package/utils/listNode.js +60 -84
  42. package/utils/listNode.js.map +1 -1
  43. package/utils/toggleLink.js +67 -118
  44. package/utils/toggleLink.js.map +1 -1
  45. package/types.js.map +0 -1
package/ListItemNode.js CHANGED
@@ -3,360 +3,289 @@ import { $createListNode, $isListNode } from "./ListNode.js";
3
3
  import { $handleIndent, $handleOutdent, mergeLists, updateChildrenListItemValue } from "./utils/formatList.js";
4
4
  import { $createParagraphNode, $isParagraphNode } from "./ParagraphNode.js";
5
5
  import { isNestedListNode } from "./utils/listNode.js";
6
- export const LIST_ITEM_TYPE = "wby-list-item";
7
- /** @noInheritDoc */
8
- export class ListItemNode extends ElementNode {
9
- /** @internal */
10
-
11
- /** @internal */
12
-
13
- static getType() {
14
- return LIST_ITEM_TYPE;
15
- }
16
- static clone(node) {
17
- return new ListItemNode(node.__value, node.__checked, node.__key);
18
- }
19
- constructor(value, checked, key) {
20
- super(key);
21
- this.__value = value === undefined ? 1 : value;
22
- this.__checked = checked;
23
- }
24
- createDOM(config) {
25
- const element = document.createElement("li");
26
- const parent = this.getParent();
27
- if ($isListNode(parent) && parent.getListType() === "check") {
28
- updateListItemChecked(element, this, null, parent);
6
+ const LIST_ITEM_TYPE = "wby-list-item";
7
+ class ListItemNode extends ElementNode {
8
+ static getType() {
9
+ return LIST_ITEM_TYPE;
29
10
  }
30
- element.value = this.__value;
31
- $setListItemThemeClassNames(element, config.theme, this);
32
- return element;
33
- }
34
- updateDOM(prevNode, dom, config) {
35
- const parent = this.getParent();
36
- if ($isListNode(parent) && parent.getListType() === "check") {
37
- updateListItemChecked(dom, this, prevNode, parent);
11
+ static clone(node) {
12
+ return new ListItemNode(node.__value, node.__checked, node.__key);
38
13
  }
39
- // @ts-expect-error - this is always HTMLListItemElement
40
- dom.value = this.__value;
41
- $setListItemThemeClassNames(dom, config.theme, this);
42
- return false;
43
- }
44
- static importDOM() {
45
- return {
46
- li: () => ({
47
- conversion: convertListItemElement,
48
- priority: 0
49
- })
50
- };
51
- }
52
- static importJSON(serializedNode) {
53
- const node = new ListItemNode(serializedNode.value, serializedNode.checked);
54
- node.setFormat(serializedNode.format);
55
- node.setIndent(serializedNode.indent);
56
- node.setDirection(serializedNode.direction);
57
- return node;
58
- }
59
- exportJSON() {
60
- return {
61
- ...super.exportJSON(),
62
- checked: this.getChecked(),
63
- type: LIST_ITEM_TYPE,
64
- value: this.getValue()
65
- };
66
- }
67
- append(...nodes) {
68
- for (let i = 0; i < nodes.length; i++) {
69
- const node = nodes[i];
70
- if ($isElementNode(node) && this.canMergeWith(node)) {
71
- const children = node.getChildren();
72
- this.append(...children);
73
- node.remove();
74
- } else {
75
- super.append(node);
76
- }
14
+ constructor(value, checked, key){
15
+ super(key);
16
+ this.__value = void 0 === value ? 1 : value;
17
+ this.__checked = checked;
77
18
  }
78
- return this;
79
- }
80
- replace(replaceWithNode, includeChildren) {
81
- if ($isListItemNode(replaceWithNode)) {
82
- return super.replace(replaceWithNode);
19
+ createDOM(config) {
20
+ const element = document.createElement("li");
21
+ const parent = this.getParent();
22
+ if ($isListNode(parent) && "check" === parent.getListType()) updateListItemChecked(element, this, null, parent);
23
+ element.value = this.__value;
24
+ $setListItemThemeClassNames(element, config.theme, this);
25
+ return element;
83
26
  }
84
- this.setIndent(0);
85
- const list = this.getParentOrThrow();
86
- if (!$isListNode(list)) {
87
- return replaceWithNode;
27
+ updateDOM(prevNode, dom, config) {
28
+ const parent = this.getParent();
29
+ if ($isListNode(parent) && "check" === parent.getListType()) updateListItemChecked(dom, this, prevNode, parent);
30
+ dom.value = this.__value;
31
+ $setListItemThemeClassNames(dom, config.theme, this);
32
+ return false;
88
33
  }
89
- if (list.__first === this.getKey()) {
90
- list.insertBefore(replaceWithNode);
91
- } else if (list.__last === this.getKey()) {
92
- list.insertAfter(replaceWithNode);
93
- } else {
94
- // Split the list
95
- const newList = $createListNode(list.getListType());
96
- let nextSibling = this.getNextSibling();
97
- while (nextSibling) {
98
- const nodeToAppend = nextSibling;
99
- nextSibling = nextSibling.getNextSibling();
100
- newList.append(nodeToAppend);
101
- }
102
- list.insertAfter(replaceWithNode);
103
- replaceWithNode.insertAfter(newList);
34
+ static importDOM() {
35
+ return {
36
+ li: ()=>({
37
+ conversion: convertListItemElement,
38
+ priority: 0
39
+ })
40
+ };
104
41
  }
105
- if (includeChildren) {
106
- if (!$isElementNode(replaceWithNode)) {
107
- throw Error("includeChildren should only be true for ElementNodes");
108
- }
109
- this.getChildren().forEach(child => {
110
- replaceWithNode.append(child);
111
- });
42
+ static importJSON(serializedNode) {
43
+ const node = new ListItemNode(serializedNode.value, serializedNode.checked);
44
+ node.setFormat(serializedNode.format);
45
+ node.setIndent(serializedNode.indent);
46
+ node.setDirection(serializedNode.direction);
47
+ return node;
112
48
  }
113
- this.remove();
114
- if (list.getChildrenSize() === 0) {
115
- list.remove();
49
+ exportJSON() {
50
+ return {
51
+ ...super.exportJSON(),
52
+ checked: this.getChecked(),
53
+ type: LIST_ITEM_TYPE,
54
+ value: this.getValue()
55
+ };
116
56
  }
117
- return replaceWithNode;
118
- }
119
- insertAfter(node) {
120
- const listNode = this.getParentOrThrow();
121
- if (!$isListNode(listNode)) {
122
- console.log("insertAfter: webiny list node is not parent of list item node");
123
- return listNode;
57
+ append(...nodes) {
58
+ for(let i = 0; i < nodes.length; i++){
59
+ const node = nodes[i];
60
+ if ($isElementNode(node) && this.canMergeWith(node)) {
61
+ const children = node.getChildren();
62
+ this.append(...children);
63
+ node.remove();
64
+ } else super.append(node);
65
+ }
66
+ return this;
124
67
  }
125
- const siblings = this.getNextSiblings();
126
- if ($isListItemNode(node)) {
127
- const after = super.insertAfter(node);
128
- const afterListNode = node.getParentOrThrow();
129
- if ($isListNode(afterListNode)) {
130
- updateChildrenListItemValue(afterListNode);
131
- }
132
- return after;
68
+ replace(replaceWithNode, includeChildren) {
69
+ if ($isListItemNode(replaceWithNode)) return super.replace(replaceWithNode);
70
+ this.setIndent(0);
71
+ const list = this.getParentOrThrow();
72
+ if (!$isListNode(list)) return replaceWithNode;
73
+ if (list.__first === this.getKey()) list.insertBefore(replaceWithNode);
74
+ else if (list.__last === this.getKey()) list.insertAfter(replaceWithNode);
75
+ else {
76
+ const newList = $createListNode(list.getListType());
77
+ let nextSibling = this.getNextSibling();
78
+ while(nextSibling){
79
+ const nodeToAppend = nextSibling;
80
+ nextSibling = nextSibling.getNextSibling();
81
+ newList.append(nodeToAppend);
82
+ }
83
+ list.insertAfter(replaceWithNode);
84
+ replaceWithNode.insertAfter(newList);
85
+ }
86
+ if (includeChildren) {
87
+ if (!$isElementNode(replaceWithNode)) throw Error("includeChildren should only be true for ElementNodes");
88
+ this.getChildren().forEach((child)=>{
89
+ replaceWithNode.append(child);
90
+ });
91
+ }
92
+ this.remove();
93
+ if (0 === list.getChildrenSize()) list.remove();
94
+ return replaceWithNode;
133
95
  }
134
-
135
- // Attempt to merge if the list is of the same type.
136
-
137
- if ($isListNode(node) && node.getListType() === listNode.getListType()) {
138
- let child = node;
139
- const children = node.getChildren();
140
- for (let i = children.length - 1; i >= 0; i--) {
141
- child = children[i];
142
- this.insertAfter(child);
143
- }
144
- return child;
96
+ insertAfter(node) {
97
+ const listNode = this.getParentOrThrow();
98
+ if (!$isListNode(listNode)) {
99
+ console.log("insertAfter: webiny list node is not parent of list item node");
100
+ return listNode;
101
+ }
102
+ const siblings = this.getNextSiblings();
103
+ if ($isListItemNode(node)) {
104
+ const after = super.insertAfter(node);
105
+ const afterListNode = node.getParentOrThrow();
106
+ if ($isListNode(afterListNode)) updateChildrenListItemValue(afterListNode);
107
+ return after;
108
+ }
109
+ if ($isListNode(node) && node.getListType() === listNode.getListType()) {
110
+ let child = node;
111
+ const children = node.getChildren();
112
+ for(let i = children.length - 1; i >= 0; i--){
113
+ child = children[i];
114
+ this.insertAfter(child);
115
+ }
116
+ return child;
117
+ }
118
+ listNode.insertAfter(node);
119
+ if (0 !== siblings.length) {
120
+ const newListNode = $createListNode(listNode.getListType());
121
+ siblings.forEach((sibling)=>newListNode.append(sibling));
122
+ node.insertAfter(newListNode);
123
+ }
124
+ return node;
145
125
  }
146
-
147
- // Otherwise, split the list
148
- // Split the lists and insert the node in between them
149
- listNode.insertAfter(node);
150
- if (siblings.length !== 0) {
151
- const newListNode = $createListNode(listNode.getListType());
152
- siblings.forEach(sibling => newListNode.append(sibling));
153
- node.insertAfter(newListNode);
126
+ remove(preserveEmptyParent) {
127
+ const prevSibling = this.getPreviousSibling();
128
+ const nextSibling = this.getNextSibling();
129
+ super.remove(preserveEmptyParent);
130
+ if (prevSibling && nextSibling && isNestedListNode(prevSibling) && isNestedListNode(nextSibling)) {
131
+ mergeLists(prevSibling.getFirstChild(), nextSibling.getFirstChild());
132
+ nextSibling.remove();
133
+ } else if (nextSibling) {
134
+ const parent = nextSibling.getParent();
135
+ if ($isListNode(parent)) updateChildrenListItemValue(parent);
136
+ }
154
137
  }
155
- return node;
156
- }
157
- remove(preserveEmptyParent) {
158
- const prevSibling = this.getPreviousSibling();
159
- const nextSibling = this.getNextSibling();
160
- super.remove(preserveEmptyParent);
161
- if (prevSibling && nextSibling && isNestedListNode(prevSibling) && isNestedListNode(nextSibling)) {
162
- mergeLists(prevSibling.getFirstChild(), nextSibling.getFirstChild());
163
- nextSibling.remove();
164
- } else if (nextSibling) {
165
- const parent = nextSibling.getParent();
166
- if ($isListNode(parent)) {
167
- updateChildrenListItemValue(parent);
168
- }
138
+ insertNewAfter() {
139
+ const newElement = $createListItemNode(null == this.__checked ? void 0 : false);
140
+ this.insertAfter(newElement);
141
+ return newElement;
169
142
  }
170
- }
171
- insertNewAfter() {
172
- const newElement = $createListItemNode(this.__checked == null ? undefined : false);
173
- this.insertAfter(newElement);
174
- return newElement;
175
- }
176
- collapseAtStart(selection) {
177
- const paragraph = $createParagraphNode();
178
- const children = this.getChildren();
179
- children.forEach(child => paragraph.append(child));
180
- const listNode = this.getParentOrThrow();
181
- const listNodeParent = listNode.getParentOrThrow();
182
- const isIndented = $isListItemNode(listNodeParent);
183
- if (listNode.getChildrenSize() === 1) {
184
- if (isIndented) {
185
- // if the list node is nested, we just want to remove it,
186
- // effectively unindenting it.
187
- listNode.remove();
188
- listNodeParent.select();
189
- } else {
190
- listNode.replace(paragraph);
191
- // If we have selection on the list item, we'll need to move it
192
- // to the paragraph
193
- const anchor = selection.anchor;
194
- const focus = selection.focus;
195
- const key = paragraph.getKey();
196
- if (anchor.type === "element" && anchor.getNode().is(this)) {
197
- anchor.set(key, anchor.offset, "element");
143
+ collapseAtStart(selection) {
144
+ const paragraph = $createParagraphNode();
145
+ const children = this.getChildren();
146
+ children.forEach((child)=>paragraph.append(child));
147
+ const listNode = this.getParentOrThrow();
148
+ const listNodeParent = listNode.getParentOrThrow();
149
+ const isIndented = $isListItemNode(listNodeParent);
150
+ if (1 === listNode.getChildrenSize()) if (isIndented) {
151
+ listNode.remove();
152
+ listNodeParent.select();
153
+ } else {
154
+ listNode.replace(paragraph);
155
+ const anchor = selection.anchor;
156
+ const focus = selection.focus;
157
+ const key = paragraph.getKey();
158
+ if ("element" === anchor.type && anchor.getNode().is(this)) anchor.set(key, anchor.offset, "element");
159
+ if ("element" === focus.type && focus.getNode().is(this)) focus.set(key, focus.offset, "element");
198
160
  }
199
- if (focus.type === "element" && focus.getNode().is(this)) {
200
- focus.set(key, focus.offset, "element");
161
+ else {
162
+ listNode.insertBefore(paragraph);
163
+ this.remove();
201
164
  }
202
- }
203
- } else {
204
- listNode.insertBefore(paragraph);
205
- this.remove();
165
+ return true;
206
166
  }
207
- return true;
208
- }
209
- getValue() {
210
- const self = this.getLatest();
211
- return self.__value;
212
- }
213
- setValue(value) {
214
- const self = this.getWritable();
215
- self.__value = value;
216
- }
217
- getChecked() {
218
- const self = this.getLatest();
219
- return self.__checked;
220
- }
221
- setChecked(checked) {
222
- const self = this.getWritable();
223
- self.__checked = checked;
224
- }
225
- getIndent() {
226
- // If we don't have a parent, we are likely serializing
227
- const parent = this.getParent();
228
- if (parent === null) {
229
- return this.getLatest().__indent;
167
+ getValue() {
168
+ const self = this.getLatest();
169
+ return self.__value;
230
170
  }
231
- // ListItemNode should always have a ListNode for a parent.
232
- let listNodeParent = parent.getParentOrThrow();
233
- let indentLevel = 0;
234
- while ($isListItemNode(listNodeParent)) {
235
- listNodeParent = listNodeParent.getParentOrThrow().getParentOrThrow();
236
- indentLevel++;
171
+ setValue(value) {
172
+ const self = this.getWritable();
173
+ self.__value = value;
237
174
  }
238
- return indentLevel;
239
- }
240
- setIndent(indent) {
241
- let currentIndent = this.getIndent();
242
- while (currentIndent !== indent) {
243
- if (currentIndent < indent) {
244
- $handleIndent([this]);
245
- currentIndent++;
246
- } else {
247
- $handleOutdent([this]);
248
- currentIndent--;
249
- }
175
+ getChecked() {
176
+ const self = this.getLatest();
177
+ return self.__checked;
250
178
  }
251
- return this;
252
- }
253
- canIndent() {
254
- // Indent/outdent is handled specifically in the RichText logic.
255
-
256
- return false;
257
- }
258
- insertBefore(nodeToInsert) {
259
- if ($isListItemNode(nodeToInsert)) {
260
- const parent = this.getParentOrThrow();
261
- if ($isListNode(parent)) {
262
- const siblings = this.getNextSiblings();
263
- updateChildrenListItemValue(parent, siblings);
264
- }
179
+ setChecked(checked) {
180
+ const self = this.getWritable();
181
+ self.__checked = checked;
182
+ }
183
+ getIndent() {
184
+ const parent = this.getParent();
185
+ if (null === parent) return this.getLatest().__indent;
186
+ let listNodeParent = parent.getParentOrThrow();
187
+ let indentLevel = 0;
188
+ while($isListItemNode(listNodeParent)){
189
+ listNodeParent = listNodeParent.getParentOrThrow().getParentOrThrow();
190
+ indentLevel++;
191
+ }
192
+ return indentLevel;
193
+ }
194
+ setIndent(indent) {
195
+ let currentIndent = this.getIndent();
196
+ while(currentIndent !== indent)if (currentIndent < indent) {
197
+ $handleIndent([
198
+ this
199
+ ]);
200
+ currentIndent++;
201
+ } else {
202
+ $handleOutdent([
203
+ this
204
+ ]);
205
+ currentIndent--;
206
+ }
207
+ return this;
208
+ }
209
+ canIndent() {
210
+ return false;
211
+ }
212
+ insertBefore(nodeToInsert) {
213
+ if ($isListItemNode(nodeToInsert)) {
214
+ const parent = this.getParentOrThrow();
215
+ if ($isListNode(parent)) {
216
+ const siblings = this.getNextSiblings();
217
+ updateChildrenListItemValue(parent, siblings);
218
+ }
219
+ }
220
+ return super.insertBefore(nodeToInsert);
221
+ }
222
+ canInsertAfter(node) {
223
+ return $isListNode(node);
224
+ }
225
+ canReplaceWith(replacement) {
226
+ return $isListItemNode(replacement);
265
227
  }
266
- return super.insertBefore(nodeToInsert);
267
- }
268
- canInsertAfter(node) {
269
- return $isListNode(node);
270
- }
271
- canReplaceWith(replacement) {
272
- return $isListItemNode(replacement);
273
- }
274
- canMergeWith(node) {
275
- return $isParagraphNode(node) || $isListItemNode(node);
276
- }
277
- extractWithChild(child, selection) {
278
- if (!$isRangeSelection(selection)) {
279
- return false;
228
+ canMergeWith(node) {
229
+ return $isParagraphNode(node) || $isListItemNode(node);
230
+ }
231
+ extractWithChild(child, selection) {
232
+ if (!$isRangeSelection(selection)) return false;
233
+ const anchorNode = selection.anchor.getNode();
234
+ const focusNode = selection.focus.getNode();
235
+ return this.isParentOf(anchorNode) && this.isParentOf(focusNode) && this.getTextContent().length === selection.getTextContent().length;
280
236
  }
281
- const anchorNode = selection.anchor.getNode();
282
- const focusNode = selection.focus.getNode();
283
- return this.isParentOf(anchorNode) && this.isParentOf(focusNode) && this.getTextContent().length === selection.getTextContent().length;
284
- }
285
237
  }
286
238
  function $setListItemThemeClassNames(dom, editorThemeClasses, node) {
287
- const classesToAdd = [];
288
- const classesToRemove = [];
289
- const listTheme = editorThemeClasses.list;
290
- const listItemClassName = listTheme ? listTheme.listitem : undefined;
291
- let nestedListItemClassName;
292
- if (listTheme && listTheme.nested) {
293
- nestedListItemClassName = listTheme.nested.listitem;
294
- }
295
- if (listItemClassName !== undefined) {
296
- const listItemClasses = listItemClassName.split(" ");
297
- classesToAdd.push(...listItemClasses);
298
- }
299
- if (listTheme) {
300
- const parentNode = node.getParent();
301
- const isCheckList = $isListNode(parentNode) && parentNode?.getListType() === "check";
302
- const checked = node.getChecked();
303
- if (!isCheckList || checked) {
304
- classesToRemove.push(listTheme.listitemUnchecked);
239
+ const classesToAdd = [];
240
+ const classesToRemove = [];
241
+ const listTheme = editorThemeClasses.list;
242
+ const listItemClassName = listTheme ? listTheme.listitem : void 0;
243
+ let nestedListItemClassName;
244
+ if (listTheme && listTheme.nested) nestedListItemClassName = listTheme.nested.listitem;
245
+ if (void 0 !== listItemClassName) {
246
+ const listItemClasses = listItemClassName.split(" ");
247
+ classesToAdd.push(...listItemClasses);
305
248
  }
306
- if (!isCheckList || !checked) {
307
- classesToRemove.push(listTheme.listitemChecked);
249
+ if (listTheme) {
250
+ const parentNode = node.getParent();
251
+ const isCheckList = $isListNode(parentNode) && parentNode?.getListType() === "check";
252
+ const checked = node.getChecked();
253
+ if (!isCheckList || checked) classesToRemove.push(listTheme.listitemUnchecked);
254
+ if (!isCheckList || !checked) classesToRemove.push(listTheme.listitemChecked);
255
+ if (isCheckList) classesToAdd.push(checked ? listTheme.listitemChecked : listTheme.listitemUnchecked);
308
256
  }
309
- if (isCheckList) {
310
- classesToAdd.push(checked ? listTheme.listitemChecked : listTheme.listitemUnchecked);
257
+ if (void 0 !== nestedListItemClassName) {
258
+ const nestedListItemClasses = nestedListItemClassName.split(" ");
259
+ if (node.getChildren().some((child)=>$isListNode(child))) classesToAdd.push(...nestedListItemClasses);
260
+ else classesToRemove.push(...nestedListItemClasses);
311
261
  }
312
- }
313
- if (nestedListItemClassName !== undefined) {
314
- const nestedListItemClasses = nestedListItemClassName.split(" ");
315
- if (node.getChildren().some(child => $isListNode(child))) {
316
- classesToAdd.push(...nestedListItemClasses);
317
- } else {
318
- classesToRemove.push(...nestedListItemClasses);
319
- }
320
- }
321
- if (classesToRemove.length > 0) {
322
- removeClassNamesFromElement(dom, ...classesToRemove);
323
- }
324
- if (classesToAdd.length > 0) {
325
- addClassNamesToElement(dom, ...classesToAdd);
326
- }
262
+ if (classesToRemove.length > 0) removeClassNamesFromElement(dom, ...classesToRemove);
263
+ if (classesToAdd.length > 0) addClassNamesToElement(dom, ...classesToAdd);
327
264
  }
328
265
  function updateListItemChecked(dom, listItemNode, prevListItemNode, listNode) {
329
- const isCheckList = listNode.getListType() === "check";
330
- if (isCheckList) {
331
- // Only add attributes for leaf list items
332
- if ($isListNode(listItemNode.getFirstChild())) {
333
- dom.removeAttribute("role");
334
- dom.removeAttribute("tabIndex");
335
- dom.removeAttribute("aria-checked");
266
+ const isCheckList = "check" === listNode.getListType();
267
+ if (isCheckList) if ($isListNode(listItemNode.getFirstChild())) {
268
+ dom.removeAttribute("role");
269
+ dom.removeAttribute("tabIndex");
270
+ dom.removeAttribute("aria-checked");
336
271
  } else {
337
- dom.setAttribute("role", "checkbox");
338
- dom.setAttribute("tabIndex", "-1");
339
- if (!prevListItemNode || listItemNode.__checked !== prevListItemNode.__checked) {
340
- dom.setAttribute("aria-checked", listItemNode.getChecked() ? "true" : "false");
341
- }
342
- }
343
- } else {
344
- // Clean up checked state
345
- if (listItemNode.getChecked() != null) {
346
- listItemNode.setChecked(undefined);
272
+ dom.setAttribute("role", "checkbox");
273
+ dom.setAttribute("tabIndex", "-1");
274
+ if (!prevListItemNode || listItemNode.__checked !== prevListItemNode.__checked) dom.setAttribute("aria-checked", listItemNode.getChecked() ? "true" : "false");
347
275
  }
348
- }
276
+ else if (null != listItemNode.getChecked()) listItemNode.setChecked(void 0);
349
277
  }
350
278
  function convertListItemElement() {
351
- return {
352
- node: $createListItemNode()
353
- };
279
+ return {
280
+ node: $createListItemNode()
281
+ };
354
282
  }
355
- export function $createListItemNode(checked) {
356
- return new ListItemNode(undefined, checked);
283
+ function $createListItemNode(checked) {
284
+ return new ListItemNode(void 0, checked);
357
285
  }
358
- export function $isListItemNode(node) {
359
- return node instanceof ListItemNode;
286
+ function $isListItemNode(node) {
287
+ return node instanceof ListItemNode;
360
288
  }
289
+ export { $createListItemNode, $isListItemNode, LIST_ITEM_TYPE, ListItemNode };
361
290
 
362
291
  //# sourceMappingURL=ListItemNode.js.map