Selaa lähdekoodia

An option "config.removePlugins" was not passed to the "plugins.load()" function.

Kamil Piechaczek 8 vuotta sitten
vanhempi
commit
9d0ec8dbc0

+ 4 - 1
packages/ckeditor5-core/src/editor/editor.js

@@ -120,7 +120,10 @@ export default class Editor {
 			.then( () => this.fire( 'pluginsReady' ) );
 
 		function loadPlugins() {
-			return that.plugins.load( config.get( 'plugins' ) || [] );
+			const plugins = config.get( 'plugins' ) || [];
+			const removePlugins = config.get( 'removePlugins' ) || [];
+
+			return that.plugins.load( plugins, removePlugins );
 		}
 
 		function initPlugins( loadedPlugins, method ) {

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

@@ -399,6 +399,56 @@ describe( 'Editor', () => {
 					expect( editor.plugins.get( PluginD ) ).to.be.an.instanceof( Plugin );
 				} );
 		} );
+
+		it( 'should not load plugins specified in the config as "removePlugins"', () => {
+			const editor = new Editor( {
+				plugins: [ PluginA, PluginD ],
+				removePlugins: [ PluginD ]
+			} );
+
+			return editor.initPlugins()
+				.then( () => {
+					expect( getPlugins( editor ).length ).to.equal( 1 );
+					expect( editor.plugins.get( PluginA ) ).to.be.an.instanceof( Plugin );
+				} );
+		} );
+
+		it( 'should not load plugins built in the Editor when "removePlugins" option is specified', () => {
+			Editor.build = {
+				plugins: [ PluginA, PluginD ]
+			};
+
+			const editor = new Editor( {
+				removePlugins: [ 'D' ]
+			} );
+
+			return editor.initPlugins()
+				.then( () => {
+					expect( getPlugins( editor ).length ).to.equal( 1 );
+					expect( editor.plugins.get( PluginA ) ).to.be.an.instanceof( Plugin );
+				} );
+		} );
+
+		it( 'should not load plugins build into Editor\'s subclass when "removePlugins" option is specified', () => {
+			class CustomEditor extends Editor {}
+
+			CustomEditor.build = {
+				plugins: [ PluginA, PluginD ]
+			};
+
+			const editor = new CustomEditor( {
+				plugins: [
+					'A'
+				],
+				removePlugins: [ 'D' ]
+			} );
+
+			return editor.initPlugins()
+				.then( () => {
+					expect( getPlugins( editor ).length ).to.equal( 1 );
+					expect( editor.plugins.get( PluginA ) ).to.be.an.instanceof( Plugin );
+				} );
+		} );
 	} );
 } );