diff --git a/src/editor/editor.js b/src/editor/editor.js index 86adfe76..62052ceb 100644 --- a/src/editor/editor.js +++ b/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 ) { diff --git a/tests/editor/editor.js b/tests/editor/editor.js index 72478486..5d30879a 100644 --- a/tests/editor/editor.js +++ b/tests/editor/editor.js @@ -399,6 +399,53 @@ 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( { + removePlugins: [ 'D' ] + } ); + + return editor.initPlugins() + .then( () => { + expect( getPlugins( editor ).length ).to.equal( 1 ); + expect( editor.plugins.get( PluginA ) ).to.be.an.instanceof( Plugin ); + } ); + } ); } ); } );