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

Commit

Permalink
Make BlockToolbar work with empty configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Dec 16, 2019
1 parent c334978 commit ea02023
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/toolbar/block/blocktoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
23 changes: 23 additions & 0 deletions tests/toolbar/block/blocktoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ describe( 'BlockToolbar', () => {
expect( BlockToolbar.pluginName ).to.equal( 'BlockToolbar' );
} );

it( 'should work with empty config', async () => {
// Remove default editor instance.
await editor.destroy();

expect( async () => {
editor = await ClassicTestEditor.create( element, {
plugins: [ BlockToolbar ]
} );
} ).to.not.throw();
} );

describe( 'child views', () => {
describe( 'panelView', () => {
it( 'should create a view instance', () => {
Expand Down Expand Up @@ -213,6 +224,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;
} );
} );
} );

Expand Down

0 comments on commit ea02023

Please sign in to comment.