@ckeditor/ckeditor5-core 40.0.0 → 40.2.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/CHANGELOG.md +28 -28
- package/LICENSE.md +3 -3
- package/README.md +1 -1
- package/lang/contexts.json +5 -1
- package/lang/translations/af.po +16 -0
- package/lang/translations/ar.po +16 -0
- package/lang/translations/ast.po +16 -0
- package/lang/translations/az.po +16 -0
- package/lang/translations/bg.po +16 -0
- package/lang/translations/bn.po +16 -0
- package/lang/translations/bs.po +16 -0
- package/lang/translations/ca.po +16 -0
- package/lang/translations/cs.po +16 -0
- package/lang/translations/da.po +16 -0
- package/lang/translations/de-ch.po +16 -0
- package/lang/translations/de.po +16 -0
- package/lang/translations/el.po +16 -0
- package/lang/translations/en-au.po +16 -0
- package/lang/translations/en-gb.po +16 -0
- package/lang/translations/en.po +16 -0
- package/lang/translations/eo.po +16 -0
- package/lang/translations/es-co.po +16 -0
- package/lang/translations/es.po +16 -0
- package/lang/translations/et.po +16 -0
- package/lang/translations/eu.po +16 -0
- package/lang/translations/fa.po +16 -0
- package/lang/translations/fi.po +16 -0
- package/lang/translations/fr.po +16 -0
- package/lang/translations/gl.po +16 -0
- package/lang/translations/gu.po +16 -0
- package/lang/translations/he.po +16 -0
- package/lang/translations/hi.po +16 -0
- package/lang/translations/hr.po +16 -0
- package/lang/translations/hu.po +16 -0
- package/lang/translations/hy.po +16 -0
- package/lang/translations/id.po +16 -0
- package/lang/translations/it.po +16 -0
- package/lang/translations/ja.po +16 -0
- package/lang/translations/jv.po +16 -0
- package/lang/translations/km.po +16 -0
- package/lang/translations/kn.po +16 -0
- package/lang/translations/ko.po +16 -0
- package/lang/translations/ku.po +16 -0
- package/lang/translations/lt.po +16 -0
- package/lang/translations/lv.po +16 -0
- package/lang/translations/ms.po +16 -0
- package/lang/translations/nb.po +16 -0
- package/lang/translations/ne.po +16 -0
- package/lang/translations/nl.po +16 -0
- package/lang/translations/no.po +16 -0
- package/lang/translations/oc.po +16 -0
- package/lang/translations/pl.po +16 -0
- package/lang/translations/pt-br.po +16 -0
- package/lang/translations/pt.po +16 -0
- package/lang/translations/ro.po +16 -0
- package/lang/translations/ru.po +16 -0
- package/lang/translations/si.po +16 -0
- package/lang/translations/sk.po +16 -0
- package/lang/translations/sl.po +16 -0
- package/lang/translations/sq.po +16 -0
- package/lang/translations/sr-latn.po +17 -1
- package/lang/translations/sr.po +16 -0
- package/lang/translations/sv.po +16 -0
- package/lang/translations/th.po +16 -0
- package/lang/translations/tk.po +16 -0
- package/lang/translations/tr.po +16 -0
- package/lang/translations/tt.po +16 -0
- package/lang/translations/ug.po +17 -1
- package/lang/translations/uk.po +16 -0
- package/lang/translations/ur.po +16 -0
- package/lang/translations/uz.po +16 -0
- package/lang/translations/vi.po +16 -0
- package/lang/translations/zh-cn.po +16 -0
- package/lang/translations/zh.po +16 -0
- package/package.json +3 -3
- package/src/augmentation.d.ts +10 -10
- package/src/augmentation.js +5 -5
- package/src/command.d.ts +189 -189
- package/src/command.js +185 -185
- package/src/commandcollection.d.ts +83 -83
- package/src/commandcollection.js +83 -83
- package/src/context.d.ts +237 -237
- package/src/context.js +225 -225
- package/src/contextplugin.d.ts +61 -61
- package/src/contextplugin.js +43 -43
- package/src/editingkeystrokehandler.d.ts +56 -56
- package/src/editingkeystrokehandler.js +57 -57
- package/src/editor/editor.d.ts +417 -417
- package/src/editor/editor.js +316 -316
- package/src/editor/editorconfig.d.ts +661 -660
- package/src/editor/editorconfig.js +5 -5
- package/src/editor/utils/attachtoform.d.ts +15 -15
- package/src/editor/utils/attachtoform.js +57 -57
- package/src/editor/utils/dataapimixin.d.ts +75 -75
- package/src/editor/utils/dataapimixin.js +24 -24
- package/src/editor/utils/elementapimixin.d.ts +35 -31
- package/src/editor/utils/elementapimixin.js +43 -42
- package/src/editor/utils/securesourceelement.d.ts +17 -17
- package/src/editor/utils/securesourceelement.js +35 -35
- package/src/index.d.ts +66 -62
- package/src/index.js +103 -95
- package/src/multicommand.d.ts +66 -66
- package/src/multicommand.js +82 -82
- package/src/pendingactions.d.ts +117 -117
- package/src/pendingactions.js +116 -116
- package/src/plugin.d.ts +274 -274
- package/src/plugin.js +106 -106
- package/src/plugincollection.d.ts +117 -117
- package/src/plugincollection.js +473 -473
- package/theme/icons/image-asset-manager.svg +1 -0
- package/theme/icons/image-upload.svg +1 -0
- package/theme/icons/image-url.svg +1 -0
- package/theme/icons/image.svg +1 -1
- package/theme/icons/low-vision.svg +1 -1
- package/theme/icons/text-alternative.svg +1 -0
package/src/plugin.js
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
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/plugin
|
|
7
|
-
*/
|
|
8
|
-
/* eslint-disable @typescript-eslint/no-invalid-void-type */
|
|
9
|
-
import { ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
10
|
-
/**
|
|
11
|
-
* The base class for CKEditor plugin classes.
|
|
12
|
-
*/
|
|
13
|
-
export default class Plugin extends ObservableMixin() {
|
|
14
|
-
/**
|
|
15
|
-
* @inheritDoc
|
|
16
|
-
*/
|
|
17
|
-
constructor(editor) {
|
|
18
|
-
super();
|
|
19
|
-
/**
|
|
20
|
-
* Holds identifiers for {@link #forceDisabled} mechanism.
|
|
21
|
-
*/
|
|
22
|
-
this._disableStack = new Set();
|
|
23
|
-
this.editor = editor;
|
|
24
|
-
this.set('isEnabled', true);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Disables the plugin.
|
|
28
|
-
*
|
|
29
|
-
* Plugin may be disabled by multiple features or algorithms (at once). When disabling a plugin, unique id should be passed
|
|
30
|
-
* (e.g. feature name). The same identifier should be used when {@link #clearForceDisabled enabling back} the plugin.
|
|
31
|
-
* The plugin becomes enabled only after all features {@link #clearForceDisabled enabled it back}.
|
|
32
|
-
*
|
|
33
|
-
* Disabling and enabling a plugin:
|
|
34
|
-
*
|
|
35
|
-
* ```ts
|
|
36
|
-
* plugin.isEnabled; // -> true
|
|
37
|
-
* plugin.forceDisabled( 'MyFeature' );
|
|
38
|
-
* plugin.isEnabled; // -> false
|
|
39
|
-
* plugin.clearForceDisabled( 'MyFeature' );
|
|
40
|
-
* plugin.isEnabled; // -> true
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* Plugin disabled by multiple features:
|
|
44
|
-
*
|
|
45
|
-
* ```ts
|
|
46
|
-
* plugin.forceDisabled( 'MyFeature' );
|
|
47
|
-
* plugin.forceDisabled( 'OtherFeature' );
|
|
48
|
-
* plugin.clearForceDisabled( 'MyFeature' );
|
|
49
|
-
* plugin.isEnabled; // -> false
|
|
50
|
-
* plugin.clearForceDisabled( 'OtherFeature' );
|
|
51
|
-
* plugin.isEnabled; // -> true
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* Multiple disabling with the same identifier is redundant:
|
|
55
|
-
*
|
|
56
|
-
* ```ts
|
|
57
|
-
* plugin.forceDisabled( 'MyFeature' );
|
|
58
|
-
* plugin.forceDisabled( 'MyFeature' );
|
|
59
|
-
* plugin.clearForceDisabled( 'MyFeature' );
|
|
60
|
-
* plugin.isEnabled; // -> true
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* **Note:** some plugins or algorithms may have more complex logic when it comes to enabling or disabling certain plugins,
|
|
64
|
-
* so the plugin might be still disabled after {@link #clearForceDisabled} was used.
|
|
65
|
-
*
|
|
66
|
-
* @param id Unique identifier for disabling. Use the same id when {@link #clearForceDisabled enabling back} the plugin.
|
|
67
|
-
*/
|
|
68
|
-
forceDisabled(id) {
|
|
69
|
-
this._disableStack.add(id);
|
|
70
|
-
if (this._disableStack.size == 1) {
|
|
71
|
-
this.on('set:isEnabled', forceDisable, { priority: 'highest' });
|
|
72
|
-
this.isEnabled = false;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Clears forced disable previously set through {@link #forceDisabled}. See {@link #forceDisabled}.
|
|
77
|
-
*
|
|
78
|
-
* @param id Unique identifier, equal to the one passed in {@link #forceDisabled} call.
|
|
79
|
-
*/
|
|
80
|
-
clearForceDisabled(id) {
|
|
81
|
-
this._disableStack.delete(id);
|
|
82
|
-
if (this._disableStack.size == 0) {
|
|
83
|
-
this.off('set:isEnabled', forceDisable);
|
|
84
|
-
this.isEnabled = true;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @inheritDoc
|
|
89
|
-
*/
|
|
90
|
-
destroy() {
|
|
91
|
-
this.stopListening();
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* @inheritDoc
|
|
95
|
-
*/
|
|
96
|
-
static get isContextPlugin() {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Helper function that forces plugin to be disabled.
|
|
102
|
-
*/
|
|
103
|
-
function forceDisable(evt) {
|
|
104
|
-
evt.return = false;
|
|
105
|
-
evt.stop();
|
|
106
|
-
}
|
|
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/plugin
|
|
7
|
+
*/
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-invalid-void-type */
|
|
9
|
+
import { ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
10
|
+
/**
|
|
11
|
+
* The base class for CKEditor plugin classes.
|
|
12
|
+
*/
|
|
13
|
+
export default class Plugin extends ObservableMixin() {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
constructor(editor) {
|
|
18
|
+
super();
|
|
19
|
+
/**
|
|
20
|
+
* Holds identifiers for {@link #forceDisabled} mechanism.
|
|
21
|
+
*/
|
|
22
|
+
this._disableStack = new Set();
|
|
23
|
+
this.editor = editor;
|
|
24
|
+
this.set('isEnabled', true);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Disables the plugin.
|
|
28
|
+
*
|
|
29
|
+
* Plugin may be disabled by multiple features or algorithms (at once). When disabling a plugin, unique id should be passed
|
|
30
|
+
* (e.g. feature name). The same identifier should be used when {@link #clearForceDisabled enabling back} the plugin.
|
|
31
|
+
* The plugin becomes enabled only after all features {@link #clearForceDisabled enabled it back}.
|
|
32
|
+
*
|
|
33
|
+
* Disabling and enabling a plugin:
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* plugin.isEnabled; // -> true
|
|
37
|
+
* plugin.forceDisabled( 'MyFeature' );
|
|
38
|
+
* plugin.isEnabled; // -> false
|
|
39
|
+
* plugin.clearForceDisabled( 'MyFeature' );
|
|
40
|
+
* plugin.isEnabled; // -> true
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Plugin disabled by multiple features:
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* plugin.forceDisabled( 'MyFeature' );
|
|
47
|
+
* plugin.forceDisabled( 'OtherFeature' );
|
|
48
|
+
* plugin.clearForceDisabled( 'MyFeature' );
|
|
49
|
+
* plugin.isEnabled; // -> false
|
|
50
|
+
* plugin.clearForceDisabled( 'OtherFeature' );
|
|
51
|
+
* plugin.isEnabled; // -> true
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* Multiple disabling with the same identifier is redundant:
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* plugin.forceDisabled( 'MyFeature' );
|
|
58
|
+
* plugin.forceDisabled( 'MyFeature' );
|
|
59
|
+
* plugin.clearForceDisabled( 'MyFeature' );
|
|
60
|
+
* plugin.isEnabled; // -> true
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* **Note:** some plugins or algorithms may have more complex logic when it comes to enabling or disabling certain plugins,
|
|
64
|
+
* so the plugin might be still disabled after {@link #clearForceDisabled} was used.
|
|
65
|
+
*
|
|
66
|
+
* @param id Unique identifier for disabling. Use the same id when {@link #clearForceDisabled enabling back} the plugin.
|
|
67
|
+
*/
|
|
68
|
+
forceDisabled(id) {
|
|
69
|
+
this._disableStack.add(id);
|
|
70
|
+
if (this._disableStack.size == 1) {
|
|
71
|
+
this.on('set:isEnabled', forceDisable, { priority: 'highest' });
|
|
72
|
+
this.isEnabled = false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Clears forced disable previously set through {@link #forceDisabled}. See {@link #forceDisabled}.
|
|
77
|
+
*
|
|
78
|
+
* @param id Unique identifier, equal to the one passed in {@link #forceDisabled} call.
|
|
79
|
+
*/
|
|
80
|
+
clearForceDisabled(id) {
|
|
81
|
+
this._disableStack.delete(id);
|
|
82
|
+
if (this._disableStack.size == 0) {
|
|
83
|
+
this.off('set:isEnabled', forceDisable);
|
|
84
|
+
this.isEnabled = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @inheritDoc
|
|
89
|
+
*/
|
|
90
|
+
destroy() {
|
|
91
|
+
this.stopListening();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @inheritDoc
|
|
95
|
+
*/
|
|
96
|
+
static get isContextPlugin() {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Helper function that forces plugin to be disabled.
|
|
102
|
+
*/
|
|
103
|
+
function forceDisable(evt) {
|
|
104
|
+
evt.return = false;
|
|
105
|
+
evt.stop();
|
|
106
|
+
}
|
|
@@ -1,117 +1,117 @@
|
|
|
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 { LoadedPlugins, PluginClassConstructor, PluginConstructor, PluginInterface } from './plugin';
|
|
6
|
-
declare const PluginCollection_base: {
|
|
7
|
-
new (): import("@ckeditor/ckeditor5-utils").Emitter;
|
|
8
|
-
prototype: import("@ckeditor/ckeditor5-utils").Emitter;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Manages a list of CKEditor plugins, including loading, resolving dependencies and initialization.
|
|
12
|
-
*/
|
|
13
|
-
export default class PluginCollection<TContext extends object> extends PluginCollection_base implements Iterable<PluginEntry<TContext>> {
|
|
14
|
-
private _context;
|
|
15
|
-
private _plugins;
|
|
16
|
-
/**
|
|
17
|
-
* A map of plugin constructors that can be retrieved by their names.
|
|
18
|
-
*/
|
|
19
|
-
private _availablePlugins;
|
|
20
|
-
/**
|
|
21
|
-
* Map of {@link module:core/contextplugin~ContextPlugin context plugins} which can be retrieved by their constructors or instances.
|
|
22
|
-
*/
|
|
23
|
-
private _contextPlugins;
|
|
24
|
-
/**
|
|
25
|
-
* Creates an instance of the plugin collection class.
|
|
26
|
-
* Allows loading and initializing plugins and their dependencies.
|
|
27
|
-
* Allows providing a list of already loaded plugins. These plugins will not be destroyed along with this collection.
|
|
28
|
-
*
|
|
29
|
-
* @param availablePlugins Plugins (constructors) which the collection will be able to use
|
|
30
|
-
* when {@link module:core/plugincollection~PluginCollection#init} is used with the plugin names (strings, instead of constructors).
|
|
31
|
-
* Usually, the editor will pass its built-in plugins to the collection so they can later be
|
|
32
|
-
* used in `config.plugins` or `config.removePlugins` by names.
|
|
33
|
-
* @param contextPlugins A list of already initialized plugins represented by a `[ PluginConstructor, pluginInstance ]` pair.
|
|
34
|
-
*/
|
|
35
|
-
constructor(context: TContext, availablePlugins?: Iterable<PluginConstructor<TContext>>, contextPlugins?: Iterable<PluginEntry<TContext>>);
|
|
36
|
-
/**
|
|
37
|
-
* Iterable interface.
|
|
38
|
-
*
|
|
39
|
-
* Returns `[ PluginConstructor, pluginInstance ]` pairs.
|
|
40
|
-
*/
|
|
41
|
-
[Symbol.iterator](): IterableIterator<PluginEntry<TContext>>;
|
|
42
|
-
get<TConstructor extends PluginClassConstructor<TContext>>(key: TConstructor): InstanceType<TConstructor>;
|
|
43
|
-
get<TName extends string>(key: TName): PluginsMap[TName];
|
|
44
|
-
/**
|
|
45
|
-
* Checks if a plugin is loaded.
|
|
46
|
-
*
|
|
47
|
-
* ```ts
|
|
48
|
-
* // Check if the 'Clipboard' plugin was loaded.
|
|
49
|
-
* if ( editor.plugins.has( 'ClipboardPipeline' ) ) {
|
|
50
|
-
* // Now use the clipboard plugin instance:
|
|
51
|
-
* const clipboard = editor.plugins.get( 'ClipboardPipeline' );
|
|
52
|
-
*
|
|
53
|
-
* // ...
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @param key The plugin constructor or {@link module:core/plugin~PluginStaticMembers#pluginName name}.
|
|
58
|
-
*/
|
|
59
|
-
has(key: PluginConstructor<TContext> | string): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Initializes a set of plugins and adds them to the collection.
|
|
62
|
-
*
|
|
63
|
-
* @param plugins An array of {@link module:core/plugin~PluginInterface plugin constructors}
|
|
64
|
-
* or {@link module:core/plugin~PluginStaticMembers#pluginName plugin names}.
|
|
65
|
-
* @param pluginsToRemove Names of the plugins or plugin constructors
|
|
66
|
-
* that should not be loaded (despite being specified in the `plugins` array).
|
|
67
|
-
* @param pluginsSubstitutions An array of {@link module:core/plugin~PluginInterface plugin constructors}
|
|
68
|
-
* that will be used to replace plugins of the same names that were passed in `plugins` or that are in their dependency tree.
|
|
69
|
-
* A useful option for replacing built-in plugins while creating tests (for mocking their APIs). Plugins that will be replaced
|
|
70
|
-
* must follow these rules:
|
|
71
|
-
* * The new plugin must be a class.
|
|
72
|
-
* * The new plugin must be named.
|
|
73
|
-
* * Both plugins must not depend on other plugins.
|
|
74
|
-
* @returns A promise which gets resolved once all plugins are loaded and available in the collection.
|
|
75
|
-
*/
|
|
76
|
-
init(plugins: ReadonlyArray<PluginConstructor<TContext> | string>, pluginsToRemove?: ReadonlyArray<PluginConstructor<TContext> | string>, pluginsSubstitutions?: ReadonlyArray<PluginConstructor<TContext>>): Promise<LoadedPlugins>;
|
|
77
|
-
/**
|
|
78
|
-
* Destroys all loaded plugins.
|
|
79
|
-
*/
|
|
80
|
-
destroy(): Promise<unknown>;
|
|
81
|
-
/**
|
|
82
|
-
* Adds the plugin to the collection. Exposed mainly for testing purposes.
|
|
83
|
-
*
|
|
84
|
-
* @param PluginConstructor The plugin constructor.
|
|
85
|
-
* @param plugin The instance of the plugin.
|
|
86
|
-
*/
|
|
87
|
-
private _add;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* A `[ PluginConstructor, pluginInstance ]` pair.
|
|
91
|
-
*/
|
|
92
|
-
export type PluginEntry<TContext> = [PluginConstructor<TContext>, PluginInterface];
|
|
93
|
-
/**
|
|
94
|
-
* Helper type that maps plugin names to their types.
|
|
95
|
-
* It is meant to be extended with module augmentation.
|
|
96
|
-
*
|
|
97
|
-
* ```ts
|
|
98
|
-
* class MyPlugin extends Plugin {
|
|
99
|
-
* public static pluginName() {
|
|
100
|
-
* return 'MyPlugin' as const;
|
|
101
|
-
* }
|
|
102
|
-
* }
|
|
103
|
-
*
|
|
104
|
-
* declare module '@ckeditor/ckeditor5-core' {
|
|
105
|
-
* interface PluginsMap {
|
|
106
|
-
* [ MyPlugin.pluginName ]: MyPlugin;
|
|
107
|
-
* }
|
|
108
|
-
* }
|
|
109
|
-
*
|
|
110
|
-
* // Returns `MyPlugin`.
|
|
111
|
-
* const myPlugin = editor.plugins.get( 'MyPlugin' );
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
export interface PluginsMap {
|
|
115
|
-
[name: string]: PluginInterface;
|
|
116
|
-
}
|
|
117
|
-
export {};
|
|
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 { LoadedPlugins, PluginClassConstructor, PluginConstructor, PluginInterface } from './plugin';
|
|
6
|
+
declare const PluginCollection_base: {
|
|
7
|
+
new (): import("@ckeditor/ckeditor5-utils").Emitter;
|
|
8
|
+
prototype: import("@ckeditor/ckeditor5-utils").Emitter;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Manages a list of CKEditor plugins, including loading, resolving dependencies and initialization.
|
|
12
|
+
*/
|
|
13
|
+
export default class PluginCollection<TContext extends object> extends PluginCollection_base implements Iterable<PluginEntry<TContext>> {
|
|
14
|
+
private _context;
|
|
15
|
+
private _plugins;
|
|
16
|
+
/**
|
|
17
|
+
* A map of plugin constructors that can be retrieved by their names.
|
|
18
|
+
*/
|
|
19
|
+
private _availablePlugins;
|
|
20
|
+
/**
|
|
21
|
+
* Map of {@link module:core/contextplugin~ContextPlugin context plugins} which can be retrieved by their constructors or instances.
|
|
22
|
+
*/
|
|
23
|
+
private _contextPlugins;
|
|
24
|
+
/**
|
|
25
|
+
* Creates an instance of the plugin collection class.
|
|
26
|
+
* Allows loading and initializing plugins and their dependencies.
|
|
27
|
+
* Allows providing a list of already loaded plugins. These plugins will not be destroyed along with this collection.
|
|
28
|
+
*
|
|
29
|
+
* @param availablePlugins Plugins (constructors) which the collection will be able to use
|
|
30
|
+
* when {@link module:core/plugincollection~PluginCollection#init} is used with the plugin names (strings, instead of constructors).
|
|
31
|
+
* Usually, the editor will pass its built-in plugins to the collection so they can later be
|
|
32
|
+
* used in `config.plugins` or `config.removePlugins` by names.
|
|
33
|
+
* @param contextPlugins A list of already initialized plugins represented by a `[ PluginConstructor, pluginInstance ]` pair.
|
|
34
|
+
*/
|
|
35
|
+
constructor(context: TContext, availablePlugins?: Iterable<PluginConstructor<TContext>>, contextPlugins?: Iterable<PluginEntry<TContext>>);
|
|
36
|
+
/**
|
|
37
|
+
* Iterable interface.
|
|
38
|
+
*
|
|
39
|
+
* Returns `[ PluginConstructor, pluginInstance ]` pairs.
|
|
40
|
+
*/
|
|
41
|
+
[Symbol.iterator](): IterableIterator<PluginEntry<TContext>>;
|
|
42
|
+
get<TConstructor extends PluginClassConstructor<TContext>>(key: TConstructor): InstanceType<TConstructor>;
|
|
43
|
+
get<TName extends string>(key: TName): PluginsMap[TName];
|
|
44
|
+
/**
|
|
45
|
+
* Checks if a plugin is loaded.
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* // Check if the 'Clipboard' plugin was loaded.
|
|
49
|
+
* if ( editor.plugins.has( 'ClipboardPipeline' ) ) {
|
|
50
|
+
* // Now use the clipboard plugin instance:
|
|
51
|
+
* const clipboard = editor.plugins.get( 'ClipboardPipeline' );
|
|
52
|
+
*
|
|
53
|
+
* // ...
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param key The plugin constructor or {@link module:core/plugin~PluginStaticMembers#pluginName name}.
|
|
58
|
+
*/
|
|
59
|
+
has(key: PluginConstructor<TContext> | string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Initializes a set of plugins and adds them to the collection.
|
|
62
|
+
*
|
|
63
|
+
* @param plugins An array of {@link module:core/plugin~PluginInterface plugin constructors}
|
|
64
|
+
* or {@link module:core/plugin~PluginStaticMembers#pluginName plugin names}.
|
|
65
|
+
* @param pluginsToRemove Names of the plugins or plugin constructors
|
|
66
|
+
* that should not be loaded (despite being specified in the `plugins` array).
|
|
67
|
+
* @param pluginsSubstitutions An array of {@link module:core/plugin~PluginInterface plugin constructors}
|
|
68
|
+
* that will be used to replace plugins of the same names that were passed in `plugins` or that are in their dependency tree.
|
|
69
|
+
* A useful option for replacing built-in plugins while creating tests (for mocking their APIs). Plugins that will be replaced
|
|
70
|
+
* must follow these rules:
|
|
71
|
+
* * The new plugin must be a class.
|
|
72
|
+
* * The new plugin must be named.
|
|
73
|
+
* * Both plugins must not depend on other plugins.
|
|
74
|
+
* @returns A promise which gets resolved once all plugins are loaded and available in the collection.
|
|
75
|
+
*/
|
|
76
|
+
init(plugins: ReadonlyArray<PluginConstructor<TContext> | string>, pluginsToRemove?: ReadonlyArray<PluginConstructor<TContext> | string>, pluginsSubstitutions?: ReadonlyArray<PluginConstructor<TContext>>): Promise<LoadedPlugins>;
|
|
77
|
+
/**
|
|
78
|
+
* Destroys all loaded plugins.
|
|
79
|
+
*/
|
|
80
|
+
destroy(): Promise<unknown>;
|
|
81
|
+
/**
|
|
82
|
+
* Adds the plugin to the collection. Exposed mainly for testing purposes.
|
|
83
|
+
*
|
|
84
|
+
* @param PluginConstructor The plugin constructor.
|
|
85
|
+
* @param plugin The instance of the plugin.
|
|
86
|
+
*/
|
|
87
|
+
private _add;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A `[ PluginConstructor, pluginInstance ]` pair.
|
|
91
|
+
*/
|
|
92
|
+
export type PluginEntry<TContext> = [PluginConstructor<TContext>, PluginInterface];
|
|
93
|
+
/**
|
|
94
|
+
* Helper type that maps plugin names to their types.
|
|
95
|
+
* It is meant to be extended with module augmentation.
|
|
96
|
+
*
|
|
97
|
+
* ```ts
|
|
98
|
+
* class MyPlugin extends Plugin {
|
|
99
|
+
* public static pluginName() {
|
|
100
|
+
* return 'MyPlugin' as const;
|
|
101
|
+
* }
|
|
102
|
+
* }
|
|
103
|
+
*
|
|
104
|
+
* declare module '@ckeditor/ckeditor5-core' {
|
|
105
|
+
* interface PluginsMap {
|
|
106
|
+
* [ MyPlugin.pluginName ]: MyPlugin;
|
|
107
|
+
* }
|
|
108
|
+
* }
|
|
109
|
+
*
|
|
110
|
+
* // Returns `MyPlugin`.
|
|
111
|
+
* const myPlugin = editor.plugins.get( 'MyPlugin' );
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export interface PluginsMap {
|
|
115
|
+
[name: string]: PluginInterface;
|
|
116
|
+
}
|
|
117
|
+
export {};
|