@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
package/dist/index.js
CHANGED
|
@@ -5,14 +5,17 @@
|
|
|
5
5
|
import { Command, Plugin } from '@ckeditor/ckeditor5-core/dist/index.js';
|
|
6
6
|
import { Delete } from '@ckeditor/ckeditor5-typing/dist/index.js';
|
|
7
7
|
import { Enter } from '@ckeditor/ckeditor5-enter/dist/index.js';
|
|
8
|
-
import { toArray, first, uid, CKEditorError, FocusTracker, KeystrokeHandler, global, getCode, parseKeystroke, getLocalizedArrowKeyCodeDirection, createElement
|
|
8
|
+
import { toArray, first, uid, CKEditorError, FocusTracker, KeystrokeHandler, global, getCode, parseKeystroke, getLocalizedArrowKeyCodeDirection, createElement } from '@ckeditor/ckeditor5-utils/dist/index.js';
|
|
9
|
+
import { _normalizeFontSizeOptions } from '@ckeditor/ckeditor5-font/dist/index.js';
|
|
9
10
|
import { ClipboardPipeline } from '@ckeditor/ckeditor5-clipboard/dist/index.js';
|
|
10
11
|
import { ButtonView, MenuBarMenuListItemButtonView, View, ViewCollection, FocusCycler, addKeyboardHandlingForGrid, CollapsibleView, LabeledFieldView, createLabeledInputNumber, SwitchButtonView, createDropdown, SplitButtonView, MenuBarMenuView, focusChildOnDropdownOpen } from '@ckeditor/ckeditor5-ui/dist/index.js';
|
|
11
12
|
import { IconNumberedList, IconBulletedList, IconListStyleDisc, IconListStyleCircle, IconListStyleSquare, IconListStyleDecimal, IconListStyleDecimalLeadingZero, IconListStyleLowerRoman, IconListStyleUpperRoman, IconListStyleLowerLatin, IconListStyleUpperLatin, IconTodoList } from '@ckeditor/ckeditor5-icons/dist/index.js';
|
|
12
|
-
import { DomEventObserver, Matcher,
|
|
13
|
+
import { DomEventObserver, Matcher, ModelTreeWalker, getViewFillerOffset } from '@ckeditor/ckeditor5-engine/dist/index.js';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Document list blocks iterator.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
16
19
|
*/ class ListWalker {
|
|
17
20
|
/**
|
|
18
21
|
* The start list item block element.
|
|
@@ -141,6 +144,8 @@ import { DomEventObserver, Matcher, TreeWalker, getFillerOffset } from '@ckedito
|
|
|
141
144
|
}
|
|
142
145
|
/**
|
|
143
146
|
* Iterates sibling list blocks starting from the given node.
|
|
147
|
+
*
|
|
148
|
+
* @internal
|
|
144
149
|
*/ class SiblingListBlocksIterator {
|
|
145
150
|
_node;
|
|
146
151
|
_isForward;
|
|
@@ -633,11 +638,14 @@ import { DomEventObserver, Matcher, TreeWalker, getFillerOffset } from '@ckedito
|
|
|
633
638
|
*
|
|
634
639
|
* @param block A block to be tested.
|
|
635
640
|
* @param schema The schema of the document.
|
|
641
|
+
* @internal
|
|
636
642
|
*/ function canBecomeSimpleListItem(block, schema) {
|
|
637
643
|
return schema.checkChild(block.parent, 'listItem') && schema.checkChild(block, '$text') && !schema.isObject(block);
|
|
638
644
|
}
|
|
639
645
|
/**
|
|
640
646
|
* Returns true if listType is of type `numbered` or `customNumbered`.
|
|
647
|
+
*
|
|
648
|
+
* @internal
|
|
641
649
|
*/ function isNumberedListType(listType) {
|
|
642
650
|
return listType == 'numbered' || listType == 'customNumbered';
|
|
643
651
|
}
|
|
@@ -1162,6 +1170,642 @@ import { DomEventObserver, Matcher, TreeWalker, getFillerOffset } from '@ckedito
|
|
|
1162
1170
|
}
|
|
1163
1171
|
}
|
|
1164
1172
|
|
|
1173
|
+
/**
|
|
1174
|
+
* The list item bold integration plugin.
|
|
1175
|
+
*/ class ListItemBoldIntegration extends Plugin {
|
|
1176
|
+
/**
|
|
1177
|
+
* @inheritDoc
|
|
1178
|
+
*/ static get pluginName() {
|
|
1179
|
+
return 'ListItemBoldIntegration';
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* @inheritDoc
|
|
1183
|
+
*/ static get isOfficialPlugin() {
|
|
1184
|
+
return true;
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* @inheritDoc
|
|
1188
|
+
*/ static get requires() {
|
|
1189
|
+
return [
|
|
1190
|
+
ListEditing
|
|
1191
|
+
];
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* @inheritDoc
|
|
1195
|
+
*/ init() {
|
|
1196
|
+
const editor = this.editor;
|
|
1197
|
+
const ListFormatting = editor.plugins.get('ListFormatting');
|
|
1198
|
+
const listEditing = editor.plugins.get(ListEditing);
|
|
1199
|
+
if (!editor.plugins.has('BoldEditing') || !this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
ListFormatting.registerFormatAttribute('bold', 'listItemBold');
|
|
1203
|
+
// Register the downcast strategy in init() so that the attribute name is registered before the list editing
|
|
1204
|
+
// registers its converters.
|
|
1205
|
+
// This ensures that the attribute is recognized by downcast strategies and bogus paragraphs are handled correctly.
|
|
1206
|
+
listEditing.registerDowncastStrategy({
|
|
1207
|
+
scope: 'item',
|
|
1208
|
+
attributeName: 'listItemBold',
|
|
1209
|
+
setAttributeOnDowncast (writer, value, viewElement) {
|
|
1210
|
+
if (value) {
|
|
1211
|
+
writer.addClass('ck-list-marker-bold', viewElement);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* @inheritDoc
|
|
1218
|
+
*/ afterInit() {
|
|
1219
|
+
const editor = this.editor;
|
|
1220
|
+
const model = editor.model;
|
|
1221
|
+
if (!editor.plugins.has('BoldEditing') || !this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
1222
|
+
return;
|
|
1223
|
+
}
|
|
1224
|
+
model.schema.extend('$listItem', {
|
|
1225
|
+
allowAttributes: 'listItemBold'
|
|
1226
|
+
});
|
|
1227
|
+
model.schema.setAttributeProperties('listItemBold', {
|
|
1228
|
+
isFormatting: true
|
|
1229
|
+
});
|
|
1230
|
+
model.schema.addAttributeCheck((context)=>{
|
|
1231
|
+
const item = context.last;
|
|
1232
|
+
if (!item.getAttribute('listItemId')) {
|
|
1233
|
+
return false;
|
|
1234
|
+
}
|
|
1235
|
+
}, 'listItemBold');
|
|
1236
|
+
editor.conversion.for('upcast').attributeToAttribute({
|
|
1237
|
+
model: 'listItemBold',
|
|
1238
|
+
view: {
|
|
1239
|
+
name: 'li',
|
|
1240
|
+
classes: 'ck-list-marker-bold'
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* The list item italic integration plugin.
|
|
1248
|
+
*/ class ListItemItalicIntegration extends Plugin {
|
|
1249
|
+
/**
|
|
1250
|
+
* @inheritDoc
|
|
1251
|
+
*/ static get pluginName() {
|
|
1252
|
+
return 'ListItemItalicIntegration';
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* @inheritDoc
|
|
1256
|
+
*/ static get isOfficialPlugin() {
|
|
1257
|
+
return true;
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* @inheritDoc
|
|
1261
|
+
*/ static get requires() {
|
|
1262
|
+
return [
|
|
1263
|
+
ListEditing
|
|
1264
|
+
];
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* @inheritDoc
|
|
1268
|
+
*/ init() {
|
|
1269
|
+
const editor = this.editor;
|
|
1270
|
+
const ListFormatting = editor.plugins.get('ListFormatting');
|
|
1271
|
+
const listEditing = editor.plugins.get(ListEditing);
|
|
1272
|
+
if (!editor.plugins.has('ItalicEditing') || !this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
ListFormatting.registerFormatAttribute('italic', 'listItemItalic');
|
|
1276
|
+
// Register the downcast strategy in init() so that the attribute name is registered before the list editing
|
|
1277
|
+
// registers its converters.
|
|
1278
|
+
// This ensures that the attribute is recognized by downcast strategies and bogus paragraphs are handled correctly.
|
|
1279
|
+
listEditing.registerDowncastStrategy({
|
|
1280
|
+
scope: 'item',
|
|
1281
|
+
attributeName: 'listItemItalic',
|
|
1282
|
+
setAttributeOnDowncast (writer, value, viewElement) {
|
|
1283
|
+
if (value) {
|
|
1284
|
+
writer.addClass('ck-list-marker-italic', viewElement);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* @inheritDoc
|
|
1291
|
+
*/ afterInit() {
|
|
1292
|
+
const editor = this.editor;
|
|
1293
|
+
const model = editor.model;
|
|
1294
|
+
if (!editor.plugins.has('ItalicEditing') || !this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
model.schema.extend('$listItem', {
|
|
1298
|
+
allowAttributes: 'listItemItalic'
|
|
1299
|
+
});
|
|
1300
|
+
model.schema.setAttributeProperties('listItemItalic', {
|
|
1301
|
+
isFormatting: true
|
|
1302
|
+
});
|
|
1303
|
+
model.schema.addAttributeCheck((context)=>{
|
|
1304
|
+
const item = context.last;
|
|
1305
|
+
if (!item.getAttribute('listItemId')) {
|
|
1306
|
+
return false;
|
|
1307
|
+
}
|
|
1308
|
+
}, 'listItemItalic');
|
|
1309
|
+
editor.conversion.for('upcast').attributeToAttribute({
|
|
1310
|
+
model: 'listItemItalic',
|
|
1311
|
+
view: {
|
|
1312
|
+
name: 'li',
|
|
1313
|
+
classes: 'ck-list-marker-italic'
|
|
1314
|
+
}
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* The list item font size integration plugin.
|
|
1321
|
+
*/ class ListItemFontSizeIntegration extends Plugin {
|
|
1322
|
+
/**
|
|
1323
|
+
* @inheritDoc
|
|
1324
|
+
*/ static get pluginName() {
|
|
1325
|
+
return 'ListItemFontSizeIntegration';
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* @inheritDoc
|
|
1329
|
+
*/ static get isOfficialPlugin() {
|
|
1330
|
+
return true;
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* @inheritDoc
|
|
1334
|
+
*/ static get requires() {
|
|
1335
|
+
return [
|
|
1336
|
+
ListEditing
|
|
1337
|
+
];
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* @inheritDoc
|
|
1341
|
+
*/ init() {
|
|
1342
|
+
const editor = this.editor;
|
|
1343
|
+
const ListFormatting = editor.plugins.get('ListFormatting');
|
|
1344
|
+
const listEditing = editor.plugins.get(ListEditing);
|
|
1345
|
+
if (!editor.plugins.has('FontSizeEditing') || !this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
const normalizedFontSizeOptions = _normalizeFontSizeOptions(editor.config.get('fontSize.options'));
|
|
1349
|
+
ListFormatting.registerFormatAttribute('fontSize', 'listItemFontSize');
|
|
1350
|
+
// Register the downcast strategy in init() so that the attribute name is registered before the list editing
|
|
1351
|
+
// registers its converters.
|
|
1352
|
+
// This ensures that the attribute is recognized by downcast strategies and bogus paragraphs are handled correctly.
|
|
1353
|
+
listEditing.registerDowncastStrategy({
|
|
1354
|
+
scope: 'item',
|
|
1355
|
+
attributeName: 'listItemFontSize',
|
|
1356
|
+
setAttributeOnDowncast (writer, value, viewElement) {
|
|
1357
|
+
if (value) {
|
|
1358
|
+
const fontSizeOption = normalizedFontSizeOptions.find((option)=>option.model == value);
|
|
1359
|
+
if (fontSizeOption && fontSizeOption.view && typeof fontSizeOption.view != 'string') {
|
|
1360
|
+
if (fontSizeOption.view.styles) {
|
|
1361
|
+
writer.addClass('ck-list-marker-font-size', viewElement);
|
|
1362
|
+
writer.setStyle('--ck-content-list-marker-font-size', fontSizeOption.view.styles['font-size'], viewElement);
|
|
1363
|
+
} else if (fontSizeOption.view.classes) {
|
|
1364
|
+
writer.addClass(`ck-list-marker-font-size-${value}`, viewElement);
|
|
1365
|
+
}
|
|
1366
|
+
} else {
|
|
1367
|
+
writer.addClass('ck-list-marker-font-size', viewElement);
|
|
1368
|
+
writer.setStyle('--ck-content-list-marker-font-size', value, viewElement);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* @inheritDoc
|
|
1376
|
+
*/ afterInit() {
|
|
1377
|
+
const editor = this.editor;
|
|
1378
|
+
const model = editor.model;
|
|
1379
|
+
if (!editor.plugins.has('FontSizeEditing') || !this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
model.schema.extend('$listItem', {
|
|
1383
|
+
allowAttributes: 'listItemFontSize'
|
|
1384
|
+
});
|
|
1385
|
+
model.schema.setAttributeProperties('listItemFontSize', {
|
|
1386
|
+
isFormatting: true
|
|
1387
|
+
});
|
|
1388
|
+
model.schema.addAttributeCheck((context)=>{
|
|
1389
|
+
const item = context.last;
|
|
1390
|
+
if (!item.getAttribute('listItemId')) {
|
|
1391
|
+
return false;
|
|
1392
|
+
}
|
|
1393
|
+
}, 'listItemFontSize');
|
|
1394
|
+
editor.conversion.for('upcast').elementToAttribute({
|
|
1395
|
+
model: {
|
|
1396
|
+
key: 'listItemFontSize',
|
|
1397
|
+
value: (viewElement)=>viewElement.getStyle('--ck-content-list-marker-font-size')
|
|
1398
|
+
},
|
|
1399
|
+
view: {
|
|
1400
|
+
name: 'li',
|
|
1401
|
+
classes: 'ck-list-marker-font-size',
|
|
1402
|
+
styles: {
|
|
1403
|
+
'--ck-content-list-marker-font-size': /.*/
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
});
|
|
1407
|
+
const fontSizeOptions = _normalizeFontSizeOptions(editor.config.get('fontSize.options'));
|
|
1408
|
+
for (const option of fontSizeOptions){
|
|
1409
|
+
if (option.model && option.view) {
|
|
1410
|
+
editor.conversion.for('upcast').elementToAttribute({
|
|
1411
|
+
model: {
|
|
1412
|
+
key: 'listItemFontSize',
|
|
1413
|
+
value: option.model
|
|
1414
|
+
},
|
|
1415
|
+
view: {
|
|
1416
|
+
name: 'li',
|
|
1417
|
+
classes: `ck-list-marker-font-size-${option.model}`
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* The list item font color integration plugin.
|
|
1427
|
+
*/ class ListItemFontColorIntegration extends Plugin {
|
|
1428
|
+
/**
|
|
1429
|
+
* @inheritDoc
|
|
1430
|
+
*/ static get pluginName() {
|
|
1431
|
+
return 'ListItemFontColorIntegration';
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* @inheritDoc
|
|
1435
|
+
*/ static get isOfficialPlugin() {
|
|
1436
|
+
return true;
|
|
1437
|
+
}
|
|
1438
|
+
/**
|
|
1439
|
+
* @inheritDoc
|
|
1440
|
+
*/ static get requires() {
|
|
1441
|
+
return [
|
|
1442
|
+
ListEditing
|
|
1443
|
+
];
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* @inheritDoc
|
|
1447
|
+
*/ init() {
|
|
1448
|
+
const editor = this.editor;
|
|
1449
|
+
const ListFormatting = editor.plugins.get('ListFormatting');
|
|
1450
|
+
const listEditing = editor.plugins.get(ListEditing);
|
|
1451
|
+
if (!editor.plugins.has('FontColorEditing') || !this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
ListFormatting.registerFormatAttribute('fontColor', 'listItemFontColor');
|
|
1455
|
+
// Register the downcast strategy in init() so that the attribute name is registered before the list editing
|
|
1456
|
+
// registers its converters.
|
|
1457
|
+
// This ensures that the attribute is recognized by downcast strategies and bogus paragraphs are handled correctly.
|
|
1458
|
+
listEditing.registerDowncastStrategy({
|
|
1459
|
+
scope: 'item',
|
|
1460
|
+
attributeName: 'listItemFontColor',
|
|
1461
|
+
setAttributeOnDowncast (writer, value, viewElement) {
|
|
1462
|
+
if (value) {
|
|
1463
|
+
writer.addClass('ck-list-marker-color', viewElement);
|
|
1464
|
+
writer.setStyle('--ck-content-list-marker-color', value, viewElement);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* @inheritDoc
|
|
1471
|
+
*/ afterInit() {
|
|
1472
|
+
const editor = this.editor;
|
|
1473
|
+
const model = editor.model;
|
|
1474
|
+
if (!editor.plugins.has('FontColorEditing') || !this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
model.schema.extend('$listItem', {
|
|
1478
|
+
allowAttributes: 'listItemFontColor'
|
|
1479
|
+
});
|
|
1480
|
+
model.schema.setAttributeProperties('listItemFontColor', {
|
|
1481
|
+
isFormatting: true
|
|
1482
|
+
});
|
|
1483
|
+
model.schema.addAttributeCheck((context)=>{
|
|
1484
|
+
const item = context.last;
|
|
1485
|
+
if (!item.getAttribute('listItemId')) {
|
|
1486
|
+
return false;
|
|
1487
|
+
}
|
|
1488
|
+
}, 'listItemFontColor');
|
|
1489
|
+
editor.conversion.for('upcast').attributeToAttribute({
|
|
1490
|
+
model: {
|
|
1491
|
+
key: 'listItemFontColor',
|
|
1492
|
+
value: (viewElement)=>{
|
|
1493
|
+
return viewElement.getStyle('--ck-content-list-marker-color');
|
|
1494
|
+
}
|
|
1495
|
+
},
|
|
1496
|
+
view: {
|
|
1497
|
+
name: 'li',
|
|
1498
|
+
classes: 'ck-list-marker-color',
|
|
1499
|
+
styles: {
|
|
1500
|
+
'--ck-content-list-marker-color': /.*/
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
/**
|
|
1508
|
+
* The list item font family integration plugin.
|
|
1509
|
+
*/ class ListItemFontFamilyIntegration extends Plugin {
|
|
1510
|
+
/**
|
|
1511
|
+
* @inheritDoc
|
|
1512
|
+
*/ static get pluginName() {
|
|
1513
|
+
return 'ListItemFontFamilyIntegration';
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* @inheritDoc
|
|
1517
|
+
*/ static get isOfficialPlugin() {
|
|
1518
|
+
return true;
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* @inheritDoc
|
|
1522
|
+
*/ static get requires() {
|
|
1523
|
+
return [
|
|
1524
|
+
ListEditing
|
|
1525
|
+
];
|
|
1526
|
+
}
|
|
1527
|
+
/**
|
|
1528
|
+
* @inheritDoc
|
|
1529
|
+
*/ init() {
|
|
1530
|
+
const editor = this.editor;
|
|
1531
|
+
const ListFormatting = editor.plugins.get('ListFormatting');
|
|
1532
|
+
const listEditing = editor.plugins.get(ListEditing);
|
|
1533
|
+
if (!editor.plugins.has('FontFamilyEditing') || !this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1536
|
+
ListFormatting.registerFormatAttribute('fontFamily', 'listItemFontFamily');
|
|
1537
|
+
// Register the downcast strategy in init() so that the attribute name is registered before the list editing
|
|
1538
|
+
// registers its converters.
|
|
1539
|
+
// This ensures that the attribute is recognized by downcast strategies and bogus paragraphs are handled correctly.
|
|
1540
|
+
listEditing.registerDowncastStrategy({
|
|
1541
|
+
scope: 'item',
|
|
1542
|
+
attributeName: 'listItemFontFamily',
|
|
1543
|
+
setAttributeOnDowncast (writer, value, viewElement) {
|
|
1544
|
+
// There is no need of removing the style because downcast strategies handles it automatically.
|
|
1545
|
+
if (value) {
|
|
1546
|
+
writer.addClass('ck-list-marker-font-family', viewElement);
|
|
1547
|
+
writer.setStyle('--ck-content-list-marker-font-family', value, viewElement);
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* @inheritDoc
|
|
1554
|
+
*/ afterInit() {
|
|
1555
|
+
const editor = this.editor;
|
|
1556
|
+
const model = editor.model;
|
|
1557
|
+
if (!editor.plugins.has('FontFamilyEditing') || !this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
1558
|
+
return;
|
|
1559
|
+
}
|
|
1560
|
+
model.schema.extend('$listItem', {
|
|
1561
|
+
allowAttributes: 'listItemFontFamily'
|
|
1562
|
+
});
|
|
1563
|
+
model.schema.setAttributeProperties('listItemFontFamily', {
|
|
1564
|
+
isFormatting: true
|
|
1565
|
+
});
|
|
1566
|
+
model.schema.addAttributeCheck((context)=>{
|
|
1567
|
+
const item = context.last;
|
|
1568
|
+
if (!item.getAttribute('listItemId')) {
|
|
1569
|
+
return false;
|
|
1570
|
+
}
|
|
1571
|
+
}, 'listItemFontFamily');
|
|
1572
|
+
editor.conversion.for('upcast').attributeToAttribute({
|
|
1573
|
+
model: {
|
|
1574
|
+
key: 'listItemFontFamily',
|
|
1575
|
+
value: (viewElement)=>{
|
|
1576
|
+
return viewElement.getStyle('--ck-content-list-marker-font-family');
|
|
1577
|
+
}
|
|
1578
|
+
},
|
|
1579
|
+
view: {
|
|
1580
|
+
name: 'li',
|
|
1581
|
+
classes: 'ck-list-marker-font-family',
|
|
1582
|
+
styles: {
|
|
1583
|
+
'--ck-content-list-marker-font-family': /.*/
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* The list formatting plugin.
|
|
1592
|
+
*
|
|
1593
|
+
* It enables integration with formatting plugins to style the list marker.
|
|
1594
|
+
* The list marker is styled based on the consistent formatting applied to the content of the list item.
|
|
1595
|
+
*
|
|
1596
|
+
* The list of supported formatting plugins includes:
|
|
1597
|
+
* * Font color.
|
|
1598
|
+
* * Font size.
|
|
1599
|
+
* * Font family.
|
|
1600
|
+
* * Bold.
|
|
1601
|
+
* * Italic.
|
|
1602
|
+
*/ class ListFormatting extends Plugin {
|
|
1603
|
+
/**
|
|
1604
|
+
* The list of loaded formatting.
|
|
1605
|
+
*/ _loadedFormatting = {};
|
|
1606
|
+
/**
|
|
1607
|
+
* @inheritDoc
|
|
1608
|
+
*/ static get pluginName() {
|
|
1609
|
+
return 'ListFormatting';
|
|
1610
|
+
}
|
|
1611
|
+
/**
|
|
1612
|
+
* @inheritDoc
|
|
1613
|
+
*/ static get isOfficialPlugin() {
|
|
1614
|
+
return true;
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* @inheritDoc
|
|
1618
|
+
*/ static get requires() {
|
|
1619
|
+
return [
|
|
1620
|
+
ListItemBoldIntegration,
|
|
1621
|
+
ListItemItalicIntegration,
|
|
1622
|
+
ListItemFontSizeIntegration,
|
|
1623
|
+
ListItemFontColorIntegration,
|
|
1624
|
+
ListItemFontFamilyIntegration
|
|
1625
|
+
];
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* @inheritDoc
|
|
1629
|
+
*/ constructor(editor){
|
|
1630
|
+
super(editor);
|
|
1631
|
+
editor.config.define('list.enableListItemMarkerFormatting', true);
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* @inheritDoc
|
|
1635
|
+
*/ afterInit() {
|
|
1636
|
+
if (!this.editor.config.get('list.enableListItemMarkerFormatting')) {
|
|
1637
|
+
return;
|
|
1638
|
+
}
|
|
1639
|
+
this._registerPostfixerForListItemFormatting();
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Registers a postfixer that ensures that the list item formatting attribute is consistent with the formatting
|
|
1643
|
+
* applied to the content of the list item.
|
|
1644
|
+
*/ _registerPostfixerForListItemFormatting() {
|
|
1645
|
+
const model = this.editor.model;
|
|
1646
|
+
model.document.registerPostFixer((writer)=>{
|
|
1647
|
+
const changes = model.document.differ.getChanges();
|
|
1648
|
+
const modifiedListItems = new Set();
|
|
1649
|
+
let returnValue = false;
|
|
1650
|
+
for (const entry of changes){
|
|
1651
|
+
if (entry.type === 'attribute') {
|
|
1652
|
+
if (entry.attributeKey == 'listItemId' || entry.attributeKey == 'listType' || this._isInlineOrSelectionFormatting(entry.attributeKey)) {
|
|
1653
|
+
if (isListItemBlock(entry.range.start.nodeAfter)) {
|
|
1654
|
+
modifiedListItems.add(entry.range.start.nodeAfter);
|
|
1655
|
+
} else if (isListItemBlock(entry.range.start.parent)) {
|
|
1656
|
+
modifiedListItems.add(entry.range.start.parent);
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
} else {
|
|
1660
|
+
if (isListItemBlock(entry.position.nodeAfter)) {
|
|
1661
|
+
modifiedListItems.add(entry.position.nodeAfter);
|
|
1662
|
+
}
|
|
1663
|
+
if (isListItemBlock(entry.position.nodeBefore)) {
|
|
1664
|
+
modifiedListItems.add(entry.position.nodeBefore);
|
|
1665
|
+
}
|
|
1666
|
+
if (isListItemBlock(entry.position.parent)) {
|
|
1667
|
+
modifiedListItems.add(entry.position.parent);
|
|
1668
|
+
}
|
|
1669
|
+
if (entry.type == 'insert' && entry.name != '$text') {
|
|
1670
|
+
const range = writer.createRangeIn(entry.position.nodeAfter);
|
|
1671
|
+
for (const item of range.getItems()){
|
|
1672
|
+
if (isListItemBlock(item)) {
|
|
1673
|
+
modifiedListItems.add(item);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
for (const listItem of modifiedListItems){
|
|
1680
|
+
const formats = getListItemConsistentFormat(model, listItem, Object.keys(this._loadedFormatting));
|
|
1681
|
+
for (const [formatAttributeName, formatValue] of Object.entries(formats)){
|
|
1682
|
+
const listItemFormatAttributeName = this._loadedFormatting[formatAttributeName];
|
|
1683
|
+
if (formatValue && setFormattingToListItem(writer, listItem, listItemFormatAttributeName, formatValue)) {
|
|
1684
|
+
returnValue = true;
|
|
1685
|
+
} else if (!formatValue && removeFormattingFromListItem(writer, listItem, listItemFormatAttributeName)) {
|
|
1686
|
+
returnValue = true;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
return returnValue;
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
/**
|
|
1694
|
+
* Registers an integration between a default attribute (e.g., `fontFamily`) and a new attribute
|
|
1695
|
+
* intended specifically for list item elements (e.g., `listItemFontFamily`).
|
|
1696
|
+
*
|
|
1697
|
+
* These attributes are later used by the postfixer logic to determine whether to add the new attribute
|
|
1698
|
+
* to the list item element, based on whether there is a consistent default formatting attribute
|
|
1699
|
+
* applied within its content.
|
|
1700
|
+
*/ registerFormatAttribute(formatAttribute, listItemFormatAttribute) {
|
|
1701
|
+
this._loadedFormatting[formatAttribute] = listItemFormatAttribute;
|
|
1702
|
+
}
|
|
1703
|
+
/**
|
|
1704
|
+
* Returns true if the given model attribute name is a supported inline formatting attribute.
|
|
1705
|
+
*/ _isInlineOrSelectionFormatting(attributeKey) {
|
|
1706
|
+
return attributeKey.replace(/^selection:/, '') in this._loadedFormatting;
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* Returns the consistent format of the list item element.
|
|
1711
|
+
* If the list item contains multiple blocks, it checks only the first block.
|
|
1712
|
+
*/ function getListItemConsistentFormat(model, listItem, attributeKeys) {
|
|
1713
|
+
if (isFirstBlockOfListItem(listItem)) {
|
|
1714
|
+
return getSingleListItemConsistentFormat(model, listItem, attributeKeys);
|
|
1715
|
+
}
|
|
1716
|
+
// Always the first block of the list item should be checked for consistent formatting.
|
|
1717
|
+
const listItemBlocks = getAllListItemBlocks(listItem);
|
|
1718
|
+
return getSingleListItemConsistentFormat(model, listItemBlocks[0], attributeKeys);
|
|
1719
|
+
}
|
|
1720
|
+
/**
|
|
1721
|
+
* Returns the consistent format of a single list item element.
|
|
1722
|
+
*/ function getSingleListItemConsistentFormat(model, listItem, attributeKeys) {
|
|
1723
|
+
// Only bulleted and numbered lists can have formatting (to-do lists are not supported).
|
|
1724
|
+
// Do not check internals of limit elements (for example, do not check table cells).
|
|
1725
|
+
if (!isNumberedOrBulletedList(listItem) || model.schema.isLimit(listItem)) {
|
|
1726
|
+
return Object.fromEntries(attributeKeys.map((attributeKey)=>[
|
|
1727
|
+
attributeKey
|
|
1728
|
+
]));
|
|
1729
|
+
}
|
|
1730
|
+
if (listItem.isEmpty) {
|
|
1731
|
+
return Object.fromEntries(attributeKeys.map((attributeKey)=>[
|
|
1732
|
+
attributeKey,
|
|
1733
|
+
listItem.getAttribute(`selection:${attributeKey}`)
|
|
1734
|
+
]));
|
|
1735
|
+
}
|
|
1736
|
+
const attributesToCheck = new Set(attributeKeys);
|
|
1737
|
+
const valuesMap = {};
|
|
1738
|
+
const range = model.createRangeIn(listItem);
|
|
1739
|
+
const walker = range.getWalker({
|
|
1740
|
+
ignoreElementEnd: true
|
|
1741
|
+
});
|
|
1742
|
+
for (const { item } of walker){
|
|
1743
|
+
for (const attributeKey of attributesToCheck){
|
|
1744
|
+
if (model.schema.checkAttribute(item, attributeKey)) {
|
|
1745
|
+
const formatAttribute = item.getAttribute(attributeKey);
|
|
1746
|
+
if (formatAttribute === undefined) {
|
|
1747
|
+
attributesToCheck.delete(attributeKey);
|
|
1748
|
+
valuesMap[attributeKey] = undefined;
|
|
1749
|
+
} else if (valuesMap[attributeKey] === undefined) {
|
|
1750
|
+
// First item inside a list item block.
|
|
1751
|
+
valuesMap[attributeKey] = formatAttribute;
|
|
1752
|
+
} else if (valuesMap[attributeKey] !== formatAttribute) {
|
|
1753
|
+
// Following items in the same block of a list item.
|
|
1754
|
+
attributesToCheck.delete(attributeKey);
|
|
1755
|
+
valuesMap[attributeKey] = undefined;
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
// End early if all attributes have been checked and are inconsistent.
|
|
1760
|
+
if (!attributesToCheck.size) {
|
|
1761
|
+
break;
|
|
1762
|
+
}
|
|
1763
|
+
// Jump over inline limit elements as we expect only outside them to be the same formatting.
|
|
1764
|
+
if (model.schema.isLimit(item)) {
|
|
1765
|
+
walker.jumpTo(model.createPositionAfter(item));
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
return valuesMap;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Adds the specified formatting attribute to the list item element.
|
|
1772
|
+
*/ function setFormattingToListItem(writer, listItem, attributeKey, attributeValue) {
|
|
1773
|
+
// Multi-block items should have consistent formatting.
|
|
1774
|
+
const listItemBlocks = getAllListItemBlocks(listItem);
|
|
1775
|
+
let wasChanged = false;
|
|
1776
|
+
for (const listItem of listItemBlocks){
|
|
1777
|
+
if (!listItem.hasAttribute(attributeKey) || listItem.getAttribute(attributeKey) !== attributeValue) {
|
|
1778
|
+
writer.setAttribute(attributeKey, attributeValue, listItem);
|
|
1779
|
+
wasChanged = true;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
return wasChanged;
|
|
1783
|
+
}
|
|
1784
|
+
/**
|
|
1785
|
+
* Removes the specified formatting attribute from the list item element.
|
|
1786
|
+
*/ function removeFormattingFromListItem(writer, listItem, attributeKey) {
|
|
1787
|
+
// Multi-block items should have consistent formatting.
|
|
1788
|
+
const listItemBlocks = getAllListItemBlocks(listItem);
|
|
1789
|
+
let wasChanged = false;
|
|
1790
|
+
for (const listItem of listItemBlocks){
|
|
1791
|
+
if (listItem.hasAttribute(attributeKey)) {
|
|
1792
|
+
writer.removeAttribute(attributeKey, listItem);
|
|
1793
|
+
wasChanged = true;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
return wasChanged;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Checks if the given list type is a numbered or bulleted list.
|
|
1800
|
+
*/ function isNumberedOrBulletedList(listItem) {
|
|
1801
|
+
return [
|
|
1802
|
+
'numbered',
|
|
1803
|
+
'bulleted',
|
|
1804
|
+
'customNumbered',
|
|
1805
|
+
'customBulleted'
|
|
1806
|
+
].includes(listItem.getAttribute('listType'));
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1165
1809
|
/**
|
|
1166
1810
|
* A set of helpers related to document lists.
|
|
1167
1811
|
*/ class ListUtils extends Plugin {
|
|
@@ -1460,7 +2104,10 @@ import { DomEventObserver, Matcher, TreeWalker, getFillerOffset } from '@ckedito
|
|
|
1460
2104
|
if (!items.length) {
|
|
1461
2105
|
return;
|
|
1462
2106
|
}
|
|
1463
|
-
const listItemId = ListItemUid.next();
|
|
2107
|
+
const listItemId = data.viewItem.getAttribute('data-list-item-id') || ListItemUid.next();
|
|
2108
|
+
conversionApi.consumable.consume(data.viewItem, {
|
|
2109
|
+
attributes: 'data-list-item-id'
|
|
2110
|
+
});
|
|
1464
2111
|
const listIndent = getIndent$1(data.viewItem);
|
|
1465
2112
|
let listType = data.viewItem.parent && data.viewItem.parent.is('element', 'ol') ? 'numbered' : 'bulleted';
|
|
1466
2113
|
// Preserve list type if was already set (for example by to-do list feature).
|
|
@@ -1668,11 +2315,13 @@ import { DomEventObserver, Matcher, TreeWalker, getFillerOffset } from '@ckedito
|
|
|
1668
2315
|
dataPipeline
|
|
1669
2316
|
});
|
|
1670
2317
|
// Then wrap them with the new list wrappers (UL, OL, LI).
|
|
1671
|
-
wrapListItemBlock(listItem, viewRange, strategies, writer);
|
|
2318
|
+
wrapListItemBlock(listItem, viewRange, strategies, writer, conversionApi.options);
|
|
1672
2319
|
};
|
|
1673
2320
|
}
|
|
1674
2321
|
/**
|
|
1675
2322
|
* The 'remove' downcast converter for custom markers.
|
|
2323
|
+
*
|
|
2324
|
+
* @internal
|
|
1676
2325
|
*/ function listItemDowncastRemoveConverter(schema) {
|
|
1677
2326
|
return (evt, data, conversionApi)=>{
|
|
1678
2327
|
const { writer, mapper } = conversionApi;
|
|
@@ -1737,6 +2386,8 @@ import { DomEventObserver, Matcher, TreeWalker, getFillerOffset } from '@ckedito
|
|
|
1737
2386
|
}
|
|
1738
2387
|
/**
|
|
1739
2388
|
* The model to view custom position mapping for cases when marker is injected at the beginning of a block.
|
|
2389
|
+
*
|
|
2390
|
+
* @internal
|
|
1740
2391
|
*/ function createModelToViewPositionMapper(strategies, view) {
|
|
1741
2392
|
return (evt, data)=>{
|
|
1742
2393
|
if (data.modelPosition.offset > 0) {
|
|
@@ -1754,7 +2405,7 @@ import { DomEventObserver, Matcher, TreeWalker, getFillerOffset } from '@ckedito
|
|
|
1754
2405
|
const viewWalker = viewRange.getWalker();
|
|
1755
2406
|
let positionAfterLastMarker = viewRange.start;
|
|
1756
2407
|
for (const { item } of viewWalker){
|
|
1757
|
-
// Walk only over the non-mapped elements (UIElements,
|
|
2408
|
+
// Walk only over the non-mapped elements (UIElements, ViewAttributeElements, $text, or any other element without mapping).
|
|
1758
2409
|
if (item.is('element') && data.mapper.toModelElement(item) || item.is('$textProxy')) {
|
|
1759
2410
|
break;
|
|
1760
2411
|
}
|
|
@@ -1787,7 +2438,7 @@ import { DomEventObserver, Matcher, TreeWalker, getFillerOffset } from '@ckedito
|
|
|
1787
2438
|
}
|
|
1788
2439
|
function collectMarkersToRemove(viewWalker) {
|
|
1789
2440
|
for (const { item } of viewWalker){
|
|
1790
|
-
// Walk only over the non-mapped elements (UIElements,
|
|
2441
|
+
// Walk only over the non-mapped elements (UIElements, ViewAttributeElements, $text, or any other element without mapping).
|
|
1791
2442
|
if (item.is('element') && mapper.toModelElement(item)) {
|
|
1792
2443
|
break;
|
|
1793
2444
|
}
|
|
@@ -1858,7 +2509,7 @@ import { DomEventObserver, Matcher, TreeWalker, getFillerOffset } from '@ckedito
|
|
|
1858
2509
|
}
|
|
1859
2510
|
/**
|
|
1860
2511
|
* Wraps the given list item with appropriate attribute elements for ul, ol, and li.
|
|
1861
|
-
*/ function wrapListItemBlock(listItem, viewRange, strategies, writer) {
|
|
2512
|
+
*/ function wrapListItemBlock(listItem, viewRange, strategies, writer, options) {
|
|
1862
2513
|
if (!listItem.hasAttribute('listIndent')) {
|
|
1863
2514
|
return;
|
|
1864
2515
|
}
|
|
@@ -1869,7 +2520,7 @@ import { DomEventObserver, Matcher, TreeWalker, getFillerOffset } from '@ckedito
|
|
|
1869
2520
|
const listViewElement = createListElement(writer, indent, currentListItem.getAttribute('listType'));
|
|
1870
2521
|
for (const strategy of strategies){
|
|
1871
2522
|
if ((strategy.scope == 'list' || strategy.scope == 'item') && currentListItem.hasAttribute(strategy.attributeName)) {
|
|
1872
|
-
strategy.setAttributeOnDowncast(writer, currentListItem.getAttribute(strategy.attributeName), strategy.scope == 'list' ? listViewElement : listItemViewElement);
|
|
2523
|
+
strategy.setAttributeOnDowncast(writer, currentListItem.getAttribute(strategy.attributeName), strategy.scope == 'list' ? listViewElement : listItemViewElement, options);
|
|
1873
2524
|
}
|
|
1874
2525
|
}
|
|
1875
2526
|
viewRange = writer.wrap(viewRange, listItemViewElement);
|
|
@@ -1952,7 +2603,8 @@ function shouldUseBogusParagraph(item, attributeNames, blocks = getAllListItemBl
|
|
|
1952
2603
|
Enter,
|
|
1953
2604
|
Delete,
|
|
1954
2605
|
ListUtils,
|
|
1955
|
-
ClipboardPipeline
|
|
2606
|
+
ClipboardPipeline,
|
|
2607
|
+
ListFormatting
|
|
1956
2608
|
];
|
|
1957
2609
|
}
|
|
1958
2610
|
/**
|
|
@@ -2023,6 +2675,7 @@ function shouldUseBogusParagraph(item, attributeNames, blocks = getAllListItemBl
|
|
|
2023
2675
|
this._setupTabIntegration();
|
|
2024
2676
|
this._setupClipboardIntegration();
|
|
2025
2677
|
this._setupAccessibilityIntegration();
|
|
2678
|
+
this._setupListItemIdConversionStrategy();
|
|
2026
2679
|
}
|
|
2027
2680
|
/**
|
|
2028
2681
|
* @inheritDoc
|
|
@@ -2068,7 +2721,7 @@ function shouldUseBogusParagraph(item, attributeNames, blocks = getAllListItemBl
|
|
|
2068
2721
|
];
|
|
2069
2722
|
}
|
|
2070
2723
|
/**
|
|
2071
|
-
* Attaches the listener to the {@link module:engine/view/document~
|
|
2724
|
+
* Attaches the listener to the {@link module:engine/view/document~ViewDocument#event:delete} event and handles backspace/delete
|
|
2072
2725
|
* keys in and around document lists.
|
|
2073
2726
|
*/ _setupDeleteIntegration() {
|
|
2074
2727
|
const editor = this.editor;
|
|
@@ -2130,7 +2783,7 @@ function shouldUseBogusParagraph(item, attributeNames, blocks = getAllListItemBl
|
|
|
2130
2783
|
});
|
|
2131
2784
|
}
|
|
2132
2785
|
/**
|
|
2133
|
-
* Attaches a listener to the {@link module:engine/view/document~
|
|
2786
|
+
* Attaches a listener to the {@link module:engine/view/document~ViewDocument#event:enter} event and handles enter key press
|
|
2134
2787
|
* in document lists.
|
|
2135
2788
|
*/ _setupEnterIntegration() {
|
|
2136
2789
|
const editor = this.editor;
|
|
@@ -2188,7 +2841,7 @@ function shouldUseBogusParagraph(item, attributeNames, blocks = getAllListItemBl
|
|
|
2188
2841
|
});
|
|
2189
2842
|
}
|
|
2190
2843
|
/**
|
|
2191
|
-
* Attaches a listener to the {@link module:engine/view/document~
|
|
2844
|
+
* Attaches a listener to the {@link module:engine/view/document~ViewDocument#event:tab} event and handles tab key and tab+shift keys
|
|
2192
2845
|
* presses in document lists.
|
|
2193
2846
|
*/ _setupTabIntegration() {
|
|
2194
2847
|
const editor = this.editor;
|
|
@@ -2389,6 +3042,20 @@ function shouldUseBogusParagraph(item, attributeNames, blocks = getAllListItemBl
|
|
|
2389
3042
|
]
|
|
2390
3043
|
});
|
|
2391
3044
|
}
|
|
3045
|
+
/**
|
|
3046
|
+
* Convert `listItemId` attribute to `data-list-item-id` attribute on the view element in both downcast pipelines.
|
|
3047
|
+
*/ _setupListItemIdConversionStrategy() {
|
|
3048
|
+
this.registerDowncastStrategy({
|
|
3049
|
+
scope: 'item',
|
|
3050
|
+
attributeName: 'listItemId',
|
|
3051
|
+
setAttributeOnDowncast (writer, attributeValue, viewElement, options) {
|
|
3052
|
+
if (options && (options.skipListItemIds || options.isClipboardPipeline)) {
|
|
3053
|
+
return;
|
|
3054
|
+
}
|
|
3055
|
+
writer.setAttribute('data-list-item-id', attributeValue, viewElement);
|
|
3056
|
+
}
|
|
3057
|
+
});
|
|
3058
|
+
}
|
|
2392
3059
|
}
|
|
2393
3060
|
/**
|
|
2394
3061
|
* Post-fixer that reacts to changes on document and fixes incorrect model states (invalid `listItemId` and `listIndent` values).
|
|
@@ -2793,27 +3460,36 @@ for (const { listStyle, typeAttribute, listType } of LIST_STYLE_TYPES){
|
|
|
2793
3460
|
}
|
|
2794
3461
|
/**
|
|
2795
3462
|
* Gets all the style types supported by given list type.
|
|
3463
|
+
*
|
|
3464
|
+
* @internal
|
|
2796
3465
|
*/ function getAllSupportedStyleTypes() {
|
|
2797
3466
|
return LIST_STYLE_TYPES.map((x)=>x.listStyle);
|
|
2798
3467
|
}
|
|
2799
3468
|
/**
|
|
2800
3469
|
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
3470
|
+
*
|
|
3471
|
+
* @internal
|
|
2801
3472
|
*/ function getListTypeFromListStyleType$1(listStyleType) {
|
|
2802
3473
|
return LIST_STYLE_TO_LIST_TYPE[listStyleType] || null;
|
|
2803
3474
|
}
|
|
2804
3475
|
/**
|
|
2805
3476
|
* Converts `type` attribute of `<ul>` or `<ol>` elements to `list-style-type` equivalent.
|
|
3477
|
+
*
|
|
3478
|
+
* @internal
|
|
2806
3479
|
*/ function getListStyleTypeFromTypeAttribute(value) {
|
|
2807
3480
|
return TYPE_ATTRIBUTE_TO_LIST_STYLE[value] || null;
|
|
2808
3481
|
}
|
|
2809
3482
|
/**
|
|
2810
3483
|
* Converts `list-style-type` style to `type` attribute of `<ul>` or `<ol>` elements.
|
|
3484
|
+
*
|
|
3485
|
+
* @internal
|
|
2811
3486
|
*/ function getTypeAttributeFromListStyleType(value) {
|
|
2812
3487
|
return LIST_STYLE_TO_TYPE_ATTRIBUTE[value] || null;
|
|
2813
3488
|
}
|
|
2814
3489
|
/**
|
|
2815
3490
|
* Normalizes list style by converting aliases to their canonical form.
|
|
2816
3491
|
*
|
|
3492
|
+
* @internal
|
|
2817
3493
|
* @param listStyle The list style value to normalize.
|
|
2818
3494
|
* @returns The canonical form of the list style.
|
|
2819
3495
|
*
|
|
@@ -3069,6 +3745,7 @@ for (const { listStyle, typeAttribute, listType } of LIST_STYLE_TYPES){
|
|
|
3069
3745
|
* }
|
|
3070
3746
|
* ```
|
|
3071
3747
|
*
|
|
3748
|
+
* @internal
|
|
3072
3749
|
* @param config The list properties {@link module:list/listconfig~ListPropertiesConfig config}.
|
|
3073
3750
|
* @returns An object with normalized list properties options.
|
|
3074
3751
|
*/ function getNormalizedConfig(config) {
|
|
@@ -4099,7 +4776,7 @@ function getStyleTypeSupportChecker(listStyleCommand) {
|
|
|
4099
4776
|
return selectedElements.every((element)=>element.getAttribute('todoListChecked'));
|
|
4100
4777
|
}
|
|
4101
4778
|
/**
|
|
4102
|
-
* Gets all to-do list items selected by the {@link module:engine/model/selection~
|
|
4779
|
+
* Gets all to-do list items selected by the {@link module:engine/model/selection~ModelSelection}.
|
|
4103
4780
|
*/ _getSelectedItems() {
|
|
4104
4781
|
const model = this.editor.model;
|
|
4105
4782
|
const schema = model.schema;
|
|
@@ -4124,7 +4801,9 @@ function getStyleTypeSupportChecker(listStyleCommand) {
|
|
|
4124
4801
|
* Observes all to-do list checkboxes state changes.
|
|
4125
4802
|
*
|
|
4126
4803
|
* Note that this observer is not available by default. To make it available it needs to be added to
|
|
4127
|
-
* {@link module:engine/view/view~
|
|
4804
|
+
* {@link module:engine/view/view~EditingView} by {@link module:engine/view/view~EditingView#addObserver} method.
|
|
4805
|
+
*
|
|
4806
|
+
* @internal
|
|
4128
4807
|
*/ class TodoCheckboxChangeObserver extends DomEventObserver {
|
|
4129
4808
|
/**
|
|
4130
4809
|
* @inheritDoc
|
|
@@ -5024,8 +5703,9 @@ const ITEM_TOGGLE_KEYSTROKE$1 = /* #__PURE__ */ parseKeystroke('Ctrl+Enter');
|
|
|
5024
5703
|
}
|
|
5025
5704
|
|
|
5026
5705
|
/**
|
|
5027
|
-
* Creates a list item {@link module:engine/view/containerelement~
|
|
5706
|
+
* Creates a list item {@link module:engine/view/containerelement~ViewContainerElement}.
|
|
5028
5707
|
*
|
|
5708
|
+
* @internal
|
|
5029
5709
|
* @param writer The writer instance.
|
|
5030
5710
|
*/ function createViewListItemElement(writer) {
|
|
5031
5711
|
const viewItem = writer.createContainerElement('li');
|
|
@@ -5037,6 +5717,7 @@ const ITEM_TOGGLE_KEYSTROKE$1 = /* #__PURE__ */ parseKeystroke('Ctrl+Enter');
|
|
|
5037
5717
|
* Then, it binds the created view list item (`<li>`) with the model `listItem` element.
|
|
5038
5718
|
* The function then returns the created view list item (`<li>`).
|
|
5039
5719
|
*
|
|
5720
|
+
* @internal
|
|
5040
5721
|
* @param modelItem Model list item.
|
|
5041
5722
|
* @param conversionApi Conversion interface.
|
|
5042
5723
|
* @returns View list element.
|
|
@@ -5056,6 +5737,7 @@ const ITEM_TOGGLE_KEYSTROKE$1 = /* #__PURE__ */ parseKeystroke('Ctrl+Enter');
|
|
|
5056
5737
|
* should be in a view list element (`<ul>` or `<ol>`) and should be its only child.
|
|
5057
5738
|
* See comments below to better understand the algorithm.
|
|
5058
5739
|
*
|
|
5740
|
+
* @internal
|
|
5059
5741
|
* @param modelItem Model list item.
|
|
5060
5742
|
* @param injectedItem
|
|
5061
5743
|
* @param conversionApi Conversion interface.
|
|
@@ -5165,6 +5847,7 @@ function mergeViewLists(viewWriter, firstList, secondList) {
|
|
|
5165
5847
|
* `<container:p>foo^<ui:span></ui:span><ui:span></ui:span>bar</container:p>`
|
|
5166
5848
|
* For position ^, the position before "bar" will be returned.
|
|
5167
5849
|
*
|
|
5850
|
+
* @internal
|
|
5168
5851
|
*/ function positionAfterUiElements(viewPosition) {
|
|
5169
5852
|
return viewPosition.getLastMatchingPosition((value)=>value.item.is('uiElement'));
|
|
5170
5853
|
}
|
|
@@ -5172,6 +5855,7 @@ function mergeViewLists(viewWriter, firstList, secondList) {
|
|
|
5172
5855
|
* Helper function that searches for a previous list item sibling of a given model item that meets the given criteria
|
|
5173
5856
|
* passed by the options object.
|
|
5174
5857
|
*
|
|
5858
|
+
* @internal
|
|
5175
5859
|
* @param options Search criteria.
|
|
5176
5860
|
* @param options.sameIndent Whether the sought sibling should have the same indentation.
|
|
5177
5861
|
* @param options.smallerIndent Whether the sought sibling should have a smaller indentation.
|
|
@@ -5197,6 +5881,8 @@ function mergeViewLists(viewWriter, firstList, secondList) {
|
|
|
5197
5881
|
}
|
|
5198
5882
|
/**
|
|
5199
5883
|
* Returns a first list view element that is direct child of the given view element.
|
|
5884
|
+
*
|
|
5885
|
+
* @internal
|
|
5200
5886
|
*/ function findNestedList(viewElement) {
|
|
5201
5887
|
for (const node of viewElement.getChildren()){
|
|
5202
5888
|
if (node.name == 'ul' || node.name == 'ol') {
|
|
@@ -5212,6 +5898,7 @@ function mergeViewLists(viewWriter, firstList, secondList) {
|
|
|
5212
5898
|
*
|
|
5213
5899
|
* Additionally, if the `position` is inside a list item, that list item will be returned as well.
|
|
5214
5900
|
*
|
|
5901
|
+
* @internal
|
|
5215
5902
|
* @param position Starting position.
|
|
5216
5903
|
* @param direction Walking direction.
|
|
5217
5904
|
*/ function getSiblingNodes(position, direction) {
|
|
@@ -5225,7 +5912,7 @@ function mergeViewLists(viewWriter, firstList, secondList) {
|
|
|
5225
5912
|
};
|
|
5226
5913
|
const limitIndent = listItem.getAttribute('listIndent');
|
|
5227
5914
|
const nodes = [
|
|
5228
|
-
...new
|
|
5915
|
+
...new ModelTreeWalker(walkerOptions)
|
|
5229
5916
|
].filter((value)=>value.item.is('element')).map((value)=>value.item);
|
|
5230
5917
|
for (const element of nodes){
|
|
5231
5918
|
// If found something else than `listItem`, we're out of the list scope.
|
|
@@ -5331,6 +6018,8 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5331
6018
|
];
|
|
5332
6019
|
/**
|
|
5333
6020
|
* Checks whether the given list-style-type is supported by numbered or bulleted list.
|
|
6021
|
+
*
|
|
6022
|
+
* @internal
|
|
5334
6023
|
*/ function getListTypeFromListStyleType(listStyleType) {
|
|
5335
6024
|
if (BULLETED_LIST_STYLE_TYPES.includes(listStyleType)) {
|
|
5336
6025
|
return 'bulleted';
|
|
@@ -5349,7 +6038,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5349
6038
|
if (this.isEmpty || hasOnlyLists) {
|
|
5350
6039
|
return 0;
|
|
5351
6040
|
}
|
|
5352
|
-
return
|
|
6041
|
+
return getViewFillerOffset.call(this);
|
|
5353
6042
|
}
|
|
5354
6043
|
|
|
5355
6044
|
/**
|
|
@@ -5399,6 +6088,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5399
6088
|
* It creates a `<ul><li></li><ul>` (or `<ol>`) view structure out of a `listItem` model element, inserts it at the correct
|
|
5400
6089
|
* position, and merges the list with surrounding lists (if available).
|
|
5401
6090
|
*
|
|
6091
|
+
* @internal
|
|
5402
6092
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
5403
6093
|
* @param model Model instance.
|
|
5404
6094
|
*/ function modelViewInsertion$1(model) {
|
|
@@ -5418,6 +6108,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5418
6108
|
/**
|
|
5419
6109
|
* A model-to-view converter for the `listItem` model element removal.
|
|
5420
6110
|
*
|
|
6111
|
+
* @internal
|
|
5421
6112
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:remove
|
|
5422
6113
|
* @param model Model instance.
|
|
5423
6114
|
* @returns Returns a conversion callback.
|
|
@@ -5460,6 +6151,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5460
6151
|
* Splitting this conversion into 2 steps makes it possible to add an additional conversion in the middle.
|
|
5461
6152
|
* Check {@link module:list/legacytodolist/legacytodolistconverters~modelViewChangeType} to see an example of it.
|
|
5462
6153
|
*
|
|
6154
|
+
* @internal
|
|
5463
6155
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
5464
6156
|
*/ const modelViewChangeType$1 = (evt, data, conversionApi)=>{
|
|
5465
6157
|
if (!conversionApi.consumable.test(data.item, evt.name)) {
|
|
@@ -5480,6 +6172,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5480
6172
|
/**
|
|
5481
6173
|
* A model-to-view converter that attempts to merge nodes split by {@link module:list/legacylist/legacyconverters~modelViewChangeType}.
|
|
5482
6174
|
*
|
|
6175
|
+
* @internal
|
|
5483
6176
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
5484
6177
|
*/ const modelViewMergeAfterChangeType = (evt, data, conversionApi)=>{
|
|
5485
6178
|
conversionApi.consumable.consume(data.item, evt.name);
|
|
@@ -5493,6 +6186,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5493
6186
|
/**
|
|
5494
6187
|
* A model-to-view converter for the `listIndent` attribute change on the `listItem` model element.
|
|
5495
6188
|
*
|
|
6189
|
+
* @internal
|
|
5496
6190
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
5497
6191
|
* @param model Model instance.
|
|
5498
6192
|
* @returns Returns a conversion callback.
|
|
@@ -5546,6 +6240,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5546
6240
|
* <listItem>bar</listItem> <ul><li>foo</li><p>xxx</p><li>bar</li></ul>
|
|
5547
6241
|
* ```
|
|
5548
6242
|
*
|
|
6243
|
+
* @internal
|
|
5549
6244
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
5550
6245
|
*/ const modelViewSplitOnInsert = (evt, data, conversionApi)=>{
|
|
5551
6246
|
if (!conversionApi.consumable.test(data.item, evt.name)) {
|
|
@@ -5657,6 +6352,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5657
6352
|
* </ul>
|
|
5658
6353
|
* ```
|
|
5659
6354
|
*
|
|
6355
|
+
* @internal
|
|
5660
6356
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:remove
|
|
5661
6357
|
*/ const modelViewMergeAfter = (evt, data, conversionApi)=>{
|
|
5662
6358
|
const viewPosition = conversionApi.mapper.toViewPosition(data.position);
|
|
@@ -5674,6 +6370,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5674
6370
|
* * checks `<li>`'s parent,
|
|
5675
6371
|
* * stores and increases the `conversionApi.store.indent` value when `<li>`'s sub-items are converted.
|
|
5676
6372
|
*
|
|
6373
|
+
* @internal
|
|
5677
6374
|
* @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
5678
6375
|
*/ const viewModelConverter = (evt, data, conversionApi)=>{
|
|
5679
6376
|
if (conversionApi.consumable.consume(data.viewItem, {
|
|
@@ -5702,6 +6399,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5702
6399
|
* This is mostly to clean whitespaces from between the `<li>` view elements inside the view list element, however, also
|
|
5703
6400
|
* incorrect data can be cleared if the view was incorrect.
|
|
5704
6401
|
*
|
|
6402
|
+
* @internal
|
|
5705
6403
|
* @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
5706
6404
|
*/ const cleanList = (evt, data, conversionApi)=>{
|
|
5707
6405
|
if (conversionApi.consumable.test(data.viewItem, {
|
|
@@ -5720,6 +6418,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5720
6418
|
/**
|
|
5721
6419
|
* A view-to-model converter for the `<li>` elements that cleans whitespace formatting from the input view.
|
|
5722
6420
|
*
|
|
6421
|
+
* @internal
|
|
5723
6422
|
* @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
5724
6423
|
*/ const cleanListItem = (evt, data, conversionApi)=>{
|
|
5725
6424
|
if (conversionApi.consumable.test(data.viewItem, {
|
|
@@ -5747,6 +6446,8 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5747
6446
|
* Returns a callback for model position to view position mapping for {@link module:engine/conversion/mapper~Mapper}. The callback fixes
|
|
5748
6447
|
* positions between the `listItem` elements that would be incorrectly mapped because of how list items are represented in the model
|
|
5749
6448
|
* and in the view.
|
|
6449
|
+
*
|
|
6450
|
+
* @internal
|
|
5750
6451
|
*/ function modelToViewPosition(view) {
|
|
5751
6452
|
return (evt, data)=>{
|
|
5752
6453
|
if (data.isPhantom) {
|
|
@@ -5774,6 +6475,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5774
6475
|
* positions between the `<li>` elements that would be incorrectly mapped because of how list items are represented in the model
|
|
5775
6476
|
* and in the view.
|
|
5776
6477
|
*
|
|
6478
|
+
* @internal
|
|
5777
6479
|
* @see module:engine/conversion/mapper~Mapper#event:viewToModelPosition
|
|
5778
6480
|
* @param model Model instance.
|
|
5779
6481
|
* @returns Returns a conversion callback.
|
|
@@ -5843,6 +6545,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5843
6545
|
* <listItem listType="bulleted" listIndent=1>Item 3</listItem> <--- note that indent got post-fixed.
|
|
5844
6546
|
* ```
|
|
5845
6547
|
*
|
|
6548
|
+
* @internal
|
|
5846
6549
|
* @param model The data model.
|
|
5847
6550
|
* @param writer The writer to do changes with.
|
|
5848
6551
|
* @returns `true` if any change has been applied, `false` otherwise.
|
|
@@ -5990,6 +6693,8 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
5990
6693
|
* <listItem listType="bulleted" listIndent=2>Y/listItem>
|
|
5991
6694
|
* <listItem listType="bulleted" listIndent=2>C</listItem>
|
|
5992
6695
|
* ```
|
|
6696
|
+
*
|
|
6697
|
+
* @internal
|
|
5993
6698
|
*/ const modelIndentPasteFixer = function(evt, [content, selectable]) {
|
|
5994
6699
|
const model = this;
|
|
5995
6700
|
// Check whether inserted content starts from a `listItem`. If it does not, it means that there are some other
|
|
@@ -6101,7 +6806,7 @@ const NUMBERED_LIST_STYLE_TYPES = [
|
|
|
6101
6806
|
/**
|
|
6102
6807
|
* Helper function that seeks for a next list item starting from given `startPosition`.
|
|
6103
6808
|
*/ function findNextListItem(startPosition) {
|
|
6104
|
-
const treeWalker = new
|
|
6809
|
+
const treeWalker = new ModelTreeWalker({
|
|
6105
6810
|
startPosition
|
|
6106
6811
|
});
|
|
6107
6812
|
let value;
|
|
@@ -7327,7 +8032,7 @@ const attributeKey = 'todoListChecked';
|
|
|
7327
8032
|
* the `checkTodoList` editor command and it is also available via aliased `todoListCheck` name.
|
|
7328
8033
|
*/ class LegacyCheckTodoListCommand extends Command {
|
|
7329
8034
|
/**
|
|
7330
|
-
* A list of to-do list items selected by the {@link module:engine/model/selection~
|
|
8035
|
+
* A list of to-do list items selected by the {@link module:engine/model/selection~ModelSelection}.
|
|
7331
8036
|
*
|
|
7332
8037
|
* @internal
|
|
7333
8038
|
*/ _selectedElements;
|
|
@@ -7352,7 +8057,7 @@ const attributeKey = 'todoListChecked';
|
|
|
7352
8057
|
this.isEnabled = !!this._selectedElements.length;
|
|
7353
8058
|
}
|
|
7354
8059
|
/**
|
|
7355
|
-
* Gets all to-do list items selected by the {@link module:engine/model/selection~
|
|
8060
|
+
* Gets all to-do list items selected by the {@link module:engine/model/selection~ModelSelection}.
|
|
7356
8061
|
*/ _getSelectedItems() {
|
|
7357
8062
|
const model = this.editor.model;
|
|
7358
8063
|
const schema = model.schema;
|
|
@@ -7392,11 +8097,12 @@ const attributeKey = 'todoListChecked';
|
|
|
7392
8097
|
/**
|
|
7393
8098
|
* A model-to-view converter for the `listItem` model element insertion.
|
|
7394
8099
|
*
|
|
7395
|
-
* It converts the `listItem` model element to an unordered list with a {@link module:engine/view/uielement~
|
|
8100
|
+
* It converts the `listItem` model element to an unordered list with a {@link module:engine/view/uielement~ViewUIElement checkbox element}
|
|
7396
8101
|
* at the beginning of each list item. It also merges the list with surrounding lists (if available).
|
|
7397
8102
|
*
|
|
7398
8103
|
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
7399
8104
|
*
|
|
8105
|
+
* @internal
|
|
7400
8106
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
7401
8107
|
* @param model Model instance.
|
|
7402
8108
|
* @param onCheckboxChecked Callback function.
|
|
@@ -7433,6 +8139,7 @@ const attributeKey = 'todoListChecked';
|
|
|
7433
8139
|
*
|
|
7434
8140
|
* It is used by {@link module:engine/controller/datacontroller~DataController}.
|
|
7435
8141
|
*
|
|
8142
|
+
* @internal
|
|
7436
8143
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
7437
8144
|
* @param model Model instance.
|
|
7438
8145
|
* @returns Returns a conversion callback.
|
|
@@ -7480,6 +8187,7 @@ const attributeKey = 'todoListChecked';
|
|
|
7480
8187
|
*
|
|
7481
8188
|
* It is used by {@link module:engine/controller/datacontroller~DataController}.
|
|
7482
8189
|
*
|
|
8190
|
+
* @internal
|
|
7483
8191
|
* @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
7484
8192
|
*/ const dataViewModelCheckmarkInsertion = (evt, data, conversionApi)=>{
|
|
7485
8193
|
const modelCursor = data.modelCursor;
|
|
@@ -7504,7 +8212,7 @@ const attributeKey = 'todoListChecked';
|
|
|
7504
8212
|
* A model-to-view converter for the `listType` attribute change on the `listItem` model element.
|
|
7505
8213
|
*
|
|
7506
8214
|
* This change means that the `<li>` element parent changes to `<ul class="todo-list">` and a
|
|
7507
|
-
* {@link module:engine/view/uielement~
|
|
8215
|
+
* {@link module:engine/view/uielement~ViewUIElement checkbox UI element} is added at the beginning
|
|
7508
8216
|
* of the list item element (or vice versa).
|
|
7509
8217
|
*
|
|
7510
8218
|
* This converter is preceded by {@link module:list/legacylist/legacyconverters~modelViewChangeType} and followed by
|
|
@@ -7513,6 +8221,7 @@ const attributeKey = 'todoListChecked';
|
|
|
7513
8221
|
*
|
|
7514
8222
|
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
7515
8223
|
*
|
|
8224
|
+
* @internal
|
|
7516
8225
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
7517
8226
|
* @param onCheckedChange Callback fired after clicking the checkbox UI element.
|
|
7518
8227
|
* @param view Editing view controller.
|
|
@@ -7552,10 +8261,11 @@ const attributeKey = 'todoListChecked';
|
|
|
7552
8261
|
/**
|
|
7553
8262
|
* A model-to-view converter for the `todoListChecked` attribute change on the `listItem` model element.
|
|
7554
8263
|
*
|
|
7555
|
-
* It marks the {@link module:engine/view/uielement~
|
|
8264
|
+
* It marks the {@link module:engine/view/uielement~ViewUIElement checkbox UI element} as checked.
|
|
7556
8265
|
*
|
|
7557
8266
|
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
7558
8267
|
*
|
|
8268
|
+
* @internal
|
|
7559
8269
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
7560
8270
|
* @param onCheckedChange Callback fired after clicking the checkbox UI element.
|
|
7561
8271
|
* @returns Returns a conversion callback.
|
|
@@ -7585,6 +8295,8 @@ const attributeKey = 'todoListChecked';
|
|
|
7585
8295
|
* This helper ensures that position inside todo-list in the view is mapped after the checkbox.
|
|
7586
8296
|
*
|
|
7587
8297
|
* It only handles the position at the beginning of a list item as other positions are properly mapped be the default mapper.
|
|
8298
|
+
*
|
|
8299
|
+
* @internal
|
|
7588
8300
|
*/ function mapModelToViewPosition(view) {
|
|
7589
8301
|
return (evt, data)=>{
|
|
7590
8302
|
const modelPosition = data.modelPosition;
|
|
@@ -7937,116 +8649,5 @@ class AdjacentListsSupport extends Plugin {
|
|
|
7937
8649
|
};
|
|
7938
8650
|
}
|
|
7939
8651
|
|
|
7940
|
-
|
|
7941
|
-
* The document list feature.
|
|
7942
|
-
*
|
|
7943
|
-
* This is an obsolete plugin that exists for backward compatibility only.
|
|
7944
|
-
* Use the {@link module:list/list~List `List`} instead.
|
|
7945
|
-
*
|
|
7946
|
-
* @deprecated
|
|
7947
|
-
*/ class DocumentList extends Plugin {
|
|
7948
|
-
/**
|
|
7949
|
-
* @inheritDoc
|
|
7950
|
-
*/ static get requires() {
|
|
7951
|
-
return [
|
|
7952
|
-
List
|
|
7953
|
-
];
|
|
7954
|
-
}
|
|
7955
|
-
/**
|
|
7956
|
-
* @inheritDoc
|
|
7957
|
-
*/ static get pluginName() {
|
|
7958
|
-
return 'DocumentList';
|
|
7959
|
-
}
|
|
7960
|
-
/**
|
|
7961
|
-
* @inheritDoc
|
|
7962
|
-
*/ static get isOfficialPlugin() {
|
|
7963
|
-
return true;
|
|
7964
|
-
}
|
|
7965
|
-
constructor(editor){
|
|
7966
|
-
super(editor);
|
|
7967
|
-
/**
|
|
7968
|
-
* The `DocumentList` plugin is obsolete. Use `List` instead.
|
|
7969
|
-
*
|
|
7970
|
-
* @error plugin-obsolete-documentlist
|
|
7971
|
-
*/ logWarning('plugin-obsolete-documentlist', {
|
|
7972
|
-
pluginName: 'DocumentList'
|
|
7973
|
-
});
|
|
7974
|
-
}
|
|
7975
|
-
}
|
|
7976
|
-
|
|
7977
|
-
/**
|
|
7978
|
-
* The document list properties feature.
|
|
7979
|
-
*
|
|
7980
|
-
* This is an obsolete plugin that exists for backward compatibility only.
|
|
7981
|
-
* Use the {@link module:list/listproperties~ListProperties `ListProperties`} instead.
|
|
7982
|
-
*
|
|
7983
|
-
* @deprecated
|
|
7984
|
-
*/ class DocumentListProperties extends Plugin {
|
|
7985
|
-
/**
|
|
7986
|
-
* @inheritDoc
|
|
7987
|
-
*/ static get requires() {
|
|
7988
|
-
return [
|
|
7989
|
-
ListProperties
|
|
7990
|
-
];
|
|
7991
|
-
}
|
|
7992
|
-
/**
|
|
7993
|
-
* @inheritDoc
|
|
7994
|
-
*/ static get pluginName() {
|
|
7995
|
-
return 'DocumentListProperties';
|
|
7996
|
-
}
|
|
7997
|
-
/**
|
|
7998
|
-
* @inheritDoc
|
|
7999
|
-
*/ static get isOfficialPlugin() {
|
|
8000
|
-
return true;
|
|
8001
|
-
}
|
|
8002
|
-
constructor(editor){
|
|
8003
|
-
super(editor);
|
|
8004
|
-
/**
|
|
8005
|
-
* The `DocumentListProperties` plugin is obsolete. Use `ListProperties` instead.
|
|
8006
|
-
*
|
|
8007
|
-
* @error plugin-obsolete-documentlistproperties
|
|
8008
|
-
*/ logWarning('plugin-obsolete-documentlistproperties', {
|
|
8009
|
-
pluginName: 'DocumentListProperties'
|
|
8010
|
-
});
|
|
8011
|
-
}
|
|
8012
|
-
}
|
|
8013
|
-
|
|
8014
|
-
/**
|
|
8015
|
-
* The to-do list feature.
|
|
8016
|
-
*
|
|
8017
|
-
* This is an obsolete plugin that exists for backward compatibility only.
|
|
8018
|
-
* Use the {@link module:list/todolist~TodoList `TodoList`} instead.
|
|
8019
|
-
*
|
|
8020
|
-
* @deprecated
|
|
8021
|
-
*/ class TodoDocumentList extends Plugin {
|
|
8022
|
-
/**
|
|
8023
|
-
* @inheritDoc
|
|
8024
|
-
*/ static get requires() {
|
|
8025
|
-
return [
|
|
8026
|
-
TodoList
|
|
8027
|
-
];
|
|
8028
|
-
}
|
|
8029
|
-
/**
|
|
8030
|
-
* @inheritDoc
|
|
8031
|
-
*/ static get pluginName() {
|
|
8032
|
-
return 'TodoDocumentList';
|
|
8033
|
-
}
|
|
8034
|
-
/**
|
|
8035
|
-
* @inheritDoc
|
|
8036
|
-
*/ static get isOfficialPlugin() {
|
|
8037
|
-
return true;
|
|
8038
|
-
}
|
|
8039
|
-
constructor(editor){
|
|
8040
|
-
super(editor);
|
|
8041
|
-
/**
|
|
8042
|
-
* The `TodoDocumentList` plugin is obsolete. Use `TodoList` instead.
|
|
8043
|
-
*
|
|
8044
|
-
* @error plugin-obsolete-tododocumentlist
|
|
8045
|
-
*/ logWarning('plugin-obsolete-tododocumentlist', {
|
|
8046
|
-
pluginName: 'TodoDocumentList'
|
|
8047
|
-
});
|
|
8048
|
-
}
|
|
8049
|
-
}
|
|
8050
|
-
|
|
8051
|
-
export { AdjacentListsSupport, DocumentList, DocumentListProperties, LegacyIndentCommand, LegacyList, LegacyListEditing, LegacyListProperties, LegacyListPropertiesEditing, LegacyListUtils, LegacyTodoList, LegacyTodoListEditing, List, ListCommand, ListEditing, ListIndentCommand, ListProperties, ListPropertiesEditing, ListPropertiesUI, ListPropertiesUtils, ListUI, ListUtils, TodoDocumentList, TodoList, TodoListEditing, TodoListUI };
|
|
8652
|
+
export { AdjacentListsSupport, CheckTodoListCommand, LegacyCheckTodoListCommand, LegacyIndentCommand, LegacyList, LegacyListCommand, LegacyListEditing, LegacyListProperties, LegacyListPropertiesEditing, LegacyListReversedCommand, LegacyListStartCommand, LegacyListStyleCommand, LegacyListUtils, LegacyTodoList, LegacyTodoListEditing, List, ListCommand, ListEditing, ListFormatting, ListIndentCommand, ListItemBoldIntegration, ListItemFontColorIntegration, ListItemFontFamilyIntegration, ListItemFontSizeIntegration, ListItemItalicIntegration, ListMergeCommand, ListProperties, ListPropertiesEditing, ListPropertiesUI, ListPropertiesUtils, ListReversedCommand, ListSplitCommand, ListStartCommand, ListStyleCommand, ListUI, ListUtils, TodoList, TodoListEditing, TodoListUI, ListBlocksIterable as _ListBlocksIterable, ListPropertiesView as _ListPropertiesView, ListWalker as _ListWalker, SiblingListBlocksIterator as _SiblingListBlocksIterator, TodoCheckboxChangeObserver as _TodoCheckboxChangeObserver, canBecomeSimpleListItem as _canBecomeSimpleListItem, createListElement as _createListElement, createListItemElement as _createListItemElement, createUIComponents as _createListUIComponents, createModelToViewPositionMapper as _createModelToViewListPositionMapper, expandListBlocksToCompleteItems as _expandListBlocksToCompleteItems, expandListBlocksToCompleteList as _expandListBlocksToCompleteList, findAndAddListHeadToMap as _findAndAddListHeadToMap, findMappedViewElement as _findMappedListItemViewElement, fixListIndents as _fixListIndents, fixListItemIds as _fixListItemIds, getAllListItemBlocks as _getAllListItemBlocks, getAllSupportedStyleTypes as _getAllSupportedListStyleTypes, getIndent$1 as _getListIndent, getListItemBlocks as _getListItemBlocks, getListItems as _getListItems, getListStyleTypeFromTypeAttribute as _getListStyleTypeFromTypeAttribute, getListTypeFromListStyleType$1 as _getListTypeFromListStyleType, getNestedListBlocks as _getNestedListBlocks, getNormalizedConfig as _getNormalizedListConfig, getSelectedBlockObject as _getSelectedBlockObject, getTypeAttributeFromListStyleType as _getTypeAttributeFromListStyleType, getViewElementIdForListType as _getViewElementIdForListType, getViewElementNameForListType as _getViewElementNameForListType, indentBlocks as _indentListBlocks, isFirstBlockOfListItem as _isFirstBlockOfListItem, isLastBlockOfListItem as _isLastBlockOfListItem, isListItemBlock as _isListItemBlock, isListItemView as _isListItemView, isListView as _isListView, isNumberedListType as _isNumberedListType, isSingleListItem as _isSingleListItem, bogusParagraphCreator as _listItemBogusParagraphCreator, listItemDowncastConverter as _listItemDowncastConverter, listItemDowncastRemoveConverter as _listItemDowncastRemoveConverter, listItemUpcastConverter as _listItemUpcastConverter, listPropertiesUpcastConverter as _listPropertiesUpcastConverter, mergeListItemBefore as _mergeListItemBefore, normalizeListStyle as _normalizeListStyle, outdentFollowingItems as _outdentFollowingListItems, outdentBlocksWithMerge as _outdentListBlocksWithMerge, reconvertItemsOnDataChange as _reconvertListItemsOnDataChange, removeListAttributes as _removeListAttributes, sortBlocks as _sortListBlocks, splitListItemBefore as _splitListItemBefore };
|
|
8052
8653
|
//# sourceMappingURL=index.js.map
|