Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #191 from ckeditor/t/175
Browse files Browse the repository at this point in the history
Docs: Added a note to the `PluginInterface` about the limitations of plugins defined as plain functions. Closes #175.
  • Loading branch information
oleq committed Jul 30, 2019
2 parents e79d2ab + b25e02c commit 940b062
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +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();
* }
*
* 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 {
Expand All @@ -76,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
*/

Expand Down

0 comments on commit 940b062

Please sign in to comment.