Răsfoiți Sursa

Merge pull request #157 from ckeditor/t/ckeditor5/1477

Other: Remove `editor#pluginsReady` event. Closes ckeditor/ckeditor5#1477.

BREAKING CHANGE: The `editor#pluginsReady` event was removed. Use plugin `afterInit()` method instead.
Piotr Jasiun 6 ani în urmă
părinte
comite
9b65dc9eea

+ 9 - 64
packages/ckeditor5-core/src/editor/editor.js

@@ -42,6 +42,7 @@ import '@ckeditor/ckeditor5-utils/src/version';
  * the specific editor implements also the {@link module:core/editor/editorwithui~EditorWithUI} interface
  * the specific editor implements also the {@link module:core/editor/editorwithui~EditorWithUI} interface
  * (as most editor implementations do).
  * (as most editor implementations do).
  *
  *
+ * @abstract
  * @mixes module:utils/observablemixin~ObservableMixin
  * @mixes module:utils/observablemixin~ObservableMixin
  */
  */
 export default class Editor {
 export default class Editor {
@@ -218,36 +219,16 @@ export default class Editor {
 	/**
 	/**
 	 * Loads and initializes plugins specified in the config.
 	 * Loads and initializes plugins specified in the config.
 	 *
 	 *
-	 * @returns {Promise} A promise which resolves once the initialization is completed.
+	 * @returns {Promise.<Array.<module:core/plugin~PluginInterface>>} returns.loadedPlugins A promise which resolves
+	 * once the initialization is completed providing array of loaded plugins.
 	 */
 	 */
 	initPlugins() {
 	initPlugins() {
-		const that = this;
 		const config = this.config;
 		const config = this.config;
+		const plugins = config.get( 'plugins' ) || [];
+		const removePlugins = config.get( 'removePlugins' ) || [];
+		const extraPlugins = config.get( 'extraPlugins' ) || [];
 
 
-		return loadPlugins()
-			.then( loadedPlugins => {
-				return initPlugins( loadedPlugins, 'init' )
-					.then( () => initPlugins( loadedPlugins, 'afterInit' ) );
-			} )
-			.then( () => this.fire( 'pluginsReady' ) );
-
-		function loadPlugins() {
-			const plugins = config.get( 'plugins' ) || [];
-			const removePlugins = config.get( 'removePlugins' ) || [];
-			const extraPlugins = config.get( 'extraPlugins' ) || [];
-
-			return that.plugins.load( plugins.concat( extraPlugins ), removePlugins );
-		}
-
-		function initPlugins( loadedPlugins, method ) {
-			return loadedPlugins.reduce( ( promise, plugin ) => {
-				if ( !plugin[ method ] ) {
-					return promise;
-				}
-
-				return promise.then( plugin[ method ].bind( plugin ) );
-			}, Promise.resolve() );
-		}
+		return this.plugins.init( plugins.concat( extraPlugins ), removePlugins );
 	}
 	}
 
 
 	/**
 	/**
@@ -294,49 +275,13 @@ export default class Editor {
 	execute( ...args ) {
 	execute( ...args ) {
 		this.commands.execute( ...args );
 		this.commands.execute( ...args );
 	}
 	}
-
-	/**
-	 * Creates and initializes a new editor instance.
-	 *
-	 * @param {Object} config The editor config. You can find the list of config options in
-	 * {@link module:core/editor/editorconfig~EditorConfig}.
-	 * @returns {Promise} Promise resolved once editor is ready.
-	 * @returns {module:core/editor/editor~Editor} return.editor The editor instance.
-	 */
-	static create( config ) {
-		return new Promise( resolve => {
-			const editor = new this( config );
-
-			resolve(
-				editor.initPlugins()
-					.then( () => {
-						editor.fire( 'dataReady' );
-						editor.fire( 'ready' );
-					} )
-					.then( () => editor )
-			);
-		} );
-	}
 }
 }
 
 
 mix( Editor, ObservableMixin );
 mix( Editor, ObservableMixin );
 
 
 /**
 /**
- * Fired after {@link #initPlugins plugins are initialized}.
- *
- * @event pluginsReady
- */
-
-/**
- * Fired when the data loaded to the editor is ready. If a specific editor doesn't load
- * any data initially, this event will be fired right before {@link #event:ready}.
- *
- * @event dataReady
- */
-
-/**
- * Fired when {@link #event:pluginsReady plugins}, and {@link #event:dataReady data} and all additional
- * editor components are ready.
+ * Fired when {@link module:core/plugincollection~PluginCollection#event:ready plugins},
+ * and {@link module:engine/controller/datacontroller~DataController#event:ready data} and all additional editor components are ready.
  *
  *
  * Note: This event is most useful for plugin developers. When integrating the editor with your website or
  * Note: This event is most useful for plugin developers. When integrating the editor with your website or
  * application you do not have to listen to `editor#ready` because when the promise returned by the static
  * application you do not have to listen to `editor#ready` because when the promise returned by the static

+ 2 - 2
packages/ckeditor5-core/src/editor/editorui.js

@@ -125,8 +125,8 @@ export default class EditorUI {
 	/**
 	/**
 	 * Fired when the editor UI is ready.
 	 * Fired when the editor UI is ready.
 	 *
 	 *
-	 * Fired after {@link module:core/editor/editor~Editor#event:pluginsReady} and before
-	 * {@link module:core/editor/editor~Editor#event:dataReady}.
+	 * Fired after {@link module:core/plugincollection~PluginCollection#event:ready} and before
+	 * {@link module:engine/controller/datacontroller~DataController#event:ready}.
 	 *
 	 *
 	 * @event ready
 	 * @event ready
 	 */
 	 */

+ 1 - 1
packages/ckeditor5-core/src/plugin.js

@@ -70,7 +70,7 @@ mix( Plugin, ObservableMixin );
  *				// `listenTo()` and `editor` are available thanks to `Plugin`.
  *				// `listenTo()` and `editor` are available thanks to `Plugin`.
  *				// By using `listenTo()` you will ensure that the listener is removed when
  *				// By using `listenTo()` you will ensure that the listener is removed when
  *				// the plugin is destroyed.
  *				// the plugin is destroyed.
- *				this.listenTo( this.editor, 'dataReady', () => {
+ *				this.listenTo( this.editor.data, 'ready', () => {
  *					// Do something when the data is ready.
  *					// Do something when the data is ready.
  *				} );
  *				} );
  *			}
  *			}

+ 21 - 2
packages/ckeditor5-core/src/plugincollection.js

@@ -10,8 +10,13 @@
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import log from '@ckeditor/ckeditor5-utils/src/log';
 import log from '@ckeditor/ckeditor5-utils/src/log';
 
 
