From 5116eaa81bd41f08fb16139b66c9b143fe7be47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Go=C5=82aszewski?= Date: Wed, 24 Jul 2019 13:13:54 +0200 Subject: [PATCH 1/2] Add note about simple plugin form limitations. --- src/plugin.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugin.js b/src/plugin.js index 1afd9eda..9db6c179 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -62,6 +62,11 @@ mix( Plugin, ObservableMixin ); * editor.data.processor = new MyDataProcessor(); * } * + * **Note:** The simple plugin form is treated as an constructor of a plugin. Most importantly - it is called on the time + * as any other plugins' constructors. Thus it will be executed before any {@link module:core/plugin~PluginInterface#init `init()`} + * or {@link module:core/plugin~PluginInterface#afterInit `afterInit()`} methods of other plugins. + * This is important because you cannot extend other plugin schema rule as they are defined in `init()` stage. + * * In most cases, however, you will want to inherit from the {@link module:core/plugin~Plugin} class which implements the * {@link module:utils/observablemixin~ObservableMixin} and is, therefore, more convenient: * From b25e02cc929f7c95eeefe52c80aa080a4f2af6b1 Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Tue, 30 Jul 2019 17:00:13 +0200 Subject: [PATCH 2/2] Docs: Improved the PluginInterface documentation. Added links, done some rewording. --- src/plugin.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/plugin.js b/src/plugin.js index 9db6c179..506387ee 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -53,21 +53,15 @@ mix( Plugin, ObservableMixin ); /** * The base interface for CKEditor plugins. * - * In its minimal form it can be a simple function (it will be used as a constructor) that accepts - * {@link module:core/editor/editor~Editor the editor} as a parameter. - * It can also implement a few methods which, when present, will be used to properly initialize and destroy the plugin. + * In its minimal form a plugin can be a simple function that accepts {@link module:core/editor/editor~Editor the editor} + * as a parameter: * * // A simple plugin that enables a data processor. * function MyPlugin( editor ) { * editor.data.processor = new MyDataProcessor(); * } * - * **Note:** The simple plugin form is treated as an constructor of a plugin. Most importantly - it is called on the time - * as any other plugins' constructors. Thus it will be executed before any {@link module:core/plugin~PluginInterface#init `init()`} - * or {@link module:core/plugin~PluginInterface#afterInit `afterInit()`} methods of other plugins. - * This is important because you cannot extend other plugin schema rule as they are defined in `init()` stage. - * - * In most cases, however, you will want to inherit from the {@link module:core/plugin~Plugin} class which implements the + * In most cases however, you will want to inherit from the {@link module:core/plugin~Plugin} class which implements the * {@link module:utils/observablemixin~ObservableMixin} and is, therefore, more convenient: * * class MyPlugin extends Plugin { @@ -81,6 +75,17 @@ mix( Plugin, ObservableMixin ); * } * } * + * The plugin can also implement methods (e.g. {@link module:core/plugin~PluginInterface#init `init()`} or + * {@link module:core/plugin~PluginInterface#destroy `destroy()`}) which, when present, will be used to properly + * initialize and destroy the plugin. + * + * **Note:** When defined as a plain function, the plugin acts as a constructor and will be + * called in parallel with other plugins' {@link module:core/plugin~PluginInterface#constructor constructors}. + * This means the code of that plugin will be executed **before** {@link module:core/plugin~PluginInterface#init `init()`} and + * {@link module:core/plugin~PluginInterface#afterInit `afterInit()`} methods of other plugins and, for instance, + * you cannot use it to extend other plugins' {@glink framework/guides/architecture/editing-engine#schema schema} + * rules as they are defined later on during the `init()` stage. + * * @interface PluginInterface */