Selaa lähdekoodia

Internal: Simplified the code and removed unnecessary test.

Kamil Piechaczek 9 vuotta sitten
vanhempi
sitoutus
b907e3349d

+ 5 - 12
packages/ckeditor5-core/src/editor/editor.js

@@ -31,13 +31,7 @@ export default class Editor {
 	 * @param {Object} config The editor config.
 	 */
 	constructor( config ) {
-		/**
-		 * An array contains plugins built-in the editor.
-		 *
-		 * @protected
-		 * @member {Array.<module:core/plugin~Plugin>}
-		 */
-		this._availablePlugins = ( this.constructor.build && this.constructor.build.plugins ) || [];
+		const availablePlugins = this.constructor.build && this.constructor.build.plugins;
 
 		/**
 		 * Holds all configurations specific to this editor instance.
@@ -47,13 +41,15 @@ export default class Editor {
 		 */
 		this.config = new Config( config, this.constructor.build && this.constructor.build.config );
 
+		this.config.define( 'plugins', availablePlugins );
+
 		/**
 		 * The plugins loaded and in use by this editor instance.
 		 *
 		 * @readonly
 		 * @member {module:core/plugin~PluginCollection}
 		 */
-		this.plugins = new PluginCollection( this, this._availablePlugins );
+		this.plugins = new PluginCollection( this, availablePlugins );
 
 		/**
 		 * Commands registered to the editor.
@@ -124,10 +120,7 @@ export default class Editor {
 			.then( () => this.fire( 'pluginsReady' ) );
 
 		function loadPlugins() {
-			const pluginsFromConfig = config.get( 'plugins' ) || [];
-			const pluginsToLoad = pluginsFromConfig.concat( that._availablePlugins );
-
-			return that.plugins.load( pluginsToLoad );
+			return that.plugins.load( config.get( 'plugins' ) || [] );
 		}
 
 		function initPlugins( loadedPlugins, method ) {

+ 0 - 22
packages/ckeditor5-core/tests/editor/editor.js

@@ -289,28 +289,6 @@ describe( 'Editor', () => {
 					expect( editor.plugins.get( PluginC ) ).to.be.an.instanceof( Plugin );
 				} );
 		} );
-
-		it( 'should load plugins built in the Editor and specified in the config', () => {
-			Editor.build = {
-				plugins: [ PluginA ]
-			};
-
-			const editor = new Editor( {
-				plugins: [
-					PluginD
-				]
-			} );
-
-			return editor.initPlugins()
-				.then( () => {
-					expect( getPlugins( editor ).length ).to.equal( 4 );
-
-					expect( editor.plugins.get( PluginA ) ).to.be.an.instanceof( Plugin );
-					expect( editor.plugins.get( PluginB ) ).to.be.an.instanceof( Plugin );
-					expect( editor.plugins.get( PluginC ) ).to.be.an.instanceof( Plugin );
-					expect( editor.plugins.get( PluginD ) ).to.be.an.instanceof( Plugin );
-				} );
-		} );
 	} );
 } );