@ckeditor/ckeditor5-core 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.
package/README.md CHANGED
@@ -10,7 +10,7 @@ This package implements CKEditor 5's core editor architecture — a set of c
10
10
 
11
11
  ## Documentation
12
12
 
13
- For general introduction see the [Overview of CKEditor 5 framework](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/overview.html) guide and then the [core editor architecture guide](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/architecture/core-editor-architecture.html).
13
+ For general introduction see the [Overview of CKEditor 5 framework](https://ckeditor.com/docs/ckeditor5/latest/framework/index.html) guide and then the [core editor architecture guide](https://ckeditor.com/docs/ckeditor5/latest/framework/architecture/core-editor-architecture.html).
14
14
 
15
15
  Additionally, see the [`@ckeditor/ckeditor5-core` package](https://ckeditor.com/docs/ckeditor5/latest/api/core.html) page in [CKEditor 5 documentation](https://ckeditor.com/docs/ckeditor5/latest/) for even more information.
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-core",
3
- "version": "36.0.0",
3
+ "version": "37.0.0-alpha.0",
4
4
  "description": "The core architecture of CKEditor 5 – the best browser-based rich text editor.",
5
5
  "keywords": [
6
6
  "wysiwyg",
@@ -23,25 +23,25 @@
23
23
  ],
24
24
  "main": "src/index.js",
25
25
  "dependencies": {
26
- "@ckeditor/ckeditor5-engine": "^36.0.0",
27
- "@ckeditor/ckeditor5-utils": "^36.0.0",
26
+ "@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
27
+ "@ckeditor/ckeditor5-utils": "^37.0.0-alpha.0",
28
28
  "lodash-es": "^4.17.15"
29
29
  },
30
30
  "devDependencies": {
31
- "@ckeditor/ckeditor5-autoformat": "^36.0.0",
32
- "@ckeditor/ckeditor5-basic-styles": "^36.0.0",
33
- "@ckeditor/ckeditor5-block-quote": "^36.0.0",
34
- "@ckeditor/ckeditor5-editor-classic": "^36.0.0",
35
- "@ckeditor/ckeditor5-essentials": "^36.0.0",
36
- "@ckeditor/ckeditor5-heading": "^36.0.0",
37
- "@ckeditor/ckeditor5-image": "^36.0.0",
38
- "@ckeditor/ckeditor5-indent": "^36.0.0",
39
- "@ckeditor/ckeditor5-link": "^36.0.0",
40
- "@ckeditor/ckeditor5-list": "^36.0.0",
41
- "@ckeditor/ckeditor5-media-embed": "^36.0.0",
42
- "@ckeditor/ckeditor5-paragraph": "^36.0.0",
43
- "@ckeditor/ckeditor5-table": "^36.0.0",
44
- "@ckeditor/ckeditor5-ui": "^36.0.0",
31
+ "@ckeditor/ckeditor5-autoformat": "^37.0.0-alpha.0",
32
+ "@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.0",
33
+ "@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.0",
34
+ "@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.0",
35
+ "@ckeditor/ckeditor5-essentials": "^37.0.0-alpha.0",
36
+ "@ckeditor/ckeditor5-heading": "^37.0.0-alpha.0",
37
+ "@ckeditor/ckeditor5-image": "^37.0.0-alpha.0",
38
+ "@ckeditor/ckeditor5-indent": "^37.0.0-alpha.0",
39
+ "@ckeditor/ckeditor5-link": "^37.0.0-alpha.0",
40
+ "@ckeditor/ckeditor5-list": "^37.0.0-alpha.0",
41
+ "@ckeditor/ckeditor5-media-embed": "^37.0.0-alpha.0",
42
+ "@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
43
+ "@ckeditor/ckeditor5-table": "^37.0.0-alpha.0",
44
+ "@ckeditor/ckeditor5-ui": "^37.0.0-alpha.0",
45
45
  "typescript": "^4.8.4",
46
46
  "webpack": "^5.58.1",
47
47
  "webpack-cli": "^4.9.0"
@@ -70,5 +70,6 @@
70
70
  "scripts": {
71
71
  "build": "tsc -p ./tsconfig.release.json",
72
72
  "postversion": "npm run build"
73
- }
73
+ },
74
+ "types": "src/index.d.ts"
74
75
  }
@@ -0,0 +1,178 @@
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 core/command
7
+ */
8
+ import { type DecoratedMethodEvent } from '@ckeditor/ckeditor5-utils';
9
+ import type Editor from './editor/editor';
10
+ declare const Command_base: {
11
+ new (): import("@ckeditor/ckeditor5-utils").Observable;
12
+ prototype: import("@ckeditor/ckeditor5-utils").Observable;
13
+ };
14
+ /**
15
+ * Base class for the CKEditor commands.
16
+ *
17
+ * Commands are the main way to manipulate the editor contents and state. They are mostly used by UI elements (or by other
18
+ * commands) to make changes in the model. Commands are available in every part of the code that has access to
19
+ * the {@link module:core/editor/editor~Editor editor} instance.
20
+ *
21
+ * Instances of registered commands can be retrieved from {@link module:core/editor/editor~Editor#commands `editor.commands`}.
22
+ * The easiest way to execute a command is through {@link module:core/editor/editor~Editor#execute `editor.execute()`}.
23
+ *
24
+ * By default, commands are disabled when the editor is in the {@link module:core/editor/editor~Editor#isReadOnly read-only} mode
25
+ * but commands with the {@link module:core/command~Command#affectsData `affectsData`} flag set to `false` will not be disabled.
26
+ */
27
+ export default class Command extends Command_base {
28
+ /**
29
+ * The editor on which this command will be used.
30
+ */
31
+ readonly editor: Editor;
32
+ /**
33
+ * The value of the command. A given command class should define what it represents for it.
34
+ *
35
+ * For example, the `'bold'` command's value indicates whether the selection starts in a bolded text.
36
+ * And the value of the `'link'` command may be an object with link details.
37
+ *
38
+ * It is possible for a command to have no value (e.g. for stateless actions such as `'uploadImage'`).
39
+ *
40
+ * A given command class should control this value by overriding the {@link #refresh `refresh()`} method.
41
+ *
42
+ * @observable
43
+ * @readonly
44
+ */
45
+ value: unknown;
46
+ /**
47
+ * Flag indicating whether a command is enabled or disabled.
48
+ * A disabled command will do nothing when executed.
49
+ *
50
+ * A given command class should control this value by overriding the {@link #refresh `refresh()`} method.
51
+ *
52
+ * It is possible to disable a command "from outside" using {@link #forceDisabled} method.
53
+ *
54
+ * @observable
55
+ * @readonly
56
+ */
57
+ isEnabled: boolean;
58
+ /**
59
+ * A flag indicating whether a command execution changes the editor data or not.
60
+ *
61
+ * @see #affectsData
62
+ */
63
+ private _affectsData;
64
+ /**
65
+ * Holds identifiers for {@link #forceDisabled} mechanism.
66
+ */
67
+ private readonly _disableStack;
68
+ /**
69
+ * Creates a new `Command` instance.
70
+ *
71
+ * @param editor The editor on which this command will be used.
72
+ */
73
+ constructor(editor: Editor);
74
+ /**
75
+ * A flag indicating whether a command execution changes the editor data or not.
76
+ *
77
+ * Commands with `affectsData` set to `false` will not be automatically disabled in
78
+ * the {@link module:core/editor/editor~Editor#isReadOnly read-only mode} and
79
+ * {@glink features/read-only#related-features other editor modes} with restricted user write permissions.
80
+ *
81
+ * **Note:** You do not have to set it for your every command. It is `true` by default.
82
+ *
83
+ * @default true
84
+ */
85
+ get affectsData(): boolean;
86
+ protected set affectsData(affectsData: boolean);
87
+ /**
88
+ * Refreshes the command. The command should update its {@link #isEnabled} and {@link #value} properties
89
+ * in this method.
90
+ *
91
+ * This method is automatically called when
92
+ * {@link module:engine/model/document~Document#event:change any changes are applied to the document}.
93
+ */
94
+ refresh(): void;
95
+ /**
96
+ * Disables the command.
97
+ *
98
+ * Command may be disabled by multiple features or algorithms (at once). When disabling a command, unique id should be passed
99
+ * (e.g. the feature name). The same identifier should be used when {@link #clearForceDisabled enabling back} the command.
100
+ * The command becomes enabled only after all features {@link #clearForceDisabled enabled it back}.
101
+ *
102
+ * Disabling and enabling a command:
103
+ *
104
+ * ```ts
105
+ * command.isEnabled; // -> true
106
+ * command.forceDisabled( 'MyFeature' );
107
+ * command.isEnabled; // -> false
108
+ * command.clearForceDisabled( 'MyFeature' );
109
+ * command.isEnabled; // -> true
110
+ * ```
111
+ *
112
+ * Command disabled by multiple features:
113
+ *
114
+ * ```ts
115
+ * command.forceDisabled( 'MyFeature' );
116
+ * command.forceDisabled( 'OtherFeature' );
117
+ * command.clearForceDisabled( 'MyFeature' );
118
+ * command.isEnabled; // -> false
119
+ * command.clearForceDisabled( 'OtherFeature' );
120
+ * command.isEnabled; // -> true
121
+ * ```
122
+ *
123
+ * Multiple disabling with the same identifier is redundant:
124
+ *
125
+ * ```ts
126
+ * command.forceDisabled( 'MyFeature' );
127
+ * command.forceDisabled( 'MyFeature' );
128
+ * command.clearForceDisabled( 'MyFeature' );
129
+ * command.isEnabled; // -> true
130
+ * ```
131
+ *
132
+ * **Note:** some commands or algorithms may have more complex logic when it comes to enabling or disabling certain commands,
133
+ * so the command might be still disabled after {@link #clearForceDisabled} was used.
134
+ *
135
+ * @param id Unique identifier for disabling. Use the same id when {@link #clearForceDisabled enabling back} the command.
136
+ */
137
+ forceDisabled(id: string): void;
138
+ /**
139
+ * Clears forced disable previously set through {@link #forceDisabled}. See {@link #forceDisabled}.
140
+ *
141
+ * @param id Unique identifier, equal to the one passed in {@link #forceDisabled} call.
142
+ */
143
+ clearForceDisabled(id: string): void;
144
+ /**
145
+ * Executes the command.
146
+ *
147
+ * A command may accept parameters. They will be passed from {@link module:core/editor/editor~Editor#execute `editor.execute()`}
148
+ * to the command.
149
+ *
150
+ * The `execute()` method will automatically abort when the command is disabled ({@link #isEnabled} is `false`).
151
+ * This behavior is implemented by a high priority listener to the {@link #event:execute} event.
152
+ *
153
+ * In order to see how to disable a command from "outside" see the {@link #isEnabled} documentation.
154
+ *
155
+ * This method may return a value, which would be forwarded all the way down to the
156
+ * {@link module:core/editor/editor~Editor#execute `editor.execute()`}.
157
+ *
158
+ * @fires execute
159
+ */
160
+ execute(...args: Array<unknown>): unknown;
161
+ /**
162
+ * Destroys the command.
163
+ */
164
+ destroy(): void;
165
+ }
166
+ /**
167
+ * Event fired by the {@link ~Command#execute} method. The command action is a listener to this event so it's
168
+ * possible to change/cancel the behavior of the command by listening to this event.
169
+ *
170
+ * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
171
+ *
172
+ * **Note:** This event is fired even if command is disabled. However, it is automatically blocked
173
+ * by a high priority listener in order to prevent command execution.
174
+ *
175
+ * @eventName execute
176
+ */
177
+ export type CommandExecuteEvent = DecoratedMethodEvent<Command, 'execute'>;
178
+ export {};
package/src/command.js CHANGED
@@ -18,99 +18,19 @@ import { ObservableMixin } from '@ckeditor/ckeditor5-utils';
18
18
  *
19
19
  * By default, commands are disabled when the editor is in the {@link module:core/editor/editor~Editor#isReadOnly read-only} mode
20
20
  * but commands with the {@link module:core/command~Command#affectsData `affectsData`} flag set to `false` will not be disabled.
21
- *
22
- * @mixes module:utils/observablemixin~ObservableMixin
23
21
  */
24
22
  export default class Command extends ObservableMixin() {
25
23
  /**
26
24
  * Creates a new `Command` instance.
27
25
  *
28
- * @param {module:core/editor/editor~Editor} editor The editor on which this command will be used.
26
+ * @param editor The editor on which this command will be used.
29
27
  */
30
28
  constructor(editor) {
31
29
  super();
32
- /**
33
- * The editor on which this command will be used.
34
- *
35
- * @readonly
36
- * @member {module:core/editor/editor~Editor}
37
- */
38
30
  this.editor = editor;
39
- /**
40
- * The value of the command. A given command class should define what it represents for it.
41
- *
42
- * For example, the `'bold'` command's value indicates whether the selection starts in a bolded text.
43
- * And the value of the `'link'` command may be an object with link details.
44
- *
45
- * It is possible for a command to have no value (e.g. for stateless actions such as `'uploadImage'`).
46
- *
47
- * A given command class should control this value by overriding the {@link #refresh `refresh()`} method.
48
- *
49
- * @observable
50
- * @readonly
51
- * @member #value
52
- */
53
31
  this.set('value', undefined);
54
- /**
55
- * Flag indicating whether a command is enabled or disabled.
56
- * A disabled command will do nothing when executed.
57
- *
58
- * A given command class should control this value by overriding the {@link #refresh `refresh()`} method.
59
- *
60
- * It is possible to disable a command "from outside". For instance, in your integration you may want to disable
61
- * a certain set of commands for the time being. To do that, you can use the fact that `isEnabled` is observable
62
- * and it fires the `set:isEnabled` event every time anyone tries to modify its value:
63
- *
64
- * function disableCommand( cmd ) {
65
- * cmd.on( 'set:isEnabled', forceDisable, { priority: 'highest' } );
66
- *
67
- * cmd.isEnabled = false;
68
- *
69
- * // Make it possible to enable the command again.
70
- * return () => {
71
- * cmd.off( 'set:isEnabled', forceDisable );
72
- * cmd.refresh();
73
- * };
74
- *
75
- * function forceDisable( evt ) {
76
- * evt.return = false;
77
- * evt.stop();
78
- * }
79
- * }
80
- *
81
- * // Usage:
82
- *
83
- * // Disabling the command.
84
- * const enableBold = disableCommand( editor.commands.get( 'bold' ) );
85
- *
86
- * // Enabling the command again.
87
- * enableBold();
88
- *
89
- * @observable
90
- * @readonly
91
- * @member {Boolean} #isEnabled
92
- */
93
32
  this.set('isEnabled', false);
94
- /**
95
- * A flag indicating whether a command execution changes the editor data or not.
96
- *
97
- * Commands with `affectsData` set to `false` will not be automatically disabled in
98
- * the {@link module:core/editor/editor~Editor#isReadOnly read-only mode} and
99
- * {@glink features/read-only#related-features other editor modes} with restricted user write permissions.
100
- *
101
- * **Note:** You do not have to set it for your every command. It is `true` by default.
102
- *
103
- * @readonly
104
- * @default true
105
- * @member {Boolean} #affectsData
106
- */
107
33
  this._affectsData = true;
108
- /**
109
- * Holds identifiers for {@link #forceDisabled} mechanism.
110
- *
111
- * @type {Set.<String>}
112
- * @private
113
- */
114
34
  this._disableStack = new Set();
115
35
  this.decorate('execute');
116
36
  // By default every command is refreshed when changes are applied to the model.
@@ -132,6 +52,17 @@ export default class Command extends ObservableMixin() {
132
52
  }
133
53
  });
134
54
  }
55
+ /**
56
+ * A flag indicating whether a command execution changes the editor data or not.
57
+ *
58
+ * Commands with `affectsData` set to `false` will not be automatically disabled in
59
+ * the {@link module:core/editor/editor~Editor#isReadOnly read-only mode} and
60
+ * {@glink features/read-only#related-features other editor modes} with restricted user write permissions.
61
+ *
62
+ * **Note:** You do not have to set it for your every command. It is `true` by default.
63
+ *
64
+ * @default true
65
+ */
135
66
  get affectsData() {
136
67
  return this._affectsData;
137
68
  }
@@ -157,32 +88,38 @@ export default class Command extends ObservableMixin() {
157
88
  *
158
89
  * Disabling and enabling a command:
159
90
  *
160
- * command.isEnabled; // -> true
161
- * command.forceDisabled( 'MyFeature' );
162
- * command.isEnabled; // -> false
163
- * command.clearForceDisabled( 'MyFeature' );
164
- * command.isEnabled; // -> true
91
+ * ```ts
92
+ * command.isEnabled; // -> true
93
+ * command.forceDisabled( 'MyFeature' );
94
+ * command.isEnabled; // -> false
95
+ * command.clearForceDisabled( 'MyFeature' );
96
+ * command.isEnabled; // -> true
97
+ * ```
165
98
  *
166
99
  * Command disabled by multiple features:
167
100
  *
168
- * command.forceDisabled( 'MyFeature' );
169
- * command.forceDisabled( 'OtherFeature' );
170
- * command.clearForceDisabled( 'MyFeature' );
171
- * command.isEnabled; // -> false
172
- * command.clearForceDisabled( 'OtherFeature' );
173
- * command.isEnabled; // -> true
101
+ * ```ts
102
+ * command.forceDisabled( 'MyFeature' );
103
+ * command.forceDisabled( 'OtherFeature' );
104
+ * command.clearForceDisabled( 'MyFeature' );
105
+ * command.isEnabled; // -> false
106
+ * command.clearForceDisabled( 'OtherFeature' );
107
+ * command.isEnabled; // -> true
108
+ * ```
174
109
  *
175
110
  * Multiple disabling with the same identifier is redundant:
176
111
  *
177
- * command.forceDisabled( 'MyFeature' );
178
- * command.forceDisabled( 'MyFeature' );
179
- * command.clearForceDisabled( 'MyFeature' );
180
- * command.isEnabled; // -> true
112
+ * ```ts
113
+ * command.forceDisabled( 'MyFeature' );
114
+ * command.forceDisabled( 'MyFeature' );
115
+ * command.clearForceDisabled( 'MyFeature' );
116
+ * command.isEnabled; // -> true
117
+ * ```
181
118
  *
182
119
  * **Note:** some commands or algorithms may have more complex logic when it comes to enabling or disabling certain commands,
183
120
  * so the command might be still disabled after {@link #clearForceDisabled} was used.
184
121
  *
185
- * @param {String} id Unique identifier for disabling. Use the same id when {@link #clearForceDisabled enabling back} the command.
122
+ * @param id Unique identifier for disabling. Use the same id when {@link #clearForceDisabled enabling back} the command.
186
123
  */
187
124
  forceDisabled(id) {
188
125
  this._disableStack.add(id);
@@ -194,7 +131,7 @@ export default class Command extends ObservableMixin() {
194
131
  /**
195
132
  * Clears forced disable previously set through {@link #forceDisabled}. See {@link #forceDisabled}.
196
133
  *
197
- * @param {String} id Unique identifier, equal to the one passed in {@link #forceDisabled} call.
134
+ * @param id Unique identifier, equal to the one passed in {@link #forceDisabled} call.
198
135
  */
199
136
  clearForceDisabled(id) {
200
137
  this._disableStack.delete(id);
@@ -227,7 +164,9 @@ export default class Command extends ObservableMixin() {
227
164
  this.stopListening();
228
165
  }
229
166
  }
230
- // Helper function that forces command to be disabled.
167
+ /**
168
+ * Helper function that forces command to be disabled.
169
+ */
231
170
  function forceDisable(evt) {
232
171
  evt.return = false;
233
172
  evt.stop();
@@ -0,0 +1,83 @@
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
+ import type Command from './command';
6
+ /**
7
+ * Collection of commands. Its instance is available in {@link module:core/editor/editor~Editor#commands `editor.commands`}.
8
+ */
9
+ export default class CommandCollection implements Iterable<[string, Command]> {
10
+ /**
11
+ * Command map.
12
+ */
13
+ private _commands;
14
+ /**
15
+ * Creates collection instance.
16
+ */
17
+ constructor();
18
+ /**
19
+ * Registers a new command.
20
+ *
21
+ * @param commandName The name of the command.
22
+ */
23
+ add<TName extends string>(commandName: TName, command: CommandsMap[TName]): void;
24
+ /**
25
+ * Retrieves a command from the collection.
26
+ *
27
+ * @param commandName The name of the command.
28
+ */
29
+ get<TName extends string>(commandName: TName): CommandsMap[TName] | undefined;
30
+ /**
31
+ * Executes a command.
32
+ *
33
+ * @param commandName The name of the command.
34
+ * @param commandParams Command parameters.
35
+ * @returns The value returned by the {@link module:core/command~Command#execute `command.execute()`}.
36
+ */
37
+ execute<TName extends string>(commandName: TName, ...commandParams: Parameters<CommandsMap[TName]['execute']>): ReturnType<CommandsMap[TName]['execute']>;
38
+ /**
39
+ * Returns iterator of command names.
40
+ */
41
+ names(): IterableIterator<string>;
42
+ /**
43
+ * Returns iterator of command instances.
44
+ */
45
+ commands(): IterableIterator<Command>;
46
+ /**
47
+ * Iterable interface.
48
+ *
49
+ * Returns `[ commandName, commandInstance ]` pairs.
50
+ */
51
+ [Symbol.iterator](): Iterator<[string, Command]>;
52
+ /**
53
+ * Destroys all collection commands.
54
+ */
55
+ destroy(): void;
56
+ }
57
+ /**
58
+ * Helper type that maps command names to their types.
59
+ * It is meant to be extended with module augmentation.
60
+ *
61
+ * ```ts
62
+ * class MyCommand extends Command {
63
+ * public execute( parameter: A ): B {
64
+ * // ...
65
+ * }
66
+ * }
67
+ *
68
+ * declare module '@ckeditor/ckeditor5-core' {
69
+ * interface CommandsMap {
70
+ * myCommand: MyCommand;
71
+ * }
72
+ * }
73
+ *
74
+ * // Returns `MyCommand | undefined`.
75
+ * const myCommand = editor.commands.get( 'myCommand' );
76
+ *
77
+ * // Expects `A` type as parameter and returns `B`.
78
+ * const value = editor.commands.execute( 'myCommand', new A() );
79
+ * ```
80
+ */
81
+ export interface CommandsMap {
82
+ [name: string]: Command;
83
+ }
@@ -14,19 +14,12 @@ export default class CommandCollection {
14
14
  * Creates collection instance.
15
15
  */
16
16
  constructor() {
17
- /**
18
- * Command map.
19
- *
20
- * @private
21
- * @member {Map}
22
- */
23
17
  this._commands = new Map();
24
18
  }
25
19
  /**
26
20
  * Registers a new command.
27
21
  *
28
- * @param {String} commandName The name of the command.
29
- * @param {module:core/command~Command} command
22
+ * @param commandName The name of the command.
30
23
  */
31
24
  add(commandName, command) {
32
25
  this._commands.set(commandName, command);
@@ -34,8 +27,7 @@ export default class CommandCollection {
34
27
  /**
35
28
  * Retrieves a command from the collection.
36
29
  *
37
- * @param {String} commandName The name of the command.
38
- * @returns {module:core/command~Command}
30
+ * @param commandName The name of the command.
39
31
  */
40
32
  get(commandName) {
41
33
  return this._commands.get(commandName);
@@ -43,35 +35,31 @@ export default class CommandCollection {
43
35
  /**
44
36
  * Executes a command.
45
37
  *
46
- * @param {String} commandName The name of the command.
47
- * @param {*} [...commandParams] Command parameters.
48
- * @returns {*} The value returned by the {@link module:core/command~Command#execute `command.execute()`}.
38
+ * @param commandName The name of the command.
39
+ * @param commandParams Command parameters.
40
+ * @returns The value returned by the {@link module:core/command~Command#execute `command.execute()`}.
49
41
  */
50
- execute(commandName, ...args) {
42
+ execute(commandName, ...commandParams) {
51
43
  const command = this.get(commandName);
52
44
  if (!command) {
53
45
  /**
54
46
  * Command does not exist.
55
47
  *
56
48
  * @error commandcollection-command-not-found
57
- * @param {String} commandName Name of the command.
49
+ * @param commandName Name of the command.
58
50
  */
59
51
  throw new CKEditorError('commandcollection-command-not-found', this, { commandName });
60
52
  }
61
- return command.execute(...args);
53
+ return command.execute(...commandParams);
62
54
  }
63
55
  /**
64
56
  * Returns iterator of command names.
65
- *
66
- * @returns {Iterable.<String>}
67
57
  */
68
58
  *names() {
69
59
  yield* this._commands.keys();
70
60
  }
71
61
  /**
72
62
  * Returns iterator of command instances.
73
- *
74
- * @returns {Iterable.<module:core/command~Command>}
75
63
  */
76
64
  *commands() {
77
65
  yield* this._commands.values();
@@ -80,8 +68,6 @@ export default class CommandCollection {
80
68
  * Iterable interface.
81
69
  *
82
70
  * Returns `[ commandName, commandInstance ]` pairs.
83
- *
84
- * @returns {Iterator.<Array>}
85
71
  */
86
72
  [Symbol.iterator]() {
87
73
  return this._commands[Symbol.iterator]();