@ckeditor/ckeditor5-list 36.0.0 → 37.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.
Files changed (68) hide show
  1. package/build/list.js +1 -1
  2. package/package.json +39 -38
  3. package/src/documentlist/converters.d.ts +63 -0
  4. package/src/documentlist/converters.js +4 -4
  5. package/src/documentlist/documentlistcommand.d.ts +81 -0
  6. package/src/documentlist/documentlistcommand.js +1 -0
  7. package/src/documentlist/documentlistediting.d.ts +156 -0
  8. package/src/documentlist/documentlistindentcommand.d.ts +63 -0
  9. package/src/documentlist/documentlistindentcommand.js +1 -0
  10. package/src/documentlist/documentlistmergecommand.d.ts +77 -0
  11. package/src/documentlist/documentlistmergecommand.js +1 -0
  12. package/src/documentlist/documentlistsplitcommand.d.ts +68 -0
  13. package/src/documentlist/documentlistsplitcommand.js +1 -0
  14. package/src/documentlist/documentlistutils.d.ts +42 -0
  15. package/src/documentlist/utils/listwalker.d.ts +141 -0
  16. package/src/documentlist/utils/model.d.ts +193 -0
  17. package/src/documentlist/utils/postfixers.d.ts +37 -0
  18. package/src/documentlist/utils/view.d.ts +81 -0
  19. package/src/documentlist.d.ts +30 -0
  20. package/src/documentlist.js +1 -0
  21. package/src/documentlistproperties/converters.d.ts +19 -0
  22. package/src/documentlistproperties/documentlistpropertiesediting.d.ts +92 -0
  23. package/src/documentlistproperties/documentlistpropertiesutils.d.ts +38 -0
  24. package/src/documentlistproperties/documentlistreversedcommand.d.ts +37 -0
  25. package/src/documentlistproperties/documentlistreversedcommand.js +1 -0
  26. package/src/documentlistproperties/documentliststartcommand.d.ts +39 -0
  27. package/src/documentlistproperties/documentliststartcommand.js +1 -0
  28. package/src/documentlistproperties/documentliststylecommand.d.ts +73 -0
  29. package/src/documentlistproperties/documentliststylecommand.js +1 -0
  30. package/src/documentlistproperties/utils/style.d.ts +20 -0
  31. package/src/documentlistproperties.d.ts +31 -0
  32. package/src/documentlistproperties.js +1 -0
  33. package/src/index.d.ts +25 -0
  34. package/src/index.js +2 -0
  35. package/src/list/converters.d.ts +196 -0
  36. package/src/list/converters.js +2 -2
  37. package/src/list/indentcommand.d.ts +39 -0
  38. package/src/list/indentcommand.js +1 -0
  39. package/src/list/listcommand.d.ts +56 -0
  40. package/src/list/listcommand.js +1 -0
  41. package/src/list/listediting.d.ts +34 -0
  42. package/src/list/listui.d.ts +24 -0
  43. package/src/list/listutils.d.ts +46 -0
  44. package/src/list/utils.d.ts +113 -0
  45. package/src/list/utils.js +2 -1
  46. package/src/list.d.ts +26 -0
  47. package/src/listcommands.d.ts +37 -0
  48. package/src/listconfig.d.ts +132 -0
  49. package/src/listproperties/listpropertiesediting.d.ts +76 -0
  50. package/src/listproperties/listpropertiesui.d.ts +29 -0
  51. package/src/listproperties/listpropertiesui.js +1 -0
  52. package/src/listproperties/listreversedcommand.d.ts +39 -0
  53. package/src/listproperties/listreversedcommand.js +1 -0
  54. package/src/listproperties/liststartcommand.d.ts +38 -0
  55. package/src/listproperties/liststartcommand.js +1 -0
  56. package/src/listproperties/liststylecommand.d.ts +68 -0
  57. package/src/listproperties/liststylecommand.js +2 -1
  58. package/src/listproperties/ui/collapsibleview.d.ts +63 -0
  59. package/src/listproperties/ui/listpropertiesview.d.ts +157 -0
  60. package/src/listproperties.d.ts +30 -0
  61. package/src/listproperties.js +1 -0
  62. package/src/liststyle.d.ts +32 -0
  63. package/src/todolist/checktodolistcommand.d.ts +53 -0
  64. package/src/todolist/checktodolistcommand.js +1 -0
  65. package/src/todolist/todolistconverters.d.ts +82 -0
  66. package/src/todolist/todolistediting.d.ts +43 -0
  67. package/src/todolist/todolistui.d.ts +24 -0
  68. package/src/todolist.d.ts +27 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-list",
