|
@@ -21,11 +21,11 @@ export default class PluginCollection {
|
|
|
/**
|
|
/**
|
|
|
* Creates an instance of the plugin collection class.
|
|
* Creates an instance of the plugin collection class.
|
|
|
* Allows loading and initializing plugins and their dependencies.
|
|
* Allows loading and initializing plugins and their dependencies.
|
|
|
- * Allows to provide a list of already loaded plugins. These plugins will not be destroyed along with this collection.
|
|
|
|
|
|
|
+ * Allows providing a list of already loaded plugins. These plugins will not be destroyed along with this collection.
|
|
|
*
|
|
*
|
|
|
* @param {module:core/editor/editor~Editor|module:core/context~Context} context
|
|
* @param {module:core/editor/editor~Editor|module:core/context~Context} context
|
|
|
* @param {Array.<Function>} [availablePlugins] Plugins (constructors) which the collection will be able to use
|
|
* @param {Array.<Function>} [availablePlugins] Plugins (constructors) which the collection will be able to use
|
|
|
- * when {@link module:core/plugincollection~PluginCollection#init} is used with plugin names (strings, instead of constructors).
|
|
|
|
|
|
|
+ * when {@link module:core/plugincollection~PluginCollection#init} is used with the plugin names (strings, instead of constructors).
|
|
|
* Usually, the editor will pass its built-in plugins to the collection so they can later be
|
|
* Usually, the editor will pass its built-in plugins to the collection so they can later be
|
|
|
* used in `config.plugins` or `config.removePlugins` by names.
|
|
* used in `config.plugins` or `config.removePlugins` by names.
|
|
|
* @param {Iterable.<Array>} contextPlugins A list of already initialized plugins represented by a
|
|
* @param {Iterable.<Array>} contextPlugins A list of already initialized plugins represented by a
|
|
@@ -105,8 +105,8 @@ export default class PluginCollection {
|
|
|
* } );
|
|
* } );
|
|
|
* }
|
|
* }
|
|
|
*
|
|
*
|
|
|
- * **Note**: This method will throw error if plugin is not loaded. Use `{@link #has editor.plugins.has()}`
|
|
|
|
|
- * to check if plugin is available.
|
|
|
|
|
|
|
+ * **Note**: This method will throw an error if a plugin is not loaded. Use `{@link #has editor.plugins.has()}`
|
|
|
|
|
+ * to check if a plugin is available.
|
|
|
*
|
|
*
|
|
|
* @param {Function|String} key The plugin constructor or {@link module:core/plugin~PluginInterface.pluginName name}.
|
|
* @param {Function|String} key The plugin constructor or {@link module:core/plugin~PluginInterface.pluginName name}.
|
|
|
* @returns {module:core/plugin~PluginInterface}
|
|
* @returns {module:core/plugin~PluginInterface}
|
|
@@ -130,7 +130,7 @@ export default class PluginCollection {
|
|
|
* property.
|
|
* property.
|
|
|
*
|
|
*
|
|
|
* **Note**: You can use `{@link module:core/plugincollection~PluginCollection#has editor.plugins.has()}`
|
|
* **Note**: You can use `{@link module:core/plugincollection~PluginCollection#has editor.plugins.has()}`
|
|
|
- * to check if plugin was loaded.
|
|
|
|
|
|
|
+ * to check if a plugin was loaded.
|
|
|
*
|
|
*
|
|
|
* @error plugincollection-plugin-not-loaded
|
|
* @error plugincollection-plugin-not-loaded
|
|
|
* @param {String} plugin The name of the plugin which is not loaded.
|
|
* @param {String} plugin The name of the plugin which is not loaded.
|
|
@@ -165,7 +165,7 @@ export default class PluginCollection {
|
|
|
* @param {Array.<Function|String>} plugins An array of {@link module:core/plugin~PluginInterface plugin constructors}
|
|
* @param {Array.<Function|String>} plugins An array of {@link module:core/plugin~PluginInterface plugin constructors}
|
|
|
* or {@link module:core/plugin~PluginInterface.pluginName plugin names}. The second option (names) works only if
|
|
* or {@link module:core/plugin~PluginInterface.pluginName plugin names}. The second option (names) works only if
|
|
|
* `availablePlugins` were passed to the {@link #constructor}.
|
|
* `availablePlugins` were passed to the {@link #constructor}.
|
|
|
- * @param {Array.<String|Function>} [removePlugins] Names of plugins or plugin constructors
|
|
|
|
|
|
|
+ * @param {Array.<String|Function>} [removePlugins] Names of the plugins or plugin constructors
|
|
|
* that should not be loaded (despite being specified in the `plugins` array).
|
|
* that should not be loaded (despite being specified in the `plugins` array).
|
|
|
* @returns {Promise.<module:core/plugin~LoadedPlugins>} A promise which gets resolved once all plugins are loaded
|
|
* @returns {Promise.<module:core/plugin~LoadedPlugins>} A promise which gets resolved once all plugins are loaded
|
|
|
* and available in the collection.
|
|
* and available in the collection.
|
|
@@ -196,7 +196,7 @@ export default class PluginCollection {
|
|
|
* **If you see this warning when using one of the editor creators directly** (not a build), then it means
|
|
* **If you see this warning when using one of the editor creators directly** (not a build), then it means
|
|
|
* that you tried loading plugins by name. However, unlike CKEditor 4, CKEditor 5 does not implement a "plugin loader".
|
|
* that you tried loading plugins by name. However, unlike CKEditor 4, CKEditor 5 does not implement a "plugin loader".
|
|
|
* This means that CKEditor 5 does not know where to load the plugin modules from. Therefore, you need to
|
|
* This means that CKEditor 5 does not know where to load the plugin modules from. Therefore, you need to
|
|
|
- * provide each plugin through reference (as a constructor function). Check out the examples in
|
|
|
|
|
|
|
+ * provide each plugin through a reference (as a constructor function). Check out the examples in
|
|
|
* {@glink builds/guides/integration/advanced-setup#scenario-2-building-from-source "Building from source"}.
|
|
* {@glink builds/guides/integration/advanced-setup#scenario-2-building-from-source "Building from source"}.
|
|
|
*
|
|
*
|
|
|
* @error plugincollection-plugin-not-found
|
|
* @error plugincollection-plugin-not-found
|
|
@@ -204,7 +204,7 @@ export default class PluginCollection {
|
|
|
*/
|
|
*/
|
|
|
const errorId = 'plugincollection-plugin-not-found';
|
|
const errorId = 'plugincollection-plugin-not-found';
|
|
|
|
|
|
|
|
- // Log the error, so it's more visible on the console. Hopefully, for better DX.
|
|
|
|
|
|
|
+ // Log the error, so it's more visible on the console. Hopefully, for a better DX.
|
|
|
logError( errorId, { plugins: missingPlugins } );
|
|
logError( errorId, { plugins: missingPlugins } );
|
|
|
|
|
|
|
|
return Promise.reject( new CKEditorError( errorId, context, { plugins: missingPlugins } ) );
|
|
return Promise.reject( new CKEditorError( errorId, context, { plugins: missingPlugins } ) );
|
|
@@ -230,10 +230,10 @@ export default class PluginCollection {
|
|
|
/**
|
|
/**
|
|
|
* It was not possible to load the plugin.
|
|
* It was not possible to load the plugin.
|
|
|
*
|
|
*
|
|
|
- * This is a generic error logged to the console when a JavaSript error is thrown during the initialization
|
|
|
|
|
|
|
+ * This is a generic error logged to the console when a JavaScript error is thrown during the initialization
|
|
|
* of one of the plugins.
|
|
* of one of the plugins.
|
|
|
*
|
|
*
|
|
|
- * If you correctly handled the promise returned by the editor's `create()` method (like shown below),
|
|
|
|
|
|
|
+ * If you correctly handled the promise returned by the editor's `create()` method (as shown below),
|
|
|
* you will find the original error logged to the console, too:
|
|
* you will find the original error logged to the console, too:
|
|
|
*
|
|
*
|
|
|
* ClassicEditor.create( document.getElementById( 'editor' ) )
|
|
* ClassicEditor.create( document.getElementById( 'editor' ) )
|
|
@@ -398,11 +398,11 @@ export default class PluginCollection {
|
|
|
* The second option is that your `node_modules/` directory contains duplicated versions of the same
|
|
* The second option is that your `node_modules/` directory contains duplicated versions of the same
|
|
|
* CKEditor 5 packages. Normally, on clean installations, npm deduplicates packages in `node_modules/`, so
|
|
* CKEditor 5 packages. Normally, on clean installations, npm deduplicates packages in `node_modules/`, so
|
|
|
* it may be enough to call `rm -rf node_modules && npm i`. However, if you installed conflicting versions
|
|
* it may be enough to call `rm -rf node_modules && npm i`. However, if you installed conflicting versions
|
|
|
- * of packages, their dependencies may need to be installed in more than one version which may lead to this
|
|
|
|
|
|
|
+ * of some packages, their dependencies may need to be installed in more than one version which may lead to this
|
|
|
* warning.
|
|
* warning.
|
|
|
*
|
|
*
|
|
|
* Technically speaking, this error occurs because after adding a plugin to an existing editor build
|
|
* Technically speaking, this error occurs because after adding a plugin to an existing editor build
|
|
|
- * dependencies of this plugin are being duplicated.
|
|
|
|
|
|
|
+ * the dependencies of this plugin are being duplicated.
|
|
|
* They are already built into that editor build and now get added for the second time as dependencies
|
|
* They are already built into that editor build and now get added for the second time as dependencies
|
|
|
* of the plugin you are installing.
|
|
* of the plugin you are installing.
|
|
|
*
|
|
*
|