@ckeditor/ckeditor5-list 36.0.0 → 37.0.0-alpha.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/build/list.js +1 -1
- package/package.json +39 -38
- package/src/documentlist/converters.d.ts +63 -0
- package/src/documentlist/converters.js +4 -4
- package/src/documentlist/documentlistcommand.d.ts +81 -0
- package/src/documentlist/documentlistcommand.js +1 -0
- package/src/documentlist/documentlistediting.d.ts +156 -0
- package/src/documentlist/documentlistindentcommand.d.ts +63 -0
- package/src/documentlist/documentlistindentcommand.js +1 -0
- package/src/documentlist/documentlistmergecommand.d.ts +77 -0
- package/src/documentlist/documentlistmergecommand.js +1 -0
- package/src/documentlist/documentlistsplitcommand.d.ts +68 -0
- package/src/documentlist/documentlistsplitcommand.js +1 -0
- package/src/documentlist/documentlistutils.d.ts +42 -0
- package/src/documentlist/utils/listwalker.d.ts +141 -0
- package/src/documentlist/utils/model.d.ts +193 -0
- package/src/documentlist/utils/postfixers.d.ts +37 -0
- package/src/documentlist/utils/view.d.ts +81 -0
- package/src/documentlist.d.ts +30 -0
- package/src/documentlist.js +1 -0
- package/src/documentlistproperties/converters.d.ts +19 -0
- package/src/documentlistproperties/documentlistpropertiesediting.d.ts +92 -0
- package/src/documentlistproperties/documentlistpropertiesutils.d.ts +38 -0
- package/src/documentlistproperties/documentlistreversedcommand.d.ts +37 -0
- package/src/documentlistproperties/documentlistreversedcommand.js +1 -0
- package/src/documentlistproperties/documentliststartcommand.d.ts +39 -0
- package/src/documentlistproperties/documentliststartcommand.js +1 -0
- package/src/documentlistproperties/documentliststylecommand.d.ts +73 -0
- package/src/documentlistproperties/documentliststylecommand.js +1 -0
- package/src/documentlistproperties/utils/style.d.ts +20 -0
- package/src/documentlistproperties.d.ts +31 -0
- package/src/documentlistproperties.js +1 -0
- package/src/index.d.ts +25 -0
- package/src/index.js +2 -0
- package/src/list/converters.d.ts +196 -0
- package/src/list/converters.js +2 -2
- package/src/list/indentcommand.d.ts +39 -0
- package/src/list/indentcommand.js +1 -0
- package/src/list/listcommand.d.ts +56 -0
- package/src/list/listcommand.js +1 -0
- package/src/list/listediting.d.ts +34 -0
- package/src/list/listui.d.ts +24 -0
- package/src/list/listutils.d.ts +46 -0
- package/src/list/utils.d.ts +113 -0
- package/src/list/utils.js +2 -1
- package/src/list.d.ts +26 -0
- package/src/listcommands.d.ts +37 -0
- package/src/listconfig.d.ts +132 -0
- package/src/listproperties/listpropertiesediting.d.ts +76 -0
- package/src/listproperties/listpropertiesui.d.ts +29 -0
- package/src/listproperties/listpropertiesui.js +1 -0
- package/src/listproperties/listreversedcommand.d.ts +39 -0
- package/src/listproperties/listreversedcommand.js +1 -0
- package/src/listproperties/liststartcommand.d.ts +38 -0
- package/src/listproperties/liststartcommand.js +1 -0
- package/src/listproperties/liststylecommand.d.ts +68 -0
- package/src/listproperties/liststylecommand.js +2 -1
- package/src/listproperties/ui/collapsibleview.d.ts +63 -0
- package/src/listproperties/ui/listpropertiesview.d.ts +157 -0
- package/src/listproperties.d.ts +30 -0
- package/src/listproperties.js +1 -0
- package/src/liststyle.d.ts +32 -0
- package/src/todolist/checktodolistcommand.d.ts +53 -0
- package/src/todolist/checktodolistcommand.js +1 -0
- package/src/todolist/todolistconverters.d.ts +82 -0
- package/src/todolist/todolistediting.d.ts +43 -0
- package/src/todolist/todolistui.d.ts +24 -0
- package/src/todolist.d.ts +27 -0
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
39
|
+
interface PluginsMap {
|
|
40
|
+
[DocumentListUtils.pluginName]: DocumentListUtils;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
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/model
|
|
7
|
+
*/
|
|
8
|
+
import type { DocumentFragment, Element, Model, Node, Writer, Item } from 'ckeditor5/src/engine';
|
|
9
|
+
import { type ArrayOrItem } from 'ckeditor5/src/utils';
|
|
10
|
+
/**
|
|
11
|
+
* The list item ID generator.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare class ListItemUid {
|
|
16
|
+
/**
|
|
17
|
+
* Returns the next ID.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
static next(): string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* An {@link module:engine/model/element~Element} that is known to be a list element.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export interface ListElement extends Element {
|
|
29
|
+
getAttribute(key: 'listItemId'): string;
|
|
30
|
+
getAttribute(key: 'listIndent'): number;
|
|
31
|
+
getAttribute(key: 'listType'): 'numbered' | 'bulleted';
|
|
32
|
+
getAttribute(key: string): unknown;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns true if the given model node is a list item block.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare function isListItemBlock(node: Item | DocumentFragment | null): node is ListElement;
|
|
40
|
+
/**
|
|
41
|
+
* Returns an array with all elements that represents the same list item.
|
|
42
|
+
*
|
|
43
|
+
* It means that values for `listIndent`, and `listItemId` for all items are equal.
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
* @param listItem Starting list item element.
|
|
47
|
+
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
48
|
+
* in the result.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getAllListItemBlocks(listItem: Node, options?: {
|
|
51
|
+
higherIndent?: boolean;
|
|
52
|
+
}): Array<ListElement>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns an array with elements that represents the same list item in the specified direction.
|
|
55
|
+
*
|
|
56
|
+
* It means that values for `listIndent` and `listItemId` for all items are equal.
|
|
57
|
+
*
|
|
58
|
+
* **Note**: For backward search the provided item is not included, but for forward search it is included in the result.
|
|
59
|
+
*
|
|
60
|
+
* @internal
|
|
61
|
+
* @param listItem Starting list item element.
|
|
62
|
+
* @param options.direction Walking direction.
|
|
63
|
+
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included in the result.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getListItemBlocks(listItem: Node, options?: {
|
|
66
|
+
direction?: 'forward' | 'backward';
|
|
67
|
+
higherIndent?: boolean;
|
|
68
|
+
}): Array<ListElement>;
|
|
69
|
+
/**
|
|
70
|
+
* Returns a list items nested inside the given list item.
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
export declare function getNestedListBlocks(listItem: Element): Array<ListElement>;
|
|
75
|
+
/**
|
|
76
|
+
* Returns array of all blocks/items of the same list as given block (same indent, same type and properties).
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
* @param listItem Starting list item element.
|
|
80
|
+
*/
|
|
81
|
+
export declare function getListItems(listItem: Element): Array<ListElement>;
|
|
82
|
+
/**
|
|
83
|
+
* Check if the given block is the first in the list item.
|
|
84
|
+
*
|
|
85
|
+
* @internal
|
|
86
|
+
* @param listBlock The list block element.
|
|
87
|
+
*/
|
|
88
|
+
export declare function isFirstBlockOfListItem(listBlock: Node): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Check if the given block is the last in the list item.
|
|
91
|
+
*
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export declare function isLastBlockOfListItem(listBlock: Element): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.
|
|
97
|
+
*
|
|
98
|
+
* @internal
|
|
99
|
+
* @param blocks The list of selected blocks.
|
|
100
|
+
* @param options.withNested Whether should include nested list items.
|
|
101
|
+
*/
|
|
102
|
+
export declare function expandListBlocksToCompleteItems(blocks: ArrayOrItem<Element>, options?: {
|
|
103
|
+
withNested?: boolean;
|
|
104
|
+
}): Array<ListElement>;
|
|
105
|
+
/**
|
|
106
|
+
* Expands the given list of selected blocks to include all the items of the lists they're in.
|
|
107
|
+
*
|
|
108
|
+
* @internal
|
|
109
|
+
* @param blocks The list of selected blocks.
|
|
110
|
+
*/
|
|
111
|
+
export declare function expandListBlocksToCompleteList(blocks: ArrayOrItem<Element>): Array<ListElement>;
|
|
112
|
+
/**
|
|
113
|
+
* Splits the list item just before the provided list block.
|
|
114
|
+
*
|
|
115
|
+
* @internal
|
|
116
|
+
* @param listBlock The list block element.
|
|
117
|
+
* @param writer The model writer.
|
|
118
|
+
* @returns The array of updated blocks.
|
|
119
|
+
*/
|
|
120
|
+
export declare function splitListItemBefore(listBlock: Element, writer: Writer): Array<ListElement>;
|
|
121
|
+
/**
|
|
122
|
+
* Merges the list item with the parent list item.
|
|
123
|
+
*
|
|
124
|
+
* @internal
|
|
125
|
+
* @param listBlock The list block element.
|
|
126
|
+
* @param parentBlock The list block element to merge with.
|
|
127
|
+
* @param writer The model writer.
|
|
128
|
+
* @returns The array of updated blocks.
|
|
129
|
+
*/
|
|
130
|
+
export declare function mergeListItemBefore(listBlock: Node, parentBlock: Element, writer: Writer): Array<ListElement>;
|
|
131
|
+
/**
|
|
132
|
+
* Increases indentation of given list blocks.
|
|
133
|
+
*
|
|
134
|
+
* @internal
|
|
135
|
+
* @param blocks The block or iterable of blocks.
|
|
136
|
+
* @param writer The model writer.
|
|
137
|
+
* @param options.expand Whether should expand the list of blocks to include complete list items.
|
|
138
|
+
* @param options.indentBy The number of levels the indentation should change (could be negative).
|
|
139
|
+
*/
|
|
140
|
+
export declare function indentBlocks(blocks: ArrayOrItem<ListElement>, writer: Writer, { expand, indentBy }?: {
|
|
141
|
+
expand?: boolean;
|
|
142
|
+
indentBy?: number;
|
|
143
|
+
}): Array<ListElement>;
|
|
144
|
+
/**
|
|
145
|
+
* Decreases indentation of given list of blocks. If the indentation of some blocks matches the indentation
|
|
146
|
+
* of surrounding blocks, they get merged together.
|
|
147
|
+
*
|
|
148
|
+
* @internal
|
|
149
|
+
* @param blocks The block or iterable of blocks.
|
|
150
|
+
* @param writer The model writer.
|
|
151
|
+
*/
|
|
152
|
+
export declare function outdentBlocksWithMerge(blocks: ArrayOrItem<ListElement>, writer: Writer): Array<ListElement>;
|
|
153
|
+
/**
|
|
154
|
+
* Removes all list attributes from the given blocks.
|
|
155
|
+
*
|
|
156
|
+
* @internal
|
|
157
|
+
* @param blocks The block or iterable of blocks.
|
|
158
|
+
* @param writer The model writer.
|
|
159
|
+
* @returns Array of altered blocks.
|
|
160
|
+
*/
|
|
161
|
+
export declare function removeListAttributes(blocks: ArrayOrItem<Element>, writer: Writer): Array<Element>;
|
|
162
|
+
/**
|
|
163
|
+
* Checks whether the given blocks are related to a single list item.
|
|
164
|
+
*
|
|
165
|
+
* @internal
|
|
166
|
+
* @param blocks The list block elements.
|
|
167
|
+
*/
|
|
168
|
+
export declare function isSingleListItem(blocks: Array<Node>): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Modifies the indents of list blocks following the given list block so the indentation is valid after
|
|
171
|
+
* the given block is no longer a list item.
|
|
172
|
+
*
|
|
173
|
+
* @internal
|
|
174
|
+
* @param lastBlock The last list block that has become a non-list element.
|
|
175
|
+
* @param writer The model writer.
|
|
176
|
+
* @returns Array of altered blocks.
|
|
177
|
+
*/
|
|
178
|
+
export declare function outdentFollowingItems(lastBlock: Element, writer: Writer): Array<ListElement>;
|
|
179
|
+
/**
|
|
180
|
+
* Returns the array of given blocks sorted by model indexes (document order).
|
|
181
|
+
*
|
|
182
|
+
* @internal
|
|
183
|
+
*/
|
|
184
|
+
export declare function sortBlocks<T extends Element>(blocks: Iterable<T>): Array<T>;
|
|
185
|
+
/**
|
|
186
|
+
* Returns a selected block object. If a selected object is inline or when there is no selected
|
|
187
|
+
* object, `null` is returned.
|
|
188
|
+
*
|
|
189
|
+
* @internal
|
|
190
|
+
* @param model The instance of editor model.
|
|
191
|
+
* @returns Selected block object or `null`.
|
|
192
|
+
*/
|
|
193
|
+
export declare function getSelectedBlockObject(model: Model): Element | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
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/postfixers
|
|
7
|
+
*/
|
|
8
|
+
import type { Position, Writer } from 'ckeditor5/src/engine';
|
|
9
|
+
import { type ListIteratorValue } from './listwalker';
|
|
10
|
+
import { type ListElement } from './model';
|
|
11
|
+
/**
|
|
12
|
+
* Based on the provided positions looks for the list head and stores it in the provided map.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
* @param position The search starting position.
|
|
16
|
+
* @param itemToListHead The map from list item element to the list head element.
|
|
17
|
+
*/
|
|
18
|
+
export declare function findAndAddListHeadToMap(position: Position, itemToListHead: Map<ListElement, ListElement>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Scans the list starting from the given list head element and fixes items' indentation.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
* @param listNodes The iterable of list nodes.
|
|
24
|
+
* @param writer The model writer.
|
|
25
|
+
* @returns Whether the model was modified.
|
|
26
|
+
*/
|
|
27
|
+
export declare function fixListIndents(listNodes: Iterable<ListIteratorValue>, writer: Writer): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Scans the list starting from the given list head element and fixes items' types.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
* @param listNodes The iterable of list nodes.
|
|
33
|
+
* @param seenIds The set of already known IDs.
|
|
34
|
+
* @param writer The model writer.
|
|
35
|
+
* @returns Whether the model was modified.
|
|
36
|
+
*/
|
|
37
|
+
export declare function fixListItemIds(listNodes: Iterable<ListIteratorValue>, seenIds: Set<string>, writer: Writer): boolean;
|
|
@@ -0,0 +1,81 @@
|
|
|
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/view
|
|
7
|
+
*/
|
|
8
|
+
import type { DowncastWriter, ViewAttributeElement, ViewDocumentFragment, ViewElement, ViewNode } from 'ckeditor5/src/engine';
|
|
9
|
+
/**
|
|
10
|
+
* Checks if view element is a list type (ul or ol).
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare function isListView(viewElement: ViewNode | ViewDocumentFragment): viewElement is ViewElement & {
|
|
15
|
+
name: 'ul' | 'ol';
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Checks if view element is a list item (li).
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare function isListItemView(viewElement: ViewNode | ViewDocumentFragment): viewElement is ViewElement & {
|
|
23
|
+
name: 'li';
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Calculates the indent value for a list item. Handles HTML compliant and non-compliant lists.
|
|
27
|
+
*
|
|
28
|
+
* Also, fixes non HTML compliant lists indents:
|
|
29
|
+
*
|
|
30
|
+
* ```
|
|
31
|
+
* before: fixed list:
|
|
32
|
+
* OL OL
|
|
33
|
+
* |-> LI (parent LIs: 0) |-> LI (indent: 0)
|
|
34
|
+
* |-> OL |-> OL
|
|
35
|
+
* |-> OL |
|
|
36
|
+
* | |-> OL |
|
|
37
|
+
* | |-> OL |
|
|
38
|
+
* | |-> LI (parent LIs: 1) |-> LI (indent: 1)
|
|
39
|
+
* |-> LI (parent LIs: 1) |-> LI (indent: 1)
|
|
40
|
+
*
|
|
41
|
+
* before: fixed list:
|
|
42
|
+
* OL OL
|
|
43
|
+
* |-> OL |
|
|
44
|
+
* |-> OL |
|
|
45
|
+
* |-> OL |
|
|
46
|
+
* |-> LI (parent LIs: 0) |-> LI (indent: 0)
|
|
47
|
+
*
|
|
48
|
+
* before: fixed list:
|
|
49
|
+
* OL OL
|
|
50
|
+
* |-> LI (parent LIs: 0) |-> LI (indent: 0)
|
|
51
|
+
* |-> OL |-> OL
|
|
52
|
+
* |-> LI (parent LIs: 0) |-> LI (indent: 1)
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
export declare function getIndent(listItem: ViewElement): number;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a list attribute element (ol or ul).
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare function createListElement(writer: DowncastWriter, indent: number, type: 'bulleted' | 'numbered', id?: string): ViewAttributeElement;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a list item attribute element (li).
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
export declare function createListItemElement(writer: DowncastWriter, indent: number, id: string): ViewAttributeElement;
|
|
70
|
+
/**
|
|
71
|
+
* Returns a view element name for the given list type.
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
export declare function getViewElementNameForListType(type?: 'bulleted' | 'numbered'): 'ol' | 'ul';
|
|
76
|
+
/**
|
|
77
|
+
* Returns a view element ID for the given list type and indent.
|
|
78
|
+
*
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export declare function getViewElementIdForListType(type?: 'bulleted' | 'numbered', indent?: number): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
import './listconfig';
|
|
10
|
+
/**
|
|
11
|
+
* The document list feature.
|
|
12
|
+
*
|
|
13
|
+
* This is a "glue" plugin that loads the {@link module:list/documentlist/documentlistediting~DocumentListEditing document list
|
|
14
|
+
* editing feature} and {@link module:list/list/listui~ListUI list UI feature}.
|
|
15
|
+
*/
|
|
16
|
+
export default class DocumentList extends Plugin {
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get requires(): PluginDependencies;
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get pluginName(): 'DocumentList';
|
|
25
|
+
}
|
|
26
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
27
|
+
interface PluginsMap {
|
|
28
|
+
[DocumentList.pluginName]: DocumentList;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/documentlist.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
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/documentlistproperties/converters
|
|
7
|
+
*/
|
|
8
|
+
import type { UpcastElementEvent } from 'ckeditor5/src/engine';
|
|
9
|
+
import type { GetCallback } from 'ckeditor5/src/utils';
|
|
10
|
+
import type { AttributeStrategy } from './documentlistpropertiesediting';
|
|
11
|
+
/**
|
|
12
|
+
* Returns a converter that consumes the `style`, `reversed`, and `start` attributes.
|
|
13
|
+
* In `style`, it searches for the `list-style-type` definition.
|
|
14
|
+
* If not found, the `"default"` value will be used.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
* @param strategy
|
|
18
|
+
*/
|
|
19
|
+
export declare function listPropertiesUpcastConverter(strategy: AttributeStrategy): GetCallback<UpcastElementEvent>;
|
|
@@ -0,0 +1,92 @@
|
|
|
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/documentlistproperties/documentlistpropertiesediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type Editor, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
import type { Consumables, DowncastWriter, Element, Item, ViewElement } from 'ckeditor5/src/engine';
|
|
10
|
+
import { type ListItemAttributesMap } from '../documentlist/documentlistediting';
|
|
11
|
+
/**
|
|
12
|
+
* The document list properties engine feature.
|
|
13
|
+
*
|
|
14
|
+
* It registers the `'listStyle'`, `'listReversed'` and `'listStart'` commands if they are enabled in the configuration.
|
|
15
|
+
* Read more in {@link module:list/listconfig~ListPropertiesConfig}.
|
|
16
|
+
*/
|
|
17
|
+
export default class DocumentListPropertiesEditing extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get requires(): PluginDependencies;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get pluginName(): 'DocumentListPropertiesEditing';
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
constructor(editor: Editor);
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
init(): void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Strategy for dealing with `listItem` attributes supported by this plugin.
|
|
37
|
+
*
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export interface AttributeStrategy {
|
|
41
|
+
/**
|
|
42
|
+
* The model attribute name.
|
|
43
|
+
*/
|
|
44
|
+
attributeName: keyof ListItemAttributesMap;
|
|
45
|
+
/**
|
|
46
|
+
* The model attribute default value.
|
|
47
|
+
*/
|
|
48
|
+
defaultValue: unknown;
|
|
49
|
+
/**
|
|
50
|
+
* The view consumable as expected by {@link module:engine/conversion/viewconsumable~ViewConsumable#consume `ViewConsumable`}.
|
|
51
|
+
*/
|
|
52
|
+
viewConsumables: Consumables;
|
|
53
|
+
/**
|
|
54
|
+
* Registers an editor command.
|
|
55
|
+
*/
|
|
56
|
+
addCommand(editor: Editor): void;
|
|
57
|
+
/**
|
|
58
|
+
* Verifies whether the strategy is applicable for the specified model element.
|
|
59
|
+
*/
|
|
60
|
+
appliesToListItem(element: Item): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Verifies whether the model attribute value is valid.
|
|
63
|
+
*/
|
|
64
|
+
hasValidAttribute(element: Element): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Sets the property on the view element.
|
|
67
|
+
*/
|
|
68
|
+
setAttributeOnDowncast(writer: DowncastWriter, value: unknown, element: ViewElement): void;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves the property value from the view element.
|
|
71
|
+
*/
|
|
72
|
+
getAttributeOnUpcast(element: ViewElement): unknown;
|
|
73
|
+
}
|
|
74
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
75
|
+
interface PluginsMap {
|
|
76
|
+
[DocumentListPropertiesEditing.pluginName]: DocumentListPropertiesEditing;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
declare module '../documentlist/documentlistediting' {
|
|
80
|
+
interface ListItemAttributesMap {
|
|
81
|
+
listStyle?: string;
|
|
82
|
+
listStart?: number;
|
|
83
|
+
listReversed?: boolean;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
declare module '../documentlist/utils/model' {
|
|
87
|
+
interface ListElement extends Element {
|
|
88
|
+
getAttribute(key: 'listStyle'): string;
|
|
89
|
+
getAttribute(key: 'listStart'): number;
|
|
90
|
+
getAttribute(key: 'listReversed'): boolean;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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/documentlistpropertiesutils
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* A set of helpers related to document lists.
|
|
11
|
+
*/
|
|
12
|
+
export default class DocumentListPropertiesUtils extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get pluginName(): 'DocumentListPropertiesUtils';
|
|
17
|
+
/**
|
|
18
|
+
* Gets all the style types supported by given list type.
|
|
19
|
+
*/
|
|
20
|
+
getAllSupportedStyleTypes(): Array<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
23
|
+
*/
|
|
24
|
+
getListTypeFromListStyleType(listStyleType: string): 'bulleted' | 'numbered' | null;
|
|
25
|
+
/**
|
|
26
|
+
* Converts `type` attribute of `<ul>` or `<ol>` elements to `list-style-type` equivalent.
|
|
27
|
+
*/
|
|
28
|
+
getListStyleTypeFromTypeAttribute(value: string): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Converts `list-style-type` style to `type` attribute of `<ul>` or `<ol>` elements.
|
|
31
|
+
*/
|
|
32
|
+
getTypeAttributeFromListStyleType(value: string): string | null;
|
|
33
|
+
}
|
|
34
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
35
|
+
interface PluginsMap {
|
|
36
|
+
[DocumentListPropertiesUtils.pluginName]: DocumentListPropertiesUtils;
|
|
37
|
+
}
|
|
38
|
+
}
|