3
- "version": "36.0.0",
3
+ "version": "37.0.0-alpha.0",
4
4
  "description": "Ordered and unordered lists feature to CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,44 +12,44 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "^36.0.0",
16
- "@ckeditor/ckeditor5-ui": "^36.0.0"
15
+ "ckeditor5": "^37.0.0-alpha.0",
16
+ "@ckeditor/ckeditor5-ui": "^37.0.0-alpha.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@ckeditor/ckeditor5-alignment": "^36.0.0",
20
- "@ckeditor/ckeditor5-autoformat": "^36.0.0",
21
- "@ckeditor/ckeditor5-basic-styles": "^36.0.0",
22
- "@ckeditor/ckeditor5-block-quote": "^36.0.0",
23
- "@ckeditor/ckeditor5-clipboard": "^36.0.0",
24
- "@ckeditor/ckeditor5-cloud-services": "^36.0.0",
25
- "@ckeditor/ckeditor5-code-block": "^36.0.0",
26
- "@ckeditor/ckeditor5-core": "^36.0.0",
27
- "@ckeditor/ckeditor5-dev-utils": "^32.0.0",
28
- "@ckeditor/ckeditor5-easy-image": "^36.0.0",
29
- "@ckeditor/ckeditor5-editor-classic": "^36.0.0",
30
- "@ckeditor/ckeditor5-engine": "^36.0.0",
31
- "@ckeditor/ckeditor5-enter": "^36.0.0",
32
- "@ckeditor/ckeditor5-essentials": "^36.0.0",
33
- "@ckeditor/ckeditor5-font": "^36.0.0",
34
- "@ckeditor/ckeditor5-heading": "^36.0.0",
35
- "@ckeditor/ckeditor5-highlight": "^36.0.0",
36
- "@ckeditor/ckeditor5-horizontal-line": "^36.0.0",
37
- "@ckeditor/ckeditor5-html-embed": "^36.0.0",
38
- "@ckeditor/ckeditor5-html-support": "^36.0.0",
39
- "@ckeditor/ckeditor5-image": "^36.0.0",
40
- "@ckeditor/ckeditor5-indent": "^36.0.0",
41
- "@ckeditor/ckeditor5-link": "^36.0.0",
42
- "@ckeditor/ckeditor5-media-embed": "^36.0.0",
43
- "@ckeditor/ckeditor5-page-break": "^36.0.0",
44
- "@ckeditor/ckeditor5-paragraph": "^36.0.0",
45
- "@ckeditor/ckeditor5-remove-format": "^36.0.0",
46
- "@ckeditor/ckeditor5-source-editing": "^36.0.0",
47
- "@ckeditor/ckeditor5-table": "^36.0.0",
48
- "@ckeditor/ckeditor5-theme-lark": "^36.0.0",
49
- "@ckeditor/ckeditor5-typing": "^36.0.0",
50
- "@ckeditor/ckeditor5-undo": "^36.0.0",
51
- "@ckeditor/ckeditor5-utils": "^36.0.0",
52
- "@ckeditor/ckeditor5-widget": "^36.0.0",
19
+ "@ckeditor/ckeditor5-alignment": "^37.0.0-alpha.0",
20
+ "@ckeditor/ckeditor5-autoformat": "^37.0.0-alpha.0",
21
+ "@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.0",
22
+ "@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.0",
23
+ "@ckeditor/ckeditor5-clipboard": "^37.0.0-alpha.0",
24
+ "@ckeditor/ckeditor5-cloud-services": "^37.0.0-alpha.0",
25
+ "@ckeditor/ckeditor5-code-block": "^37.0.0-alpha.0",
26
+ "@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
27
+ "@ckeditor/ckeditor5-dev-utils": "^34.0.0",
28
+ "@ckeditor/ckeditor5-easy-image": "^37.0.0-alpha.0",
29
+ "@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.0",
30
+ "@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
31
+ "@ckeditor/ckeditor5-enter": "^37.0.0-alpha.0",
32
+ "@ckeditor/ckeditor5-essentials": "^37.0.0-alpha.0",
33
+ "@ckeditor/ckeditor5-font": "^37.0.0-alpha.0",
34
+ "@ckeditor/ckeditor5-heading": "^37.0.0-alpha.0",
35
+ "@ckeditor/ckeditor5-highlight": "^37.0.0-alpha.0",
36
+ "@ckeditor/ckeditor5-horizontal-line": "^37.0.0-alpha.0",
37
+ "@ckeditor/ckeditor5-html-embed": "^37.0.0-alpha.0",
38
+ "@ckeditor/ckeditor5-html-support": "^37.0.0-alpha.0",
39
+ "@ckeditor/ckeditor5-image": "^37.0.0-alpha.0",
40
+ "@ckeditor/ckeditor5-indent": "^37.0.0-alpha.0",
41
+ "@ckeditor/ckeditor5-link": "^37.0.0-alpha.0",
42
+ "@ckeditor/ckeditor5-media-embed": "^37.0.0-alpha.0",
43
+ "@ckeditor/ckeditor5-page-break": "^37.0.0-alpha.0",
44
+ "@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
45
+ "@ckeditor/ckeditor5-remove-format": "^37.0.0-alpha.0",
46
+ "@ckeditor/ckeditor5-source-editing": "^37.0.0-alpha.0",
47
+ "@ckeditor/ckeditor5-table": "^37.0.0-alpha.0",
48
+ "@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.0",
49
+ "@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
50
+ "@ckeditor/ckeditor5-undo": "^37.0.0-alpha.0",
51
+ "@ckeditor/ckeditor5-utils": "^37.0.0-alpha.0",
52
+ "@ckeditor/ckeditor5-widget": "^37.0.0-alpha.0",
53
53
  "typescript": "^4.8.4",
