@ckeditor/ckeditor5-list 40.0.0 → 40.2.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.
- package/CHANGELOG.md +25 -25
- package/LICENSE.md +2 -2
- package/build/list.js +1 -1
- package/build/translations/ug.js +1 -1
- package/lang/translations/ug.po +3 -3
- package/package.json +2 -3
- package/src/augmentation.d.ts +52 -52
- package/src/augmentation.js +5 -5
- package/src/documentlist/adjacentlistssupport.d.ts +15 -15
- package/src/documentlist/adjacentlistssupport.js +81 -81
- package/src/documentlist/converters.d.ts +65 -65
- package/src/documentlist/converters.js +441 -441
- package/src/documentlist/documentlistcommand.d.ts +80 -80
- package/src/documentlist/documentlistcommand.js +150 -150
- package/src/documentlist/documentlistediting.d.ts +212 -212
- package/src/documentlist/documentlistediting.js +646 -645
- package/src/documentlist/documentlistindentcommand.d.ts +62 -62
- package/src/documentlist/documentlistindentcommand.js +129 -129
- package/src/documentlist/documentlistmergecommand.d.ts +76 -76
- package/src/documentlist/documentlistmergecommand.js +174 -174
- package/src/documentlist/documentlistsplitcommand.d.ts +67 -67
- package/src/documentlist/documentlistsplitcommand.js +70 -70
- package/src/documentlist/documentlistutils.d.ts +46 -46
- package/src/documentlist/documentlistutils.js +50 -50
- package/src/documentlist/utils/listwalker.d.ts +145 -145
- package/src/documentlist/utils/listwalker.js +182 -182
- package/src/documentlist/utils/model.d.ts +202 -202
- package/src/documentlist/utils/model.js +455 -455
- package/src/documentlist/utils/postfixers.d.ts +37 -37
- package/src/documentlist/utils/postfixers.js +126 -126
- package/src/documentlist/utils/view.d.ts +81 -81
- package/src/documentlist/utils/view.js +117 -117
- package/src/documentlist.d.ts +26 -26
- package/src/documentlist.js +30 -30
- package/src/documentlistproperties/converters.d.ts +19 -19
- package/src/documentlistproperties/converters.js +43 -43
- package/src/documentlistproperties/documentlistpropertiesediting.d.ts +88 -88
- package/src/documentlistproperties/documentlistpropertiesediting.js +266 -266
- package/src/documentlistproperties/documentlistpropertiesutils.d.ts +33 -33
- package/src/documentlistproperties/documentlistpropertiesutils.js +44 -44
- package/src/documentlistproperties/documentlistreversedcommand.d.ts +36 -36
- package/src/documentlistproperties/documentlistreversedcommand.js +55 -55
- package/src/documentlistproperties/documentliststartcommand.d.ts +38 -38
- package/src/documentlistproperties/documentliststartcommand.js +57 -57
- package/src/documentlistproperties/documentliststylecommand.d.ts +72 -72
- package/src/documentlistproperties/documentliststylecommand.js +113 -113
- package/src/documentlistproperties/utils/style.d.ts +20 -20
- package/src/documentlistproperties/utils/style.js +54 -54
- package/src/documentlistproperties.d.ts +27 -27
- package/src/documentlistproperties.js +31 -31
- package/src/index.d.ts +43 -43
- package/src/index.js +29 -29
- package/src/list/converters.d.ts +196 -196
- package/src/list/converters.js +905 -905
- package/src/list/indentcommand.d.ts +37 -37
- package/src/list/indentcommand.js +107 -107
- package/src/list/listcommand.d.ts +55 -55
- package/src/list/listcommand.js +274 -274
- package/src/list/listediting.d.ts +32 -32
- package/src/list/listediting.js +161 -161
- package/src/list/listui.d.ts +19 -19
- package/src/list/listui.js +32 -32
- package/src/list/listutils.d.ts +41 -41
- package/src/list/listutils.js +46 -46
- package/src/list/utils.d.ts +112 -112
- package/src/list/utils.js +374 -374
- package/src/list.d.ts +26 -26
- package/src/list.js +30 -30
- package/src/listconfig.d.ts +132 -132
- package/src/listconfig.js +5 -5
- package/src/listproperties/listpropertiesediting.d.ts +72 -72
- package/src/listproperties/listpropertiesediting.js +696 -696
- package/src/listproperties/listpropertiesui.d.ts +23 -23
- package/src/listproperties/listpropertiesui.js +277 -277
- package/src/listproperties/listreversedcommand.d.ts +38 -38
- package/src/listproperties/listreversedcommand.js +52 -52
- package/src/listproperties/liststartcommand.d.ts +37 -37
- package/src/listproperties/liststartcommand.js +51 -51
- package/src/listproperties/liststylecommand.d.ts +67 -67
- package/src/listproperties/liststylecommand.js +99 -99
- package/src/listproperties/ui/listpropertiesview.d.ts +156 -157
- package/src/listproperties/ui/listpropertiesview.js +298 -299
- package/src/listproperties.d.ts +26 -26
- package/src/listproperties.js +30 -30
- package/src/liststyle.d.ts +28 -28
- package/src/liststyle.js +36 -36
- package/src/tododocumentlist/checktododocumentlistcommand.d.ts +49 -49
- package/src/tododocumentlist/checktododocumentlistcommand.js +82 -82
- package/src/tododocumentlist/todocheckboxchangeobserver.d.ts +41 -41
- package/src/tododocumentlist/todocheckboxchangeobserver.js +37 -37
- package/src/tododocumentlist/tododocumentlistediting.d.ts +38 -38
- package/src/tododocumentlist/tododocumentlistediting.js +399 -399
- package/src/tododocumentlist.d.ts +27 -27
- package/src/tododocumentlist.js +31 -31
- package/src/todolist/checktodolistcommand.d.ts +52 -52
- package/src/todolist/checktodolistcommand.js +76 -76
- package/src/todolist/todolistconverters.d.ts +82 -82
- package/src/todolist/todolistconverters.js +260 -260
- package/src/todolist/todolistediting.d.ts +39 -39
- package/src/todolist/todolistediting.js +161 -161
- package/src/todolist/todolistui.d.ts +19 -19
- package/src/todolist/todolistui.js +29 -29
- package/src/todolist.d.ts +27 -27
- package/src/todolist.js +31 -31
- package/build/list.js.map +0 -1
- package/src/listproperties/ui/collapsibleview.d.ts +0 -63
- package/src/listproperties/ui/collapsibleview.js +0 -89
- package/theme/collapsible.css +0 -10
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module list/documentlist/utils/listwalker
|
|
7
|
-
*/
|
|
8
|
-
import { first, toArray } from 'ckeditor5/src/utils';
|
|
9
|
-
import { isListItemBlock } from './model';
|
|
10
|
-
/**
|
|
11
|
-
* Document list blocks iterator.
|
|
12
|
-
*/
|
|
13
|
-
export default class ListWalker {
|
|
14
|
-
/**
|
|
15
|
-
* Creates a document list iterator.
|
|
16
|
-
*
|
|
17
|
-
* @param startElement The start list item block element.
|
|
18
|
-
* @param options.direction The iterating direction.
|
|
19
|
-
* @param options.includeSelf Whether start block should be included in the result (if it's matching other criteria).
|
|
20
|
-
* @param options.sameAttributes Additional attributes that must be the same for each block.
|
|
21
|
-
* @param options.sameIndent Whether blocks with the same indent level as the start block should be included
|
|
22
|
-
* in the result.
|
|
23
|
-
* @param options.lowerIndent Whether blocks with a lower indent level than the start block should be included
|
|
24
|
-
* in the result.
|
|
25
|
-
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
26
|
-
* in the result.
|
|
27
|
-
*/
|
|
28
|
-
constructor(startElement, options) {
|
|
29
|
-
this._startElement = startElement;
|
|
30
|
-
this._referenceIndent = startElement.getAttribute('listIndent');
|
|
31
|
-
this._isForward = options.direction == 'forward';
|
|
32
|
-
this._includeSelf = !!options.includeSelf;
|
|
33
|
-
this._sameAttributes = toArray(options.sameAttributes || []);
|
|
34
|
-
this._sameIndent = !!options.sameIndent;
|
|
35
|
-
this._lowerIndent = !!options.lowerIndent;
|
|
36
|
-
this._higherIndent = !!options.higherIndent;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Performs only first step of iteration and returns the result.
|
|
40
|
-
*
|
|
41
|
-
* @param startElement The start list item block element.
|
|
42
|
-
* @param options.direction The iterating direction.
|
|
43
|
-
* @param options.includeSelf Whether start block should be included in the result (if it's matching other criteria).
|
|
44
|
-
* @param options.sameAttributes Additional attributes that must be the same for each block.
|
|
45
|
-
* @param options.sameIndent Whether blocks with the same indent level as the start block should be included
|
|
46
|
-
* in the result.
|
|
47
|
-
* @param options.lowerIndent Whether blocks with a lower indent level than the start block should be included
|
|
48
|
-
* in the result.
|
|
49
|
-
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
50
|
-
* in the result.
|
|
51
|
-
*/
|
|
52
|
-
static first(startElement, options) {
|
|
53
|
-
const walker = new this(startElement, options);
|
|
54
|
-
const iterator = walker[Symbol.iterator]();
|
|
55
|
-
return first(iterator);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Iterable interface.
|
|
59
|
-
*/
|
|
60
|
-
*[Symbol.iterator]() {
|
|
61
|
-
const nestedItems = [];
|
|
62
|
-
for (const { node } of iterateSiblingListBlocks(this._getStartNode(), this._isForward ? 'forward' : 'backward')) {
|
|
63
|
-
const indent = node.getAttribute('listIndent');
|
|
64
|
-
// Leaving a nested list.
|
|
65
|
-
if (indent < this._referenceIndent) {
|
|
66
|
-
// Abort searching blocks.
|
|
67
|
-
if (!this._lowerIndent) {
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
// While searching for lower indents, update the reference indent to find another parent in the next step.
|
|
71
|
-
this._referenceIndent = indent;
|
|
72
|
-
}
|
|
73
|
-
// Entering a nested list.
|
|
74
|
-
else if (indent > this._referenceIndent) {
|
|
75
|
-
// Ignore nested blocks.
|
|
76
|
-
if (!this._higherIndent) {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
// Collect nested blocks to verify if they are really nested, or it's a different item.
|
|
80
|
-
if (!this._isForward) {
|
|
81
|
-
nestedItems.push(node);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
// Same indent level block.
|
|
86
|
-
else {
|
|
87
|
-
// Ignore same indent block.
|
|
88
|
-
if (!this._sameIndent) {
|
|
89
|
-
// While looking for nested blocks, stop iterating while encountering first same indent block.
|
|
90
|
-
if (this._higherIndent) {
|
|
91
|
-
// No more nested blocks so yield nested items.
|
|
92
|
-
if (nestedItems.length) {
|
|
93
|
-
yield* nestedItems;
|
|
94
|
-
nestedItems.length = 0;
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
// Abort if item has any additionally specified attribute different.
|
|
101
|
-
if (this._sameAttributes.some(attr => node.getAttribute(attr) !== this._startElement.getAttribute(attr))) {
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
// There is another block for the same list item so the nested items were in the same list item.
|
|
106
|
-
if (nestedItems.length) {
|
|
107
|
-
yield* nestedItems;
|
|
108
|
-
nestedItems.length = 0;
|
|
109
|
-
}
|
|
110
|
-
yield node;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Returns the model element to start iterating.
|
|
115
|
-
*/
|
|
116
|
-
_getStartNode() {
|
|
117
|
-
if (this._includeSelf) {
|
|
118
|
-
return this._startElement;
|
|
119
|
-
}
|
|
120
|
-
return this._isForward ?
|
|
121
|
-
this._startElement.nextSibling :
|
|
122
|
-
this._startElement.previousSibling;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Iterates sibling list blocks starting from the given node.
|
|
127
|
-
*
|
|
128
|
-
* @internal
|
|
129
|
-
* @param node The model node.
|
|
130
|
-
* @param direction Iteration direction.
|
|
131
|
-
* @returns The object with `node` and `previous` {@link module:engine/model/element~Element blocks}.
|
|
132
|
-
*/
|
|
133
|
-
export function* iterateSiblingListBlocks(node, direction = 'forward') {
|
|
134
|
-
const isForward = direction == 'forward';
|
|
135
|
-
const previousNodesByIndent = []; // Last seen nodes of lower indented lists.
|
|
136
|
-
let previous = null;
|
|
137
|
-
while (isListItemBlock(node)) {
|
|
138
|
-
let previousNodeInList = null; // It's like `previous` but has the same indent as current node.
|
|
139
|
-
if (previous) {
|
|
140
|
-
const nodeIndent = node.getAttribute('listIndent');
|
|
141
|
-
const previousNodeIndent = previous.getAttribute('listIndent');
|
|
142
|
-
// Let's find previous node for the same indent.
|
|
143
|
-
// We're going to need that when we get back to previous indent.
|
|
144
|
-
if (nodeIndent > previousNodeIndent) {
|
|
145
|
-
previousNodesByIndent[previousNodeIndent] = previous;
|
|
146
|
-
}
|
|
147
|
-
// Restore the one for given indent.
|
|
148
|
-
else if (nodeIndent < previousNodeIndent) {
|
|
149
|
-
previousNodeInList = previousNodesByIndent[nodeIndent];
|
|
150
|
-
previousNodesByIndent.length = nodeIndent;
|
|
151
|
-
}
|
|
152
|
-
// Same indent.
|
|
153
|
-
else {
|
|
154
|
-
previousNodeInList = previous;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
yield { node, previous, previousNodeInList };
|
|
158
|
-
previous = node;
|
|
159
|
-
node = isForward ? node.nextSibling : node.previousSibling;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* The iterable protocol over the list elements.
|
|
164
|
-
*
|
|
165
|
-
* @internal
|
|
166
|
-
*/
|
|
167
|
-
export class ListBlocksIterable {
|
|
168
|
-
/**
|
|
169
|
-
* @param listHead The head element of a list.
|
|
170
|
-
*/
|
|
171
|
-
constructor(listHead) {
|
|
172
|
-
this._listHead = listHead;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* List blocks iterator.
|
|
176
|
-
*
|
|
177
|
-
* Iterates over all blocks of a list.
|
|
178
|
-
*/
|
|
179
|
-
[Symbol.iterator]() {
|
|
180
|
-
return iterateSiblingListBlocks(this._listHead, 'forward');
|
|
181
|
-
}
|
|
182
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module list/documentlist/utils/listwalker
|
|
7
|
+
*/
|
|
8
|
+
import { first, toArray } from 'ckeditor5/src/utils';
|
|
9
|
+
import { isListItemBlock } from './model';
|
|
10
|
+
/**
|
|
11
|
+
* Document list blocks iterator.
|
|
12
|
+
*/
|
|
13
|
+
export default class ListWalker {
|
|
14
|
+
/**
|
|
15
|
+
* Creates a document list iterator.
|
|
16
|
+
*
|
|
17
|
+
* @param startElement The start list item block element.
|
|
18
|
+
* @param options.direction The iterating direction.
|
|
19
|
+
* @param options.includeSelf Whether start block should be included in the result (if it's matching other criteria).
|
|
20
|
+
* @param options.sameAttributes Additional attributes that must be the same for each block.
|
|
21
|
+
* @param options.sameIndent Whether blocks with the same indent level as the start block should be included
|
|
22
|
+
* in the result.
|
|
23
|
+
* @param options.lowerIndent Whether blocks with a lower indent level than the start block should be included
|
|
24
|
+
* in the result.
|
|
25
|
+
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
26
|
+
* in the result.
|
|
27
|
+
*/
|
|
28
|
+
constructor(startElement, options) {
|
|
29
|
+
this._startElement = startElement;
|
|
30
|
+
this._referenceIndent = startElement.getAttribute('listIndent');
|
|
31
|
+
this._isForward = options.direction == 'forward';
|
|
32
|
+
this._includeSelf = !!options.includeSelf;
|
|
33
|
+
this._sameAttributes = toArray(options.sameAttributes || []);
|
|
34
|
+
this._sameIndent = !!options.sameIndent;
|
|
35
|
+
this._lowerIndent = !!options.lowerIndent;
|
|
36
|
+
this._higherIndent = !!options.higherIndent;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Performs only first step of iteration and returns the result.
|
|
40
|
+
*
|
|
41
|
+
* @param startElement The start list item block element.
|
|
42
|
+
* @param options.direction The iterating direction.
|
|
43
|
+
* @param options.includeSelf Whether start block should be included in the result (if it's matching other criteria).
|
|
44
|
+
* @param options.sameAttributes Additional attributes that must be the same for each block.
|
|
45
|
+
* @param options.sameIndent Whether blocks with the same indent level as the start block should be included
|
|
46
|
+
* in the result.
|
|
47
|
+
* @param options.lowerIndent Whether blocks with a lower indent level than the start block should be included
|
|
48
|
+
* in the result.
|
|
49
|
+
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
50
|
+
* in the result.
|
|
51
|
+
*/
|
|
52
|
+
static first(startElement, options) {
|
|
53
|
+
const walker = new this(startElement, options);
|
|
54
|
+
const iterator = walker[Symbol.iterator]();
|
|
55
|
+
return first(iterator);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Iterable interface.
|
|
59
|
+
*/
|
|
60
|
+
*[Symbol.iterator]() {
|
|
61
|
+
const nestedItems = [];
|
|
62
|
+
for (const { node } of iterateSiblingListBlocks(this._getStartNode(), this._isForward ? 'forward' : 'backward')) {
|
|
63
|
+
const indent = node.getAttribute('listIndent');
|
|
64
|
+
// Leaving a nested list.
|
|
65
|
+
if (indent < this._referenceIndent) {
|
|
66
|
+
// Abort searching blocks.
|
|
67
|
+
if (!this._lowerIndent) {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
// While searching for lower indents, update the reference indent to find another parent in the next step.
|
|
71
|
+
this._referenceIndent = indent;
|
|
72
|
+
}
|
|
73
|
+
// Entering a nested list.
|
|
74
|
+
else if (indent > this._referenceIndent) {
|
|
75
|
+
// Ignore nested blocks.
|
|
76
|
+
if (!this._higherIndent) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
// Collect nested blocks to verify if they are really nested, or it's a different item.
|
|
80
|
+
if (!this._isForward) {
|
|
81
|
+
nestedItems.push(node);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Same indent level block.
|
|
86
|
+
else {
|
|
87
|
+
// Ignore same indent block.
|
|
88
|
+
if (!this._sameIndent) {
|
|
89
|
+
// While looking for nested blocks, stop iterating while encountering first same indent block.
|
|
90
|
+
if (this._higherIndent) {
|
|
91
|
+
// No more nested blocks so yield nested items.
|
|
92
|
+
if (nestedItems.length) {
|
|
93
|
+
yield* nestedItems;
|
|
94
|
+
nestedItems.length = 0;
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
// Abort if item has any additionally specified attribute different.
|
|
101
|
+
if (this._sameAttributes.some(attr => node.getAttribute(attr) !== this._startElement.getAttribute(attr))) {
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// There is another block for the same list item so the nested items were in the same list item.
|
|
106
|
+
if (nestedItems.length) {
|
|
107
|
+
yield* nestedItems;
|
|
108
|
+
nestedItems.length = 0;
|
|
109
|
+
}
|
|
110
|
+
yield node;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Returns the model element to start iterating.
|
|
115
|
+
*/
|
|
116
|
+
_getStartNode() {
|
|
117
|
+
if (this._includeSelf) {
|
|
118
|
+
return this._startElement;
|
|
119
|
+
}
|
|
120
|
+
return this._isForward ?
|
|
121
|
+
this._startElement.nextSibling :
|
|
122
|
+
this._startElement.previousSibling;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Iterates sibling list blocks starting from the given node.
|
|
127
|
+
*
|
|
128
|
+
* @internal
|
|
129
|
+
* @param node The model node.
|
|
130
|
+
* @param direction Iteration direction.
|
|
131
|
+
* @returns The object with `node` and `previous` {@link module:engine/model/element~Element blocks}.
|
|
132
|
+
*/
|
|
133
|
+
export function* iterateSiblingListBlocks(node, direction = 'forward') {
|
|
134
|
+
const isForward = direction == 'forward';
|
|
135
|
+
const previousNodesByIndent = []; // Last seen nodes of lower indented lists.
|
|
136
|
+
let previous = null;
|
|
137
|
+
while (isListItemBlock(node)) {
|
|
138
|
+
let previousNodeInList = null; // It's like `previous` but has the same indent as current node.
|
|
139
|
+
if (previous) {
|
|
140
|
+
const nodeIndent = node.getAttribute('listIndent');
|
|
141
|
+
const previousNodeIndent = previous.getAttribute('listIndent');
|
|
142
|
+
// Let's find previous node for the same indent.
|
|
143
|
+
// We're going to need that when we get back to previous indent.
|
|
144
|
+
if (nodeIndent > previousNodeIndent) {
|
|
145
|
+
previousNodesByIndent[previousNodeIndent] = previous;
|
|
146
|
+
}
|
|
147
|
+
// Restore the one for given indent.
|
|
148
|
+
else if (nodeIndent < previousNodeIndent) {
|
|
149
|
+
previousNodeInList = previousNodesByIndent[nodeIndent];
|
|
150
|
+
previousNodesByIndent.length = nodeIndent;
|
|
151
|
+
}
|
|
152
|
+
// Same indent.
|
|
153
|
+
else {
|
|
154
|
+
previousNodeInList = previous;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
yield { node, previous, previousNodeInList };
|
|
158
|
+
previous = node;
|
|
159
|
+
node = isForward ? node.nextSibling : node.previousSibling;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The iterable protocol over the list elements.
|
|
164
|
+
*
|
|
165
|
+
* @internal
|
|
166
|
+
*/
|
|
167
|
+
export class ListBlocksIterable {
|
|
168
|
+
/**
|
|
169
|
+
* @param listHead The head element of a list.
|
|
170
|
+
*/
|
|
171
|
+
constructor(listHead) {
|
|
172
|
+
this._listHead = listHead;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* List blocks iterator.
|
|
176
|
+
*
|
|
177
|
+
* Iterates over all blocks of a list.
|
|
178
|
+
*/
|
|
179
|
+
[Symbol.iterator]() {
|
|
180
|
+
return iterateSiblingListBlocks(this._listHead, 'forward');
|
|
181
|
+
}
|
|
182
|
+
}
|