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 #534 from ckeditor/i/5980
Browse files Browse the repository at this point in the history
Fix: Make `BlockToolbar` work with an empty configuration. Closes ckeditor/ckeditor5#5980.
  • Loading branch information
Reinmar authored Dec 20, 2019
2 parents c334978 + 53d35ff commit 1e05098
Show file tree
Hide file tree
Showing 2 changed files with 22 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
21 changes: 21 additions & 0 deletions tests/toolbar/block/blocktoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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;
} );
} );
} );

Expand Down

0 comments on commit 1e05098

Please sign in to comment.