+import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
+import mix from '@ckeditor/ckeditor5-utils/src/mix';
+
 /**
 /**
  * Manages a list of CKEditor plugins, including loading, resolving dependencies and initialization.
  * Manages a list of CKEditor plugins, including loading, resolving dependencies and initialization.
+ *
+ * @mixes module:utils/emittermixin~EmitterMixin
  */
  */
 export default class PluginCollection {
 export default class PluginCollection {
 	/**
 	/**
@@ -139,7 +144,7 @@ export default class PluginCollection {
 	}
 	}
 
 
 	/**
 	/**
-	 * Loads a set of plugins and adds them to the collection.
+	 * Initializes a set of plugins and adds them to the collection.
 	 *
 	 *
 	 * @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
@@ -150,7 +155,7 @@ export default class PluginCollection {
 	 * collection.
 	 * collection.
 	 * @returns {Promise.<Array.<module:core/plugin~PluginInterface>>} returns.loadedPlugins The array of loaded plugins.
 	 * @returns {Promise.<Array.<module:core/plugin~PluginInterface>>} returns.loadedPlugins The array of loaded plugins.
 	 */
 	 */
-	load( plugins, removePlugins = [] ) {
+	init( plugins, removePlugins = [] ) {
 		const that = this;
 		const that = this;
 		const editor = this._editor;
 		const editor = this._editor;
 		const loading = new Set();
 		const loading = new Set();
@@ -191,6 +196,8 @@ export default class PluginCollection {
 		}
 		}
 
 
 		return Promise.all( pluginConstructors.map( loadPlugin ) )
 		return Promise.all( pluginConstructors.map( loadPlugin ) )
+			.then( () => initPlugins( loaded, 'init' ) )
+			.then( () => initPlugins( loaded, 'afterInit' ) )
 			.then( () => loaded );
 			.then( () => loaded );
 
 
 		function loadPlugin( PluginConstructor ) {
 		function loadPlugin( PluginConstructor ) {
@@ -231,6 +238,16 @@ export default class PluginCollection {
 				} );
 				} );
 		}
 		}
 
 
+		function initPlugins( loadedPlugins, method ) {
+			return loadedPlugins.reduce( ( promise, plugin ) => {
+				if ( !plugin[ method ] ) {
+					return promise;
+				}
+
+				return promise.then( plugin[ method ].bind( plugin ) );
+			}, Promise.resolve() );
+		}
+
 		function instantiatePlugin( PluginConstructor ) {
 		function instantiatePlugin( PluginConstructor ) {
 			return new Promise( resolve => {
 			return new Promise( resolve => {
 				loading.add( PluginConstructor );
 				loading.add( PluginConstructor );
@@ -363,3 +380,5 @@ export default class PluginCollection {
 		}
 		}
 	}
 	}
 }
 }
+
+mix( PluginCollection, EmitterMixin );

+ 7 - 4
packages/ckeditor5-core/tests/_utils-tests/classictesteditor.js

@@ -116,14 +116,13 @@ describe( 'ClassicTestEditor', () => {
 			const fired = [];
 			const fired = [];
 
 
 			function spy( evt ) {
 			function spy( evt ) {
-				fired.push( evt.name );
+				fired.push( `${ evt.name }-${ evt.source.constructor.name.toLowerCase() }` );
 			}
 			}
 
 
 			class EventWatcher extends Plugin {
 			class EventWatcher extends Plugin {
 				init() {
 				init() {
-					this.editor.on( 'pluginsReady', spy );
 					this.editor.ui.on( 'ready', spy );
 					this.editor.ui.on( 'ready', spy );
-					this.editor.on( 'dataReady', spy );
+					this.editor.data.on( 'ready', spy );
 					this.editor.on( 'ready', spy );
 					this.editor.on( 'ready', spy );
 				}
 				}
 			}
 			}
@@ -133,7 +132,11 @@ describe( 'ClassicTestEditor', () => {
 					plugins: [ EventWatcher ]
 					plugins: [ EventWatcher ]
 				} )
 				} )
 				.then( editor => {
 				.then( editor => {
-					expect( fired ).to.deep.equal( [ 'pluginsReady', 'ready', 'dataReady', 'ready' ] );
+					expect( fired ).to.deep.equal( [
+						'ready-classictesteditorui',
+						'ready-datacontroller',
+						'ready-classictesteditor'
+					] );
 
 
 					return editor.destroy();
 					return editor.destroy();
 				} );
 				} );

+ 0 - 1
packages/ckeditor5-core/tests/_utils/classictesteditor.js

@@ -66,7 +66,6 @@ export default class ClassicTestEditor extends Editor {
 					.then( () => editor.editing.view.attachDomRoot( editor.ui.getEditableElement() ) )
 					.then( () => editor.editing.view.attachDomRoot( editor.ui.getEditableElement() ) )
 					.then( () => editor.data.init( getDataFromElement( element ) ) )
 					.then( () => editor.data.init( getDataFromElement( element ) ) )
 					.then( () => {
 					.then( () => {
-						editor.fire( 'dataReady' );
 						editor.state = 'ready';
 						editor.state = 'ready';
 						editor.fire( 'ready' );
 						editor.fire( 'ready' );
 					} )
 					} )

+ 16 - 0
packages/ckeditor5-core/tests/_utils/modeltesteditor.js

@@ -29,6 +29,22 @@ export default class ModelTestEditor extends Editor {
 		// Create the ("main") root element of the model tree.
 		// Create the ("main") root element of the model tree.
 		this.model.document.createRoot();
 		this.model.document.createRoot();
 	}
 	}
+
+	static create( config ) {
+		return new Promise( resolve => {
+			const editor = new this( config );
+
+			resolve(
+				editor.initPlugins()
+					.then( () => {
+						// Fire `data#ready` event manually as `data#init()` method is not used.
+						editor.data.fire( 'ready' );
+						editor.fire( 'ready' );
+					} )
+					.then( () => editor )
+			);
+		} );
+	}
 }
 }
 
 
 mix( ModelTestEditor, DataApiMixin );
 mix( ModelTestEditor, DataApiMixin );

+ 16 - 0
packages/ckeditor5-core/tests/_utils/virtualtesteditor.js

@@ -26,6 +26,22 @@ export default class VirtualTestEditor extends Editor {
 		// Create the ("main") root element of the model tree.
 		// Create the ("main") root element of the model tree.
 		this.model.document.createRoot();
 		this.model.document.createRoot();
 	}
 	}
