Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

T/49: Implement options extraPlugins and removePlugins #77

Merged
merged 2 commits into from
Apr 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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