@ckeditor/ckeditor5-list 41.3.0-alpha.4 → 41.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/list.js +1 -1
- package/package.json +2 -3
- package/src/index.d.ts +2 -2
- package/src/index.js +1 -0
- package/src/legacylist/legacylistcommand.d.ts +3 -2
- package/src/legacylistproperties/legacyliststylecommand.js +1 -0
- package/src/list/converters.d.ts +9 -1
- package/src/list/converters.js +87 -13
- package/src/list/listcommand.d.ts +14 -2
- package/src/list/listcommand.js +17 -4
- package/src/list/listediting.d.ts +7 -1
- package/src/list/listediting.js +7 -1
- package/src/list/listui.js +3 -3
- package/src/list/listutils.d.ts +7 -1
- package/src/list/listutils.js +7 -1
- package/src/list/utils/listwalker.d.ts +13 -16
- package/src/list/utils/model.d.ts +9 -2
- package/src/list/utils/model.js +12 -3
- package/src/list/utils/view.d.ts +4 -3
- package/src/list/utils/view.js +1 -1
- package/src/list/utils.d.ts +2 -2
- package/src/list/utils.js +25 -15
- package/src/listproperties/listpropertiesediting.js +2 -1
- package/src/listproperties/listpropertiesui.js +169 -82
- package/src/listproperties/liststartcommand.js +6 -3
- package/src/todolist/todolistediting.js +4 -12
- package/src/todolist/todolistui.js +2 -2
- package/dist/content-index.css +0 -102
- package/dist/editor-index.css +0 -74
- package/dist/index.css +0 -228
- package/dist/index.css.map +0 -1
- package/dist/translations/ar.d.ts +0 -8
- package/dist/translations/ar.js +0 -5
- package/dist/translations/ast.d.ts +0 -8
- package/dist/translations/ast.js +0 -5
- package/dist/translations/az.d.ts +0 -8
- package/dist/translations/az.js +0 -5
- package/dist/translations/bg.d.ts +0 -8
- package/dist/translations/bg.js +0 -5
- package/dist/translations/bn.d.ts +0 -8
- package/dist/translations/bn.js +0 -5
- package/dist/translations/ca.d.ts +0 -8
- package/dist/translations/ca.js +0 -5
- package/dist/translations/cs.d.ts +0 -8
- package/dist/translations/cs.js +0 -5
- package/dist/translations/da.d.ts +0 -8
- package/dist/translations/da.js +0 -5
- package/dist/translations/de-ch.d.ts +0 -8
- package/dist/translations/de-ch.js +0 -5
- package/dist/translations/de.d.ts +0 -8
- package/dist/translations/de.js +0 -5
- package/dist/translations/el.d.ts +0 -8
- package/dist/translations/el.js +0 -5
- package/dist/translations/en-au.d.ts +0 -8
- package/dist/translations/en-au.js +0 -5
- package/dist/translations/en-gb.d.ts +0 -8
- package/dist/translations/en-gb.js +0 -5
- package/dist/translations/en.d.ts +0 -8
- package/dist/translations/en.js +0 -5
- package/dist/translations/eo.d.ts +0 -8
- package/dist/translations/eo.js +0 -5
- package/dist/translations/es.d.ts +0 -8
- package/dist/translations/es.js +0 -5
- package/dist/translations/et.d.ts +0 -8
- package/dist/translations/et.js +0 -5
- package/dist/translations/eu.d.ts +0 -8
- package/dist/translations/eu.js +0 -5
- package/dist/translations/fa.d.ts +0 -8
- package/dist/translations/fa.js +0 -5
- package/dist/translations/fi.d.ts +0 -8
- package/dist/translations/fi.js +0 -5
- package/dist/translations/fr.d.ts +0 -8
- package/dist/translations/fr.js +0 -5
- package/dist/translations/gl.d.ts +0 -8
- package/dist/translations/gl.js +0 -5
- package/dist/translations/he.d.ts +0 -8
- package/dist/translations/he.js +0 -5
- package/dist/translations/hi.d.ts +0 -8
- package/dist/translations/hi.js +0 -5
- package/dist/translations/hr.d.ts +0 -8
- package/dist/translations/hr.js +0 -5
- package/dist/translations/hu.d.ts +0 -8
- package/dist/translations/hu.js +0 -5
- package/dist/translations/id.d.ts +0 -8
- package/dist/translations/id.js +0 -5
- package/dist/translations/it.d.ts +0 -8
- package/dist/translations/it.js +0 -5
- package/dist/translations/ja.d.ts +0 -8
- package/dist/translations/ja.js +0 -5
- package/dist/translations/jv.d.ts +0 -8
- package/dist/translations/jv.js +0 -5
- package/dist/translations/km.d.ts +0 -8
- package/dist/translations/km.js +0 -5
- package/dist/translations/kn.d.ts +0 -8
- package/dist/translations/kn.js +0 -5
- package/dist/translations/ko.d.ts +0 -8
- package/dist/translations/ko.js +0 -5
- package/dist/translations/ku.d.ts +0 -8
- package/dist/translations/ku.js +0 -5
- package/dist/translations/lt.d.ts +0 -8
- package/dist/translations/lt.js +0 -5
- package/dist/translations/lv.d.ts +0 -8
- package/dist/translations/lv.js +0 -5
- package/dist/translations/ms.d.ts +0 -8
- package/dist/translations/ms.js +0 -5
- package/dist/translations/nb.d.ts +0 -8
- package/dist/translations/nb.js +0 -5
- package/dist/translations/ne.d.ts +0 -8
- package/dist/translations/ne.js +0 -5
- package/dist/translations/nl.d.ts +0 -8
- package/dist/translations/nl.js +0 -5
- package/dist/translations/no.d.ts +0 -8
- package/dist/translations/no.js +0 -5
- package/dist/translations/pl.d.ts +0 -8
- package/dist/translations/pl.js +0 -5
- package/dist/translations/pt-br.d.ts +0 -8
- package/dist/translations/pt-br.js +0 -5
- package/dist/translations/pt.d.ts +0 -8
- package/dist/translations/pt.js +0 -5
- package/dist/translations/ro.d.ts +0 -8
- package/dist/translations/ro.js +0 -5
- package/dist/translations/ru.d.ts +0 -8
- package/dist/translations/ru.js +0 -5
- package/dist/translations/si.d.ts +0 -8
- package/dist/translations/si.js +0 -5
- package/dist/translations/sk.d.ts +0 -8
- package/dist/translations/sk.js +0 -5
- package/dist/translations/sq.d.ts +0 -8
- package/dist/translations/sq.js +0 -5
- package/dist/translations/sr-latn.d.ts +0 -8
- package/dist/translations/sr-latn.js +0 -5
- package/dist/translations/sr.d.ts +0 -8
- package/dist/translations/sr.js +0 -5
- package/dist/translations/sv.d.ts +0 -8
- package/dist/translations/sv.js +0 -5
- package/dist/translations/th.d.ts +0 -8
- package/dist/translations/th.js +0 -5
- package/dist/translations/tk.d.ts +0 -8
- package/dist/translations/tk.js +0 -5
- package/dist/translations/tr.d.ts +0 -8
- package/dist/translations/tr.js +0 -5
- package/dist/translations/tt.d.ts +0 -8
- package/dist/translations/tt.js +0 -5
- package/dist/translations/ug.d.ts +0 -8
- package/dist/translations/ug.js +0 -5
- package/dist/translations/uk.d.ts +0 -8
- package/dist/translations/uk.js +0 -5
- package/dist/translations/ur.d.ts +0 -8
- package/dist/translations/ur.js +0 -5
- package/dist/translations/uz.d.ts +0 -8
- package/dist/translations/uz.js +0 -5
- package/dist/translations/vi.d.ts +0 -8
- package/dist/translations/vi.js +0 -5
- package/dist/translations/zh-cn.d.ts +0 -8
- package/dist/translations/zh-cn.js +0 -5
- package/dist/translations/zh.d.ts +0 -8
- package/dist/translations/zh.js +0 -5
- package/dist/types/augmentation.d.ts +0 -57
- package/dist/types/documentlist.d.ts +0 -32
- package/dist/types/documentlistproperties.d.ts +0 -32
- package/dist/types/index.d.ts +0 -49
- package/dist/types/legacylist/legacyconverters.d.ts +0 -200
- package/dist/types/legacylist/legacyindentcommand.d.ts +0 -41
- package/dist/types/legacylist/legacylistcommand.d.ts +0 -59
- package/dist/types/legacylist/legacylistediting.d.ts +0 -36
- package/dist/types/legacylist/legacylistutils.d.ts +0 -45
- package/dist/types/legacylist/legacyutils.d.ts +0 -105
- package/dist/types/legacylist.d.ts +0 -30
- package/dist/types/legacylistproperties/legacylistpropertiesediting.d.ts +0 -76
- package/dist/types/legacylistproperties/legacylistreversedcommand.d.ts +0 -42
- package/dist/types/legacylistproperties/legacyliststartcommand.d.ts +0 -41
- package/dist/types/legacylistproperties/legacyliststylecommand.d.ts +0 -71
- package/dist/types/legacylistproperties.d.ts +0 -31
- package/dist/types/legacytodolist/legacychecktodolistcommand.d.ts +0 -56
- package/dist/types/legacytodolist/legacytodolistconverters.d.ts +0 -87
- package/dist/types/legacytodolist/legacytodolistediting.d.ts +0 -43
- package/dist/types/legacytodolist.d.ts +0 -31
- package/dist/types/list/adjacentlistssupport.d.ts +0 -19
- package/dist/types/list/converters.d.ts +0 -69
- package/dist/types/list/listcommand.d.ts +0 -84
- package/dist/types/list/listediting.d.ts +0 -220
- package/dist/types/list/listindentcommand.d.ts +0 -66
- package/dist/types/list/listmergecommand.d.ts +0 -80
- package/dist/types/list/listsplitcommand.d.ts +0 -71
- package/dist/types/list/listui.d.ts +0 -23
- package/dist/types/list/listutils.d.ts +0 -50
- package/dist/types/list/utils/listwalker.d.ts +0 -149
- package/dist/types/list/utils/model.d.ts +0 -206
- package/dist/types/list/utils/postfixers.d.ts +0 -41
- package/dist/types/list/utils/view.d.ts +0 -85
- package/dist/types/list/utils.d.ts +0 -22
- package/dist/types/list.d.ts +0 -30
- package/dist/types/listconfig.d.ts +0 -136
- package/dist/types/listproperties/converters.d.ts +0 -23
- package/dist/types/listproperties/listpropertiesediting.d.ts +0 -92
- package/dist/types/listproperties/listpropertiesui.d.ts +0 -27
- package/dist/types/listproperties/listpropertiesutils.d.ts +0 -37
- package/dist/types/listproperties/listreversedcommand.d.ts +0 -40
- package/dist/types/listproperties/liststartcommand.d.ts +0 -42
- package/dist/types/listproperties/liststylecommand.d.ts +0 -76
- package/dist/types/listproperties/ui/listpropertiesview.d.ts +0 -160
- package/dist/types/listproperties/utils/style.d.ts +0 -24
- package/dist/types/listproperties.d.ts +0 -31
- package/dist/types/tododocumentlist.d.ts +0 -32
- package/dist/types/todolist/checktodolistcommand.d.ts +0 -53
- package/dist/types/todolist/todocheckboxchangeobserver.d.ts +0 -45
- package/dist/types/todolist/todolistediting.d.ts +0 -42
- package/dist/types/todolist/todolistui.d.ts +0 -23
- package/dist/types/todolist.d.ts +0 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-list",
|
|
3
|
-
"version": "41.3.
|
|
3
|
+
"version": "41.3.1",
|
|
4
4
|
"description": "Ordered and unordered lists feature to CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"ckeditor5": "41.3.
|
|
16
|
+
"ckeditor5": "41.3.1"
|
|
17
17
|
},
|
|
18
18
|
"author": "CKSource (http://cksource.com/)",
|
|
19
19
|
"license": "GPL-2.0-or-later",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"directory": "packages/ckeditor5-list"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
-
"dist",
|
|
29
28
|
"lang",
|
|
30
29
|
"src/**/*.js",
|
|
31
30
|
"src/**/*.d.ts",
|
package/src/index.d.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* @module list
|
|
7
7
|
*/
|
|
8
8
|
export { default as List } from './list.js';
|
|
9
|
-
export { default as ListEditing, type ListEditingPostFixerEvent } from './list/listediting.js';
|
|
9
|
+
export { default as ListEditing, type ListEditingPostFixerEvent, type ListType } from './list/listediting.js';
|
|
10
10
|
export { default as ListUtils } from './list/listutils.js';
|
|
11
11
|
export { default as ListUI } from './list/listui.js';
|
|
12
12
|
export { default as ListIndentCommand } from './list/listindentcommand.js';
|
|
13
|
-
export
|
|
13
|
+
export { default as ListCommand } from './list/listcommand.js';
|
|
14
14
|
export type { default as ListMergeCommand } from './list/listmergecommand.js';
|
|
15
15
|
export type { default as ListSplitCommand } from './list/listsplitcommand.js';
|
|
16
16
|
export { default as ListProperties } from './listproperties.js';
|
package/src/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { default as ListEditing } from './list/listediting.js';
|
|
|
11
11
|
export { default as ListUtils } from './list/listutils.js';
|
|
12
12
|
export { default as ListUI } from './list/listui.js';
|
|
13
13
|
export { default as ListIndentCommand } from './list/listindentcommand.js';
|
|
14
|
+
export { default as ListCommand } from './list/listcommand.js';
|
|
14
15
|
// ListProperties.
|
|
15
16
|
export { default as ListProperties } from './listproperties.js';
|
|
16
17
|
export { default as ListPropertiesEditing } from './listproperties/listpropertiesediting.js';
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
6
|
+
import { type ListType } from '../list/listediting.js';
|
|
6
7
|
/**
|
|
7
8
|
* The list command. It is used by the {@link module:list/legacylist~LegacyList legacy list feature}.
|
|
8
9
|
*/
|
|
@@ -10,7 +11,7 @@ export default class LegacyListCommand extends Command {
|
|
|
10
11
|
/**
|
|
11
12
|
* The type of the list created by the command.
|
|
12
13
|
*/
|
|
13
|
-
readonly type:
|
|
14
|
+
readonly type: ListType;
|
|
14
15
|
/**
|
|
15
16
|
* A flag indicating whether the command is active, which means that the selection starts in a list of the same type.
|
|
16
17
|
*
|
|
@@ -23,7 +24,7 @@ export default class LegacyListCommand extends Command {
|
|
|
23
24
|
* @param editor The editor instance.
|
|
24
25
|
* @param type List type that will be handled by this command.
|
|
25
26
|
*/
|
|
26
|
-
constructor(editor: Editor, type:
|
|
27
|
+
constructor(editor: Editor, type: ListType);
|
|
27
28
|
/**
|
|
28
29
|
* @inheritDoc
|
|
29
30
|
*/
|
package/src/list/converters.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module list/list/converters
|
|
7
7
|
*/
|
|
8
|
-
import { type DowncastAttributeEvent, type EditingController, type Element, type ElementCreatorFunction, type Mapper, type Model, type UpcastElementEvent, type ViewElement } from 'ckeditor5/src/engine.js';
|
|
8
|
+
import { type DowncastAttributeEvent, type EditingController, type Element, type ElementCreatorFunction, type Mapper, type Model, type UpcastElementEvent, type ViewElement, type DowncastRemoveEvent, type EditingView, type MapperModelToViewPositionEvent, type Schema } from 'ckeditor5/src/engine.js';
|
|
9
9
|
import type { GetCallback } from 'ckeditor5/src/utils.js';
|
|
10
10
|
import { type ListElement } from './utils/model.js';
|
|
11
11
|
import type { default as ListEditing, DowncastStrategy } from './listediting.js';
|
|
@@ -44,6 +44,10 @@ export declare function reconvertItemsOnDataChange(model: Model, editing: Editin
|
|
|
44
44
|
export declare function listItemDowncastConverter(attributeNames: Array<string>, strategies: Array<DowncastStrategy>, model: Model, { dataPipeline }?: {
|
|
45
45
|
dataPipeline?: boolean;
|
|
46
46
|
}): GetCallback<DowncastAttributeEvent<ListElement>>;
|
|
47
|
+
/**
|
|
48
|
+
* The 'remove' downcast converter for custom markers.
|
|
49
|
+
*/
|
|
50
|
+
export declare function listItemDowncastRemoveConverter(schema: Schema): GetCallback<DowncastRemoveEvent>;
|
|
47
51
|
/**
|
|
48
52
|
* Returns the bogus paragraph view element creator. A bogus paragraph is used if a list item contains only a single block or nested list.
|
|
49
53
|
*
|
|
@@ -63,3 +67,7 @@ export declare function bogusParagraphCreator(attributeNames: Array<string>, { d
|
|
|
63
67
|
* @param model The model.
|
|
64
68
|
*/
|
|
65
69
|
export declare function findMappedViewElement(element: Element, mapper: Mapper, model: Model): ViewElement | null;
|
|
70
|
+
/**
|
|
71
|
+
* The model to view custom position mapping for cases when marker is injected at the beginning of a block.
|
|
72
|
+
*/
|
|
73
|
+
export declare function createModelToViewPositionMapper(strategies: Array<DowncastStrategy>, view: EditingView): GetCallback<MapperModelToViewPositionEvent>;
|
package/src/list/converters.js
CHANGED
|
@@ -265,6 +265,35 @@ export function listItemDowncastConverter(attributeNames, strategies, model, { d
|
|
|
265
265
|
wrapListItemBlock(listItem, viewRange, strategies, writer);
|
|
266
266
|
};
|
|
267
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* The 'remove' downcast converter for custom markers.
|
|
270
|
+
*/
|
|
271
|
+
export function listItemDowncastRemoveConverter(schema) {
|
|
272
|
+
return (evt, data, conversionApi) => {
|
|
273
|
+
const { writer, mapper } = conversionApi;
|
|
274
|
+
const elementName = evt.name.split(':')[1];
|
|
275
|
+
// Do not remove marker if the deleted element is some inline object inside paragraph.
|
|
276
|
+
// See https://github.com/cksource/ckeditor5-internal/issues/3680.
|
|
277
|
+
if (!schema.checkAttribute(elementName, 'listItemId')) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
// Find the view range start position by mapping the model position at which the remove happened.
|
|
281
|
+
const viewStart = mapper.toViewPosition(data.position);
|
|
282
|
+
const modelEnd = data.position.getShiftedBy(data.length);
|
|
283
|
+
const viewEnd = mapper.toViewPosition(modelEnd, { isPhantom: true });
|
|
284
|
+
// Trim the range to remove in case some UI elements are on the view range boundaries.
|
|
285
|
+
const viewRange = writer.createRange(viewStart, viewEnd).getTrimmed();
|
|
286
|
+
// Use positions mapping instead of mapper.toViewElement( listItem ) to find outermost view element.
|
|
287
|
+
// This is for cases when mapping is using inner view element like in the code blocks (pre > code).
|
|
288
|
+
const viewElement = viewRange.end.nodeBefore;
|
|
289
|
+
/* istanbul ignore next -- @preserve */
|
|
290
|
+
if (!viewElement) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
// Remove custom item marker.
|
|
294
|
+
removeCustomMarkerElements(viewElement, writer, mapper);
|
|
295
|
+
};
|
|
296
|
+
}
|
|
268
297
|
/**
|
|
269
298
|
* Returns the bogus paragraph view element creator. A bogus paragraph is used if a list item contains only a single block or nested list.
|
|
270
299
|
*
|
|
@@ -300,29 +329,69 @@ export function findMappedViewElement(element, mapper, model) {
|
|
|
300
329
|
const viewRange = mapper.toViewRange(modelRange).getTrimmed();
|
|
301
330
|
return viewRange.end.nodeBefore;
|
|
302
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* The model to view custom position mapping for cases when marker is injected at the beginning of a block.
|
|
334
|
+
*/
|
|
335
|
+
export function createModelToViewPositionMapper(strategies, view) {
|
|
336
|
+
return (evt, data) => {
|
|
337
|
+
if (data.modelPosition.offset > 0) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const positionParent = data.modelPosition.parent;
|
|
341
|
+
if (!isListItemBlock(positionParent)) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (!strategies.some(strategy => (strategy.scope == 'itemMarker' &&
|
|
345
|
+
strategy.canInjectMarkerIntoElement &&
|
|
346
|
+
strategy.canInjectMarkerIntoElement(positionParent)))) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const viewElement = data.mapper.toViewElement(positionParent);
|
|
350
|
+
const viewRange = view.createRangeIn(viewElement);
|
|
351
|
+
const viewWalker = viewRange.getWalker();
|
|
352
|
+
let positionAfterLastMarker = viewRange.start;
|
|
353
|
+
for (const { item } of viewWalker) {
|
|
354
|
+
// Walk only over the non-mapped elements (UIElements, AttributeElements, $text, or any other element without mapping).
|
|
355
|
+
if (item.is('element') && data.mapper.toModelElement(item) || item.is('$textProxy')) {
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
if (item.is('element') && item.getCustomProperty('listItemMarker')) {
|
|
359
|
+
positionAfterLastMarker = view.createPositionAfter(item);
|
|
360
|
+
// Jump over the content of the marker (this is not needed for UIElement but required for other element types).
|
|
361
|
+
viewWalker.skip(({ previousPosition }) => !previousPosition.isEqual(positionAfterLastMarker));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
data.viewPosition = positionAfterLastMarker;
|
|
365
|
+
};
|
|
366
|
+
}
|
|
303
367
|
/**
|
|
304
368
|
* Removes a custom marker elements and item wrappers related to that marker.
|
|
305
369
|
*/
|
|
306
370
|
function removeCustomMarkerElements(viewElement, viewWriter, mapper) {
|
|
307
371
|
// Remove item wrapper.
|
|
308
372
|
while (viewElement.parent.is('attributeElement') && viewElement.parent.getCustomProperty('listItemWrapper')) {
|
|
309
|
-
viewWriter.unwrap(viewWriter.
|
|
373
|
+
viewWriter.unwrap(viewWriter.createRangeOn(viewElement), viewElement.parent);
|
|
310
374
|
}
|
|
311
375
|
// Remove custom item markers.
|
|
312
|
-
const viewWalker = viewWriter.createPositionBefore(viewElement).getWalker({ direction: 'backward' });
|
|
313
376
|
const markersToRemove = [];
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
if (item.is('element') && item.getCustomProperty('listItemMarker')) {
|
|
320
|
-
markersToRemove.push(item);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
377
|
+
// Markers before a block.
|
|
378
|
+
collectMarkersToRemove(viewWriter.createPositionBefore(viewElement).getWalker({ direction: 'backward' }));
|
|
379
|
+
// Markers inside a block.
|
|
380
|
+
collectMarkersToRemove(viewWriter.createRangeIn(viewElement).getWalker());
|
|
323
381
|
for (const marker of markersToRemove) {
|
|
324
382
|
viewWriter.remove(marker);
|
|
325
383
|
}
|
|
384
|
+
function collectMarkersToRemove(viewWalker) {
|
|
385
|
+
for (const { item } of viewWalker) {
|
|
386
|
+
// Walk only over the non-mapped elements (UIElements, AttributeElements, $text, or any other element without mapping).
|
|
387
|
+
if (item.is('element') && mapper.toModelElement(item)) {
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
if (item.is('element') && item.getCustomProperty('listItemMarker')) {
|
|
391
|
+
markersToRemove.push(item);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
326
395
|
}
|
|
327
396
|
/**
|
|
328
397
|
* Inserts a custom marker elements and wraps first block of a list item if marker requires it.
|
|
@@ -343,8 +412,13 @@ function insertCustomMarkerElements(listItem, viewElement, strategies, writer, {
|
|
|
343
412
|
continue;
|
|
344
413
|
}
|
|
345
414
|
writer.setCustomProperty('listItemMarker', true, markerElement);
|
|
346
|
-
|
|
347
|
-
|
|
415
|
+
if (strategy.canInjectMarkerIntoElement && strategy.canInjectMarkerIntoElement(listItem)) {
|
|
416
|
+
writer.insert(writer.createPositionAt(viewElement, 0), markerElement);
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
writer.insert(viewRange.start, markerElement);
|
|
420
|
+
viewRange = writer.createRange(writer.createPositionBefore(markerElement), writer.createPositionAfter(viewElement));
|
|
421
|
+
}
|
|
348
422
|
// Wrap the marker and optionally the first block with an attribute element (label for to-do lists).
|
|
349
423
|
if (!strategy.createWrapperElement || !strategy.canWrapElement) {
|
|
350
424
|
continue;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { Element } from 'ckeditor5/src/engine.js';
|
|
9
9
|
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
10
|
+
import { type ListType } from './listediting.js';
|
|
10
11
|
/**
|
|
11
12
|
* The list command. It is used by the {@link module:list/list~List list feature}.
|
|
12
13
|
*/
|
|
@@ -14,7 +15,7 @@ export default class ListCommand extends Command {
|
|
|
14
15
|
/**
|
|
15
16
|
* The type of the list created by the command.
|
|
16
17
|
*/
|
|
17
|
-
readonly type:
|
|
18
|
+
readonly type: ListType;
|
|
18
19
|
/**
|
|
19
20
|
* A flag indicating whether the command is active, which means that the selection starts in a list of the same type.
|
|
20
21
|
*
|
|
@@ -22,13 +23,22 @@ export default class ListCommand extends Command {
|
|
|
22
23
|
* @readonly
|
|
23
24
|
*/
|
|
24
25
|
value: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* List Walker options that change the range of the list items to be changed when the selection is collapsed within a list item.
|
|
28
|
+
*
|
|
29
|
+
* In a multi-level list, when the selection is collapsed within a list item, instead of changing only the list items of the same list
|
|
30
|
+
* type and current indent level, the entire list structure is changed (all list items at all indent levels of any list type).
|
|
31
|
+
*/
|
|
32
|
+
private readonly _listWalkerOptions?;
|
|
25
33
|
/**
|
|
26
34
|
* Creates an instance of the command.
|
|
27
35
|
*
|
|
28
36
|
* @param editor The editor instance.
|
|
29
37
|
* @param type List type that will be handled by this command.
|
|
30
38
|
*/
|
|
31
|
-
constructor(editor: Editor, type:
|
|
39
|
+
constructor(editor: Editor, type: ListType, options?: {
|
|
40
|
+
multiLevel?: boolean;
|
|
41
|
+
});
|
|
32
42
|
/**
|
|
33
43
|
* @inheritDoc
|
|
34
44
|
*/
|
|
@@ -42,9 +52,11 @@ export default class ListCommand extends Command {
|
|
|
42
52
|
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will try to convert the
|
|
43
53
|
* selected items and potentially the neighbor elements to the proper list items. If set to `false` it will convert selected elements
|
|
44
54
|
* to paragraphs. If not set, the command will toggle selected elements to list items or paragraphs, depending on the selection.
|
|
55
|
+
* @param options.additionalAttributes Additional attributes that are set for list items when the command is executed.
|
|
45
56
|
*/
|
|
46
57
|
execute(options?: {
|
|
47
58
|
forceValue?: boolean;
|
|
59
|
+
additionalAttributes?: Record<string, unknown>;
|
|
48
60
|
}): void;
|
|
49
61
|
/**
|
|
50
62
|
* Fires the `afterExecute` event.
|
package/src/list/listcommand.js
CHANGED
|
@@ -14,9 +14,14 @@ export default class ListCommand extends Command {
|
|
|
14
14
|
* @param editor The editor instance.
|
|
15
15
|
* @param type List type that will be handled by this command.
|
|
16
16
|
*/
|
|
17
|
-
constructor(editor, type) {
|
|
17
|
+
constructor(editor, type, options = {}) {
|
|
18
18
|
super(editor);
|
|
19
19
|
this.type = type;
|
|
20
|
+
this._listWalkerOptions = options.multiLevel ? {
|
|
21
|
+
higherIndent: true,
|
|
22
|
+
lowerIndent: true,
|
|
23
|
+
sameAttributes: []
|
|
24
|
+
} : undefined;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* @inheritDoc
|
|
@@ -34,6 +39,7 @@ export default class ListCommand extends Command {
|
|
|
34
39
|
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will try to convert the
|
|
35
40
|
* selected items and potentially the neighbor elements to the proper list items. If set to `false` it will convert selected elements
|
|
36
41
|
* to paragraphs. If not set, the command will toggle selected elements to list items or paragraphs, depending on the selection.
|
|
42
|
+
* @param options.additionalAttributes Additional attributes that are set for list items when the command is executed.
|
|
37
43
|
*/
|
|
38
44
|
execute(options = {}) {
|
|
39
45
|
const model = this.editor.model;
|
|
@@ -60,9 +66,12 @@ export default class ListCommand extends Command {
|
|
|
60
66
|
}
|
|
61
67
|
// Changing type of list items for a collapsed selection inside a list item.
|
|
62
68
|
else if ((selectedBlockObject || document.selection.isCollapsed) && isListItemBlock(blocks[0])) {
|
|
63
|
-
const changedBlocks = getListItems(selectedBlockObject || blocks[0]);
|
|
69
|
+
const changedBlocks = getListItems(selectedBlockObject || blocks[0], this._listWalkerOptions);
|
|
64
70
|
for (const block of changedBlocks) {
|
|
65
|
-
writer.
|
|
71
|
+
writer.setAttributes({
|
|
72
|
+
...options.additionalAttributes,
|
|
73
|
+
listType: this.type
|
|
74
|
+
}, block);
|
|
66
75
|
}
|
|
67
76
|
this._fireAfterExecute(changedBlocks);
|
|
68
77
|
}
|
|
@@ -77,6 +86,7 @@ export default class ListCommand extends Command {
|
|
|
77
86
|
writer.rename(block, 'listItem');
|
|
78
87
|
}
|
|
79
88
|
writer.setAttributes({
|
|
89
|
+
...options.additionalAttributes,
|
|
80
90
|
listIndent: 0,
|
|
81
91
|
listItemId: ListItemUid.next(),
|
|
82
92
|
listType: this.type
|
|
@@ -87,7 +97,10 @@ export default class ListCommand extends Command {
|
|
|
87
97
|
else {
|
|
88
98
|
for (const node of expandListBlocksToCompleteItems(block, { withNested: false })) {
|
|
89
99
|
if (node.getAttribute('listType') != this.type) {
|
|
90
|
-
writer.
|
|
100
|
+
writer.setAttributes({
|
|
101
|
+
...options.additionalAttributes,
|
|
102
|
+
listType: this.type
|
|
103
|
+
}, node);
|
|
91
104
|
changedBlocks.push(node);
|
|
92
105
|
}
|
|
93
106
|
}
|
|
@@ -14,11 +14,12 @@ import { ListBlocksIterable } from './utils/listwalker.js';
|
|
|
14
14
|
import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
|
|
15
15
|
import '../../theme/documentlist.css';
|
|
16
16
|
import '../../theme/list.css';
|
|
17
|
+
export type ListType = 'numbered' | 'bulleted' | 'todo' | 'customNumbered' | 'customBulleted';
|
|
17
18
|
/**
|
|
18
19
|
* Map of model attributes applicable to list blocks.
|
|
19
20
|
*/
|
|
20
21
|
export interface ListItemAttributesMap {
|
|
21
|
-
listType?:
|
|
22
|
+
listType?: ListType;
|
|
22
23
|
listIndent?: number;
|
|
23
24
|
listItemId?: string;
|
|
24
25
|
}
|
|
@@ -142,6 +143,11 @@ export interface ItemMarkerDowncastStrategy {
|
|
|
142
143
|
* or only the marker element should be wrapped.
|
|
143
144
|
*/
|
|
144
145
|
canWrapElement?(modelElement: Element): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Should return true if the custom marker can be injected into a given list block.
|
|
148
|
+
* Otherwise, custom marker view element is always injected before the block element.
|
|
149
|
+
*/
|
|
150
|
+
canInjectMarkerIntoElement?(modelElement: Element): boolean;
|
|
145
151
|
}
|
|
146
152
|
/**
|
|
147
153
|
* The downcast strategy.
|
package/src/list/listediting.js
CHANGED
|
@@ -14,7 +14,7 @@ import ListCommand from './listcommand.js';
|
|
|
14
14
|
import ListMergeCommand from './listmergecommand.js';
|
|
15
15
|
import ListSplitCommand from './listsplitcommand.js';
|
|
16
16
|
import ListUtils from './listutils.js';
|
|
17
|
-
import { bogusParagraphCreator, listItemDowncastConverter, listItemUpcastConverter, listUpcastCleanList, reconvertItemsOnDataChange } from './converters.js';
|
|
17
|
+
import { bogusParagraphCreator, createModelToViewPositionMapper, listItemDowncastConverter, listItemDowncastRemoveConverter, listItemUpcastConverter, listUpcastCleanList, reconvertItemsOnDataChange } from './converters.js';
|
|
18
18
|
import { findAndAddListHeadToMap, fixListIndents, fixListItemIds } from './utils/postfixers.js';
|
|
19
19
|
import { getAllListItemBlocks, isFirstBlockOfListItem, isLastBlockOfListItem, isSingleListItem, getSelectedBlockObject, isListItemBlock, removeListAttributes, ListItemUid } from './utils/model.js';
|
|
20
20
|
import { getViewElementIdForListType, getViewElementNameForListType } from './utils/view.js';
|
|
@@ -89,6 +89,8 @@ export default class ListEditing extends Plugin {
|
|
|
89
89
|
// Register commands.
|
|
90
90
|
editor.commands.add('numberedList', new ListCommand(editor, 'numbered'));
|
|
91
91
|
editor.commands.add('bulletedList', new ListCommand(editor, 'bulleted'));
|
|
92
|
+
editor.commands.add('customNumberedList', new ListCommand(editor, 'customNumbered', { multiLevel: true }));
|
|
93
|
+
editor.commands.add('customBulletedList', new ListCommand(editor, 'customBulleted', { multiLevel: true }));
|
|
92
94
|
editor.commands.add('indentList', new ListIndentCommand(editor, 'forward'));
|
|
93
95
|
editor.commands.add('outdentList', new ListIndentCommand(editor, 'backward'));
|
|
94
96
|
editor.commands.add('splitListItemBefore', new ListSplitCommand(editor, 'before'));
|
|
@@ -347,6 +349,7 @@ export default class ListEditing extends Plugin {
|
|
|
347
349
|
})
|
|
348
350
|
.add(dispatcher => {
|
|
349
351
|
dispatcher.on('attribute', listItemDowncastConverter(attributeNames, this._downcastStrategies, model));
|
|
352
|
+
dispatcher.on('remove', listItemDowncastRemoveConverter(model.schema));
|
|
350
353
|
});
|
|
351
354
|
editor.conversion.for('dataDowncast')
|
|
352
355
|
.elementToElement({
|
|
@@ -357,6 +360,9 @@ export default class ListEditing extends Plugin {
|
|
|
357
360
|
.add(dispatcher => {
|
|
358
361
|
dispatcher.on('attribute', listItemDowncastConverter(attributeNames, this._downcastStrategies, model, { dataPipeline: true }));
|
|
359
362
|
});
|
|
363
|
+
const modelToViewPositionMapper = createModelToViewPositionMapper(this._downcastStrategies, editor.editing.view);
|
|
364
|
+
editor.editing.mapper.on('modelToViewPosition', modelToViewPositionMapper);
|
|
365
|
+
editor.data.mapper.on('modelToViewPosition', modelToViewPositionMapper);
|
|
360
366
|
this.listenTo(model.document, 'change:data', reconvertItemsOnDataChange(model, editor.editing, attributeNames, this), { priority: 'high' });
|
|
361
367
|
// For LI verify if an ID of the attribute element is correct.
|
|
362
368
|
this.on('checkAttributes:item', (evt, { viewElement, modelAttributes }) => {
|
package/src/list/listui.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module list/list/listui
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { createUIComponents } from './utils.js';
|
|
9
9
|
import { icons, Plugin } from 'ckeditor5/src/core.js';
|
|
10
10
|
/**
|
|
11
11
|
* The list UI feature. It introduces the `'numberedList'` and `'bulletedList'` buttons that
|
|
@@ -24,7 +24,7 @@ export default class ListUI extends Plugin {
|
|
|
24
24
|
init() {
|
|
25
25
|
const t = this.editor.t;
|
|
26
26
|
// Create two buttons and link them with numberedList and bulletedList commands.
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
createUIComponents(this.editor, 'numberedList', t('Numbered List'), icons.numberedList);
|
|
28
|
+
createUIComponents(this.editor, 'bulletedList', t('Bulleted List'), icons.bulletedList);
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/list/listutils.d.ts
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
import type { Element, Node } from 'ckeditor5/src/engine.js';
|
|
9
9
|
import type { ArrayOrItem } from 'ckeditor5/src/utils.js';
|
|
10
10
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
11
|
+
import { type ListElement } from './utils/model.js';
|
|
12
|
+
import type { ListType } from './listediting.js';
|
|
11
13
|
/**
|
|
12
14
|
* A set of helpers related to document lists.
|
|
13
15
|
*/
|
|
@@ -33,7 +35,7 @@ export default class ListUtils extends Plugin {
|
|
|
33
35
|
*
|
|
34
36
|
* @param node A model node.
|
|
35
37
|
*/
|
|
36
|
-
isListItemBlock(node: Node):
|
|
38
|
+
isListItemBlock(node: Node | null): node is ListElement;
|
|
37
39
|
/**
|
|
38
40
|
* Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.
|
|
39
41
|
*
|
|
@@ -43,4 +45,8 @@ export default class ListUtils extends Plugin {
|
|
|
43
45
|
expandListBlocksToCompleteItems(blocks: ArrayOrItem<Element>, options?: {
|
|
44
46
|
withNested?: boolean;
|
|
45
47
|
}): Array<Element>;
|
|
48
|
+
/**
|
|
49
|
+
* Returns true if listType is of type `numbered` or `customNumbered`.
|
|
50
|
+
*/
|
|
51
|
+
isNumberedListType(listType: ListType): boolean;
|
|
46
52
|
}
|
package/src/list/listutils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
import { expandListBlocksToCompleteItems, expandListBlocksToCompleteList, isFirstBlockOfListItem, isListItemBlock } from './utils/model.js';
|
|
6
|
+
import { expandListBlocksToCompleteItems, expandListBlocksToCompleteList, isFirstBlockOfListItem, isListItemBlock, isNumberedListType } from './utils/model.js';
|
|
7
7
|
/**
|
|
8
8
|
* A set of helpers related to document lists.
|
|
9
9
|
*/
|
|
@@ -47,4 +47,10 @@ export default class ListUtils extends Plugin {
|
|
|
47
47
|
expandListBlocksToCompleteItems(blocks, options = {}) {
|
|
48
48
|
return expandListBlocksToCompleteItems(blocks, options);
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns true if listType is of type `numbered` or `customNumbered`.
|
|
52
|
+
*/
|
|
53
|
+
isNumberedListType(listType) {
|
|
54
|
+
return isNumberedListType(listType);
|
|
55
|
+
}
|
|
50
56
|
}
|
|
@@ -58,14 +58,7 @@ export default class ListWalker {
|
|
|
58
58
|
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
59
59
|
* in the result.
|
|
60
60
|
*/
|
|
61
|
-
constructor(startElement: Node, options:
|
|
62
|
-
direction?: 'forward' | 'backward';
|
|
63
|
-
includeSelf?: boolean;
|
|
64
|
-
sameAttributes?: ArrayOrItem<string>;
|
|
65
|
-
sameIndent?: boolean;
|
|
66
|
-
lowerIndent?: boolean;
|
|
67
|
-
higherIndent?: boolean;
|
|
68
|
-
});
|
|
61
|
+
constructor(startElement: Node, options: ListWalkerOptions);
|
|
69
62
|
/**
|
|
70
63
|
* Performs only first step of iteration and returns the result.
|
|
71
64
|
*
|
|
@@ -80,14 +73,7 @@ export default class ListWalker {
|
|
|
80
73
|
* @param options.higherIndent Whether blocks with a higher indent level than the start block should be included
|
|
81
74
|
* in the result.
|
|
82
75
|
*/
|
|
83
|
-
static first(startElement: Node, options:
|
|
84
|
-
direction?: 'forward' | 'backward';
|
|
85
|
-
includeSelf?: boolean;
|
|
86
|
-
sameAttributes?: ArrayOrItem<string>;
|
|
87
|
-
sameIndent?: boolean;
|
|
88
|
-
lowerIndent?: boolean;
|
|
89
|
-
higherIndent?: boolean;
|
|
90
|
-
}): ListElement | null;
|
|
76
|
+
static first(startElement: Node, options: ListWalkerOptions): ListElement | null;
|
|
91
77
|
/**
|
|
92
78
|
* Iterable interface.
|
|
93
79
|
*/
|
|
@@ -143,3 +129,14 @@ export interface ListIteratorValue {
|
|
|
143
129
|
*/
|
|
144
130
|
previousNodeInList: ListElement | null;
|
|
145
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Document list blocks iterator options.
|
|
134
|
+
*/
|
|
135
|
+
export type ListWalkerOptions = {
|
|
136
|
+
direction?: 'forward' | 'backward';
|
|
137
|
+
includeSelf?: boolean;
|
|
138
|
+
sameAttributes?: ArrayOrItem<string>;
|
|
139
|
+
sameIndent?: boolean;
|
|
140
|
+
lowerIndent?: boolean;
|
|
141
|
+
higherIndent?: boolean;
|
|
142
|
+
};
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { DocumentFragment, Element, Model, Node, Writer, Item, Schema } from 'ckeditor5/src/engine.js';
|
|
9
9
|
import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
|
|
10
|
+
import { type ListWalkerOptions } from './listwalker.js';
|
|
11
|
+
import { type ListType } from '../listediting.js';
|
|
10
12
|
/**
|
|
11
13
|
* The list item ID generator.
|
|
12
14
|
*
|
|
@@ -28,7 +30,7 @@ export declare class ListItemUid {
|
|
|
28
30
|
export interface ListElement extends Element {
|
|
29
31
|
getAttribute(key: 'listItemId'): string;
|
|
30
32
|
getAttribute(key: 'listIndent'): number;
|
|
31
|
-
getAttribute(key: 'listType'):
|
|
33
|
+
getAttribute(key: 'listType'): ListType;
|
|
32
34
|
getAttribute(key: string): unknown;
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
@@ -77,8 +79,9 @@ export declare function getNestedListBlocks(listItem: Element): Array<ListElemen
|
|
|
77
79
|
*
|
|
78
80
|
* @internal
|
|
79
81
|
* @param listItem Starting list item element.
|
|
82
|
+
* @param options Additional list walker options to modify the range of returned list items.
|
|
80
83
|
*/
|
|
81
|
-
export declare function getListItems(listItem: Element): Array<ListElement>;
|
|
84
|
+
export declare function getListItems(listItem: Element, options?: ListWalkerOptions): Array<ListElement>;
|
|
82
85
|
/**
|
|
83
86
|
* Check if the given block is the first in the list item.
|
|
84
87
|
*
|
|
@@ -200,3 +203,7 @@ export declare function getSelectedBlockObject(model: Model): Element | null;
|
|
|
200
203
|
* @param schema The schema of the document.
|
|
201
204
|
*/
|
|
202
205
|
export declare function canBecomeSimpleListItem(block: Element, schema: Schema): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Returns true if listType is of type `numbered` or `customNumbered`.
|
|
208
|
+
*/
|
|
209
|
+
export declare function isNumberedListType(listType: ListType): boolean;
|
package/src/list/utils/model.js
CHANGED
|
@@ -82,17 +82,20 @@ export function getNestedListBlocks(listItem) {
|
|
|
82
82
|
*
|
|
83
83
|
* @internal
|
|
84
84
|
* @param listItem Starting list item element.
|
|
85
|
+
* @param options Additional list walker options to modify the range of returned list items.
|
|
85
86
|
*/
|
|
86
|
-
export function getListItems(listItem) {
|
|
87
|
+
export function getListItems(listItem, options) {
|
|
87
88
|
const backwardBlocks = new ListWalker(listItem, {
|
|
88
89
|
sameIndent: true,
|
|
89
|
-
sameAttributes: 'listType'
|
|
90
|
+
sameAttributes: 'listType',
|
|
91
|
+
...options
|
|
90
92
|
});
|
|
91
93
|
const forwardBlocks = new ListWalker(listItem, {
|
|
92
94
|
sameIndent: true,
|
|
93
95
|
sameAttributes: 'listType',
|
|
94
96
|
includeSelf: true,
|
|
95
|
-
direction: 'forward'
|
|
97
|
+
direction: 'forward',
|
|
98
|
+
...options
|
|
96
99
|
});
|
|
97
100
|
return [
|
|
98
101
|
...Array.from(backwardBlocks).reverse(),
|
|
@@ -434,6 +437,12 @@ export function getSelectedBlockObject(model) {
|
|
|
434
437
|
export function canBecomeSimpleListItem(block, schema) {
|
|
435
438
|
return schema.checkChild(block.parent, 'listItem') && schema.checkChild(block, '$text') && !schema.isObject(block);
|
|
436
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Returns true if listType is of type `numbered` or `customNumbered`.
|
|
442
|
+
*/
|
|
443
|
+
export function isNumberedListType(listType) {
|
|
444
|
+
return listType == 'numbered' || listType == 'customNumbered';
|
|
445
|
+
}
|
|
437
446
|
/**
|
|
438
447
|
* Merges a given block to the given parent block if parent is a list item and there is no more blocks in the same item.
|
|
439
448
|
*/
|
package/src/list/utils/view.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @module list/list/utils/view
|
|
7
7
|
*/
|
|
8
8
|
import type { DowncastWriter, ViewAttributeElement, ViewDocumentFragment, ViewElement, ViewNode } from 'ckeditor5/src/engine.js';
|
|
9
|
+
import { type ListType } from '../listediting.js';
|
|
9
10
|
/**
|
|
10
11
|
* Checks if view element is a list type (ul or ol).
|
|
11
12
|
*
|
|
@@ -60,7 +61,7 @@ export declare function getIndent(listItem: ViewElement): number;
|
|
|
60
61
|
*
|
|
61
62
|
* @internal
|
|
62
63
|
*/
|
|
63
|
-
export declare function createListElement(writer: DowncastWriter, indent: number, type:
|
|
64
|
+
export declare function createListElement(writer: DowncastWriter, indent: number, type: ListType, id?: string): ViewAttributeElement;
|
|
64
65
|
/**
|
|
65
66
|
* Creates a list item attribute element (li).
|
|
66
67
|
*
|
|
@@ -72,10 +73,10 @@ export declare function createListItemElement(writer: DowncastWriter, indent: nu
|
|
|
72
73
|
*
|
|
73
74
|
* @internal
|
|
74
75
|
*/
|
|
75
|
-
export declare function getViewElementNameForListType(type?:
|
|
76
|
+
export declare function getViewElementNameForListType(type?: ListType): 'ol' | 'ul';
|
|
76
77
|
/**
|
|
77
78
|
* Returns a view element ID for the given list type and indent.
|
|
78
79
|
*
|
|
79
80
|
* @internal
|
|
80
81
|
*/
|
|
81
|
-
export declare function getViewElementIdForListType(type?:
|
|
82
|
+
export declare function getViewElementIdForListType(type?: ListType, indent?: number): string;
|
package/src/list/utils/view.js
CHANGED
|
@@ -105,7 +105,7 @@ export function createListItemElement(writer, indent, id) {
|
|
|
105
105
|
* @internal
|
|
106
106
|
*/
|
|
107
107
|
export function getViewElementNameForListType(type) {
|
|
108
|
-
return type == 'numbered' ? 'ol' : 'ul';
|
|
108
|
+
return type == 'numbered' || type == 'customNumbered' ? 'ol' : 'ul';
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* Returns a view element ID for the given list type and indent.
|