+
+	static create( config ) {
+		return new Promise( resolve => {
+			const editor = new this( config );
+
+			resolve(
+				editor.initPlugins()
+					.then( () => {
+						// Fire `data#ready` event manually as `data#init()` method is not used.
+						editor.data.fire( 'ready' );
+						editor.fire( 'ready' );
+					} )
+					.then( () => editor )
+			);
+		} );
+	}
 }
 }
 
 
 mix( VirtualTestEditor, DataApiMixin );
 mix( VirtualTestEditor, DataApiMixin );

+ 66 - 64
packages/ckeditor5-core/tests/editor/editor.js

@@ -16,6 +16,22 @@ import Locale from '@ckeditor/ckeditor5-utils/src/locale';
 import Command from '../../src/command';
 import Command from '../../src/command';
 import EditingKeystrokeHandler from '../../src/editingkeystrokehandler';
 import EditingKeystrokeHandler from '../../src/editingkeystrokehandler';
 
 
+class TestEditor extends Editor {
+	static create( config ) {
+		return new Promise( resolve => {
+			const editor = new this( config );
+
+			resolve(
+				editor.initPlugins()
+					.then( () => {
+						editor.fire( 'ready' );
+					} )
+					.then( () => editor )
+			);
+		} );
+	}
+}
+
 class PluginA extends Plugin {
 class PluginA extends Plugin {
 	constructor( editor ) {
 	constructor( editor ) {
 		super( editor );
 		super( editor );
@@ -96,8 +112,8 @@ class PluginF {
 
 
 describe( 'Editor', () => {
 describe( 'Editor', () => {
 	afterEach( () => {
 	afterEach( () => {
-		delete Editor.builtinPlugins;
-		delete Editor.defaultConfig;
+		delete TestEditor.builtinPlugins;
+		delete TestEditor.defaultConfig;
 	} );
 	} );
 
 
 	it( 'imports the version helper', () => {
 	it( 'imports the version helper', () => {
@@ -106,7 +122,7 @@ describe( 'Editor', () => {
 
 
 	describe( 'constructor()', () => {
 	describe( 'constructor()', () => {
 		it( 'should create a new editor instance', () => {
 		it( 'should create a new editor instance', () => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			expect( editor.config ).to.be.an.instanceof( Config );
 			expect( editor.config ).to.be.an.instanceof( Config );
 			expect( editor.commands ).to.be.an.instanceof( CommandCollection );
 			expect( editor.commands ).to.be.an.instanceof( CommandCollection );
@@ -125,7 +141,7 @@ describe( 'Editor', () => {
 				}
 				}
 			};
 			};
 
 
-			const editor = new Editor( {
+			const editor = new TestEditor( {
 				bar: 'foo',
 				bar: 'foo',
 				foo: {
 				foo: {
 					c: 3
 					c: 3
@@ -142,7 +158,7 @@ describe( 'Editor', () => {
 		} );
 		} );
 
 
 		it( 'should bind editing.view.document#isReadOnly to the editor', () => {
 		it( 'should bind editing.view.document#isReadOnly to the editor', () => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			editor.isReadOnly = false;
 			editor.isReadOnly = false;
 
 
@@ -155,7 +171,7 @@ describe( 'Editor', () => {
 
 
 		it( 'should activate #keystrokes', () => {
 		it( 'should activate #keystrokes', () => {
 			const spy = sinon.spy( EditingKeystrokeHandler.prototype, 'listenTo' );
 			const spy = sinon.spy( EditingKeystrokeHandler.prototype, 'listenTo' );
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			sinon.assert.calledWith( spy, editor.editing.view.document );
 			sinon.assert.calledWith( spy, editor.editing.view.document );
 		} );
 		} );
@@ -163,7 +179,7 @@ describe( 'Editor', () => {
 
 
 	describe( 'plugins', () => {
 	describe( 'plugins', () => {
 		it( 'should be empty on new editor', () => {
 		it( 'should be empty on new editor', () => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			expect( getPlugins( editor ) ).to.be.empty;
 			expect( getPlugins( editor ) ).to.be.empty;
 		} );
 		} );
@@ -171,14 +187,14 @@ describe( 'Editor', () => {
 
 
 	describe( 'locale', () => {
 	describe( 'locale', () => {
 		it( 'is instantiated and t() is exposed', () => {
 		it( 'is instantiated and t() is exposed', () => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			expect( editor.locale ).to.be.instanceof( Locale );
 			expect( editor.locale ).to.be.instanceof( Locale );
 			expect( editor.t ).to.equal( editor.locale.t );
 			expect( editor.t ).to.equal( editor.locale.t );
 		} );
 		} );
 
 
 		it( 'is configured with the config.language', () => {
 		it( 'is configured with the config.language', () => {
-			const editor = new Editor( { language: 'pl' } );
+			const editor = new TestEditor( { language: 'pl' } );
 
 
 			expect( editor.locale.language ).to.equal( 'pl' );
 			expect( editor.locale.language ).to.equal( 'pl' );
 		} );
 		} );
@@ -186,13 +202,13 @@ describe( 'Editor', () => {
 
 
 	describe( 'state', () => {
 	describe( 'state', () => {
 		it( 'is `initializing` initially', () => {
 		it( 'is `initializing` initially', () => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			expect( editor.state ).to.equal( 'initializing' );
 			expect( editor.state ).to.equal( 'initializing' );
 		} );
 		} );
 
 
 		it( 'is `ready` after initialization chain', () => {
 		it( 'is `ready` after initialization chain', () => {
-			return Editor.create().then( editor => {
+			return TestEditor.create().then( editor => {
 				expect( editor.state ).to.equal( 'ready' );
 				expect( editor.state ).to.equal( 'ready' );
 
 
 				return editor.destroy();
 				return editor.destroy();
@@ -200,7 +216,7 @@ describe( 'Editor', () => {
 		} );
 		} );
 
 
 		it( 'is `destroyed` after editor destroy', () => {
 		it( 'is `destroyed` after editor destroy', () => {
-			return Editor.create().then( editor => {
+			return TestEditor.create().then( editor => {
 				return editor.destroy().then( () => {
 				return editor.destroy().then( () => {
 					expect( editor.state ).to.equal( 'destroyed' );
 					expect( editor.state ).to.equal( 'destroyed' );
 				} );
 				} );
@@ -208,7 +224,7 @@ describe( 'Editor', () => {
 		} );
 		} );
 
 
 		it( 'is observable', () => {
 		it( 'is observable', () => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 			const spy = sinon.spy();
 			const spy = sinon.spy();
 
 
 			editor.on( 'change:state', spy );
 			editor.on( 'change:state', spy );
@@ -219,7 +235,7 @@ describe( 'Editor', () => {
 		} );
 		} );
 
 
 		it( 'reacts on #ready event', done => {
 		it( 'reacts on #ready event', done => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			expect( editor.state ).to.equal( 'initializing' );
 			expect( editor.state ).to.equal( 'initializing' );
 
 
@@ -232,7 +248,7 @@ describe( 'Editor', () => {
 		} );
 		} );
 
 
 		it( 'reacts on #destroy event', done => {
 		it( 'reacts on #destroy event', done => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			expect( editor.state ).to.equal( 'initializing' );
 			expect( editor.state ).to.equal( 'initializing' );
 
 
@@ -247,13 +263,13 @@ describe( 'Editor', () => {
 
 
 	describe( 'isReadOnly', () => {
 	describe( 'isReadOnly', () => {
 		it( 'is false initially', () => {
 		it( 'is false initially', () => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			expect( editor.isReadOnly ).to.false;
 			expect( editor.isReadOnly ).to.false;
 		} );
 		} );
 
 
 		it( 'is observable', () => {
 		it( 'is observable', () => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 			const spy = sinon.spy();
 			const spy = sinon.spy();
 
 
 			editor.on( 'change:isReadOnly', spy );
 			editor.on( 'change:isReadOnly', spy );
@@ -266,13 +282,13 @@ describe( 'Editor', () => {
 
 
 	describe( 'conversion', () => {
 	describe( 'conversion', () => {
 		it( 'should have conversion property', () => {
 		it( 'should have conversion property', () => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			expect( editor ).to.have.property( 'conversion' );
 			expect( editor ).to.have.property( 'conversion' );
 		} );
 		} );
 
 
 		it( 'should have defined default conversion groups', () => {
 		it( 'should have defined default conversion groups', () => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			expect( () => {
 			expect( () => {
 				// Would throw if any of this group won't exist.
 				// Would throw if any of this group won't exist.
@@ -286,7 +302,7 @@ describe( 'Editor', () => {
 
 
 	describe( 'destroy()', () => {
 	describe( 'destroy()', () => {
 		it( 'should fire "destroy"', () => {
 		it( 'should fire "destroy"', () => {
-			return Editor.create().then( editor => {
+			return TestEditor.create().then( editor => {
 				const spy = sinon.spy();
 				const spy = sinon.spy();
 
 
 				editor.on( 'destroy', spy );
 				editor.on( 'destroy', spy );
@@ -298,7 +314,7 @@ describe( 'Editor', () => {
 		} );
 		} );
 
 
 		it( 'should destroy all components it initialized', () => {
 		it( 'should destroy all components it initialized', () => {
-			return Editor.create().then( editor => {
+			return TestEditor.create().then( editor => {
 				const dataDestroySpy = sinon.spy( editor.data, 'destroy' );
 				const dataDestroySpy = sinon.spy( editor.data, 'destroy' );
 				const modelDestroySpy = sinon.spy( editor.model, 'destroy' );
 				const modelDestroySpy = sinon.spy( editor.model, 'destroy' );
 				const editingDestroySpy = sinon.spy( editor.editing, 'destroy' );
 				const editingDestroySpy = sinon.spy( editor.editing, 'destroy' );
@@ -318,7 +334,7 @@ describe( 'Editor', () => {
 
 
 		it( 'should wait for the full init before destroying', done => {
 		it( 'should wait for the full init before destroying', done => {
 			const spy = sinon.spy();
 			const spy = sinon.spy();
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			editor.on( 'destroy', () => {
 			editor.on( 'destroy', () => {
 				done();
 				done();
@@ -338,7 +354,7 @@ describe( 'Editor', () => {
 				execute() {}
 				execute() {}
 			}
 			}
 
 
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			const command = new SomeCommand( editor );
 			const command = new SomeCommand( editor );
 			sinon.spy( command, 'execute' );
 			sinon.spy( command, 'execute' );
@@ -350,7 +366,7 @@ describe( 'Editor', () => {
 		} );
 		} );
 
 
 		it( 'should throw an error if specified command has not been added', () => {
 		it( 'should throw an error if specified command has not been added', () => {
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			expect( () => {
 			expect( () => {
 				editor.execute( 'command' );
 				editor.execute( 'command' );
@@ -360,7 +376,7 @@ describe( 'Editor', () => {
 
 
 	describe( 'create()', () => {
 	describe( 'create()', () => {
 		it( 'should return a promise that resolves properly', () => {
 		it( 'should return a promise that resolves properly', () => {
-			const promise = Editor.create();
+			const promise = TestEditor.create();
 
 
 			expect( promise ).to.be.an.instanceof( Promise );
 			expect( promise ).to.be.an.instanceof( Promise );
 
 
@@ -368,7 +384,7 @@ describe( 'Editor', () => {
 		} );
 		} );
 
 
 		it( 'loads plugins', () => {
 		it( 'loads plugins', () => {
-			return Editor.create( { plugins: [ PluginA ] } )
+			return TestEditor.create( { plugins: [ PluginA ] } )
 				.then( editor => {
 				.then( editor => {
 					expect( getPlugins( editor ).length ).to.equal( 1 );
 					expect( getPlugins( editor ).length ).to.equal( 1 );
 
 
@@ -376,7 +392,7 @@ describe( 'Editor', () => {
 				} );
 				} );
 		} );
 		} );
 
 
-		it( 'fires all events in the right order', () => {
+		it( 'fires ready event', () => {
 			const fired = [];
 			const fired = [];
 
 
 			function spy( evt ) {
 			function spy( evt ) {
@@ -385,22 +401,20 @@ describe( 'Editor', () => {
 
 
 			class EventWatcher extends Plugin {
 			class EventWatcher extends Plugin {
 				init() {
 				init() {
-					this.editor.on( 'pluginsReady', spy );
-					this.editor.on( 'dataReady', spy );
 					this.editor.on( 'ready', spy );
 					this.editor.on( 'ready', spy );
 				}
 				}
 			}
 			}
 
 
-			return Editor.create( { plugins: [ EventWatcher ] } )
+			return TestEditor.create( { plugins: [ EventWatcher ] } )
 				.then( () => {
 				.then( () => {
-					expect( fired ).to.deep.equal( [ 'pluginsReady', 'dataReady', 'ready' ] );
+					expect( fired ).to.deep.equal( [ 'ready' ] );
 				} );
 				} );
 		} );
 		} );
 	} );
 	} );
 
 
 	describe( 'initPlugins()', () => {
 	describe( 'initPlugins()', () => {
 		it( 'should load plugins', () => {
 		it( 'should load plugins', () => {
-			const editor = new Editor( {
+			const editor = new TestEditor( {
 				plugins: [ PluginA, PluginB ]
 				plugins: [ PluginA, PluginB ]
 			} );
 			} );
 
 
@@ -415,13 +429,10 @@ describe( 'Editor', () => {
 		} );
 		} );
 
 
 		it( 'should initialize plugins in the right order', () => {
 		it( 'should initialize plugins in the right order', () => {
-			const editor = new Editor( {
+			const editor = new TestEditor( {
 				plugins: [ PluginA, PluginD ]
 				plugins: [ PluginA, PluginD ]
 			} );
 			} );
 
 
-			const pluginsReadySpy = sinon.spy().named( 'pluginsReady' );
-			editor.on( 'pluginsReady', pluginsReadySpy );
-
 			return editor.initPlugins()
 			return editor.initPlugins()
 				.then( () => {
 				.then( () => {
 					sinon.assert.callOrder(
 					sinon.assert.callOrder(
@@ -432,8 +443,7 @@ describe( 'Editor', () => {
 						editor.plugins.get( PluginA ).afterInit,
 						editor.plugins.get( PluginA ).afterInit,
 						editor.plugins.get( PluginB ).afterInit,
 						editor.plugins.get( PluginB ).afterInit,
 						editor.plugins.get( PluginC ).afterInit,
 						editor.plugins.get( PluginC ).afterInit,
-						editor.plugins.get( PluginD ).afterInit,
-						pluginsReadySpy
+						editor.plugins.get( PluginD ).afterInit
 					);
 					);
 				} );
 				} );
 		} );
 		} );
@@ -468,7 +478,7 @@ describe( 'Editor', () => {
 				}
 				}
 			}
 			}
 
 
-			const editor = new Editor( {
+			const editor = new TestEditor( {
 				plugins: [ PluginA, PluginSync ]
 				plugins: [ PluginA, PluginSync ]
 			} );
 			} );
 
 
@@ -514,7 +524,7 @@ describe( 'Editor', () => {
 				}
 				}
 			}
 			}
 
 
-			const editor = new Editor( {
+			const editor = new TestEditor( {
 				plugins: [ PluginA, PluginSync ]
 				plugins: [ PluginA, PluginSync ]
 			} );
 			} );
 
 
@@ -534,7 +544,7 @@ describe( 'Editor', () => {
 		it( 'should load plugins built in the Editor even if the passed config is empty', () => {
 		it( 'should load plugins built in the Editor even if the passed config is empty', () => {
 			Editor.builtinPlugins = [ PluginA, PluginB, PluginC ];
 			Editor.builtinPlugins = [ PluginA, PluginB, PluginC ];
 
 
-			const editor = new Editor();
+			const editor = new TestEditor();
 
 
 			return editor.initPlugins()
 			return editor.initPlugins()
 				.then( () => {
 				.then( () => {
@@ -549,7 +559,7 @@ describe( 'Editor', () => {
 		it( 'should load plugins provided in the config and should ignore plugins built in the Editor', () => {
 		it( 'should load plugins provided in the config and should ignore plugins built in the Editor', () => {
 			Editor.builtinPlugins = [ PluginA, PluginB, PluginC, PluginD ];
 			Editor.builtinPlugins = [ PluginA, PluginB, PluginC, PluginD ];
 
 
-			const editor = new Editor( {
+			const editor = new TestEditor( {
 				plugins: [
 				plugins: [
 					'A'
 					'A'
 				]
 				]
@@ -568,7 +578,7 @@ describe( 'Editor', () => {
 
 
 			Editor.builtinPlugins = [ PluginA, PluginB, PluginC, PluginD ];
 			Editor.builtinPlugins = [ PluginA, PluginB, PluginC, PluginD ];
 
 
-			const editor = new Editor( {
+			const editor = new TestEditor( {
 				plugins: [
 				plugins: [
 					'A',
 					'A',
 					'B',
 					'B',
@@ -591,7 +601,7 @@ describe( 'Editor', () => {
 		it( 'should load plugins inherited from the base Editor', () => {
 		it( 'should load plugins inherited from the base Editor', () => {
 			Editor.builtinPlugins = [ PluginA, PluginB, PluginC, PluginD ];
 			Editor.builtinPlugins = [ PluginA, PluginB, PluginC, PluginD ];
 
 
-			class CustomEditor extends Editor {}
+			class CustomEditor extends TestEditor {}
 
 
 			const editor = new CustomEditor( {
 			const editor = new CustomEditor( {
 				plugins: [
 				plugins: [
@@ -610,7 +620,7 @@ describe( 'Editor', () => {
 		} );
 		} );
 
 
 		it( 'should load plugins build into Editor\'s subclass', () => {
 		it( 'should load plugins build into Editor\'s subclass', () => {
-			class CustomEditor extends Editor {}
+			class CustomEditor extends TestEditor {}
 
 
 			CustomEditor.builtinPlugins = [ PluginA, PluginB, PluginC, PluginD ];
 			CustomEditor.builtinPlugins = [ PluginA, PluginB, PluginC, PluginD ];
 
 
@@ -632,7 +642,7 @@ describe( 'Editor', () => {
 
 
 		describe( '"removePlugins" config', () => {
 		describe( '"removePlugins" config', () => {
 			it( 'should prevent plugins from being loaded', () => {
 			it( 'should prevent plugins from being loaded', () => {
-				const editor = new Editor( {
+				const editor = new TestEditor( {
 					plugins: [ PluginA, PluginD ],
 					plugins: [ PluginA, PluginD ],
 					removePlugins: [ PluginD ]
 					removePlugins: [ PluginD ]
 				} );
 				} );
@@ -647,7 +657,7 @@ describe( 'Editor', () => {
 			it( 'should not load plugins built in the Editor', () => {
 			it( 'should not load plugins built in the Editor', () => {
 				Editor.builtinPlugins = [ PluginA, PluginD ];
 				Editor.builtinPlugins = [ PluginA, PluginD ];
 
 
-				const editor = new Editor( {
+				const editor = new TestEditor( {
 					removePlugins: [ 'D' ]
 					removePlugins: [ 'D' ]
 				} );
 				} );
 
 
@@ -659,7 +669,7 @@ describe( 'Editor', () => {
 			} );
 			} );
 
 
 			it( 'should not load plugins build into Editor\'s subclass', () => {
 			it( 'should not load plugins build into Editor\'s subclass', () => {
-				class CustomEditor extends Editor {}
+				class CustomEditor extends TestEditor {}
 
 
 				CustomEditor.builtinPlugins = [ PluginA, PluginD ];
 				CustomEditor.builtinPlugins = [ PluginA, PluginD ];
 
 
@@ -677,7 +687,7 @@ describe( 'Editor', () => {
 
 
 		describe( '"extraPlugins" config', () => {
 		describe( '"extraPlugins" config', () => {
 			it( 'should load additional plugins', () => {
 			it( 'should load additional plugins', () => {
-				const editor = new Editor( {
+				const editor = new TestEditor( {
 					plugins: [ PluginA, PluginC ],
 					plugins: [ PluginA, PluginC ],
 					extraPlugins: [ PluginB ]
 					extraPlugins: [ PluginB ]
 				} );
 				} );
@@ -690,7 +700,7 @@ describe( 'Editor', () => {
 			} );
 			} );
 
 
 			it( 'should not duplicate plugins', () => {
 			it( 'should not duplicate plugins', () => {
-				const editor = new Editor( {
+				const editor = new TestEditor( {
 					plugins: [ PluginA, PluginB ],
 					plugins: [ PluginA, PluginB ],
 					extraPlugins: [ PluginB ]
 					extraPlugins: [ PluginB ]
 				} );
 				} );
@@ -705,7 +715,7 @@ describe( 'Editor', () => {
 			it( 'should not duplicate plugins built in the Editor', () => {
 			it( 'should not duplicate plugins built in the Editor', () => {
 				Editor.builtinPlugins = [ PluginA, PluginB ];
 				Editor.builtinPlugins = [ PluginA, PluginB ];
 
 
-				const editor = new Editor( {
+				const editor = new TestEditor( {
 					extraPlugins: [ 'B' ]
 					extraPlugins: [ 'B' ]
 				} );
 				} );
 
 
@@ -717,7 +727,7 @@ describe( 'Editor', () => {
 			} );
 			} );
 
 
 			it( 'should not duplicate plugins build into Editor\'s subclass', () => {
 			it( 'should not duplicate plugins build into Editor\'s subclass', () => {
-				class CustomEditor extends Editor {}
+				class CustomEditor extends TestEditor {}
 
 
 				CustomEditor.builtinPlugins = [ PluginA, PluginB ];
 				CustomEditor.builtinPlugins = [ PluginA, PluginB ];
 
 
@@ -734,39 +744,31 @@ describe( 'Editor', () => {
 		} );
 		} );
 
 
 		it( 'should not call "afterInit" method if plugin does not have this method', () => {
 		it( 'should not call "afterInit" method if plugin does not have this method', () => {
-			const editor = new Editor( {
+			const editor = new TestEditor( {
 				plugins: [ PluginA, PluginE ]
 				plugins: [ PluginA, PluginE ]
 			} );
 			} );
 
 
-			const pluginsReadySpy = sinon.spy().named( 'pluginsReady' );
-			editor.on( 'pluginsReady', pluginsReadySpy );
-
 			return editor.initPlugins()
 			return editor.initPlugins()
 				.then( () => {
 				.then( () => {
 					sinon.assert.callOrder(
 					sinon.assert.callOrder(
 						editor.plugins.get( PluginA ).init,
 						editor.plugins.get( PluginA ).init,
 						editor.plugins.get( PluginE ).init,
 						editor.plugins.get( PluginE ).init,
-						editor.plugins.get( PluginA ).afterInit,
-						pluginsReadySpy
+						editor.plugins.get( PluginA ).afterInit
 					);
 					);
 				} );
 				} );
 		} );
 		} );
 
 
 		it( 'should not call "init" method if plugin does not have this method', () => {
 		it( 'should not call "init" method if plugin does not have this method', () => {
-			const editor = new Editor( {
+			const editor = new TestEditor( {
 				plugins: [ PluginA, PluginF ]
 				plugins: [ PluginA, PluginF ]
 			} );
 			} );
 
 
-			const pluginsReadySpy = sinon.spy().named( 'pluginsReady' );
-			editor.on( 'pluginsReady', pluginsReadySpy );
-
 			return editor.initPlugins()
 			return editor.initPlugins()
 				.then( () => {
 				.then( () => {
 					sinon.assert.callOrder(
 					sinon.assert.callOrder(
 						editor.plugins.get( PluginA ).init,
 						editor.plugins.get( PluginA ).init,
 						editor.plugins.get( PluginA ).afterInit,
 						editor.plugins.get( PluginA ).afterInit,
-						editor.plugins.get( PluginF ).afterInit,
-						pluginsReadySpy
+						editor.plugins.get( PluginF ).afterInit
 					);
 					);
 				} );
 				} );
 		} );
 		} );

+ 37 - 37
packages/ckeditor5-core/tests/plugincollection.js

@@ -77,7 +77,7 @@ describe( 'PluginCollection', () => {
 		it( 'should not fail when trying to load 0 plugins (empty array)', () => {
 		it( 'should not fail when trying to load 0 plugins (empty array)', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [] )
+			return plugins.init( [] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ) ).to.be.empty;
 					expect( getPlugins( plugins ) ).to.be.empty;
 				} );
 				} );
@@ -86,7 +86,7 @@ describe( 'PluginCollection', () => {
 		it( 'should add collection items for loaded plugins', () => {
 		it( 'should add collection items for loaded plugins', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ PluginA, PluginB ] )
+			return plugins.init( [ PluginA, PluginB ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 
 
@@ -98,7 +98,7 @@ describe( 'PluginCollection', () => {
 		it( 'should add collection items for loaded plugins using plugin names', () => {
 		it( 'should add collection items for loaded plugins using plugin names', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ 'A', 'B' ] )
+			return plugins.init( [ 'A', 'B' ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 
 
@@ -111,7 +111,7 @@ describe( 'PluginCollection', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const spy = sinon.spy( plugins, '_add' );
 			const spy = sinon.spy( plugins, '_add' );
 
 
-			return plugins.load( [ PluginA, PluginC ] )
+			return plugins.init( [ PluginA, PluginC ] )
 				.then( loadedPlugins => {
 				.then( loadedPlugins => {
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 
 
@@ -126,7 +126,7 @@ describe( 'PluginCollection', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const spy = sinon.spy( plugins, '_add' );
 			const spy = sinon.spy( plugins, '_add' );
 
 
-			return plugins.load( [ 'J' ] )
+			return plugins.init( [ 'J' ] )
 				.then( loadedPlugins => {
 				.then( loadedPlugins => {
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 
 
@@ -141,7 +141,7 @@ describe( 'PluginCollection', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const spy = sinon.spy( plugins, '_add' );
 			const spy = sinon.spy( plugins, '_add' );
 
 
-			return plugins.load( [ PluginA, PluginB, PluginC ] )
+			return plugins.init( [ PluginA, PluginB, PluginC ] )
 				.then( loadedPlugins => {
 				.then( loadedPlugins => {
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 
 
@@ -156,7 +156,7 @@ describe( 'PluginCollection', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const spy = sinon.spy( plugins, '_add' );
 			const spy = sinon.spy( plugins, '_add' );
 
 
-			return plugins.load( [ PluginD ] )
+			return plugins.init( [ PluginD ] )
 				.then( loadedPlugins => {
 				.then( loadedPlugins => {
 					expect( getPlugins( plugins ).length ).to.equal( 4 );
 					expect( getPlugins( plugins ).length ).to.equal( 4 );
 
 
@@ -172,7 +172,7 @@ describe( 'PluginCollection', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const spy = sinon.spy( plugins, '_add' );
 			const spy = sinon.spy( plugins, '_add' );
 
 
-			return plugins.load( [ PluginA, PluginE ] )
+			return plugins.init( [ PluginA, PluginE ] )
 				.then( loadedPlugins => {
 				.then( loadedPlugins => {
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 					expect( getPlugins( plugins ).length ).to.equal( 3 );
 
 
@@ -187,7 +187,7 @@ describe( 'PluginCollection', () => {
 		it( 'should load grand child classes', () => {
 		it( 'should load grand child classes', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ PluginG ] )
+			return plugins.init( [ PluginG ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 1 );
 					expect( getPlugins( plugins ).length ).to.equal( 1 );
 				} );
 				} );
@@ -198,7 +198,7 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ Y ] )
+			return plugins.init( [ Y ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 1 );
 					expect( getPlugins( plugins ).length ).to.equal( 1 );
 				} );
 				} );
@@ -211,7 +211,7 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ pluginAsFunction ] )
+			return plugins.init( [ pluginAsFunction ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 1 );
 					expect( getPlugins( plugins ).length ).to.equal( 1 );
 				} );
 				} );
@@ -230,7 +230,7 @@ describe( 'PluginCollection', () => {
 				}
 				}
 			}
 			}
 
 
-			return plugins.load( [ PluginA, PluginB, pluginAsFunction, Y ] )
+			return plugins.init( [ PluginA, PluginB, pluginAsFunction, Y ] )
 				.then( () => {
 				.then( () => {
 					expect( plugins.get( PluginA ).editor ).to.equal( editor );
 					expect( plugins.get( PluginA ).editor ).to.equal( editor );
 					expect( plugins.get( PluginB ).editor ).to.equal( editor );
 					expect( plugins.get( PluginB ).editor ).to.equal( editor );
@@ -244,8 +244,8 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ PluginA, PluginX, PluginB ] )
-				// Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
+			return plugins.init( [ PluginA, PluginX, PluginB ] )
+				// Throw here, so if by any chance plugins.init() was resolved correctly catch() will be stil executed.
 				.then( () => {
 				.then( () => {
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
 				} )
 				} )
@@ -263,8 +263,8 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ 'NonExistentPlugin' ] )
-				// Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
+			return plugins.init( [ 'NonExistentPlugin' ] )
+				// Throw here, so if by any chance plugins.init() was resolved correctly catch() will be stil executed.
 				.then( () => {
 				.then( () => {
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
 				} )
 				} )
@@ -280,7 +280,7 @@ describe( 'PluginCollection', () => {
 		it( 'should load chosen plugins (plugins and removePlugins are constructors)', () => {
 		it( 'should load chosen plugins (plugins and removePlugins are constructors)', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ PluginA, PluginB, PluginC ], [ PluginA ] )
+			return plugins.init( [ PluginA, PluginB, PluginC ], [ PluginA ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 
 
@@ -292,7 +292,7 @@ describe( 'PluginCollection', () => {
 		it( 'should load chosen plugins (plugins are constructors, removePlugins are names)', () => {
 		it( 'should load chosen plugins (plugins are constructors, removePlugins are names)', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ PluginA, PluginB, PluginC ], [ 'A' ] )
+			return plugins.init( [ PluginA, PluginB, PluginC ], [ 'A' ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 
 
@@ -304,7 +304,7 @@ describe( 'PluginCollection', () => {
 		it( 'should load chosen plugins (plugins and removePlugins are names)', () => {
 		it( 'should load chosen plugins (plugins and removePlugins are names)', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ 'A', 'B', 'C' ], [ 'A' ] )
+			return plugins.init( [ 'A', 'B', 'C' ], [ 'A' ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 
 
@@ -316,7 +316,7 @@ describe( 'PluginCollection', () => {
 		it( 'should load chosen plugins (plugins are names, removePlugins are constructors)', () => {
 		it( 'should load chosen plugins (plugins are names, removePlugins are constructors)', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ 'A', 'B', 'C' ], [ PluginA ] )
+			return plugins.init( [ 'A', 'B', 'C' ], [ PluginA ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 
 
@@ -330,7 +330,7 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, [ AnonymousPlugin ].concat( availablePlugins ) );
 			const plugins = new PluginCollection( editor, [ AnonymousPlugin ].concat( availablePlugins ) );
 
 
-			return plugins.load( [ AnonymousPlugin, 'A', 'B' ], [ AnonymousPlugin ] )
+			return plugins.init( [ AnonymousPlugin, 'A', 'B' ], [ AnonymousPlugin ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 
 
@@ -343,8 +343,8 @@ describe( 'PluginCollection', () => {
 			const logSpy = testUtils.sinon.stub( log, 'error' );
 			const logSpy = testUtils.sinon.stub( log, 'error' );
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ PluginA, PluginB, PluginC, PluginD ], [ PluginA, PluginB ] )
-				// Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
+			return plugins.init( [ PluginA, PluginB, PluginC, PluginD ], [ PluginA, PluginB ] )
+				// Throw here, so if by any chance plugins.init() was resolved correctly catch() will be stil executed.
 				.then( () => {
 				.then( () => {
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
 				} )
 				} )
@@ -360,7 +360,7 @@ describe( 'PluginCollection', () => {
 			const logSpy = testUtils.sinon.stub( log, 'warn' );
 			const logSpy = testUtils.sinon.stub( log, 'warn' );
 			const plugins = new PluginCollection( editor );
 			const plugins = new PluginCollection( editor );
 
 
-			return plugins.load( [ PluginFoo, AnotherPluginFoo ] )
+			return plugins.init( [ PluginFoo, AnotherPluginFoo ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 
 
@@ -384,7 +384,7 @@ describe( 'PluginCollection', () => {
 			const logSpy = testUtils.sinon.stub( log, 'warn' );
 			const logSpy = testUtils.sinon.stub( log, 'warn' );
 			const plugins = new PluginCollection( editor );
 			const plugins = new PluginCollection( editor );
 
 
-			return plugins.load( [ PluginFoo ] )
+			return plugins.init( [ PluginFoo ] )
 				.then( () => {
 				.then( () => {
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 					expect( getPlugins( plugins ).length ).to.equal( 2 );
 
 
@@ -405,7 +405,7 @@ describe( 'PluginCollection', () => {
 				const logSpy = testUtils.sinon.stub( log, 'warn' );
 				const logSpy = testUtils.sinon.stub( log, 'warn' );
 				const plugins = new PluginCollection( editor, availablePlugins );
 				const plugins = new PluginCollection( editor, availablePlugins );
 
 
-				return plugins.load( [ 'Foo', AnotherPluginFoo ] )
+				return plugins.init( [ 'Foo', AnotherPluginFoo ] )
 					.then( () => {
 					.then( () => {
 						expect( getPlugins( plugins ).length ).to.equal( 2 );
 						expect( getPlugins( plugins ).length ).to.equal( 2 );
 
 
@@ -428,7 +428,7 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ SomePlugin ] )
+			return plugins.init( [ SomePlugin ] )
 				.then( () => {
 				.then( () => {
 					expect( plugins.get( SomePlugin ) ).to.be.instanceOf( SomePlugin );
 					expect( plugins.get( SomePlugin ) ).to.be.instanceOf( SomePlugin );
 				} );
 				} );
@@ -442,7 +442,7 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ SomePlugin ] )
+			return plugins.init( [ SomePlugin ] )
 				.then( () => {
 				.then( () => {
 					expect( plugins.get( 'foo/bar' ) ).to.be.instanceOf( SomePlugin );
 					expect( plugins.get( 'foo/bar' ) ).to.be.instanceOf( SomePlugin );
 					expect( plugins.get( SomePlugin ) ).to.be.instanceOf( SomePlugin );
 					expect( plugins.get( SomePlugin ) ).to.be.instanceOf( SomePlugin );
@@ -452,7 +452,7 @@ describe( 'PluginCollection', () => {
 		it( 'throws if plugin cannot be retrieved by name', () => {
 		it( 'throws if plugin cannot be retrieved by name', () => {
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [] ).then( () => {
+			return plugins.init( [] ).then( () => {
 				expect( () => plugins.get( 'foo' ) )
 				expect( () => plugins.get( 'foo' ) )
 					.to.throw( CKEditorError, /^plugincollection-plugin-not-loaded:/ )
 					.to.throw( CKEditorError, /^plugincollection-plugin-not-loaded:/ )
 					.with.deep.property( 'data', { plugin: 'foo' } );
 					.with.deep.property( 'data', { plugin: 'foo' } );
@@ -465,7 +465,7 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [] ).then( () => {
+			return plugins.init( [] ).then( () => {
 				expect( () => plugins.get( SomePlugin ) )
 				expect( () => plugins.get( SomePlugin ) )
 					.to.throw( CKEditorError, /^plugincollection-plugin-not-loaded:/ )
 					.to.throw( CKEditorError, /^plugincollection-plugin-not-loaded:/ )
 					.with.deep.property( 'data', { plugin: 'foo' } );
 					.with.deep.property( 'data', { plugin: 'foo' } );
@@ -477,7 +477,7 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [] ).then( () => {
+			return plugins.init( [] ).then( () => {
 				expect( () => plugins.get( SomePlugin ) )
 				expect( () => plugins.get( SomePlugin ) )
 					.to.throw( CKEditorError, /^plugincollection-plugin-not-loaded:/ )
 					.to.throw( CKEditorError, /^plugincollection-plugin-not-loaded:/ )
 					.with.deep.property( 'data', { plugin: 'SomePlugin' } );
 					.with.deep.property( 'data', { plugin: 'SomePlugin' } );
@@ -504,13 +504,13 @@ describe( 'PluginCollection', () => {
 		} );
 		} );
 
 
 		it( 'returns true if plugins is loaded (retrieved by name)', () => {
 		it( 'returns true if plugins is loaded (retrieved by name)', () => {
-			return plugins.load( [ PluginA ] ).then( () => {
+			return plugins.init( [ PluginA ] ).then( () => {
 				expect( plugins.has( 'A' ) ).to.be.true;
 				expect( plugins.has( 'A' ) ).to.be.true;
 			} );
 			} );
 		} );
 		} );
 
 
 		it( 'returns true if plugins is loaded (retrieved by class)', () => {
 		it( 'returns true if plugins is loaded (retrieved by class)', () => {
-			return plugins.load( [ PluginA ] ).then( () => {
+			return plugins.init( [ PluginA ] ).then( () => {
 				expect( plugins.has( PluginA ) ).to.be.true;
 				expect( plugins.has( PluginA ) ).to.be.true;
 			} );
 			} );
 		} );
 		} );
@@ -522,7 +522,7 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, [] );
 			const plugins = new PluginCollection( editor, [] );
 
 
-			return plugins.load( [ PluginA, PluginB ] )
+			return plugins.init( [ PluginA, PluginB ] )
 				.then( () => {
 				.then( () => {
 					destroySpyForPluginA = sinon.spy( plugins.get( PluginA ), 'destroy' );
 					destroySpyForPluginA = sinon.spy( plugins.get( PluginA ), 'destroy' );
 					destroySpyForPluginB = sinon.spy( plugins.get( PluginB ), 'destroy' );
 					destroySpyForPluginB = sinon.spy( plugins.get( PluginB ), 'destroy' );
@@ -566,7 +566,7 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, [] );
 			const plugins = new PluginCollection( editor, [] );
 
 
-			return plugins.load( [ AsynchronousPluginA, AsynchronousPluginB ] )
+			return plugins.init( [ AsynchronousPluginA, AsynchronousPluginB ] )
 				.then( () => plugins.destroy() )
 				.then( () => plugins.destroy() )
 				.then( () => {
 				.then( () => {
 					expect( destroyedPlugins ).to.contain( 'AsynchronousPluginB.destroy()' );
 					expect( destroyedPlugins ).to.contain( 'AsynchronousPluginB.destroy()' );
@@ -583,7 +583,7 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, [] );
 			const plugins = new PluginCollection( editor, [] );
 
 
-			return plugins.load( [ PluginA, FooPlugin ] )
+			return plugins.init( [ PluginA, FooPlugin ] )
 				.then( () => plugins.destroy() )
 				.then( () => plugins.destroy() )
 				.then( destroyedPlugins => {
 				.then( destroyedPlugins => {
 					expect( destroyedPlugins.length ).to.equal( 1 );
 					expect( destroyedPlugins.length ).to.equal( 1 );
@@ -608,7 +608,7 @@ describe( 'PluginCollection', () => {
 
 
 			const plugins = new PluginCollection( editor, availablePlugins );
 			const plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ SomePlugin1, SomePlugin2 ] )
+			return plugins.init( [ SomePlugin1, SomePlugin2 ] )
 				.then( () => {
 				.then( () => {
 					const pluginConstructors = Array.from( plugins )
 					const pluginConstructors = Array.from( plugins )
 						.map( entry => entry[ 0 ] );
 						.map( entry => entry[ 0 ] );