@ckeditor/ckeditor5-core 35.2.0 → 35.3.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/package.json +27 -19
- package/src/command.js +209 -238
- package/src/commandcollection.js +84 -96
- package/src/context.js +219 -314
- package/src/contextplugin.js +29 -36
- package/src/editingkeystrokehandler.js +42 -49
- package/src/editor/editor.js +360 -440
- package/src/editor/editorconfig.js +5 -0
- package/src/editor/editorui.js +436 -544
- package/src/editor/utils/attachtoform.js +39 -49
- package/src/editor/utils/dataapimixin.js +17 -68
- package/src/editor/utils/elementapimixin.js +32 -67
- package/src/editor/utils/securesourceelement.js +22 -32
- package/src/index.js +34 -51
- package/src/multicommand.js +59 -73
- package/src/pendingactions.js +77 -103
- package/src/plugin.js +119 -276
- package/src/plugincollection.js +470 -584
- package/src/editor/editorconfig.jsdoc +0 -426
- package/src/editor/editorwithui.jsdoc +0 -29
package/src/commandcollection.js
CHANGED
|
@@ -2,108 +2,96 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module core/commandcollection
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Collection of commands. Its instance is available in {@link module:core/editor/editor~Editor#commands `editor.commands`}.
|
|
14
11
|
*/
|
|
15
12
|
export default class CommandCollection {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Destroys all collection commands.
|
|
103
|
-
*/
|
|
104
|
-
destroy() {
|
|
105
|
-
for ( const command of this.commands() ) {
|
|
106
|
-
command.destroy();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates collection instance.
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
/**
|
|
18
|
+
* Command map.
|
|
19
|
+
*
|
|
20
|
+
* @private
|
|
21
|
+
* @member {Map}
|
|
22
|
+
*/
|
|
23
|
+
this._commands = new Map();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Registers a new command.
|
|
27
|
+
*
|
|
28
|
+
* @param {String} commandName The name of the command.
|
|
29
|
+
* @param {module:core/command~Command} command
|
|
30
|
+
*/
|
|
31
|
+
add(commandName, command) {
|
|
32
|
+
this._commands.set(commandName, command);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves a command from the collection.
|
|
36
|
+
*
|
|
37
|
+
* @param {String} commandName The name of the command.
|
|
38
|
+
* @returns {module:core/command~Command}
|
|
39
|
+
*/
|
|
40
|
+
get(commandName) {
|
|
41
|
+
return this._commands.get(commandName);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Executes a command.
|
|
45
|
+
*
|
|
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()`}.
|
|
49
|
+
*/
|
|
50
|
+
execute(commandName, ...args) {
|
|
51
|
+
const command = this.get(commandName);
|
|
52
|
+
if (!command) {
|
|
53
|
+
/**
|
|
54
|
+
* Command does not exist.
|
|
55
|
+
*
|
|
56
|
+
* @error commandcollection-command-not-found
|
|
57
|
+
* @param {String} commandName Name of the command.
|
|
58
|
+
*/
|
|
59
|
+
throw new CKEditorError('commandcollection-command-not-found', this, { commandName });
|
|
60
|
+
}
|
|
61
|
+
return command.execute(...args);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns iterator of command names.
|
|
65
|
+
*
|
|
66
|
+
* @returns {Iterable.<String>}
|
|
67
|
+
*/
|
|
68
|
+
*names() {
|
|
69
|
+
yield* this._commands.keys();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns iterator of command instances.
|
|
73
|
+
*
|
|
74
|
+
* @returns {Iterable.<module:core/command~Command>}
|
|
75
|
+
*/
|
|
76
|
+
*commands() {
|
|
77
|
+
yield* this._commands.values();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Iterable interface.
|
|
81
|
+
*
|
|
82
|
+
* Returns `[ commandName, commandInstance ]` pairs.
|
|
83
|
+
*
|
|
84
|
+
* @returns {Iterator.<Array>}
|
|
85
|
+
*/
|
|
86
|
+
[Symbol.iterator]() {
|
|
87
|
+
return this._commands[Symbol.iterator]();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Destroys all collection commands.
|
|
91
|
+
*/
|
|
92
|
+
destroy() {
|
|
93
|
+
for (const command of this.commands()) {
|
|
94
|
+
command.destroy();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
109
97
|
}
|