1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
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 |
|
13 |
|
14 | export default class ListWalker {
|
15 | |
16 |
|
17 |
|
18 | private _startElement;
|
19 | |
20 |
|
21 |
|
22 | private _referenceIndent;
|
23 | |
24 |
|
25 |
|
26 | private _isForward;
|
27 | |
28 |
|
29 |
|
30 | private _includeSelf;
|
31 | |
32 |
|
33 |
|
34 | private _sameAttributes;
|
35 | |
36 |
|
37 |
|
38 | private _sameIndent;
|
39 | |
40 |
|
41 |
|
42 | private _lowerIndent;
|
43 | |
44 |
|
45 |
|
46 | private _higherIndent;
|
47 | |
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
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 |
|
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 |
|
135 |
|
136 | node: ListElement;
|
137 | |
138 |
|
139 |
|
140 | previous: ListElement | null;
|
141 | }
|