54
54
  "webpack": "^5.58.1",
55
55
  "webpack-cli": "^4.9.0"
@@ -80,5 +80,6 @@
80
80
  "dll:build": "webpack",
81
81
  "build": "tsc -p ./tsconfig.release.json",
82
82
  "postversion": "npm run build"
83
- }
83
+ },
84
+ "types": "src/index.d.ts"
84
85
  }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module list/documentlist/converters
7
+ */
8
+ import { type DowncastAttributeEvent, type EditingController, type Element, type ElementCreatorFunction, type Mapper, type Model, type UpcastElementEvent, type ViewElement } from 'ckeditor5/src/engine';
9
+ import type { GetCallback } from 'ckeditor5/src/utils';
10
+ import { type ListElement } from './utils/model';
11
+ import type { default as DocumentListEditing, DowncastStrategy } from './documentlistediting';
12
+ /**
13
+ * Returns the upcast converter for list items. It's supposed to work after the block converters (content inside list items) are converted.
14
+ *
15
+ * @internal
16
+ */
17
+ export declare function listItemUpcastConverter(): GetCallback<UpcastElementEvent>;
18
+ /**
19
+ * Returns the upcast converter for the `<ul>` and `<ol>` view elements that cleans the input view of garbage.
20
+ * This is mostly to clean whitespaces from between the `<li>` view elements inside the view list element. However,
21
+ * incorrect data can also be cleared if the view was incorrect.
22
+ *
23
+ * @internal
24
+ */
25
+ export declare function listUpcastCleanList(): GetCallback<UpcastElementEvent>;
26
+ /**
27
+ * Returns a model document change:data event listener that triggers conversion of related items if needed.
28
+ *
29
+ * @internal
30
+ * @param model The editor model.
31
+ * @param editing The editing controller.
32
+ * @param attributeNames The list of all model list attributes (including registered strategies).
33
+ * @param documentListEditing The document list editing plugin.
34
+ */
35
+ export declare function reconvertItemsOnDataChange(model: Model, editing: EditingController, attributeNames: Array<string>, documentListEditing: DocumentListEditing): () => void;
36
+ /**
37
+ * Returns the list item downcast converter.
38
+ *
39
+ * @internal
40
+ * @param attributeNames A list of attribute names that should be converted if they are set.
41
+ * @param strategies The strategies.
42
+ * @param model The model.
43
+ */
44
+ export declare function listItemDowncastConverter(attributeNames: Array<string>, strategies: Array<DowncastStrategy>, model: Model): GetCallback<DowncastAttributeEvent<ListElement>>;
45
+ /**
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.
47
+ *
48
+ * @internal
49
+ * @param attributeNames The list of all model list attributes (including registered strategies).
50
+ */
51
+ export declare function bogusParagraphCreator(attributeNames: Array<string>, { dataPipeline }?: {
52
+ dataPipeline?: boolean;
53
+ }): ElementCreatorFunction;
54
+ /**
55
+ * Helper for mapping mode to view elements. It's using positions mapping instead of mapper.toViewElement( element )
56
+ * to find outermost view element. This is for cases when mapping is using inner view element like in the code blocks (pre > code).
57
+ *
58
+ * @internal
59
+ * @param element The model element.
60
+ * @param mapper The mapper instance.
61
+ * @param model The model.
62
+ */
63
+ export declare function findMappedViewElement(element: Element, mapper: Mapper, model: Model): ViewElement | null;
@@ -11,7 +11,7 @@ import { createListElement, createListItemElement, getIndent, isListView, isList
11
11
  import ListWalker, { iterateSiblingListBlocks } from './utils/listwalker';
12
12
  import { findAndAddListHeadToMap } from './utils/postfixers';
13
13
  /**
14
- * Returns the upcast converter for list items. It's supposed to work after the block converters (content inside list items) is converted.
14
+ * Returns the upcast converter for list items. It's supposed to work after the block converters (content inside list items) are converted.
15
15
  *
16
16
  * @internal
17
17
  */
@@ -55,8 +55,8 @@ export function listItemUpcastConverter() {
55
55
  }
56
56
  /**
57
57
  * Returns the upcast converter for the `<ul>` and `<ol>` view elements that cleans the input view of garbage.
58
- * This is mostly to clean whitespaces from between the `<li>` view elements inside the view list element, however, also
59
- * incorrect data can be cleared if the view was incorrect.
58
+ * This is mostly to clean whitespaces from between the `<li>` view elements inside the view list element. However,
59
+ * incorrect data can also be cleared if the view was incorrect.
60
60
  *
61
61
  * @internal
62
62
  */
@@ -221,7 +221,7 @@ export function reconvertItemsOnDataChange(model, editing, attributeNames, docum
221
221
  * Returns the list item downcast converter.
222
222
  *
223
223
  * @internal
224
- * @param attributeNames A list of attribute names that should be converted if are set.
224
+ * @param attributeNames A list of attribute names that should be converted if they are set.
225
225
  * @param strategies The strategies.
226
226
  * @param model The model.
227
227
  */
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module list/documentlist/documentlistcommand
7
+ */
8
+ import type { Element } from 'ckeditor5/src/engine';
9
+ import { Command, type Editor } from 'ckeditor5/src/core';
10
+ import '../listcommands';
11
+ /**
12
+ * The list command. It is used by the {@link module:list/documentlist~DocumentList document list feature}.
13
+ */
14
+ export default class DocumentListCommand extends Command {
15
+ /**
16
+ * The type of the list created by the command.
17
+ */
18
+ readonly type: 'numbered' | 'bulleted';
19
+ /**
20
+ * A flag indicating whether the command is active, which means that the selection starts in a list of the same type.
21
+ *
22
+ * @observable
23
+ * @readonly
24
+ */
25
+ value: boolean;
26
+ /**
27
+ * Creates an instance of the command.
28
+ *
29
+ * @param editor The editor instance.
30
+ * @param type List type that will be handled by this command.
31
+ */
32
+ constructor(editor: Editor, type: 'numbered' | 'bulleted');
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ refresh(): void;
37
+ /**
38
+ * Executes the list command.
39
+ *
40
+ * @fires execute
41
+ * @fires afterExecute
42
+ * @param options Command options.
43
+ * @param options.forceValue If set, it will force the command behavior. If `true`, the command will try to convert the
44
+ * selected items and potentially the neighbor elements to the proper list items. If set to `false` it will convert selected elements
45
+ * to paragraphs. If not set, the command will toggle selected elements to list items or paragraphs, depending on the selection.
46
+ */
47
+ execute(options?: {
48
+ forceValue?: boolean;
49
+ }): void;
50
+ /**
51
+ * Fires the `afterExecute` event.
52
+ *
53
+ * @param changedBlocks The changed list elements.
54
+ */
55
+ private _fireAfterExecute;
56
+ /**
57
+ * Checks the command's {@link #value}.
58
+ *
59
+ * @returns The current value.
60
+ */
61
+ private _getValue;
62
+ /**
63
+ * Checks whether the command can be enabled in the current context.
64
+ *
65
+ * @returns Whether the command should be enabled.
66
+ */
67
+ private _checkEnabled;
68
+ }
69
+ /**
70
+ * Event fired by the {@link #execute} method.
71
+ *
72
+ * It allows to execute an action after executing the {@link ~DocumentListCommand#execute} method,
73
+ * for example adjusting attributes of changed list items.
74
+ *
75
+ * @internal
76
+ * @eventName afterExecute
77
+ */
78
+ export type DocumentListCommandAfterExecuteEvent = {
79
+ name: 'afterExecute';
80
+ args: [changedBlocks: Array<Element>];
81
+ };
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { Command } from 'ckeditor5/src/core';
6
6
  import { splitListItemBefore, expandListBlocksToCompleteItems, getListItemBlocks, getListItems, removeListAttributes, outdentFollowingItems, ListItemUid, sortBlocks, getSelectedBlockObject, isListItemBlock } from './utils/model';
7
+ import '../listcommands';
7
8
  /**
8
9
  * The list command. It is used by the {@link module:list/documentlist~DocumentList document list feature}.
9
10
  */
@@ -0,0 +1,156 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module list/documentlist/documentlistediting
7
+ */
8
+ import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
9
+ import type { DowncastWriter, Element, ViewElement, Writer } from 'ckeditor5/src/engine';
10
+ import { ListBlocksIterable } from './utils/listwalker';
11
+ import '../../theme/documentlist.css';
12
+ import '../../theme/list.css';
13
+ /**
14
+ * Map of model attributes applicable to list blocks.
15
+ */
16
+ export interface ListItemAttributesMap {
17
+ listType?: 'numbered' | 'bulleted';
18
+ listIndent?: number;
19
+ listItemId?: string;
20
+ }
21
+ /**
22
+ * The editing part of the document-list feature. It handles creating, editing and removing lists and list items.
23
+ */
24
+ export default class DocumentListEditing extends Plugin {
25
+ /**
26
+ * The list of registered downcast strategies.
27
+ */
28
+ private readonly _downcastStrategies;
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ static get pluginName(): 'DocumentListEditing';
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ static get requires(): PluginDependencies;
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ init(): void;
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ afterInit(): void;
45
+ /**
46
+ * Registers a downcast strategy.
47
+ *
48
+ * **Note**: Strategies must be registered in the `Plugin#init()` phase so that it can be applied
49
+ * in the `DocumentListEditing#afterInit()`.
50
+ *
51
+ * @param strategy The downcast strategy to register.
52
+ */
53
+ registerDowncastStrategy(strategy: DowncastStrategy): void;
54
+ /**
55
+ * Returns list of model attribute names that should affect downcast conversion.
56
+ */
57
+ private _getListAttributeNames;
58
+ /**
59
+ * Attaches the listener to the {@link module:engine/view/document~Document#event:delete} event and handles backspace/delete
60
+ * keys in and around document lists.
61
+ */
62
+ private _setupDeleteIntegration;
63
+ /**
64
+ * Attaches a listener to the {@link module:engine/view/document~Document#event:enter} event and handles enter key press
65
+ * in document lists.
66
+ */
67
+ private _setupEnterIntegration;
68
+ /**
69
+ * Attaches a listener to the {@link module:engine/view/document~Document#event:tab} event and handles tab key and tab+shift keys
70
+ * presses in document lists.
71
+ */
72
+ private _setupTabIntegration;
73
+ /**
74
+ * Registers the conversion helpers for the document-list feature.
75
+ */
76
+ private _setupConversion;
77
+ /**
78
+ * Registers model post-fixers.
79
+ */
80
+ private _setupModelPostFixing;
81
+ /**
82
+ * Integrates the feature with the clipboard via {@link module:engine/model/model~Model#insertContent} and
83
+ * {@link module:engine/model/model~Model#getSelectedContent}.
84
+ */
85
+ private _setupClipboardIntegration;
86
+ }
87
+ /**
88
+ * The downcast strategy.
89
+ */
90
+ export interface DowncastStrategy {
91
+ /**
92
+ * The scope of the downcast (whether it applies to LI or OL/UL).
93
+ */
94
+ scope: 'list' | 'item';
95
+ /**
96
+ * The model attribute name.
97
+ */
98
+ attributeName: string;
99
+ /**
100
+ * Sets the property on the view element.
101
+ */
102
+ setAttributeOnDowncast(writer: DowncastWriter, value: unknown, element: ViewElement): void;
103
+ }
104
+ /**
105
+ * Event fired on changes detected on the model list element to verify if the view representation of a list element
106
+ * is representing those attributes.
107
+ *
108
+ * It allows triggering a re-wrapping of a list item.
109
+ *
110
+ * @internal
111
+ * @eventName postFixer
112
+ * @param listHead The head element of a list.
113
+ * @param writer The writer to do changes with.
114
+ * @param seenIds The set of already known IDs.
115
+ * @returns If a post-fixer made a change of the model tree, it should return `true`.
116
+ */
117
+ export type DocumentListEditingPostFixerEvent = {
118
+ name: 'postFixer';
119
+ args: [
120
+ {
121
+ listNodes: ListBlocksIterable;
122
+ listHead: Element;
123
+ writer: Writer;
124
+ seenIds: Set<string>;
125
+ }
126
+ ];
127
+ return: boolean;
128
+ };
129
+ /**
130
+ * Event fired on changes detected on the model list element to verify if the view representation of a list element
131
+ * is representing those attributes.
132
+ *
133
+ * It allows triggering a re-wrapping of a list item.
134
+ *
135
+ * **Note**: For convenience this event is namespaced and could be captured as `checkAttributes:list` or `checkAttributes:item`.
136
+ *
137
+ * @internal
138
+ * @eventName checkAttributes
139
+ */
140
+ export type DocumentListEditingCheckAttributesEvent = {
141
+ name: 'checkAttributes' | 'checkAttributes:list' | 'checkAttributes:item';
142
+ args: [
143
+ {
144
+ viewElement: ViewElement & {
145
+ id?: string;
146
+ };
147
+ modelAttributes: ListItemAttributesMap;
148
+ }
149
+ ];
150
+ return: boolean;
151
+ };
152
+ declare module '@ckeditor/ckeditor5-core' {
153
+ interface PluginsMap {
154
+ [DocumentListEditing.pluginName]: DocumentListEditing;
155
+ }
156
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module list/documentlist/documentlistindentcommand
7
+ */
8
+ import { Command, type Editor } from 'ckeditor5/src/core';
9
+ import type { Element } from 'ckeditor5/src/engine';
10
+ import '../listcommands';
11
+ /**
12
+ * The document list indent command. It is used by the {@link module:list/documentlist~DocumentList list feature}.
13
+ */
14
+ export default class DocumentListIndentCommand extends Command {
15
+ /**
16
+ * Determines by how much the command will change the list item's indent attribute.
17
+ */
18
+ private readonly _direction;
19
+ /**
20
+ * Creates an instance of the command.
21
+ *
22
+ * @param editor The editor instance.
23
+ * @param indentDirection The direction of indent. If it is equal to `backward`, the command
24
+ * will outdent a list item.
25
+ */
26
+ constructor(editor: Editor, indentDirection: 'forward' | 'backward');
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ refresh(): void;
31
+ /**
32
+ * Indents or outdents (depending on the {@link #constructor}'s `indentDirection` parameter) selected list items.
33
+ *
34
+ * @fires execute
35
+ * @fires afterExecute
36
+ */
37
+ execute(): void;
38
+ /**
39
+ * Fires the `afterExecute` event.
40
+ *
41
+ * @param changedBlocks The changed list elements.
42
+ */
43
+ private _fireAfterExecute;
44
+ /**
45
+ * Checks whether the command can be enabled in the current context.
46
+ *
47
+ * @returns Whether the command should be enabled.
48
+ */
49
+ private _checkEnabled;
50
+ }
51
+ /**
52
+ * Event fired by the {@link #execute} method.
53
+ *
54
+ * It allows to execute an action after executing the {@link ~DocumentListCommand#execute} method,
55
+ * for example adjusting attributes of changed list items.
56
+ *
57
+ * @internal
58
+ * @eventName afterExecute
59
+ */
60
+ export type DocumentListIndentCommandAfterExecuteEvent = {
61
+ name: 'afterExecute';
62
+ args: [changedBlocks: Array<Element>];
63
+ };
@@ -8,6 +8,7 @@
8
8
  import { Command } from 'ckeditor5/src/core';
9
9
  import { expandListBlocksToCompleteItems, indentBlocks, isFirstBlockOfListItem, isListItemBlock, isSingleListItem, outdentBlocksWithMerge, sortBlocks, splitListItemBefore } from './utils/model';
10
10
  import ListWalker from './utils/listwalker';
11
+ import '../listcommands';
11
12
  /**
12
13
  * The document list indent command. It is used by the {@link module:list/documentlist~DocumentList list feature}.
13
14
  */
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module list/documentlist/documentlistmergecommand
7
+ */
8
+ import { Command, type Editor } from 'ckeditor5/src/core';
9
+ import type { Element } from 'ckeditor5/src/engine';
10
+ import '../listcommands';
11
+ /**
12
+ * The document list merge command. It is used by the {@link module:list/documentlist~DocumentList list feature}.
13
+ */
14
+ export default class DocumentListMergeCommand extends Command {
15
+ /**
16
+ * Whether list item should be merged before or after the selected block.
17
+ */
18
+ private readonly _direction;
19
+ /**
20
+ * Creates an instance of the command.
21
+ *
22
+ * @param editor The editor instance.
23
+ * @param direction Whether list item should be merged before or after the selected block.
24
+ */
25
+ constructor(editor: Editor, direction: 'forward' | 'backward');
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ refresh(): void;
30
+ /**
31
+ * Merges list blocks together (depending on the {@link #constructor}'s `direction` parameter).
32
+ *
33
+ * @fires execute
34
+ * @fires afterExecute
35
+ * @param options Command options.
36
+ * @param options.shouldMergeOnBlocksContentLevel When set `true`, merging will be performed together
37
+ * with {@link module:engine/model/model~Model#deleteContent} to get rid of the inline content in the selection or take advantage
38
+ * of the heuristics in `deleteContent()` that helps convert lists into paragraphs in certain cases.
39
+ */
40
+ execute({ shouldMergeOnBlocksContentLevel }?: {
41
+ shouldMergeOnBlocksContentLevel?: boolean;
42
+ }): void;
43
+ /**
44
+ * Fires the `afterExecute` event.
45
+ *
46
+ * @param changedBlocks The changed list elements.
47
+ */
48
+ private _fireAfterExecute;
49
+ /**
50
+ * Checks whether the command can be enabled in the current context.
51
+ *
52
+ * @returns Whether the command should be enabled.
53
+ */
54
+ private _checkEnabled;
55
+ /**
56
+ * Returns the boundary elements the merge should be executed for. These are not necessarily selection's first
57
+ * and last position parents but sometimes sibling or even further blocks depending on the context.
58
+ *
59
+ * @param selection The selection the merge is executed for.
60
+ * @param shouldMergeOnBlocksContentLevel When `true`, merge is performed together with
61
+ * {@link module:engine/model/model~Model#deleteContent} to remove the inline content within the selection.
62
+ */
63
+ private _getMergeSubjectElements;
64
+ }
65
+ /**
66
+ * Event fired by the {@link #execute} method.
67
+ *
68
+ * It allows to execute an action after executing the {@link ~DocumentListCommand#execute} method,
69
+ * for example adjusting attributes of changed list items.
70
+ *
71
+ * @internal
72
+ * @eventName afterExecute
73
+ */
74
+ export type DocumentListMergeCommandAfterExecuteEvent = {
75
+ name: 'afterExecute';
76
+ args: [changedBlocks: Array<Element>];
77
+ };
@@ -8,6 +8,7 @@
8
8
  import { Command } from 'ckeditor5/src/core';
9
9
  import { getNestedListBlocks, indentBlocks, sortBlocks, isFirstBlockOfListItem, mergeListItemBefore, isSingleListItem, getSelectedBlockObject, isListItemBlock } from './utils/model';
10
10
  import ListWalker from './utils/listwalker';
11
+ import '../listcommands';
11
12
  /**
12
13
  * The document list merge command. It is used by the {@link module:list/documentlist~DocumentList list feature}.
13
14
  */
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module list/documentlist/documentlistsplitcommand
7
+ */
8
+ import type { Element } from 'ckeditor5/src/engine';
9
+ import { Command, type Editor } from 'ckeditor5/src/core';
10
+ import '../listcommands';
11
+ /**
12
+ * The document list split command that splits the list item at the selection.
13
+ *
14
+ * It is used by the {@link module:list/documentlist~DocumentList document list feature}.
15
+ */
16
+ export default class DocumentListSplitCommand extends Command {
17
+ /**
18
+ * Whether list item should be split before or after the selected block.
19
+ */
20
+ private readonly _direction;
21
+ /**
22
+ * Creates an instance of the command.
23
+ *
24
+ * @param editor The editor instance.
25
+ * @param direction Whether list item should be split before or after the selected block.
26
+ */
27
+ constructor(editor: Editor, direction: 'before' | 'after');
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ refresh(): void;
32
+ /**
33
+ * Splits the list item at the selection.
34
+ *
35
+ * @fires execute
36
+ * @fires afterExecute
37
+ */
38
+ execute(): void;
39
+ /**
40
+ * Fires the `afterExecute` event.
41
+ *
42
+ * @param changedBlocks The changed list elements.
43
+ */
44
+ private _fireAfterExecute;
45
+ /**
46
+ * Checks whether the command can be enabled in the current context.
47
+ *
48
+ * @returns Whether the command should be enabled.
49
+ */
50
+ private _checkEnabled;
51
+ /**
52
+ * Returns the model element that is the main focus of the command (according to the current selection and command direction).
53
+ */
54
+ private _getStartBlock;
55
+ }
56
+ /**
57
+ * Event fired by the {@link #execute} method.
58
+ *
59
+ * It allows to execute an action after executing the {@link ~DocumentListCommand#execute} method,
60
+ * for example adjusting attributes of changed list items.
61
+ *
62
+ * @internal
63
+ * @eventName afterExecute
64
+ */
65
+ export type DocumentListSplitCommandAfterExecuteEvent = {
66
+ name: 'afterExecute';
67
+ args: [changedBlocks: Array<Element>];
68
+ };
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { Command } from 'ckeditor5/src/core';
6
6
  import { isFirstBlockOfListItem, isListItemBlock, sortBlocks, splitListItemBefore } from './utils/model';
7
+ import '../listcommands';
7
8
  /**
8
9
  * The document list split command that splits the list item at the selection.
9
10
  *