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 #77 from ckeditor/t/49
Browse files Browse the repository at this point in the history
Fix: Now introduced support for `config.removePlugins` for real (we said that we did this in the previous release). Closes #49.
  • Loading branch information
Reinmar authored Apr 4, 2017
2 parents 68f739f + 4387f54 commit 5834fed
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
47 changes: 47 additions & 0 deletions tests/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
} );
} );
} );
} );

Expand Down

0 comments on commit 5834fed

Please sign in to comment.