@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,46 +1,46 @@
|
|
|
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/documentlistutils
|
|
7
|
-
*/
|
|
8
|
-
import type { Element, Node } from 'ckeditor5/src/engine';
|
|
9
|
-
import type { ArrayOrItem } from 'ckeditor5/src/utils';
|
|
10
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
/**
|
|
12
|
-
* A set of helpers related to document lists.
|
|
13
|
-
*/
|
|
14
|
-
export default class DocumentListUtils extends Plugin {
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
static get pluginName(): "DocumentListUtils";
|
|
19
|
-
/**
|
|
20
|
-
* Expands the given list of selected blocks to include all the items of the lists they're in.
|
|
21
|
-
*
|
|
22
|
-
* @param blocks The list of selected blocks.
|
|
23
|
-
*/
|
|
24
|
-
expandListBlocksToCompleteList(blocks: ArrayOrItem<Element>): Array<Element>;
|
|
25
|
-
/**
|
|
26
|
-
* Check if the given block is the first in the list item.
|
|
27
|
-
*
|
|
28
|
-
* @param listBlock The list block element.
|
|
29
|
-
*/
|
|
30
|
-
isFirstBlockOfListItem(listBlock: Element): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Returns true if the given model node is a list item block.
|
|
33
|
-
*
|
|
34
|
-
* @param node A model node.
|
|
35
|
-
*/
|
|
36
|
-
isListItemBlock(node: Node): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.
|
|
39
|
-
*
|
|
40
|
-
* @param blocks The list of selected blocks.
|
|
41
|
-
* @param options.withNested Whether should include nested list items.
|
|
42
|
-
*/
|
|
43
|
-
expandListBlocksToCompleteItems(blocks: ArrayOrItem<Element>, options?: {
|
|
44
|
-
withNested?: boolean;
|
|
45
|
-
}): Array<Element>;
|
|
46
|
-
}
|
|
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/documentlistutils
|
|
7
|
+
*/
|
|
8
|
+
import type { Element, Node } from 'ckeditor5/src/engine';
|
|
9
|
+
import type { ArrayOrItem } from 'ckeditor5/src/utils';
|
|
10
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
+
/**
|
|
12
|
+
* A set of helpers related to document lists.
|
|
13
|
+
*/
|
|
14
|
+
export default class DocumentListUtils extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get pluginName(): "DocumentListUtils";
|
|
19
|
+
/**
|
|
20
|
+
* Expands the given list of selected blocks to include all the items of the lists they're in.
|
|
21
|
+
*
|
|
22
|
+
* @param blocks The list of selected blocks.
|
|
23
|
+
*/
|
|
24
|
+
expandListBlocksToCompleteList(blocks: ArrayOrItem<Element>): Array<Element>;
|
|
25
|
+
/**
|
|
26
|
+
* Check if the given block is the first in the list item.
|
|
27
|
+
*
|
|
28
|
+
* @param listBlock The list block element.
|
|
29
|
+
*/
|
|
30
|
+
isFirstBlockOfListItem(listBlock: Element): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if the given model node is a list item block.
|
|
33
|
+
*
|
|
34
|
+
* @param node A model node.
|
|
35
|
+
*/
|
|
36
|
+
isListItemBlock(node: Node): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.
|
|
39
|
+
*
|
|
40
|
+
* @param blocks The list of selected blocks.
|
|
41
|
+
* @param options.withNested Whether should include nested list items.
|
|
42
|
+
*/
|
|
43
|
+
expandListBlocksToCompleteItems(blocks: ArrayOrItem<Element>, options?: {
|
|
44
|
+
withNested?: boolean;
|
|
45
|
+
}): Array<Element>;
|
|
46
|
+
}
|
|
@@ -1,50 +1,50 @@
|
|
|
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
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
6
|
-
import { expandListBlocksToCompleteItems, expandListBlocksToCompleteList, isFirstBlockOfListItem, isListItemBlock } from './utils/model';
|
|
7
|
-
/**
|
|
8
|
-
* A set of helpers related to document lists.
|
|
9
|
-
*/
|
|
10
|
-
export default class DocumentListUtils extends Plugin {
|
|
11
|
-
/**
|
|
12
|
-
* @inheritDoc
|
|
13
|
-
*/
|
|
14
|
-
static get pluginName() {
|
|
15
|
-
return 'DocumentListUtils';
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Expands the given list of selected blocks to include all the items of the lists they're in.
|
|
19
|
-
*
|
|
20
|
-
* @param blocks The list of selected blocks.
|
|
21
|
-
*/
|
|
22
|
-
expandListBlocksToCompleteList(blocks) {
|
|
23
|
-
return expandListBlocksToCompleteList(blocks);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Check if the given block is the first in the list item.
|
|
27
|
-
*
|
|
28
|
-
* @param listBlock The list block element.
|
|
29
|
-
*/
|
|
30
|
-
isFirstBlockOfListItem(listBlock) {
|
|
31
|
-
return isFirstBlockOfListItem(listBlock);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Returns true if the given model node is a list item block.
|
|
35
|
-
*
|
|
36
|
-
* @param node A model node.
|
|
37
|
-
*/
|
|
38
|
-
isListItemBlock(node) {
|
|
39
|
-
return isListItemBlock(node);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.
|
|
43
|
-
*
|
|
44
|
-
* @param blocks The list of selected blocks.
|
|
45
|
-
* @param options.withNested Whether should include nested list items.
|
|
46
|
-
*/
|
|
47
|
-
expandListBlocksToCompleteItems(blocks, options = {}) {
|
|
48
|
-
return expandListBlocksToCompleteItems(blocks, options);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
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
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
6
|
+
import { expandListBlocksToCompleteItems, expandListBlocksToCompleteList, isFirstBlockOfListItem, isListItemBlock } from './utils/model';
|
|
7
|
+
/**
|
|
8
|
+
* A set of helpers related to document lists.
|
|
9
|
+
*/
|
|
10
|
+
export default class DocumentListUtils extends Plugin {
|
|
11
|
+
/**
|
|
12
|
+
* @inheritDoc
|
|
13
|
+
*/
|
|
14
|
+
static get pluginName() {
|
|
15
|
+
return 'DocumentListUtils';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Expands the given list of selected blocks to include all the items of the lists they're in.
|
|
19
|
+
*
|
|
20
|
+
* @param blocks The list of selected blocks.
|
|
21
|
+
*/
|
|
22
|
+
expandListBlocksToCompleteList(blocks) {
|
|
23
|
+
return expandListBlocksToCompleteList(blocks);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Check if the given block is the first in the list item.
|
|
27
|
+
*
|
|
28
|
+
* @param listBlock The list block element.
|
|
29
|
+
*/
|
|
30
|
+
isFirstBlockOfListItem(listBlock) {
|
|
31
|
+
return isFirstBlockOfListItem(listBlock);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns true if the given model node is a list item block.
|
|
35
|
+
*
|
|
36
|
+
* @param node A model node.
|
|
37
|
+
*/
|
|
38
|
+
isListItemBlock(node) {
|
|
39
|
+
return isListItemBlock(node);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.
|
|
43
|
+
*
|
|
44
|
+
* @param blocks The list of selected blocks.
|
|
45
|
+
* @param options.withNested Whether should include nested list items.
|
|
46
|
+
*/
|
|
47
|
+
expandListBlocksToCompleteItems(blocks, options = {}) {
|
|
48
|
+
return expandListBlocksToCompleteItems(blocks, options);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,145 +1,145 @@
|
|
|
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 { type ArrayOrItem } from 'ckeditor5/src/utils';
|
|
9
|
-
import { type ListElement } from './model';
|
|
10
|
-
import type { Element, Node } from 'ckeditor5/src/engine';
|
|
11
|
-
/**
|
|
12
|
-
* Document list blocks iterator.
|
|
13
|
-
*/
|
|
14
|
-
export default class ListWalker {
|
|
15
|
-
/**
|
|
16
|
-
* The start list item block element.
|
|
17
|
-
*/
|
|
18
|
-
private _startElement;
|
|
19
|
-
/**
|
|
20
|
-
* The reference indent. Initialized by the indent of the start block.
|
|
21
|
-
*/
|
|
22
|
-
private _referenceIndent;
|
|
23
|
-
/**
|
|
24
|
-
* The iterating direction.
|
|
25
|
-
*/
|
|
26
|
-
private _isForward;
|
|
27
|
-
/**
|
|
28
|
-
* Whether start block should be included in the result (if it's matching other criteria).
|
|
29
|
-
*/
|
|
30
|
-
private _includeSelf;
|
|
31
|
-
/**
|
|
32
|
-
* Additional attributes that must be the same for each block.
|
|
33
|
-
*/
|
|
34
|
-
private _sameAttributes;
|
|
35
|
-
/**
|
|
36
|
-
* Whether blocks with the same indent level as the start block should be included in the result.
|
|
37
|
-
*/
|
|
38
|
-
private _sameIndent;
|
|
39
|
-
/**
|
|
40
|
-
* Whether blocks with a lower indent level than the start block should be included in the result.
|
|
41
|
-
*/
|
|
42
|
-
private _lowerIndent;
|
|
43
|
-
/**
|
|
44
|
-
* Whether blocks with a higher indent level than the start block should be included in the result.
|
|
45
|
-
*/
|
|
46
|
-
private _higherIndent;
|
|
47
|
-
/**
|
|
48
|
-
* Creates a document list iterator.
|
|
49
|
-
*
|
|
50
|
-
* @param startElement The start list item block element.
|
|
51
|
-
* @param options.direction The iterating direction.
|
|
52
|
-
* @param options.includeSelf Whether start block should be included in the result (if it's matching other criteria).
|
|
53
|
-
* @param options.sameAttributes Additional attributes that must be the same for each block.
|
|
54
|
-
* @param options.sameIndent Whether blocks with the same indent level as the start block should be included
|
|
55
|
-
* in the result.
|
|
56
|
-
* @param options.lowerIndent Whether blocks with a lower indent level than the start block should be included
|
|
57
|
-
* in the result.
|
|
58
|
-
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
59
|
-
* in the result.
|
|
60
|
-
*/
|
|
61
|
-
constructor(startElement: Node, options: {
|
|
62
|
-
direction?: 'forward' | 'backward';
|
|
63
|
-
includeSelf?: boolean;
|
|
64
|
-
sameAttributes?: ArrayOrItem<string>;
|
|
65
|
-
sameIndent?: boolean;
|
|
66
|
-
lowerIndent?: boolean;
|
|
67
|
-
higherIndent?: boolean;
|
|
68
|
-
});
|
|
69
|
-
/**
|
|
70
|
-
* Performs only first step of iteration and returns the result.
|
|
71
|
-
*
|
|
72
|
-
* @param startElement The start list item block element.
|
|
73
|
-
* @param options.direction The iterating direction.
|
|
74
|
-
* @param options.includeSelf Whether start block should be included in the result (if it's matching other criteria).
|
|
75
|
-
* @param options.sameAttributes Additional attributes that must be the same for each block.
|
|
76
|
-
* @param options.sameIndent Whether blocks with the same indent level as the start block should be included
|
|
77
|
-
* in the result.
|
|
78
|
-
* @param options.lowerIndent Whether blocks with a lower indent level than the start block should be included
|
|
79
|
-
* in the result.
|
|
80
|
-
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
81
|
-
* in the result.
|
|
82
|
-
*/
|
|
83
|
-
static first(startElement: Node, options: {
|
|
84
|
-
direction?: 'forward' | 'backward';
|
|
85
|
-
includeSelf?: boolean;
|
|
86
|
-
sameAttributes?: ArrayOrItem<string>;
|
|
87
|
-
sameIndent?: boolean;
|
|
88
|
-
lowerIndent?: boolean;
|
|
89
|
-
higherIndent?: boolean;
|
|
90
|
-
}): ListElement | null;
|
|
91
|
-
/**
|
|
92
|
-
* Iterable interface.
|
|
93
|
-
*/
|
|
94
|
-
[Symbol.iterator](): Iterator<ListElement>;
|
|
95
|
-
/**
|
|
96
|
-
* Returns the model element to start iterating.
|
|
97
|
-
*/
|
|
98
|
-
private _getStartNode;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Iterates sibling list blocks starting from the given node.
|
|
102
|
-
*
|
|
103
|
-
* @internal
|
|
104
|
-
* @param node The model node.
|
|
105
|
-
* @param direction Iteration direction.
|
|
106
|
-
* @returns The object with `node` and `previous` {@link module:engine/model/element~Element blocks}.
|
|
107
|
-
*/
|
|
108
|
-
export declare function iterateSiblingListBlocks(node: Node | null, direction?: 'forward' | 'backward'): IterableIterator<ListIteratorValue>;
|
|
109
|
-
/**
|
|
110
|
-
* The iterable protocol over the list elements.
|
|
111
|
-
*
|
|
112
|
-
* @internal
|
|
113
|
-
*/
|
|
114
|
-
export declare class ListBlocksIterable {
|
|
115
|
-
private _listHead;
|
|
116
|
-
/**
|
|
117
|
-
* @param listHead The head element of a list.
|
|
118
|
-
*/
|
|
119
|
-
constructor(listHead: Element);
|
|
120
|
-
/**
|
|
121
|
-
* List blocks iterator.
|
|
122
|
-
*
|
|
123
|
-
* Iterates over all blocks of a list.
|
|
124
|
-
*/
|
|
125
|
-
[Symbol.iterator](): Iterator<ListIteratorValue>;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Object returned by `iterateSiblingListBlocks()` when traversing a list.
|
|
129
|
-
*
|
|
130
|
-
* @internal
|
|
131
|
-
*/
|
|
132
|
-
export interface ListIteratorValue {
|
|
133
|
-
/**
|
|
134
|
-
* The current list node.
|
|
135
|
-
*/
|
|
136
|
-
node: ListElement;
|
|
137
|
-
/**
|
|
138
|
-
* The previous list node.
|
|
139
|
-
*/
|
|
140
|
-
previous: ListElement | null;
|
|
141
|
-
/**
|
|
142
|
-
* The previous list node at the same indent as current node.
|
|
143
|
-
*/
|
|
144
|
-
previousNodeInList: ListElement | null;
|
|
145
|
-
}
|
|
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 { type ArrayOrItem } from 'ckeditor5/src/utils';
|
|
9
|
+
import { type ListElement } from './model';
|
|
10
|
+
import type { Element, Node } from 'ckeditor5/src/engine';
|
|
11
|
+
/**
|
|
12
|
+
* Document list blocks iterator.
|
|
13
|
+
*/
|
|
14
|
+
export default class ListWalker {
|
|
15
|
+
/**
|
|
16
|
+
* The start list item block element.
|
|
17
|
+
*/
|
|
18
|
+
private _startElement;
|
|
19
|
+
/**
|
|
20
|
+
* The reference indent. Initialized by the indent of the start block.
|
|
21
|
+
*/
|
|
22
|
+
private _referenceIndent;
|
|
23
|
+
/**
|
|
24
|
+
* The iterating direction.
|
|
25
|
+
*/
|
|
26
|
+
private _isForward;
|
|
27
|
+
/**
|
|
28
|
+
* Whether start block should be included in the result (if it's matching other criteria).
|
|
29
|
+
*/
|
|
30
|
+
private _includeSelf;
|
|
31
|
+
/**
|
|
32
|
+
* Additional attributes that must be the same for each block.
|
|
33
|
+
*/
|
|
34
|
+
private _sameAttributes;
|
|
35
|
+
/**
|
|
36
|
+
* Whether blocks with the same indent level as the start block should be included in the result.
|
|
37
|
+
*/
|
|
38
|
+
private _sameIndent;
|
|
39
|
+
/**
|
|
40
|
+
* Whether blocks with a lower indent level than the start block should be included in the result.
|
|
41
|
+
*/
|
|
42
|
+
private _lowerIndent;
|
|
43
|
+
/**
|
|
44
|
+
* Whether blocks with a higher indent level than the start block should be included in the result.
|
|
45
|
+
*/
|
|
46
|
+
private _higherIndent;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a document list iterator.
|
|
49
|
+
*
|
|
50
|
+
* @param startElement The start list item block element.
|
|
51
|
+
* @param options.direction The iterating direction.
|
|
52
|
+
* @param options.includeSelf Whether start block should be included in the result (if it's matching other criteria).
|
|
53
|
+
* @param options.sameAttributes Additional attributes that must be the same for each block.
|
|
54
|
+
* @param options.sameIndent Whether blocks with the same indent level as the start block should be included
|
|
55
|
+
* in the result.
|
|
56
|
+
* @param options.lowerIndent Whether blocks with a lower indent level than the start block should be included
|
|
57
|
+
* in the result.
|
|
58
|
+
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
59
|
+
* in the result.
|
|
60
|
+
*/
|
|
61
|
+
constructor(startElement: Node, options: {
|
|
62
|
+
direction?: 'forward' | 'backward';
|
|
63
|
+
includeSelf?: boolean;
|
|
64
|
+
sameAttributes?: ArrayOrItem<string>;
|
|
65
|
+
sameIndent?: boolean;
|
|
66
|
+
lowerIndent?: boolean;
|
|
67
|
+
higherIndent?: boolean;
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Performs only first step of iteration and returns the result.
|
|
71
|
+
*
|
|
72
|
+
* @param startElement The start list item block element.
|
|
73
|
+
* @param options.direction The iterating direction.
|
|
74
|
+
* @param options.includeSelf Whether start block should be included in the result (if it's matching other criteria).
|
|
75
|
+
* @param options.sameAttributes Additional attributes that must be the same for each block.
|
|
76
|
+
* @param options.sameIndent Whether blocks with the same indent level as the start block should be included
|
|
77
|
+
* in the result.
|
|
78
|
+
* @param options.lowerIndent Whether blocks with a lower indent level than the start block should be included
|
|
79
|
+
* in the result.
|
|
80
|
+
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
81
|
+
* in the result.
|
|
82
|
+
*/
|
|
83
|
+
static first(startElement: Node, options: {
|
|
84
|
+
direction?: 'forward' | 'backward';
|
|
85
|
+
includeSelf?: boolean;
|
|
86
|
+
sameAttributes?: ArrayOrItem<string>;
|
|
87
|
+
sameIndent?: boolean;
|
|
88
|
+
lowerIndent?: boolean;
|
|
89
|
+
higherIndent?: boolean;
|
|
90
|
+
}): ListElement | null;
|
|
91
|
+
/**
|
|
92
|
+
* Iterable interface.
|
|
93
|
+
*/
|
|
94
|
+
[Symbol.iterator](): Iterator<ListElement>;
|
|
95
|
+
/**
|
|
96
|
+
* Returns the model element to start iterating.
|
|
97
|
+
*/
|
|
98
|
+
private _getStartNode;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Iterates sibling list blocks starting from the given node.
|
|
102
|
+
*
|
|
103
|
+
* @internal
|
|
104
|
+
* @param node The model node.
|
|
105
|
+
* @param direction Iteration direction.
|
|
106
|
+
* @returns The object with `node` and `previous` {@link module:engine/model/element~Element blocks}.
|
|
107
|
+
*/
|
|
108
|
+
export declare function iterateSiblingListBlocks(node: Node | null, direction?: 'forward' | 'backward'): IterableIterator<ListIteratorValue>;
|
|
109
|
+
/**
|
|
110
|
+
* The iterable protocol over the list elements.
|
|
111
|
+
*
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
export declare class ListBlocksIterable {
|
|
115
|
+
private _listHead;
|
|
116
|
+
/**
|
|
117
|
+
* @param listHead The head element of a list.
|
|
118
|
+
*/
|
|
119
|
+
constructor(listHead: Element);
|
|
120
|
+
/**
|
|
121
|
+
* List blocks iterator.
|
|
122
|
+
*
|
|
123
|
+
* Iterates over all blocks of a list.
|
|
124
|
+
*/
|
|
125
|
+
[Symbol.iterator](): Iterator<ListIteratorValue>;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Object returned by `iterateSiblingListBlocks()` when traversing a list.
|
|
129
|
+
*
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
export interface ListIteratorValue {
|
|
133
|
+
/**
|
|
134
|
+
* The current list node.
|
|
135
|
+
*/
|
|
136
|
+
node: ListElement;
|
|
137
|
+
/**
|
|
138
|
+
* The previous list node.
|
|
139
|
+
*/
|
|
140
|
+
previous: ListElement | null;
|
|
141
|
+
/**
|
|
142
|
+
* The previous list node at the same indent as current node.
|
|
143
|
+
*/
|
|
144
|
+
previousNodeInList: ListElement | null;
|
|
145
|
+
}
|