diff --git a/src/toolbar/block/blocktoolbar.js b/src/toolbar/block/blocktoolbar.js index 5dead3ad..85074f65 100644 --- a/src/toolbar/block/blocktoolbar.js +++ b/src/toolbar/block/blocktoolbar.js @@ -149,7 +149,7 @@ export default class BlockToolbar extends Plugin { */ afterInit() { const factory = this.editor.ui.componentFactory; - const config = this.editor.config.get( 'blockToolbar' ); + const config = this.editor.config.get( 'blockToolbar' ) || []; this.toolbarView.fillFromConfig( config, factory ); diff --git a/tests/toolbar/block/blocktoolbar.js b/tests/toolbar/block/blocktoolbar.js index 2d92a82d..0b50c94c 100644 --- a/tests/toolbar/block/blocktoolbar.js +++ b/tests/toolbar/block/blocktoolbar.js @@ -55,6 +55,15 @@ describe( 'BlockToolbar', () => { expect( BlockToolbar.pluginName ).to.equal( 'BlockToolbar' ); } ); + it( 'should not throw when empty config is provided', async () => { + // Remove default editor instance. + await editor.destroy(); + + editor = await ClassicTestEditor.create( element, { + plugins: [ BlockToolbar ] + } ); + } ); + describe( 'child views', () => { describe( 'panelView', () => { it( 'should create a view instance', () => { @@ -213,6 +222,18 @@ describe( 'BlockToolbar', () => { expect( blockToolbar.buttonView.tooltip ).to.be.false; } ); + + it( 'should hide the #button if empty config was passed', async () => { + // Remove default editor instance. + await editor.destroy(); + + editor = await ClassicTestEditor.create( element, { + plugins: [ BlockToolbar ] + } ); + + const blockToolbar = editor.plugins.get( BlockToolbar ); + expect( blockToolbar.buttonView.isVisible ).to.be.false; + } ); } ); } );