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

Make BlockToolbar work with empty configuration. #534

Merged
merged 2 commits into from
Dec 20, 2019
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
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