This repository was archived by the owner on Jun 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments