@ckeditor/ckeditor5-list 45.2.1 → 46.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/dist/index-content.css +50 -8
- package/dist/index-editor.css +14 -8
- package/dist/index.css +62 -15
- package/dist/index.css.map +1 -1
- package/dist/index.js +736 -135
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
- package/src/augmentation.d.ts +8 -5
- package/src/index.d.ts +61 -37
- package/src/index.js +53 -25
- package/src/legacyerrors.d.ts +5 -0
- package/src/legacyerrors.js +28 -0
- package/src/legacylist/legacyconverters.d.ts +23 -7
- package/src/legacylist/legacyconverters.js +18 -2
- package/src/legacylist/legacyindentcommand.d.ts +1 -1
- package/src/legacylist/legacyindentcommand.js +1 -1
- package/src/legacylist/legacylistcommand.d.ts +1 -1
- package/src/legacylist/legacylistcommand.js +1 -1
- package/src/legacylist/legacylistediting.d.ts +2 -2
- package/src/legacylist/legacylistediting.js +4 -4
- package/src/legacylist/legacylistutils.d.ts +4 -4
- package/src/legacylist/legacylistutils.js +1 -1
- package/src/legacylist/legacyutils.d.ts +21 -10
- package/src/legacylist/legacyutils.js +14 -4
- package/src/legacylist.d.ts +3 -3
- package/src/legacylist.js +3 -3
- package/src/legacylistproperties/legacylistpropertiesediting.d.ts +2 -2
- package/src/legacylistproperties/legacylistpropertiesediting.js +5 -5
- package/src/legacylistproperties/legacylistreversedcommand.d.ts +1 -1
- package/src/legacylistproperties/legacylistreversedcommand.js +1 -1
- package/src/legacylistproperties/legacyliststartcommand.d.ts +1 -1
- package/src/legacylistproperties/legacyliststartcommand.js +1 -1
- package/src/legacylistproperties/legacyliststylecommand.d.ts +1 -1
- package/src/legacylistproperties/legacyliststylecommand.js +1 -1
- package/src/legacylistproperties.d.ts +3 -3
- package/src/legacylistproperties.js +3 -3
- package/src/legacytodolist/legacychecktodolistcommand.d.ts +6 -6
- package/src/legacytodolist/legacychecktodolistcommand.js +3 -3
- package/src/legacytodolist/legacytodolistconverters.d.ts +15 -8
- package/src/legacytodolist/legacytodolistconverters.js +10 -3
- package/src/legacytodolist/legacytodolistediting.d.ts +2 -2
- package/src/legacytodolist/legacytodolistediting.js +4 -4
- package/src/legacytodolist.d.ts +3 -3
- package/src/legacytodolist.js +3 -3
- package/src/list/adjacentlistssupport.d.ts +1 -1
- package/src/list/adjacentlistssupport.js +1 -1
- package/src/list/converters.d.ts +9 -5
- package/src/list/converters.js +12 -7
- package/src/list/listcommand.d.ts +3 -3
- package/src/list/listcommand.js +1 -1
- package/src/list/listediting.d.ts +21 -17
- package/src/list/listediting.js +28 -11
- package/src/list/listindentcommand.d.ts +3 -3
- package/src/list/listindentcommand.js +2 -2
- package/src/list/listmergecommand.d.ts +3 -3
- package/src/list/listmergecommand.js +2 -2
- package/src/list/listsplitcommand.d.ts +3 -3
- package/src/list/listsplitcommand.js +1 -1
- package/src/list/listui.d.ts +1 -1
- package/src/list/listui.js +1 -1
- package/src/list/listutils.d.ts +7 -7
- package/src/list/listutils.js +1 -1
- package/src/list/utils/listwalker.d.ts +12 -6
- package/src/list/utils/listwalker.js +5 -1
- package/src/list/utils/model.d.ts +25 -22
- package/src/list/utils/model.js +7 -2
- package/src/list/utils/postfixers.d.ts +4 -4
- package/src/list/utils/view.d.ts +3 -3
- package/src/list.d.ts +3 -3
- package/src/list.js +3 -3
- package/src/listconfig.d.ts +13 -0
- package/src/listformatting/listitemboldintegration.d.ts +34 -0
- package/src/listformatting/listitemboldintegration.js +83 -0
- package/src/listformatting/listitemfontcolorintegration.d.ts +34 -0
- package/src/listformatting/listitemfontcolorintegration.js +92 -0
- package/src/listformatting/listitemfontfamilyintegration.d.ts +34 -0
- package/src/listformatting/listitemfontfamilyintegration.js +93 -0
- package/src/listformatting/listitemfontsizeintegration.d.ts +34 -0
- package/src/listformatting/listitemfontsizeintegration.js +119 -0
- package/src/listformatting/listitemitalicintegration.d.ts +34 -0
- package/src/listformatting/listitemitalicintegration.js +83 -0
- package/src/listformatting.d.ts +71 -0
- package/src/listformatting.js +243 -0
- package/src/listproperties/listpropertiesediting.d.ts +7 -7
- package/src/listproperties/listpropertiesediting.js +6 -6
- package/src/listproperties/listpropertiesui.d.ts +1 -1
- package/src/listproperties/listpropertiesui.js +2 -2
- package/src/listproperties/listpropertiesutils.d.ts +1 -1
- package/src/listproperties/listpropertiesutils.js +1 -1
- package/src/listproperties/listreversedcommand.d.ts +1 -1
- package/src/listproperties/listreversedcommand.js +1 -1
- package/src/listproperties/liststartcommand.d.ts +1 -1
- package/src/listproperties/liststartcommand.js +1 -1
- package/src/listproperties/liststylecommand.d.ts +1 -1
- package/src/listproperties/liststylecommand.js +1 -1
- package/src/listproperties/ui/listpropertiesview.d.ts +6 -1
- package/src/listproperties/ui/listpropertiesview.js +1 -1
- package/src/listproperties/utils/config.d.ts +3 -0
- package/src/listproperties/utils/config.js +1 -0
- package/src/listproperties/utils/style.d.ts +9 -0
- package/src/listproperties/utils/style.js +9 -0
- package/src/listproperties.d.ts +3 -3
- package/src/listproperties.js +3 -3
- package/src/todolist/checktodolistcommand.d.ts +3 -3
- package/src/todolist/checktodolistcommand.js +2 -2
- package/src/todolist/todocheckboxchangeobserver.d.ts +8 -6
- package/src/todolist/todocheckboxchangeobserver.js +4 -2
- package/src/todolist/todolistediting.d.ts +2 -2
- package/src/todolist/todolistediting.js +5 -5
- package/src/todolist/todolistui.d.ts +1 -1
- package/src/todolist/todolistui.js +1 -1
- package/src/todolist.d.ts +3 -3
- package/src/todolist.js +3 -3
- package/theme/listformatting.css +48 -0
- package/theme/todolist.css +8 -8
- package/src/documentlist.d.ts +0 -32
- package/src/documentlist.js +0 -47
- package/src/documentlistproperties.d.ts +0 -32
- package/src/documentlistproperties.js +0 -47
- package/src/tododocumentlist.d.ts +0 -32
- package/src/tododocumentlist.js +0 -47
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module list/listformatting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { ListItemBoldIntegration } from './listformatting/listitemboldintegration.js';
|
|
10
|
+
import { ListItemItalicIntegration } from './listformatting/listitemitalicintegration.js';
|
|
11
|
+
import { ListItemFontSizeIntegration } from './listformatting/listitemfontsizeintegration.js';
|
|
12
|
+
import { ListItemFontColorIntegration } from './listformatting/listitemfontcolorintegration.js';
|
|
13
|
+
import { ListItemFontFamilyIntegration } from './listformatting/listitemfontfamilyintegration.js';
|
|
14
|
+
import { isListItemBlock, getAllListItemBlocks, isFirstBlockOfListItem } from './list/utils/model.js';
|
|
15
|
+
import '../theme/listformatting.css';
|
|
16
|
+
/**
|
|
17
|
+
* The list formatting plugin.
|
|
18
|
+
*
|
|
19
|
+
* It enables integration with formatting plugins to style the list marker.
|
|
20
|
+
* The list marker is styled based on the consistent formatting applied to the content of the list item.
|
|
21
|
+
*
|
|
22
|
+
* The list of supported formatting plugins includes:
|
|
23
|
+
* * Font color.
|
|
24
|
+
* * Font size.
|
|
25
|
+
* * Font family.
|
|
26
|
+
* * Bold.
|
|
27
|
+
* * Italic.
|
|
28
|
+
*/
|
|
29
|
+
export class ListFormatting extends Plugin {
|
|
30
|
+
/**
|
|
31
|
+
* The list of loaded formatting.
|
|
32
|
+
*/
|
|
33
|
+
_loadedFormatting = {};
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
37
|
+
static get pluginName() {
|
|
38
|
+
return 'ListFormatting';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @inheritDoc
|
|
42
|
+
*/
|
|
43
|
+
static get isOfficialPlugin() {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @inheritDoc
|
|
48
|
+
*/
|
|
49
|
+
static get requires() {
|
|
50
|
+
return [
|
|
51
|
+
ListItemBoldIntegration,
|
|
52
|
+
ListItemItalicIntegration,
|
|
53
|
+
ListItemFontSizeIntegration,
|
|
54
|
+
ListItemFontColorIntegration,
|
|
55
|
+
ListItemFontFamilyIntegration
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @inheritDoc
|
|
60
|
+
*/
|
|
61
|
+
constructor(editor) {
|
|
62
|
+
super(editor);
|
|
63
|
+
editor.config.define('list.enableListItemMarkerFormatting', true);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @inheritDoc
|
|
67
|
+
*/
|
|
68
|
+
afterInit() {
|
|
69
|
+
if (!this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this._registerPostfixerForListItemFormatting();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Registers a postfixer that ensures that the list item formatting attribute is consistent with the formatting
|
|
76
|
+
* applied to the content of the list item.
|
|
77
|
+
*/
|
|
78
|
+
_registerPostfixerForListItemFormatting() {
|
|
79
|
+
const model = this.editor.model;
|
|
80
|
+
model.document.registerPostFixer(writer => {
|
|
81
|
+
const changes = model.document.differ.getChanges();
|
|
82
|
+
const modifiedListItems = new Set();
|
|
83
|
+
let returnValue = false;
|
|
84
|
+
for (const entry of changes) {
|
|
85
|
+
if (entry.type === 'attribute') {
|
|
86
|
+
if (entry.attributeKey == 'listItemId' ||
|
|
87
|
+
entry.attributeKey == 'listType' ||
|
|
88
|
+
this._isInlineOrSelectionFormatting(entry.attributeKey)) {
|
|
89
|
+
if (isListItemBlock(entry.range.start.nodeAfter)) {
|
|
90
|
+
modifiedListItems.add(entry.range.start.nodeAfter);
|
|
91
|
+
}
|
|
92
|
+
else if (isListItemBlock(entry.range.start.parent)) {
|
|
93
|
+
modifiedListItems.add(entry.range.start.parent);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
if (isListItemBlock(entry.position.nodeAfter)) {
|
|
99
|
+
modifiedListItems.add(entry.position.nodeAfter);
|
|
100
|
+
}
|
|
101
|
+
if (isListItemBlock(entry.position.nodeBefore)) {
|
|
102
|
+
modifiedListItems.add(entry.position.nodeBefore);
|
|
103
|
+
}
|
|
104
|
+
if (isListItemBlock(entry.position.parent)) {
|
|
105
|
+
modifiedListItems.add(entry.position.parent);
|
|
106
|
+
}
|
|
107
|
+
if (entry.type == 'insert' && entry.name != '$text') {
|
|
108
|
+
const range = writer.createRangeIn(entry.position.nodeAfter);
|
|
109
|
+
for (const item of range.getItems()) {
|
|
110
|
+
if (isListItemBlock(item)) {
|
|
111
|
+
modifiedListItems.add(item);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
for (const listItem of modifiedListItems) {
|
|
118
|
+
const formats = getListItemConsistentFormat(model, listItem, Object.keys(this._loadedFormatting));
|
|
119
|
+
for (const [formatAttributeName, formatValue] of Object.entries(formats)) {
|
|
120
|
+
const listItemFormatAttributeName = this._loadedFormatting[formatAttributeName];
|
|
121
|
+
if (formatValue && setFormattingToListItem(writer, listItem, listItemFormatAttributeName, formatValue)) {
|
|
122
|
+
returnValue = true;
|
|
123
|
+
}
|
|
124
|
+
else if (!formatValue && removeFormattingFromListItem(writer, listItem, listItemFormatAttributeName)) {
|
|
125
|
+
returnValue = true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return returnValue;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Registers an integration between a default attribute (e.g., `fontFamily`) and a new attribute
|
|
134
|
+
* intended specifically for list item elements (e.g., `listItemFontFamily`).
|
|
135
|
+
*
|
|
136
|
+
* These attributes are later used by the postfixer logic to determine whether to add the new attribute
|
|
137
|
+
* to the list item element, based on whether there is a consistent default formatting attribute
|
|
138
|
+
* applied within its content.
|
|
139
|
+
*/
|
|
140
|
+
registerFormatAttribute(formatAttribute, listItemFormatAttribute) {
|
|
141
|
+
this._loadedFormatting[formatAttribute] = listItemFormatAttribute;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Returns true if the given model attribute name is a supported inline formatting attribute.
|
|
145
|
+
*/
|
|
146
|
+
_isInlineOrSelectionFormatting(attributeKey) {
|
|
147
|
+
return attributeKey.replace(/^selection:/, '') in this._loadedFormatting;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Returns the consistent format of the list item element.
|
|
152
|
+
* If the list item contains multiple blocks, it checks only the first block.
|
|
153
|
+
*/
|
|
154
|
+
function getListItemConsistentFormat(model, listItem, attributeKeys) {
|
|
155
|
+
if (isFirstBlockOfListItem(listItem)) {
|
|
156
|
+
return getSingleListItemConsistentFormat(model, listItem, attributeKeys);
|
|
157
|
+
}
|
|
158
|
+
// Always the first block of the list item should be checked for consistent formatting.
|
|
159
|
+
const listItemBlocks = getAllListItemBlocks(listItem);
|
|
160
|
+
return getSingleListItemConsistentFormat(model, listItemBlocks[0], attributeKeys);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Returns the consistent format of a single list item element.
|
|
164
|
+
*/
|
|
165
|
+
function getSingleListItemConsistentFormat(model, listItem, attributeKeys) {
|
|
166
|
+
// Only bulleted and numbered lists can have formatting (to-do lists are not supported).
|
|
167
|
+
// Do not check internals of limit elements (for example, do not check table cells).
|
|
168
|
+
if (!isNumberedOrBulletedList(listItem) || model.schema.isLimit(listItem)) {
|
|
169
|
+
return Object.fromEntries(attributeKeys.map(attributeKey => [attributeKey]));
|
|
170
|
+
}
|
|
171
|
+
if (listItem.isEmpty) {
|
|
172
|
+
return Object.fromEntries(attributeKeys.map(attributeKey => ([attributeKey, listItem.getAttribute(`selection:${attributeKey}`)])));
|
|
173
|
+
}
|
|
174
|
+
const attributesToCheck = new Set(attributeKeys);
|
|
175
|
+
const valuesMap = {};
|
|
176
|
+
const range = model.createRangeIn(listItem);
|
|
177
|
+
const walker = range.getWalker({ ignoreElementEnd: true });
|
|
178
|
+
for (const { item } of walker) {
|
|
179
|
+
for (const attributeKey of attributesToCheck) {
|
|
180
|
+
if (model.schema.checkAttribute(item, attributeKey)) {
|
|
181
|
+
const formatAttribute = item.getAttribute(attributeKey);
|
|
182
|
+
if (formatAttribute === undefined) {
|
|
183
|
+
attributesToCheck.delete(attributeKey);
|
|
184
|
+
valuesMap[attributeKey] = undefined;
|
|
185
|
+
}
|
|
186
|
+
else if (valuesMap[attributeKey] === undefined) {
|
|
187
|
+
// First item inside a list item block.
|
|
188
|
+
valuesMap[attributeKey] = formatAttribute;
|
|
189
|
+
}
|
|
190
|
+
else if (valuesMap[attributeKey] !== formatAttribute) {
|
|
191
|
+
// Following items in the same block of a list item.
|
|
192
|
+
attributesToCheck.delete(attributeKey);
|
|
193
|
+
valuesMap[attributeKey] = undefined;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// End early if all attributes have been checked and are inconsistent.
|
|
198
|
+
if (!attributesToCheck.size) {
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
// Jump over inline limit elements as we expect only outside them to be the same formatting.
|
|
202
|
+
if (model.schema.isLimit(item)) {
|
|
203
|
+
walker.jumpTo(model.createPositionAfter(item));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return valuesMap;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Adds the specified formatting attribute to the list item element.
|
|
210
|
+
*/
|
|
211
|
+
function setFormattingToListItem(writer, listItem, attributeKey, attributeValue) {
|
|
212
|
+
// Multi-block items should have consistent formatting.
|
|
213
|
+
const listItemBlocks = getAllListItemBlocks(listItem);
|
|
214
|
+
let wasChanged = false;
|
|
215
|
+
for (const listItem of listItemBlocks) {
|
|
216
|
+
if (!listItem.hasAttribute(attributeKey) || listItem.getAttribute(attributeKey) !== attributeValue) {
|
|
217
|
+
writer.setAttribute(attributeKey, attributeValue, listItem);
|
|
218
|
+
wasChanged = true;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return wasChanged;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Removes the specified formatting attribute from the list item element.
|
|
225
|
+
*/
|
|
226
|
+
function removeFormattingFromListItem(writer, listItem, attributeKey) {
|
|
227
|
+
// Multi-block items should have consistent formatting.
|
|
228
|
+
const listItemBlocks = getAllListItemBlocks(listItem);
|
|
229
|
+
let wasChanged = false;
|
|
230
|
+
for (const listItem of listItemBlocks) {
|
|
231
|
+
if (listItem.hasAttribute(attributeKey)) {
|
|
232
|
+
writer.removeAttribute(attributeKey, listItem);
|
|
233
|
+
wasChanged = true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return wasChanged;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Checks if the given list type is a numbered or bulleted list.
|
|
240
|
+
*/
|
|
241
|
+
function isNumberedOrBulletedList(listItem) {
|
|
242
|
+
return ['numbered', 'bulleted', 'customNumbered', 'customBulleted'].includes(listItem.getAttribute('listType'));
|
|
243
|
+
}
|
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
* @module list/listproperties/listpropertiesediting
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
-
import type { Consumables,
|
|
10
|
-
import ListEditing,
|
|
11
|
-
import ListPropertiesUtils from './listpropertiesutils.js';
|
|
9
|
+
import type { Consumables, ViewDowncastWriter, ModelElement, ModelItem, ViewElement } from 'ckeditor5/src/engine.js';
|
|
10
|
+
import { ListEditing, type ListItemAttributesMap } from '../list/listediting.js';
|
|
11
|
+
import { ListPropertiesUtils } from './listpropertiesutils.js';
|
|
12
12
|
/**
|
|
13
13
|
* The document list properties engine feature.
|
|
14
14
|
*
|
|
15
15
|
* It registers the `'listStyle'`, `'listReversed'` and `'listStart'` commands if they are enabled in the configuration.
|
|
16
16
|
* Read more in {@link module:list/listconfig~ListPropertiesConfig}.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export declare class ListPropertiesEditing extends Plugin {
|
|
19
19
|
/**
|
|
20
20
|
* @inheritDoc
|
|
21
21
|
*/
|
|
@@ -62,15 +62,15 @@ export interface AttributeStrategy {
|
|
|
62
62
|
/**
|
|
63
63
|
* Verifies whether the strategy is applicable for the specified model element.
|
|
64
64
|
*/
|
|
65
|
-
appliesToListItem(element:
|
|
65
|
+
appliesToListItem(element: ModelItem): boolean;
|
|
66
66
|
/**
|
|
67
67
|
* Verifies whether the model attribute value is valid.
|
|
68
68
|
*/
|
|
69
|
-
hasValidAttribute(element:
|
|
69
|
+
hasValidAttribute(element: ModelElement): boolean;
|
|
70
70
|
/**
|
|
71
71
|
* Sets the property on the view element.
|
|
72
72
|
*/
|
|
73
|
-
setAttributeOnDowncast(writer:
|
|
73
|
+
setAttributeOnDowncast(writer: ViewDowncastWriter, value: unknown, element: ViewElement): void;
|
|
74
74
|
/**
|
|
75
75
|
* Retrieves the property value from the view element.
|
|
76
76
|
*/
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* @module list/listproperties/listpropertiesediting
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ListEditing from '../list/listediting.js';
|
|
10
|
-
import ListStartCommand from './liststartcommand.js';
|
|
11
|
-
import ListStyleCommand from './liststylecommand.js';
|
|
12
|
-
import ListReversedCommand from './listreversedcommand.js';
|
|
9
|
+
import { ListEditing } from '../list/listediting.js';
|
|
10
|
+
import { ListStartCommand } from './liststartcommand.js';
|
|
11
|
+
import { ListStyleCommand } from './liststylecommand.js';
|
|
12
|
+
import { ListReversedCommand } from './listreversedcommand.js';
|
|
13
13
|
import { listPropertiesUpcastConverter } from './converters.js';
|
|
14
14
|
import { getAllSupportedStyleTypes, getListTypeFromListStyleType, getListStyleTypeFromTypeAttribute, getTypeAttributeFromListStyleType, normalizeListStyle } from './utils/style.js';
|
|
15
|
-
import ListPropertiesUtils from './listpropertiesutils.js';
|
|
15
|
+
import { ListPropertiesUtils } from './listpropertiesutils.js';
|
|
16
16
|
import { isNumberedListType } from '../list/utils/model.js';
|
|
17
17
|
import { getNormalizedConfig } from './utils/config.js';
|
|
18
18
|
const DEFAULT_LIST_TYPE = 'default';
|
|
@@ -22,7 +22,7 @@ const DEFAULT_LIST_TYPE = 'default';
|
|
|
22
22
|
* It registers the `'listStyle'`, `'listReversed'` and `'listStart'` commands if they are enabled in the configuration.
|
|
23
23
|
* Read more in {@link module:list/listconfig~ListPropertiesConfig}.
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export class ListPropertiesEditing extends Plugin {
|
|
26
26
|
/**
|
|
27
27
|
* @inheritDoc
|
|
28
28
|
*/
|
|
@@ -14,7 +14,7 @@ import '../../theme/liststyles.css';
|
|
|
14
14
|
* **Note**: Buttons introduced by this plugin override implementations from the {@link module:list/list/listui~ListUI}
|
|
15
15
|
* (because they share the same names).
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export declare class ListPropertiesUI extends Plugin {
|
|
18
18
|
/**
|
|
19
19
|
* @inheritDoc
|
|
20
20
|
*/
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
9
|
import { IconBulletedList, IconNumberedList, IconListStyleCircle, IconListStyleDecimal, IconListStyleDecimalLeadingZero, IconListStyleDisc, IconListStyleLowerLatin, IconListStyleLowerRoman, IconListStyleSquare, IconListStyleUpperLatin, IconListStyleUpperRoman } from 'ckeditor5/src/icons.js';
|
|
10
10
|
import { ButtonView, SplitButtonView, createDropdown, focusChildOnDropdownOpen, MenuBarMenuView } from 'ckeditor5/src/ui.js';
|
|
11
|
-
import ListPropertiesView from './ui/listpropertiesview.js';
|
|
11
|
+
import { ListPropertiesView } from './ui/listpropertiesview.js';
|
|
12
12
|
import { getNormalizedConfig } from './utils/config.js';
|
|
13
13
|
import '../../theme/liststyles.css';
|
|
14
14
|
/**
|
|
@@ -18,7 +18,7 @@ import '../../theme/liststyles.css';
|
|
|
18
18
|
* **Note**: Buttons introduced by this plugin override implementations from the {@link module:list/list/listui~ListUI}
|
|
19
19
|
* (because they share the same names).
|
|
20
20
|
*/
|
|
21
|
-
export
|
|
21
|
+
export class ListPropertiesUI extends Plugin {
|
|
22
22
|
/**
|
|
23
23
|
* @inheritDoc
|
|
24
24
|
*/
|
|
@@ -10,7 +10,7 @@ import { getAllSupportedStyleTypes, getListStyleTypeFromTypeAttribute, getListTy
|
|
|
10
10
|
/**
|
|
11
11
|
* A set of helpers related to document lists.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export class ListPropertiesUtils extends Plugin {
|
|
14
14
|
/**
|
|
15
15
|
* @inheritDoc
|
|
16
16
|
*/
|
|
@@ -11,7 +11,7 @@ import { Command } from 'ckeditor5/src/core.js';
|
|
|
11
11
|
* letting the user to choose the order of an ordered list.
|
|
12
12
|
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export declare class ListReversedCommand extends Command {
|
|
15
15
|
/**
|
|
16
16
|
* @inheritDoc
|
|
17
17
|
*/
|
|
@@ -13,7 +13,7 @@ import { expandListBlocksToCompleteList, isListItemBlock } from '../list/utils/m
|
|
|
13
13
|
* letting the user to choose the order of an ordered list.
|
|
14
14
|
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export class ListReversedCommand extends Command {
|
|
17
17
|
/**
|
|
18
18
|
* @inheritDoc
|
|
19
19
|
*/
|
|
@@ -11,7 +11,7 @@ import { Command } from 'ckeditor5/src/core.js';
|
|
|
11
11
|
* letting the user to choose the starting point of an ordered list.
|
|
12
12
|
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export declare class ListStartCommand extends Command {
|
|
15
15
|
/**
|
|
16
16
|
* @inheritDoc
|
|
17
17
|
*/
|
|
@@ -13,7 +13,7 @@ import { expandListBlocksToCompleteList, isListItemBlock, isNumberedListType } f
|
|
|
13
13
|
* letting the user to choose the starting point of an ordered list.
|
|
14
14
|
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export class ListStartCommand extends Command {
|
|
17
17
|
/**
|
|
18
18
|
* @inheritDoc
|
|
19
19
|
*/
|
|
@@ -11,7 +11,7 @@ import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
|
11
11
|
* letting the user choose styles for the list item markers.
|
|
12
12
|
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export declare class ListStyleCommand extends Command {
|
|
15
15
|
/**
|
|
16
16
|
* @inheritDoc
|
|
17
17
|
*/
|
|
@@ -14,7 +14,7 @@ import { getListTypeFromListStyleType } from './utils/style.js';
|
|
|
14
14
|
* letting the user choose styles for the list item markers.
|
|
15
15
|
* It is used by the {@link module:list/listproperties~ListProperties list properties feature}.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export class ListStyleCommand extends Command {
|
|
18
18
|
/**
|
|
19
19
|
* The default type of the list style.
|
|
20
20
|
*/
|
|
@@ -16,7 +16,7 @@ import '../../../theme/listproperties.css';
|
|
|
16
16
|
*
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export declare class ListPropertiesView extends View {
|
|
20
20
|
/**
|
|
21
21
|
* @inheritDoc
|
|
22
22
|
*/
|
|
@@ -128,6 +128,11 @@ export default class ListPropertiesView extends View {
|
|
|
128
128
|
*/
|
|
129
129
|
private _createReversedSwitchButton;
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* The view that renders the grid of styles.
|
|
133
|
+
*
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
131
136
|
export type StylesView = View & {
|
|
132
137
|
children: ViewCollection;
|
|
133
138
|
focusTracker: FocusTracker;
|
|
@@ -18,12 +18,15 @@ import type { ListPropertiesConfig, ListPropertiesStyleListType } from '../../li
|
|
|
18
18
|
* }
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
|
+
* @internal
|
|
21
22
|
* @param config The list properties {@link module:list/listconfig~ListPropertiesConfig config}.
|
|
22
23
|
* @returns An object with normalized list properties options.
|
|
23
24
|
*/
|
|
24
25
|
export declare function getNormalizedConfig(config: ListPropertiesConfig): NormalizedListPropertiesConfig;
|
|
25
26
|
/**
|
|
26
27
|
* Normalized list properties config.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
27
30
|
*/
|
|
28
31
|
export type NormalizedListPropertiesConfig = {
|
|
29
32
|
styles: {
|
|
@@ -4,23 +4,32 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Gets all the style types supported by given list type.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
7
9
|
*/
|
|
8
10
|
export declare function getAllSupportedStyleTypes(): Array<string>;
|
|
9
11
|
/**
|
|
10
12
|
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
11
15
|
*/
|
|
12
16
|
export declare function getListTypeFromListStyleType(listStyleType: string): 'bulleted' | 'numbered' | null;
|
|
13
17
|
/**
|
|
14
18
|
* Converts `type` attribute of `<ul>` or `<ol>` elements to `list-style-type` equivalent.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
15
21
|
*/
|
|
16
22
|
export declare function getListStyleTypeFromTypeAttribute(value: string): string | null;
|
|
17
23
|
/**
|
|
18
24
|
* Converts `list-style-type` style to `type` attribute of `<ul>` or `<ol>` elements.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
19
27
|
*/
|
|
20
28
|
export declare function getTypeAttributeFromListStyleType(value: string): string | null;
|
|
21
29
|
/**
|
|
22
30
|
* Normalizes list style by converting aliases to their canonical form.
|
|
23
31
|
*
|
|
32
|
+
* @internal
|
|
24
33
|
* @param listStyle The list style value to normalize.
|
|
25
34
|
* @returns The canonical form of the list style.
|
|
26
35
|
*
|
|
@@ -30,24 +30,32 @@ for (const { listStyle, typeAttribute, listType } of LIST_STYLE_TYPES) {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Gets all the style types supported by given list type.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
33
35
|
*/
|
|
34
36
|
export function getAllSupportedStyleTypes() {
|
|
35
37
|
return LIST_STYLE_TYPES.map(x => x.listStyle);
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
39
43
|
*/
|
|
40
44
|
export function getListTypeFromListStyleType(listStyleType) {
|
|
41
45
|
return LIST_STYLE_TO_LIST_TYPE[listStyleType] || null;
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* Converts `type` attribute of `<ul>` or `<ol>` elements to `list-style-type` equivalent.
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
45
51
|
*/
|
|
46
52
|
export function getListStyleTypeFromTypeAttribute(value) {
|
|
47
53
|
return TYPE_ATTRIBUTE_TO_LIST_STYLE[value] || null;
|
|
48
54
|
}
|
|
49
55
|
/**
|
|
50
56
|
* Converts `list-style-type` style to `type` attribute of `<ul>` or `<ol>` elements.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
51
59
|
*/
|
|
52
60
|
export function getTypeAttributeFromListStyleType(value) {
|
|
53
61
|
return LIST_STYLE_TO_TYPE_ATTRIBUTE[value] || null;
|
|
@@ -55,6 +63,7 @@ export function getTypeAttributeFromListStyleType(value) {
|
|
|
55
63
|
/**
|
|
56
64
|
* Normalizes list style by converting aliases to their canonical form.
|
|
57
65
|
*
|
|
66
|
+
* @internal
|
|
58
67
|
* @param listStyle The list style value to normalize.
|
|
59
68
|
* @returns The canonical form of the list style.
|
|
60
69
|
*
|
package/src/listproperties.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* @module list/listproperties
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ListPropertiesEditing from './listproperties/listpropertiesediting.js';
|
|
10
|
-
import ListPropertiesUI from './listproperties/listpropertiesui.js';
|
|
9
|
+
import { ListPropertiesEditing } from './listproperties/listpropertiesediting.js';
|
|
10
|
+
import { ListPropertiesUI } from './listproperties/listpropertiesui.js';
|
|
11
11
|
/**
|
|
12
12
|
* The list properties feature.
|
|
13
13
|
*
|
|
@@ -15,7 +15,7 @@ import ListPropertiesUI from './listproperties/listpropertiesui.js';
|
|
|
15
15
|
* {@link module:list/listproperties/listpropertiesediting~ListPropertiesEditing list properties
|
|
16
16
|
* editing feature} and the {@link module:list/listproperties/listpropertiesui~ListPropertiesUI list properties UI feature}.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export declare class ListProperties extends Plugin {
|
|
19
19
|
/**
|
|
20
20
|
* @inheritDoc
|
|
21
21
|
*/
|
package/src/listproperties.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* @module list/listproperties
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ListPropertiesEditing from './listproperties/listpropertiesediting.js';
|
|
10
|
-
import ListPropertiesUI from './listproperties/listpropertiesui.js';
|
|
9
|
+
import { ListPropertiesEditing } from './listproperties/listpropertiesediting.js';
|
|
10
|
+
import { ListPropertiesUI } from './listproperties/listpropertiesui.js';
|
|
11
11
|
/**
|
|
12
12
|
* The list properties feature.
|
|
13
13
|
*
|
|
@@ -15,7 +15,7 @@ import ListPropertiesUI from './listproperties/listpropertiesui.js';
|
|
|
15
15
|
* {@link module:list/listproperties/listpropertiesediting~ListPropertiesEditing list properties
|
|
16
16
|
* editing feature} and the {@link module:list/listproperties/listpropertiesui~ListPropertiesUI list properties UI feature}.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export class ListProperties extends Plugin {
|
|
19
19
|
/**
|
|
20
20
|
* @inheritDoc
|
|
21
21
|
*/
|
|
@@ -12,9 +12,9 @@ import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
|
12
12
|
* The command is registered by the {@link module:list/todolist/todolistediting~TodoListEditing} as
|
|
13
13
|
* the `checkTodoList` editor command.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export declare class CheckTodoListCommand extends Command {
|
|
16
16
|
/**
|
|
17
|
-
* A list of to-do list items selected by the {@link module:engine/model/selection~
|
|
17
|
+
* A list of to-do list items selected by the {@link module:engine/model/selection~ModelSelection}.
|
|
18
18
|
*
|
|
19
19
|
* @observable
|
|
20
20
|
* @readonly
|
|
@@ -43,7 +43,7 @@ export default class CheckTodoListCommand extends Command {
|
|
|
43
43
|
*/
|
|
44
44
|
private _getValue;
|
|
45
45
|
/**
|
|
46
|
-
* Gets all to-do list items selected by the {@link module:engine/model/selection~
|
|
46
|
+
* Gets all to-do list items selected by the {@link module:engine/model/selection~ModelSelection}.
|
|
47
47
|
*/
|
|
48
48
|
private _getSelectedItems;
|
|
49
49
|
}
|
|
@@ -13,7 +13,7 @@ import { getAllListItemBlocks } from '../list/utils/model.js';
|
|
|
13
13
|
* The command is registered by the {@link module:list/todolist/todolistediting~TodoListEditing} as
|
|
14
14
|
* the `checkTodoList` editor command.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export class CheckTodoListCommand extends Command {
|
|
17
17
|
/**
|
|
18
18
|
* @inheritDoc
|
|
19
19
|
*/
|
|
@@ -61,7 +61,7 @@ export default class CheckTodoListCommand extends Command {
|
|
|
61
61
|
return selectedElements.every(element => element.getAttribute('todoListChecked'));
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Gets all to-do list items selected by the {@link module:engine/model/selection~
|
|
64
|
+
* Gets all to-do list items selected by the {@link module:engine/model/selection~ModelSelection}.
|
|
65
65
|
*/
|
|
66
66
|
_getSelectedItems() {
|
|
67
67
|
const model = this.editor.model;
|