@ckeditor/ckeditor5-list 41.1.0 → 41.3.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 +2 -2
- package/build/translations/ar.js +1 -1
- package/build/translations/ast.js +1 -1
- package/build/translations/az.js +1 -1
- package/build/translations/bg.js +1 -1
- package/build/translations/bn.js +1 -1
- package/build/translations/ca.js +1 -1
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de-ch.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/en-gb.js +1 -1
- package/build/translations/eo.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/eu.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/jv.js +1 -1
- package/build/translations/km.js +1 -1
- package/build/translations/kn.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/ku.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/ms.js +1 -1
- package/build/translations/nb.js +1 -1
- package/build/translations/ne.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/si.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sq.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/th.js +1 -1
- package/build/translations/tk.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/tt.js +1 -1
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/ur.js +1 -1
- package/build/translations/uz.js +1 -1
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/dist/content-index.css +102 -0
- package/dist/editor-index.css +74 -0
- package/dist/index.css +228 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +7925 -0
- package/dist/index.js.map +1 -0
- package/dist/types/augmentation.d.ts +53 -0
- package/dist/types/documentlist.d.ts +28 -0
- package/dist/types/documentlistproperties.d.ts +28 -0
- package/dist/types/index.d.ts +45 -0
- package/dist/types/legacylist/legacyconverters.d.ts +196 -0
- package/dist/types/legacylist/legacyindentcommand.d.ts +37 -0
- package/dist/types/legacylist/legacylistcommand.d.ts +55 -0
- package/dist/types/legacylist/legacylistediting.d.ts +32 -0
- package/dist/types/legacylist/legacylistutils.d.ts +41 -0
- package/dist/types/legacylist/legacyutils.d.ts +101 -0
- package/dist/types/legacylist.d.ts +26 -0
- package/dist/types/legacylistproperties/legacylistpropertiesediting.d.ts +72 -0
- package/dist/types/legacylistproperties/legacylistreversedcommand.d.ts +38 -0
- package/dist/types/legacylistproperties/legacyliststartcommand.d.ts +37 -0
- package/dist/types/legacylistproperties/legacyliststylecommand.d.ts +67 -0
- package/dist/types/legacylistproperties.d.ts +27 -0
- package/dist/types/legacytodolist/legacychecktodolistcommand.d.ts +52 -0
- package/dist/types/legacytodolist/legacytodolistconverters.d.ts +83 -0
- package/dist/types/legacytodolist/legacytodolistediting.d.ts +39 -0
- package/dist/types/legacytodolist.d.ts +27 -0
- package/dist/types/list/adjacentlistssupport.d.ts +15 -0
- package/dist/types/list/converters.d.ts +65 -0
- package/dist/types/list/listcommand.d.ts +80 -0
- package/dist/types/list/listediting.d.ts +216 -0
- package/dist/types/list/listindentcommand.d.ts +62 -0
- package/dist/types/list/listmergecommand.d.ts +76 -0
- package/dist/types/list/listsplitcommand.d.ts +67 -0
- package/dist/types/list/listui.d.ts +19 -0
- package/dist/types/list/listutils.d.ts +46 -0
- package/dist/types/list/utils/listwalker.d.ts +145 -0
- package/dist/types/list/utils/model.d.ts +202 -0
- package/dist/types/list/utils/postfixers.d.ts +37 -0
- package/dist/types/list/utils/view.d.ts +81 -0
- package/dist/types/list/utils.d.ts +18 -0
- package/dist/types/list.d.ts +26 -0
- package/dist/types/listconfig.d.ts +132 -0
- package/dist/types/listproperties/converters.d.ts +19 -0
- package/dist/types/listproperties/listpropertiesediting.d.ts +88 -0
- package/dist/types/listproperties/listpropertiesui.d.ts +23 -0
- package/dist/types/listproperties/listpropertiesutils.d.ts +33 -0
- package/dist/types/listproperties/listreversedcommand.d.ts +36 -0
- package/dist/types/listproperties/liststartcommand.d.ts +38 -0
- package/dist/types/listproperties/liststylecommand.d.ts +72 -0
- package/dist/types/listproperties/ui/listpropertiesview.d.ts +156 -0
- package/dist/types/listproperties/utils/style.d.ts +20 -0
- package/dist/types/listproperties.d.ts +27 -0
- package/dist/types/tododocumentlist.d.ts +28 -0
- package/dist/types/todolist/checktodolistcommand.d.ts +49 -0
- package/dist/types/todolist/todocheckboxchangeobserver.d.ts +41 -0
- package/dist/types/todolist/todolistediting.d.ts +38 -0
- package/dist/types/todolist/todolistui.d.ts +19 -0
- package/dist/types/todolist.d.ts +27 -0
- package/lang/contexts.json +5 -1
- package/lang/translations/ar.po +16 -0
- package/lang/translations/ast.po +16 -0
- package/lang/translations/az.po +16 -0
- package/lang/translations/bg.po +16 -0
- package/lang/translations/bn.po +16 -0
- package/lang/translations/ca.po +16 -0
- package/lang/translations/cs.po +16 -0
- package/lang/translations/da.po +16 -0
- package/lang/translations/de-ch.po +16 -0
- package/lang/translations/de.po +16 -0
- package/lang/translations/el.po +16 -0
- package/lang/translations/en-au.po +16 -0
- package/lang/translations/en-gb.po +16 -0
- package/lang/translations/en.po +16 -0
- package/lang/translations/eo.po +16 -0
- package/lang/translations/es.po +16 -0
- package/lang/translations/et.po +16 -0
- package/lang/translations/eu.po +16 -0
- package/lang/translations/fa.po +16 -0
- package/lang/translations/fi.po +16 -0
- package/lang/translations/fr.po +16 -0
- package/lang/translations/gl.po +16 -0
- package/lang/translations/he.po +17 -1
- package/lang/translations/hi.po +16 -0
- package/lang/translations/hr.po +16 -0
- package/lang/translations/hu.po +16 -0
- package/lang/translations/id.po +16 -0
- package/lang/translations/it.po +16 -0
- package/lang/translations/ja.po +16 -0
- package/lang/translations/jv.po +16 -0
- package/lang/translations/km.po +16 -0
- package/lang/translations/kn.po +16 -0
- package/lang/translations/ko.po +16 -0
- package/lang/translations/ku.po +16 -0
- package/lang/translations/lt.po +16 -0
- package/lang/translations/lv.po +16 -0
- package/lang/translations/ms.po +16 -0
- package/lang/translations/nb.po +16 -0
- package/lang/translations/ne.po +16 -0
- package/lang/translations/nl.po +16 -0
- package/lang/translations/no.po +16 -0
- package/lang/translations/pl.po +16 -0
- package/lang/translations/pt-br.po +16 -0
- package/lang/translations/pt.po +27 -11
- package/lang/translations/ro.po +16 -0
- package/lang/translations/ru.po +16 -0
- package/lang/translations/si.po +16 -0
- package/lang/translations/sk.po +16 -0
- package/lang/translations/sq.po +16 -0
- package/lang/translations/sr-latn.po +16 -0
- package/lang/translations/sr.po +16 -0
- package/lang/translations/sv.po +16 -0
- package/lang/translations/th.po +16 -0
- package/lang/translations/tk.po +16 -0
- package/lang/translations/tr.po +16 -0
- package/lang/translations/tt.po +16 -0
- package/lang/translations/ug.po +16 -0
- package/lang/translations/uk.po +16 -0
- package/lang/translations/ur.po +16 -0
- package/lang/translations/uz.po +16 -0
- package/lang/translations/vi.po +16 -0
- package/lang/translations/zh-cn.po +16 -0
- package/lang/translations/zh.po +16 -0
- package/package.json +3 -2
- package/src/augmentation.d.ts +1 -1
- package/src/list/listediting.d.ts +4 -0
- package/src/list/listediting.js +22 -0
- package/src/listproperties/ui/listpropertiesview.js +3 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/list/utils/model
|
|
7
|
+
*/
|
|
8
|
+
import type { DocumentFragment, Element, Model, Node, Writer, Item, Schema } from 'ckeditor5/src/engine.js';
|
|
9
|
+
import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
|
|
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' | 'todo';
|
|
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;
|
|
194
|
+
/**
|
|
195
|
+
* Checks whether the given block can be replaced by a listItem.
|
|
196
|
+
*
|
|
197
|
+
* Note that this is possible only when multiBlock = false option is set in feature config.
|
|
198
|
+
*
|
|
199
|
+
* @param block A block to be tested.
|
|
200
|
+
* @param schema The schema of the document.
|
|
201
|
+
*/
|
|
202
|
+
export declare function canBecomeSimpleListItem(block: Element, schema: Schema): boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/list/utils/postfixers
|
|
7
|
+
*/
|
|
8
|
+
import type { Position, Writer } from 'ckeditor5/src/engine.js';
|
|
9
|
+
import { type ListIteratorValue } from './listwalker.js';
|
|
10
|
+
import { type ListElement } from './model.js';
|
|
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-2024, 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/list/utils/view
|
|
7
|
+
*/
|
|
8
|
+
import type { DowncastWriter, ViewAttributeElement, ViewDocumentFragment, ViewElement, ViewNode } from 'ckeditor5/src/engine.js';
|
|
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' | 'todo', 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' | 'todo'): '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' | 'todo', indent?: number): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/list/utils
|
|
7
|
+
*/
|
|
8
|
+
import type { Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
/**
|
|
10
|
+
* Helper method for creating a UI button and linking it with an appropriate command.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
* @param editor The editor instance to which the UI component will be added.
|
|
14
|
+
* @param commandName The name of the command.
|
|
15
|
+
* @param label The button label.
|
|
16
|
+
* @param icon The source of the icon.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createUIComponent(editor: Editor, commandName: 'bulletedList' | 'numberedList' | 'todoList', label: string, icon: string): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/list
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import ListEditing from './list/listediting.js';
|
|
10
|
+
import ListUI from './list/listui.js';
|
|
11
|
+
/**
|
|
12
|
+
* The list feature.
|
|
13
|
+
*
|
|
14
|
+
* This is a "glue" plugin that loads the {@link module:list/list/listediting~ListEditing list
|
|
15
|
+
* editing feature} and {@link module:list/list/listui~ListUI list UI feature}.
|
|
16
|
+
*/
|
|
17
|
+
export default class List extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get requires(): readonly [typeof ListEditing, typeof ListUI];
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get pluginName(): "List";
|
|
26
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/listconfig
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The configuration of the {@link module:list/list~List list} feature
|
|
10
|
+
* and the {@link module:list/legacylist~LegacyList legacy list} feature.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* ClassicEditor
|
|
14
|
+
* .create( editorElement, {
|
|
15
|
+
* list: ... // The list feature configuration.
|
|
16
|
+
* } )
|
|
17
|
+
* .then( ... )
|
|
18
|
+
* .catch( ... );
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
22
|
+
*
|
|
23
|
+
* @interface ListConfig
|
|
24
|
+
*/
|
|
25
|
+
export interface ListConfig {
|
|
26
|
+
/**
|
|
27
|
+
* The configuration of the {@link module:list/listproperties~ListProperties} feature and the
|
|
28
|
+
* {@link module:list/legacylistproperties~LegacyListProperties legacy list properties} feature.
|
|
29
|
+
*
|
|
30
|
+
* Read more in {@link module:list/listconfig~ListPropertiesConfig}.
|
|
31
|
+
*/
|
|
32
|
+
properties?: ListPropertiesConfig;
|
|
33
|
+
/**
|
|
34
|
+
* Allows multiple blocks in single list item.
|
|
35
|
+
*
|
|
36
|
+
* With this option enabled you can have block widgets, for example images or even tables, within a list item.
|
|
37
|
+
*
|
|
38
|
+
* **Note:** This is enabled by default.
|
|
39
|
+
*
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
multiBlock?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The configuration of the {@link module:list/listproperties~ListProperties list properties} feature and the
|
|
46
|
+
* {@link module:list/legacylistproperties~LegacyListProperties legacy list properties} feature.
|
|
47
|
+
*
|
|
48
|
+
* This configuration controls the individual list properties. For instance, it enables or disables specific editor commands
|
|
49
|
+
* operating on lists ({@link module:list/listproperties/liststylecommand~ListStyleCommand `'listStyle'`},
|
|
50
|
+
* {@link module:list/listproperties/liststartcommand~ListStartCommand `'listStart'`},
|
|
51
|
+
* {@link module:list/listproperties/listreversedcommand~ListReversedCommand `'listReversed'`}, or on the legacy lists
|
|
52
|
+
* {@link module:list/legacylistproperties/legacyliststylecommand~LegacyListStyleCommand `'listStyle'`},
|
|
53
|
+
* {@link module:list/legacylistproperties/legacyliststartcommand~LegacyListStartCommand `'listStart'`},
|
|
54
|
+
* {@link module:list/legacylistproperties/legacylistreversedcommand~LegacyListReversedCommand `'listReversed'`}), the look of the UI
|
|
55
|
+
* (`'numberedList'` and `'bulletedList'` dropdowns), and the editor data pipeline (allowed HTML attributes).
|
|
56
|
+
*
|
|
57
|
+
* ```ts
|
|
58
|
+
* ClassicEditor
|
|
59
|
+
* .create( editorElement, {
|
|
60
|
+
* list: {
|
|
61
|
+
* properties: {
|
|
62
|
+
* styles: true,
|
|
63
|
+
* startIndex: true,
|
|
64
|
+
* reversed: true
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* } )
|
|
68
|
+
* .then( ... )
|
|
69
|
+
* .catch( ... );
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export interface ListPropertiesConfig {
|
|
73
|
+
/**
|
|
74
|
+
* When set, the list style feature will be enabled.
|
|
75
|
+
* It allows changing the `list-style-type` style or the `type` HTML attribute of a list.
|
|
76
|
+
*
|
|
77
|
+
* **Note**: Styling using the `type` HTML attribute is only available in
|
|
78
|
+
* {@link module:list/listproperties~ListProperties list properties}
|
|
79
|
+
* ({@link module:list/listconfig~ListPropertiesStyleConfig learn more}).
|
|
80
|
+
*
|
|
81
|
+
* @default true
|
|
82
|
+
*/
|
|
83
|
+
styles?: boolean | ListPropertiesStyleConfig;
|
|
84
|
+
/**
|
|
85
|
+
* When set, the list start index feature will be enabled. It allows changing the `start` HTML attribute of the numbered lists. As a
|
|
86
|
+
* result, it will be possible to specify the start value of the first item in an ordered list.
|
|
87
|
+
*
|
|
88
|
+
* **Note**: This configuration does not affect bulleted and to-do lists.
|
|
89
|
+
*
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
startIndex?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* When set, the reversed list feature will be enabled. It allows changing the `reversed` HTML attribute of the numbered lists. As a
|
|
95
|
+
* result, it will be possible to make the list order descending instead of ascending.
|
|
96
|
+
*
|
|
97
|
+
* **Note**: This configuration does not affect bulleted and to-do lists.
|
|
98
|
+
*
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
reversed?: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface ListPropertiesStyleConfig {
|
|
104
|
+
/**
|
|
105
|
+
* When set `true`, the list style feature will use the `type` attribute of `<ul>` and `<ol>` elements instead of the `list-style-type`
|
|
106
|
+
* style.
|
|
107
|
+
*
|
|
108
|
+
* ```ts
|
|
109
|
+
* {
|
|
110
|
+
* list: {
|
|
111
|
+
* properties: {
|
|
112
|
+
* styles: {
|
|
113
|
+
* useAttribute: true
|
|
114
|
+
* },
|
|
115
|
+
*
|
|
116
|
+
* // ...
|
|
117
|
+
* }
|
|
118
|
+
* },
|
|
119
|
+
*
|
|
120
|
+
* // ...
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* **Note**: Due to limitations of HTML, the "Decimal with leading zero" style is impossible to set using the `type` attribute.
|
|
125
|
+
*
|
|
126
|
+
* **Note**: This configuration works only with
|
|
127
|
+
* {@link module:list/listproperties~ListProperties list properties}.
|
|
128
|
+
*
|
|
129
|
+
* @default false
|
|
130
|
+
*/
|
|
131
|
+
useAttribute?: boolean;
|
|
132
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/listproperties/converters
|
|
7
|
+
*/
|
|
8
|
+
import type { UpcastElementEvent } from 'ckeditor5/src/engine.js';
|
|
9
|
+
import type { GetCallback } from 'ckeditor5/src/utils.js';
|
|
10
|
+
import type { AttributeStrategy } from './listpropertiesediting.js';
|
|
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,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/listproperties/listpropertiesediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
import type { Consumables, DowncastWriter, Element, Item, ViewElement } from 'ckeditor5/src/engine.js';
|
|
10
|
+
import ListEditing, { type ListItemAttributesMap } from '../list/listediting.js';
|
|
11
|
+
import ListPropertiesUtils from './listpropertiesutils.js';
|
|
12
|
+
/**
|
|
13
|
+
* The document list properties engine feature.
|
|
14
|
+
*
|
|
15
|
+
* It registers the `'listStyle'`, `'listReversed'` and `'listStart'` commands if they are enabled in the configuration.
|
|
16
|
+
* Read more in {@link module:list/listconfig~ListPropertiesConfig}.
|
|
17
|
+
*/
|
|
18
|
+
export default class ListPropertiesEditing extends Plugin {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get requires(): readonly [typeof ListEditing, typeof ListPropertiesUtils];
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get pluginName(): "ListPropertiesEditing";
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
constructor(editor: Editor);
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
init(): void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Strategy for dealing with `listItem` attributes supported by this plugin.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export interface AttributeStrategy {
|
|
42
|
+
/**
|
|
43
|
+
* The model attribute name.
|
|
44
|
+
*/
|
|
45
|
+
attributeName: keyof ListItemAttributesMap;
|
|
46
|
+
/**
|
|
47
|
+
* The model attribute default value.
|
|
48
|
+
*/
|
|
49
|
+
defaultValue: unknown;
|
|
50
|
+
/**
|
|
51
|
+
* The view consumable as expected by {@link module:engine/conversion/viewconsumable~ViewConsumable#consume `ViewConsumable`}.
|
|
52
|
+
*/
|
|
53
|
+
viewConsumables: Consumables;
|
|
54
|
+
/**
|
|
55
|
+
* Registers an editor command.
|
|
56
|
+
*/
|
|
57
|
+
addCommand(editor: Editor): void;
|
|
58
|
+
/**
|
|
59
|
+
* Verifies whether the strategy is applicable for the specified model element.
|
|
60
|
+
*/
|
|
61
|
+
appliesToListItem(element: Item): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Verifies whether the model attribute value is valid.
|
|
64
|
+
*/
|
|
65
|
+
hasValidAttribute(element: Element): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the property on the view element.
|
|
68
|
+
*/
|
|
69
|
+
setAttributeOnDowncast(writer: DowncastWriter, value: unknown, element: ViewElement): void;
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves the property value from the view element.
|
|
72
|
+
*/
|
|
73
|
+
getAttributeOnUpcast(element: ViewElement): unknown;
|
|
74
|
+
}
|
|
75
|
+
declare module '../list/listediting' {
|
|
76
|
+
interface ListItemAttributesMap {
|
|
77
|
+
listStyle?: string;
|
|
78
|
+
listStart?: number;
|
|
79
|
+
listReversed?: boolean;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
declare module '../list/utils/model' {
|
|
83
|
+
interface ListElement {
|
|
84
|
+
getAttribute(key: 'listStyle'): string;
|
|
85
|
+
getAttribute(key: 'listStart'): number;
|
|
86
|
+
getAttribute(key: 'listReversed'): boolean;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/listproperties/listpropertiesui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import '../../theme/liststyles.css';
|
|
10
|
+
/**
|
|
11
|
+
* The list properties UI plugin. It introduces the extended `'bulletedList'` and `'numberedList'` toolbar
|
|
12
|
+
* buttons that allow users to control such aspects of list as the marker, start index or order.
|
|
13
|
+
*
|
|
14
|
+
* **Note**: Buttons introduced by this plugin override implementations from the {@link module:list/list/listui~ListUI}
|
|
15
|
+
* (because they share the same names).
|
|
16
|
+
*/
|
|
17
|
+
export default class ListPropertiesUI extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName(): "ListPropertiesUI";
|
|
22
|
+
init(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/listproperties/listpropertiesutils
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
/**
|
|
10
|
+
* A set of helpers related to document lists.
|
|
11
|
+
*/
|
|
12
|
+
export default class ListPropertiesUtils extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get pluginName(): "ListPropertiesUtils";
|
|
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
|
+
}
|