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

Commit 1e05098

Browse files
authored
Merge pull request #534 from ckeditor/i/5980
Fix: Make `BlockToolbar` work with an empty configuration. Closes ckeditor/ckeditor5#5980.
2 parents c334978 + 53d35ff commit 1e05098

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/toolbar/block/blocktoolbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export default class BlockToolbar extends Plugin {
149149
*/
150150
afterInit() {
151151
const factory = this.editor.ui.componentFactory;
152-
const config = this.editor.config.get( 'blockToolbar' );
152+
const config = this.editor.config.get( 'blockToolbar' ) || [];
153153

154154
this.toolbarView.fillFromConfig( config, factory );
155155

tests/toolbar/block/blocktoolbar.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ describe( 'BlockToolbar', () => {
5555
expect( BlockToolbar.pluginName ).to.equal( 'BlockToolbar' );
5656
} );
5757

58+
it( 'should not throw when empty config is provided', async () => {
59+
// Remove default editor instance.
60+
await editor.destroy();
61+
62+
editor = await ClassicTestEditor.create( element, {
63+
plugins: [ BlockToolbar ]
64+
} );
65+
} );
66+
5867
describe( 'child views', () => {
5968
describe( 'panelView', () => {
6069
it( 'should create a view instance', () => {
@@ -213,6 +222,18 @@ describe( 'BlockToolbar', () => {
213222

214223
expect( blockToolbar.buttonView.tooltip ).to.be.false;
215224
} );
225+
226+
it( 'should hide the #button if empty config was passed', async () => {
227+
// Remove default editor instance.
228+
await editor.destroy();
229+
230+
editor = await ClassicTestEditor.create( element, {
231+
plugins: [ BlockToolbar ]
232+
} );
233+
234+
const blockToolbar = editor.plugins.get( BlockToolbar );
235+
expect( blockToolbar.buttonView.isVisible ).to.be.false;
236+
} );
216237
} );
217238
} );
218239

0 commit comments

Comments
 (0)