@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
|
@@ -7,11 +7,12 @@ import { generateLiInUl, injectViewList, positionAfterUiElements, findNestedList
|
|
|
7
7
|
/**
|
|
8
8
|
* A model-to-view converter for the `listItem` model element insertion.
|
|
9
9
|
*
|
|
10
|
-
* It converts the `listItem` model element to an unordered list with a {@link module:engine/view/uielement~
|
|
10
|
+
* It converts the `listItem` model element to an unordered list with a {@link module:engine/view/uielement~ViewUIElement checkbox element}
|
|
11
11
|
* at the beginning of each list item. It also merges the list with surrounding lists (if available).
|
|
12
12
|
*
|
|
13
13
|
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
14
14
|
*
|
|
15
|
+
* @internal
|
|
15
16
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
16
17
|
* @param model Model instance.
|
|
17
18
|
* @param onCheckboxChecked Callback function.
|
|
@@ -51,6 +52,7 @@ export function modelViewInsertion(model, onCheckboxChecked) {
|
|
|
51
52
|
*
|
|
52
53
|
* It is used by {@link module:engine/controller/datacontroller~DataController}.
|
|
53
54
|
*
|
|
55
|
+
* @internal
|
|
54
56
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert
|
|
55
57
|
* @param model Model instance.
|
|
56
58
|
* @returns Returns a conversion callback.
|
|
@@ -101,6 +103,7 @@ export function dataModelViewInsertion(model) {
|
|
|
101
103
|
*
|
|
102
104
|
* It is used by {@link module:engine/controller/datacontroller~DataController}.
|
|
103
105
|
*
|
|
106
|
+
* @internal
|
|
104
107
|
* @see module:engine/conversion/upcastdispatcher~UpcastDispatcher#event:element
|
|
105
108
|
*/
|
|
106
109
|
export const dataViewModelCheckmarkInsertion = (evt, data, conversionApi) => {
|
|
@@ -124,7 +127,7 @@ export const dataViewModelCheckmarkInsertion = (evt, data, conversionApi) => {
|
|
|
124
127
|
* A model-to-view converter for the `listType` attribute change on the `listItem` model element.
|
|
125
128
|
*
|
|
126
129
|
* This change means that the `<li>` element parent changes to `<ul class="todo-list">` and a
|
|
127
|
-
* {@link module:engine/view/uielement~
|
|
130
|
+
* {@link module:engine/view/uielement~ViewUIElement checkbox UI element} is added at the beginning
|
|
128
131
|
* of the list item element (or vice versa).
|
|
129
132
|
*
|
|
130
133
|
* This converter is preceded by {@link module:list/legacylist/legacyconverters~modelViewChangeType} and followed by
|
|
@@ -133,6 +136,7 @@ export const dataViewModelCheckmarkInsertion = (evt, data, conversionApi) => {
|
|
|
133
136
|
*
|
|
134
137
|
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
135
138
|
*
|
|
139
|
+
* @internal
|
|
136
140
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
137
141
|
* @param onCheckedChange Callback fired after clicking the checkbox UI element.
|
|
138
142
|
* @param view Editing view controller.
|
|
@@ -174,10 +178,11 @@ export function modelViewChangeType(onCheckedChange, view) {
|
|
|
174
178
|
/**
|
|
175
179
|
* A model-to-view converter for the `todoListChecked` attribute change on the `listItem` model element.
|
|
176
180
|
*
|
|
177
|
-
* It marks the {@link module:engine/view/uielement~
|
|
181
|
+
* It marks the {@link module:engine/view/uielement~ViewUIElement checkbox UI element} as checked.
|
|
178
182
|
*
|
|
179
183
|
* It is used by {@link module:engine/controller/editingcontroller~EditingController}.
|
|
180
184
|
*
|
|
185
|
+
* @internal
|
|
181
186
|
* @see module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute
|
|
182
187
|
* @param onCheckedChange Callback fired after clicking the checkbox UI element.
|
|
183
188
|
* @returns Returns a conversion callback.
|
|
@@ -208,6 +213,8 @@ export function modelViewChangeChecked(onCheckedChange) {
|
|
|
208
213
|
* This helper ensures that position inside todo-list in the view is mapped after the checkbox.
|
|
209
214
|
*
|
|
210
215
|
* It only handles the position at the beginning of a list item as other positions are properly mapped be the default mapper.
|
|
216
|
+
*
|
|
217
|
+
* @internal
|
|
211
218
|
*/
|
|
212
219
|
export function mapModelToViewPosition(view) {
|
|
213
220
|
return (evt, data) => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
import LegacyListEditing from '../legacylist/legacylistediting.js';
|
|
6
|
+
import { LegacyListEditing } from '../legacylist/legacylistediting.js';
|
|
7
7
|
/**
|
|
8
8
|
* The engine of the to-do list feature. It handles creating, editing and removing to-do lists and their items.
|
|
9
9
|
*
|
|
@@ -14,7 +14,7 @@ import LegacyListEditing from '../legacylist/legacylistediting.js';
|
|
|
14
14
|
* - `'checkTodoList'`,
|
|
15
15
|
* - `'todoListCheck'` as an alias for `checkTodoList` command.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export declare class LegacyTodoListEditing extends Plugin {
|
|
18
18
|
/**
|
|
19
19
|
* @inheritDoc
|
|
20
20
|
*/
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
6
|
import { getCode, parseKeystroke, getLocalizedArrowKeyCodeDirection } from 'ckeditor5/src/utils.js';
|
|
7
|
-
import LegacyListCommand from '../legacylist/legacylistcommand.js';
|
|
8
|
-
import LegacyListEditing from '../legacylist/legacylistediting.js';
|
|
9
|
-
import LegacyCheckTodoListCommand from './legacychecktodolistcommand.js';
|
|
7
|
+
import { LegacyListCommand } from '../legacylist/legacylistcommand.js';
|
|
8
|
+
import { LegacyListEditing } from '../legacylist/legacylistediting.js';
|
|
9
|
+
import { LegacyCheckTodoListCommand } from './legacychecktodolistcommand.js';
|
|
10
10
|
import { dataModelViewInsertion, dataViewModelCheckmarkInsertion, mapModelToViewPosition, modelViewChangeChecked, modelViewChangeType, modelViewInsertion } from './legacytodolistconverters.js';
|
|
11
11
|
const ITEM_TOGGLE_KEYSTROKE = /* #__PURE__ */ parseKeystroke('Ctrl+Enter');
|
|
12
12
|
/**
|
|
@@ -19,7 +19,7 @@ const ITEM_TOGGLE_KEYSTROKE = /* #__PURE__ */ parseKeystroke('Ctrl+Enter');
|
|
|
19
19
|
* - `'checkTodoList'`,
|
|
20
20
|
* - `'todoListCheck'` as an alias for `checkTodoList` command.
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
22
|
+
export class LegacyTodoListEditing extends Plugin {
|
|
23
23
|
/**
|
|
24
24
|
* @inheritDoc
|
|
25
25
|
*/
|
package/src/legacytodolist.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module list/legacytodolist
|
|
7
7
|
*/
|
|
8
|
-
import LegacyTodoListEditing from './legacytodolist/legacytodolistediting.js';
|
|
9
|
-
import TodoListUI from './todolist/todolistui.js';
|
|
8
|
+
import { LegacyTodoListEditing } from './legacytodolist/legacytodolistediting.js';
|
|
9
|
+
import { TodoListUI } from './todolist/todolistui.js';
|
|
10
10
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
11
11
|
import '../theme/todolist.css';
|
|
12
12
|
/**
|
|
@@ -15,7 +15,7 @@ import '../theme/todolist.css';
|
|
|
15
15
|
* This is a "glue" plugin that loads the {@link module:list/legacytodolist/legacytodolistediting~LegacyTodoListEditing legacy to-do list
|
|
16
16
|
* editing feature} and the {@link module:list/todolist/todolistui~TodoListUI to-do list UI feature}.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export declare class LegacyTodoList extends Plugin {
|
|
19
19
|
/**
|
|
20
20
|
* @inheritDoc
|
|
21
21
|
*/
|
package/src/legacytodolist.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module list/legacytodolist
|
|
7
7
|
*/
|
|
8
|
-
import LegacyTodoListEditing from './legacytodolist/legacytodolistediting.js';
|
|
9
|
-
import TodoListUI from './todolist/todolistui.js';
|
|
8
|
+
import { LegacyTodoListEditing } from './legacytodolist/legacytodolistediting.js';
|
|
9
|
+
import { TodoListUI } from './todolist/todolistui.js';
|
|
10
10
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
11
11
|
import '../theme/todolist.css';
|
|
12
12
|
/**
|
|
@@ -15,7 +15,7 @@ import '../theme/todolist.css';
|
|
|
15
15
|
* This is a "glue" plugin that loads the {@link module:list/legacytodolist/legacytodolistediting~LegacyTodoListEditing legacy to-do list
|
|
16
16
|
* editing feature} and the {@link module:list/todolist/todolistui~TodoListUI to-do list UI feature}.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export class LegacyTodoList extends Plugin {
|
|
19
19
|
/**
|
|
20
20
|
* @inheritDoc
|
|
21
21
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
export
|
|
6
|
+
export declare class AdjacentListsSupport extends Plugin {
|
|
7
7
|
/**
|
|
8
8
|
* @inheritDoc
|
|
9
9
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
export
|
|
6
|
+
export class AdjacentListsSupport extends Plugin {
|
|
7
7
|
/**
|
|
8
8
|
* @inheritDoc
|
|
9
9
|
*/
|
package/src/list/converters.d.ts
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module list/list/converters
|
|
7
7
|
*/
|
|
8
|
-
import { type DowncastAttributeEvent, type EditingController, type
|
|
8
|
+
import { type DowncastAttributeEvent, type EditingController, type ModelElement, type DowncastElementCreatorFunction, type Mapper, type Model, type UpcastElementEvent, type ViewElement, type DowncastRemoveEvent, type EditingView, type MapperModelToViewPositionEvent, type ModelSchema } 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
|
-
import type {
|
|
11
|
+
import type { ListEditing, DowncastStrategy } from './listediting.js';
|
|
12
12
|
/**
|
|
13
13
|
* Returns the upcast converter for list items. It's supposed to work after the block converters (content inside list items) are converted.
|
|
14
14
|
*
|
|
@@ -38,8 +38,10 @@ export declare function listItemDowncastConverter(attributeNames: Array<string>,
|
|
|
38
38
|
}): GetCallback<DowncastAttributeEvent<ListElement>>;
|
|
39
39
|
/**
|
|
40
40
|
* The 'remove' downcast converter for custom markers.
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
41
43
|
*/
|
|
42
|
-
export declare function listItemDowncastRemoveConverter(schema:
|
|
44
|
+
export declare function listItemDowncastRemoveConverter(schema: ModelSchema): GetCallback<DowncastRemoveEvent>;
|
|
43
45
|
/**
|
|
44
46
|
* Returns the bogus paragraph view element creator. A bogus paragraph is used if a list item contains only a single block or nested list.
|
|
45
47
|
*
|
|
@@ -48,7 +50,7 @@ export declare function listItemDowncastRemoveConverter(schema: Schema): GetCall
|
|
|
48
50
|
*/
|
|
49
51
|
export declare function bogusParagraphCreator(attributeNames: Array<string>, { dataPipeline }?: {
|
|
50
52
|
dataPipeline?: boolean;
|
|
51
|
-
}):
|
|
53
|
+
}): DowncastElementCreatorFunction;
|
|
52
54
|
/**
|
|
53
55
|
* Helper for mapping mode to view elements. It's using positions mapping instead of mapper.toViewElement( element )
|
|
54
56
|
* to find outermost view element. This is for cases when mapping is using inner view element like in the code blocks (pre > code).
|
|
@@ -58,8 +60,10 @@ export declare function bogusParagraphCreator(attributeNames: Array<string>, { d
|
|
|
58
60
|
* @param mapper The mapper instance.
|
|
59
61
|
* @param model The model.
|
|
60
62
|
*/
|
|
61
|
-
export declare function findMappedViewElement(element:
|
|
63
|
+
export declare function findMappedViewElement(element: ModelElement, mapper: Mapper, model: Model): ViewElement | null;
|
|
62
64
|
/**
|
|
63
65
|
* The model to view custom position mapping for cases when marker is injected at the beginning of a block.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
64
68
|
*/
|
|
65
69
|
export declare function createModelToViewPositionMapper(strategies: Array<DowncastStrategy>, view: EditingView): GetCallback<MapperModelToViewPositionEvent>;
|
package/src/list/converters.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { getAllListItemBlocks, getListItemBlocks, isListItemBlock, isFirstBlockOfListItem, ListItemUid } from './utils/model.js';
|
|
6
6
|
import { createListElement, createListItemElement, getIndent, isListView, isListItemView } from './utils/view.js';
|
|
7
|
-
import ListWalker,
|
|
7
|
+
import { ListWalker, SiblingListBlocksIterator } from './utils/listwalker.js';
|
|
8
8
|
import { findAndAddListHeadToMap } from './utils/postfixers.js';
|
|
9
9
|
/**
|
|
10
10
|
* Returns the upcast converter for list items. It's supposed to work after the block converters (content inside list items) are converted.
|
|
@@ -22,7 +22,8 @@ export function listItemUpcastConverter() {
|
|
|
22
22
|
if (!items.length) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
const listItemId = ListItemUid.next();
|
|
25
|
+
const listItemId = data.viewItem.getAttribute('data-list-item-id') || ListItemUid.next();
|
|
26
|
+
conversionApi.consumable.consume(data.viewItem, { attributes: 'data-list-item-id' });
|
|
26
27
|
const listIndent = getIndent(data.viewItem);
|
|
27
28
|
let listType = data.viewItem.parent && data.viewItem.parent.is('element', 'ol') ? 'numbered' : 'bulleted';
|
|
28
29
|
// Preserve list type if was already set (for example by to-do list feature).
|
|
@@ -239,11 +240,13 @@ export function listItemDowncastConverter(attributeNames, strategies, model, { d
|
|
|
239
240
|
// Insert custom item marker.
|
|
240
241
|
const viewRange = insertCustomMarkerElements(listItem, viewElement, strategies, writer, { dataPipeline });
|
|
241
242
|
// Then wrap them with the new list wrappers (UL, OL, LI).
|
|
242
|
-
wrapListItemBlock(listItem, viewRange, strategies, writer);
|
|
243
|
+
wrapListItemBlock(listItem, viewRange, strategies, writer, conversionApi.options);
|
|
243
244
|
};
|
|
244
245
|
}
|
|
245
246
|
/**
|
|
246
247
|
* The 'remove' downcast converter for custom markers.
|
|
248
|
+
*
|
|
249
|
+
* @internal
|
|
247
250
|
*/
|
|
248
251
|
export function listItemDowncastRemoveConverter(schema) {
|
|
249
252
|
return (evt, data, conversionApi) => {
|
|
@@ -308,6 +311,8 @@ export function findMappedViewElement(element, mapper, model) {
|
|
|
308
311
|
}
|
|
309
312
|
/**
|
|
310
313
|
* The model to view custom position mapping for cases when marker is injected at the beginning of a block.
|
|
314
|
+
*
|
|
315
|
+
* @internal
|
|
311
316
|
*/
|
|
312
317
|
export function createModelToViewPositionMapper(strategies, view) {
|
|
313
318
|
return (evt, data) => {
|
|
@@ -328,7 +333,7 @@ export function createModelToViewPositionMapper(strategies, view) {
|
|
|
328
333
|
const viewWalker = viewRange.getWalker();
|
|
329
334
|
let positionAfterLastMarker = viewRange.start;
|
|
330
335
|
for (const { item } of viewWalker) {
|
|
331
|
-
// Walk only over the non-mapped elements (UIElements,
|
|
336
|
+
// Walk only over the non-mapped elements (UIElements, ViewAttributeElements, $text, or any other element without mapping).
|
|
332
337
|
if (item.is('element') && data.mapper.toModelElement(item) || item.is('$textProxy')) {
|
|
333
338
|
break;
|
|
334
339
|
}
|
|
@@ -360,7 +365,7 @@ function removeCustomMarkerElements(viewElement, viewWriter, mapper) {
|
|
|
360
365
|
}
|
|
361
366
|
function collectMarkersToRemove(viewWalker) {
|
|
362
367
|
for (const { item } of viewWalker) {
|
|
363
|
-
// Walk only over the non-mapped elements (UIElements,
|
|
368
|
+
// Walk only over the non-mapped elements (UIElements, ViewAttributeElements, $text, or any other element without mapping).
|
|
364
369
|
if (item.is('element') && mapper.toModelElement(item)) {
|
|
365
370
|
break;
|
|
366
371
|
}
|
|
@@ -428,7 +433,7 @@ function unwrapListItemBlock(viewElement, viewWriter) {
|
|
|
428
433
|
/**
|
|
429
434
|
* Wraps the given list item with appropriate attribute elements for ul, ol, and li.
|
|
430
435
|
*/
|
|
431
|
-
function wrapListItemBlock(listItem, viewRange, strategies, writer) {
|
|
436
|
+
function wrapListItemBlock(listItem, viewRange, strategies, writer, options) {
|
|
432
437
|
if (!listItem.hasAttribute('listIndent')) {
|
|
433
438
|
return;
|
|
434
439
|
}
|
|
@@ -440,7 +445,7 @@ function wrapListItemBlock(listItem, viewRange, strategies, writer) {
|
|
|
440
445
|
for (const strategy of strategies) {
|
|
441
446
|
if ((strategy.scope == 'list' || strategy.scope == 'item') &&
|
|
442
447
|
currentListItem.hasAttribute(strategy.attributeName)) {
|
|
443
|
-
strategy.setAttributeOnDowncast(writer, currentListItem.getAttribute(strategy.attributeName), strategy.scope == 'list' ? listViewElement : listItemViewElement);
|
|
448
|
+
strategy.setAttributeOnDowncast(writer, currentListItem.getAttribute(strategy.attributeName), strategy.scope == 'list' ? listViewElement : listItemViewElement, options);
|
|
444
449
|
}
|
|
445
450
|
}
|
|
446
451
|
viewRange = writer.wrap(viewRange, listItemViewElement);
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module list/list/listcommand
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { ModelElement } from 'ckeditor5/src/engine.js';
|
|
9
9
|
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
10
10
|
import { type ListType } from './listediting.js';
|
|
11
11
|
/**
|
|
12
12
|
* The list command. It is used by the {@link module:list/list~List list feature}.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export declare class ListCommand extends Command {
|
|
15
15
|
/**
|
|
16
16
|
* The type of the list created by the command.
|
|
17
17
|
*/
|
|
@@ -88,5 +88,5 @@ export default class ListCommand extends Command {
|
|
|
88
88
|
*/
|
|
89
89
|
export type ListCommandAfterExecuteEvent = {
|
|
90
90
|
name: 'afterExecute';
|
|
91
|
-
args: [changedBlocks: Array<
|
|
91
|
+
args: [changedBlocks: Array<ModelElement>];
|
|
92
92
|
};
|
package/src/list/listcommand.js
CHANGED
|
@@ -7,7 +7,7 @@ import { splitListItemBefore, expandListBlocksToCompleteItems, getListItemBlocks
|
|
|
7
7
|
/**
|
|
8
8
|
* The list command. It is used by the {@link module:list/list~List list feature}.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export class ListCommand extends Command {
|
|
11
11
|
/**
|
|
12
12
|
* The type of the list created by the command.
|
|
13
13
|
*/
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* @module list/list/listediting
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
-
import type {
|
|
9
|
+
import type { ViewDowncastWriter, ModelElement, ViewElement, ViewAttributeElement, ModelWriter } from 'ckeditor5/src/engine.js';
|
|
10
10
|
import { Delete } from 'ckeditor5/src/typing.js';
|
|
11
11
|
import { Enter } from 'ckeditor5/src/enter.js';
|
|
12
|
-
import
|
|
12
|
+
import { ListFormatting } from '../listformatting.js';
|
|
13
|
+
import { ListUtils } from './listutils.js';
|
|
13
14
|
import { ListBlocksIterable } from './utils/listwalker.js';
|
|
14
15
|
import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
|
|
15
16
|
import '../../theme/documentlist.css';
|
|
@@ -26,7 +27,7 @@ export interface ListItemAttributesMap {
|
|
|
26
27
|
/**
|
|
27
28
|
* The editing part of the document-list feature. It handles creating, editing and removing lists and list items.
|
|
28
29
|
*/
|
|
29
|
-
export
|
|
30
|
+
export declare class ListEditing extends Plugin {
|
|
30
31
|
/**
|
|
31
32
|
* The list of registered downcast strategies.
|
|
32
33
|
*/
|
|
@@ -42,7 +43,7 @@ export default class ListEditing extends Plugin {
|
|
|
42
43
|
/**
|
|
43
44
|
* @inheritDoc
|
|
44
45
|
*/
|
|
45
|
-
static get requires(): readonly [typeof Enter, typeof Delete, typeof ListUtils, typeof ClipboardPipeline];
|
|
46
|
+
static get requires(): readonly [typeof Enter, typeof Delete, typeof ListUtils, typeof ClipboardPipeline, typeof ListFormatting];
|
|
46
47
|
/**
|
|
47
48
|
* @inheritDoc
|
|
48
49
|
*/
|
|
@@ -69,17 +70,17 @@ export default class ListEditing extends Plugin {
|
|
|
69
70
|
*/
|
|
70
71
|
getListAttributeNames(): Array<string>;
|
|
71
72
|
/**
|
|
72
|
-
* Attaches the listener to the {@link module:engine/view/document~
|
|
73
|
+
* Attaches the listener to the {@link module:engine/view/document~ViewDocument#event:delete} event and handles backspace/delete
|
|
73
74
|
* keys in and around document lists.
|
|
74
75
|
*/
|
|
75
76
|
private _setupDeleteIntegration;
|
|
76
77
|
/**
|
|
77
|
-
* Attaches a listener to the {@link module:engine/view/document~
|
|
78
|
+
* Attaches a listener to the {@link module:engine/view/document~ViewDocument#event:enter} event and handles enter key press
|
|
78
79
|
* in document lists.
|
|
79
80
|
*/
|
|
80
81
|
private _setupEnterIntegration;
|
|
81
82
|
/**
|
|
82
|
-
* Attaches a listener to the {@link module:engine/view/document~
|
|
83
|
+
* Attaches a listener to the {@link module:engine/view/document~ViewDocument#event:tab} event and handles tab key and tab+shift keys
|
|
83
84
|
* presses in document lists.
|
|
84
85
|
*/
|
|
85
86
|
private _setupTabIntegration;
|
|
@@ -100,6 +101,10 @@ export default class ListEditing extends Plugin {
|
|
|
100
101
|
* Informs editor accessibility features about keystrokes brought by the plugin.
|
|
101
102
|
*/
|
|
102
103
|
private _setupAccessibilityIntegration;
|
|
104
|
+
/**
|
|
105
|
+
* Convert `listItemId` attribute to `data-list-item-id` attribute on the view element in both downcast pipelines.
|
|
106
|
+
*/
|
|
107
|
+
private _setupListItemIdConversionStrategy;
|
|
103
108
|
}
|
|
104
109
|
/**
|
|
105
110
|
* The attribute to attribute downcast strategy for UL, OL, LI elements.
|
|
@@ -116,7 +121,7 @@ export interface AttributeDowncastStrategy {
|
|
|
116
121
|
/**
|
|
117
122
|
* Sets the property on the view element.
|
|
118
123
|
*/
|
|
119
|
-
setAttributeOnDowncast(writer:
|
|
124
|
+
setAttributeOnDowncast(writer: ViewDowncastWriter, value: unknown, element: ViewElement, options?: Record<string, unknown>): void;
|
|
120
125
|
}
|
|
121
126
|
/**
|
|
122
127
|
* The custom marker downcast strategy.
|
|
@@ -133,25 +138,25 @@ export interface ItemMarkerDowncastStrategy {
|
|
|
133
138
|
/**
|
|
134
139
|
* Creates a view element for a custom item marker.
|
|
135
140
|
*/
|
|
136
|
-
createElement(writer:
|
|
141
|
+
createElement(writer: ViewDowncastWriter, modelElement: ModelElement, { dataPipeline }: {
|
|
137
142
|
dataPipeline?: boolean;
|
|
138
143
|
}): ViewElement | null;
|
|
139
144
|
/**
|
|
140
|
-
* Creates an
|
|
145
|
+
* Creates an ViewAttributeElement to be used for wrapping a first block of a list item.
|
|
141
146
|
*/
|
|
142
|
-
createWrapperElement?(writer:
|
|
147
|
+
createWrapperElement?(writer: ViewDowncastWriter, modelElement: ModelElement, { dataPipeline }: {
|
|
143
148
|
dataPipeline?: boolean;
|
|
144
149
|
}): ViewAttributeElement;
|
|
145
150
|
/**
|
|
146
151
|
* Should return true if the given list block can be wrapped with the wrapper created by `createWrapperElement()`
|
|
147
152
|
* or only the marker element should be wrapped.
|
|
148
153
|
*/
|
|
149
|
-
canWrapElement?(modelElement:
|
|
154
|
+
canWrapElement?(modelElement: ModelElement): boolean;
|
|
150
155
|
/**
|
|
151
156
|
* Should return true if the custom marker can be injected into a given list block.
|
|
152
157
|
* Otherwise, custom marker view element is always injected before the block element.
|
|
153
158
|
*/
|
|
154
|
-
canInjectMarkerIntoElement?(modelElement:
|
|
159
|
+
canInjectMarkerIntoElement?(modelElement: ModelElement): boolean;
|
|
155
160
|
}
|
|
156
161
|
/**
|
|
157
162
|
* The downcast strategy.
|
|
@@ -163,7 +168,6 @@ export type DowncastStrategy = AttributeDowncastStrategy | ItemMarkerDowncastStr
|
|
|
163
168
|
*
|
|
164
169
|
* It allows triggering a re-wrapping of a list item.
|
|
165
170
|
*
|
|
166
|
-
* @internal
|
|
167
171
|
* @eventName ~ListEditing#postFixer
|
|
168
172
|
* @param listHead The head element of a list.
|
|
169
173
|
* @param writer The writer to do changes with.
|
|
@@ -175,8 +179,8 @@ export type ListEditingPostFixerEvent = {
|
|
|
175
179
|
args: [
|
|
176
180
|
{
|
|
177
181
|
listNodes: ListBlocksIterable;
|
|
178
|
-
listHead:
|
|
179
|
-
writer:
|
|
182
|
+
listHead: ModelElement;
|
|
183
|
+
writer: ModelWriter;
|
|
180
184
|
seenIds: Set<string>;
|
|
181
185
|
}
|
|
182
186
|
];
|
|
@@ -219,7 +223,7 @@ export type ListEditingCheckElementEvent = {
|
|
|
219
223
|
args: [
|
|
220
224
|
{
|
|
221
225
|
viewElement: ViewElement;
|
|
222
|
-
modelElement:
|
|
226
|
+
modelElement: ModelElement;
|
|
223
227
|
}
|
|
224
228
|
];
|
|
225
229
|
return: boolean;
|
package/src/list/listediting.js
CHANGED
|
@@ -9,16 +9,17 @@ import { Plugin } from 'ckeditor5/src/core.js';
|
|
|
9
9
|
import { Delete } from 'ckeditor5/src/typing.js';
|
|
10
10
|
import { Enter } from 'ckeditor5/src/enter.js';
|
|
11
11
|
import { CKEditorError } from 'ckeditor5/src/utils.js';
|
|
12
|
-
import ListIndentCommand from './listindentcommand.js';
|
|
13
|
-
import ListCommand from './listcommand.js';
|
|
14
|
-
import ListMergeCommand from './listmergecommand.js';
|
|
15
|
-
import ListSplitCommand from './listsplitcommand.js';
|
|
16
|
-
import
|
|
12
|
+
import { ListIndentCommand } from './listindentcommand.js';
|
|
13
|
+
import { ListCommand } from './listcommand.js';
|
|
14
|
+
import { ListMergeCommand } from './listmergecommand.js';
|
|
15
|
+
import { ListSplitCommand } from './listsplitcommand.js';
|
|
16
|
+
import { ListFormatting } from '../listformatting.js';
|
|
17
|
+
import { ListUtils } from './listutils.js';
|
|
17
18
|
import { bogusParagraphCreator, createModelToViewPositionMapper, listItemDowncastConverter, listItemDowncastRemoveConverter, listItemUpcastConverter, reconvertItemsOnDataChange } from './converters.js';
|
|
18
19
|
import { findAndAddListHeadToMap, fixListIndents, fixListItemIds } from './utils/postfixers.js';
|
|
19
20
|
import { getAllListItemBlocks, isFirstBlockOfListItem, isLastBlockOfListItem, isSingleListItem, getSelectedBlockObject, isListItemBlock, removeListAttributes, ListItemUid } from './utils/model.js';
|
|
20
21
|
import { getViewElementIdForListType, getViewElementNameForListType } from './utils/view.js';
|
|
21
|
-
import ListWalker,
|
|
22
|
+
import { ListWalker, ListBlocksIterable } from './utils/listwalker.js';
|
|
22
23
|
import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
|
|
23
24
|
import '../../theme/documentlist.css';
|
|
24
25
|
import '../../theme/list.css';
|
|
@@ -29,7 +30,7 @@ const LIST_BASE_ATTRIBUTES = ['listType', 'listIndent', 'listItemId'];
|
|
|
29
30
|
/**
|
|
30
31
|
* The editing part of the document-list feature. It handles creating, editing and removing lists and list items.
|
|
31
32
|
*/
|
|
32
|
-
export
|
|
33
|
+
export class ListEditing extends Plugin {
|
|
33
34
|
/**
|
|
34
35
|
* The list of registered downcast strategies.
|
|
35
36
|
*/
|
|
@@ -50,7 +51,7 @@ export default class ListEditing extends Plugin {
|
|
|
50
51
|
* @inheritDoc
|
|
51
52
|
*/
|
|
52
53
|
static get requires() {
|
|
53
|
-
return [Enter, Delete, ListUtils, ClipboardPipeline];
|
|
54
|
+
return [Enter, Delete, ListUtils, ClipboardPipeline, ListFormatting];
|
|
54
55
|
}
|
|
55
56
|
/**
|
|
56
57
|
* @inheritDoc
|
|
@@ -110,6 +111,7 @@ export default class ListEditing extends Plugin {
|
|
|
110
111
|
this._setupTabIntegration();
|
|
111
112
|
this._setupClipboardIntegration();
|
|
112
113
|
this._setupAccessibilityIntegration();
|
|
114
|
+
this._setupListItemIdConversionStrategy();
|
|
113
115
|
}
|
|
114
116
|
/**
|
|
115
117
|
* @inheritDoc
|
|
@@ -154,7 +156,7 @@ export default class ListEditing extends Plugin {
|
|
|
154
156
|
];
|
|
155
157
|
}
|
|
156
158
|
/**
|
|
157
|
-
* Attaches the listener to the {@link module:engine/view/document~
|
|
159
|
+
* Attaches the listener to the {@link module:engine/view/document~ViewDocument#event:delete} event and handles backspace/delete
|
|
158
160
|
* keys in and around document lists.
|
|
159
161
|
*/
|
|
160
162
|
_setupDeleteIntegration() {
|
|
@@ -219,7 +221,7 @@ export default class ListEditing extends Plugin {
|
|
|
219
221
|
}, { context: 'li' });
|
|
220
222
|
}
|
|
221
223
|
/**
|
|
222
|
-
* Attaches a listener to the {@link module:engine/view/document~
|
|
224
|
+
* Attaches a listener to the {@link module:engine/view/document~ViewDocument#event:enter} event and handles enter key press
|
|
223
225
|
* in document lists.
|
|
224
226
|
*/
|
|
225
227
|
_setupEnterIntegration() {
|
|
@@ -285,7 +287,7 @@ export default class ListEditing extends Plugin {
|
|
|
285
287
|
});
|
|
286
288
|
}
|
|
287
289
|
/**
|
|
288
|
-
* Attaches a listener to the {@link module:engine/view/document~
|
|
290
|
+
* Attaches a listener to the {@link module:engine/view/document~ViewDocument#event:tab} event and handles tab key and tab+shift keys
|
|
289
291
|
* presses in document lists.
|
|
290
292
|
*/
|
|
291
293
|
_setupTabIntegration() {
|
|
@@ -482,6 +484,21 @@ export default class ListEditing extends Plugin {
|
|
|
482
484
|
]
|
|
483
485
|
});
|
|
484
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* Convert `listItemId` attribute to `data-list-item-id` attribute on the view element in both downcast pipelines.
|
|
489
|
+
*/
|
|
490
|
+
_setupListItemIdConversionStrategy() {
|
|
491
|
+
this.registerDowncastStrategy({
|
|
492
|
+
scope: 'item',
|
|
493
|
+
attributeName: 'listItemId',
|
|
494
|
+
setAttributeOnDowncast(writer, attributeValue, viewElement, options) {
|
|
495
|
+
if (options && (options.skipListItemIds || options.isClipboardPipeline)) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
writer.setAttribute('data-list-item-id', attributeValue, viewElement);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
}
|
|
485
502
|
}
|
|
486
503
|
/**
|
|
487
504
|
* Post-fixer that reacts to changes on document and fixes incorrect model states (invalid `listItemId` and `listIndent` values).
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* @module list/list/listindentcommand
|
|
7
7
|
*/
|
|
8
8
|
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
-
import type {
|
|
9
|
+
import type { ModelElement } from 'ckeditor5/src/engine.js';
|
|
10
10
|
/**
|
|
11
11
|
* The document list indent command. It is used by the {@link module:list/list~List list feature}.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export declare class ListIndentCommand extends Command {
|
|
14
14
|
/**
|
|
15
15
|
* Determines by how much the command will change the list item's indent attribute.
|
|
16
16
|
*/
|
|
@@ -58,5 +58,5 @@ export default class ListIndentCommand extends Command {
|
|
|
58
58
|
*/
|
|
59
59
|
export type ListIndentCommandAfterExecuteEvent = {
|
|
60
60
|
name: 'afterExecute';
|
|
61
|
-
args: [changedBlocks: Array<
|
|
61
|
+
args: [changedBlocks: Array<ModelElement>];
|
|
62
62
|
};
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Command } from 'ckeditor5/src/core.js';
|
|
9
9
|
import { expandListBlocksToCompleteItems, indentBlocks, isFirstBlockOfListItem, isListItemBlock, isSingleListItem, outdentBlocksWithMerge, sortBlocks, splitListItemBefore } from './utils/model.js';
|
|
10
|
-
import ListWalker from './utils/listwalker.js';
|
|
10
|
+
import { ListWalker } from './utils/listwalker.js';
|
|
11
11
|
/**
|
|
12
12
|
* The document list indent command. It is used by the {@link module:list/list~List list feature}.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export class ListIndentCommand extends Command {
|
|
15
15
|
/**
|
|
16
16
|
* Determines by how much the command will change the list item's indent attribute.
|
|
17
17
|
*/
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* @module list/list/listmergecommand
|
|
7
7
|
*/
|
|
8
8
|
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
-
import type {
|
|
9
|
+
import type { ModelElement } from 'ckeditor5/src/engine.js';
|
|
10
10
|
/**
|
|
11
11
|
* The document list merge command. It is used by the {@link module:list/list~List list feature}.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export declare class ListMergeCommand extends Command {
|
|
14
14
|
/**
|
|
15
15
|
* Whether list item should be merged before or after the selected block.
|
|
16
16
|
*/
|
|
@@ -72,5 +72,5 @@ export default class ListMergeCommand extends Command {
|
|
|
72
72
|
*/
|
|
73
73
|
export type ListMergeCommandAfterExecuteEvent = {
|
|
74
74
|
name: 'afterExecute';
|
|
75
|
-
args: [changedBlocks: Array<
|
|
75
|
+
args: [changedBlocks: Array<ModelElement>];
|
|
76
76
|
};
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Command } from 'ckeditor5/src/core.js';
|
|
9
9
|
import { getNestedListBlocks, indentBlocks, sortBlocks, isFirstBlockOfListItem, mergeListItemBefore, isSingleListItem, getSelectedBlockObject, isListItemBlock } from './utils/model.js';
|
|
10
|
-
import ListWalker from './utils/listwalker.js';
|
|
10
|
+
import { ListWalker } from './utils/listwalker.js';
|
|
11
11
|
/**
|
|
12
12
|
* The document list merge command. It is used by the {@link module:list/list~List list feature}.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export class ListMergeCommand extends Command {
|
|
15
15
|
/**
|
|
16
16
|
* Whether list item should be merged before or after the selected block.
|
|
17
17
|
*/
|