@ckeditor/ckeditor5-core 41.2.0 → 41.3.0-alpha.1

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.
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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.js';
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 {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/typings
7
+ */
8
+ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-core",
3
- "version": "41.2.0",
3
+ "version": "41.3.0-alpha.1",
4
4
  "description": "The core architecture of CKEditor 5 – the best browser-based rich text editor.",
5
5
  "keywords": [
6
6
  "wysiwyg",
@@ -24,8 +24,8 @@
24
24
  "type": "module",
25
25
  "main": "src/index.js",
26
26
  "dependencies": {
27
- "@ckeditor/ckeditor5-engine": "41.2.0",
28
- "@ckeditor/ckeditor5-utils": "41.2.0",
27
+ "@ckeditor/ckeditor5-engine": "41.3.0-alpha.1",
28
+ "@ckeditor/ckeditor5-utils": "41.3.0-alpha.1",
29
29
  "lodash-es": "4.17.21"
30
30
  },
31
31
  "author": "CKSource (http://cksource.com/)",
@@ -38,6 +38,7 @@
38
38
  "directory": "packages/ckeditor5-core"
39
39
  },
40
40
  "files": [
41
+ "dist",
41
42
  "lang",
42
43
  "src/**/*.js",
43
44
  "src/**/*.d.ts",