|
@@ -43,6 +43,10 @@ describe( 'ImageToolbar', () => {
|
|
|
expect( editor.plugins.get( ImageToolbar ) ).to.be.instanceOf( ImageToolbar );
|
|
expect( editor.plugins.get( ImageToolbar ) ).to.be.instanceOf( ImageToolbar );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ it( 'should initialize image.defaultToolbar to an empty array', () => {
|
|
|
|
|
+ expect( editor.config.get( 'image.defaultToolbar' ) ).to.eql( [] );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
it( 'should not initialize if there is no configuration', () => {
|
|
it( 'should not initialize if there is no configuration', () => {
|
|
|
const editorElement = global.document.createElement( 'div' );
|
|
const editorElement = global.document.createElement( 'div' );
|
|
|
global.document.body.appendChild( editorElement );
|
|
global.document.body.appendChild( editorElement );
|
|
@@ -58,6 +62,25 @@ describe( 'ImageToolbar', () => {
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ it( 'should allow other plugins to alter default config', () => {
|
|
|
|
|
+ const editorElement = global.document.createElement( 'div' );
|
|
|
|
|
+ global.document.body.appendChild( editorElement );
|
|
|
|
|
+
|
|
|
|
|
+ return ClassicEditor.create( editorElement, {
|
|
|
|
|
+ plugins: [ ImageToolbar, FakeButton, AlterDefaultConfig ]
|
|
|
|
|
+ } )
|
|
|
|
|
+ .then( newEditor => {
|
|
|
|
|
+ const panel = getBalloonPanelView( newEditor.ui.view.body );
|
|
|
|
|
+ const toolbar = panel.content.get( 0 );
|
|
|
|
|
+ const button = toolbar.items.get( 0 );
|
|
|
|
|
+
|
|
|
|
|
+ expect( newEditor.config.get( 'image.defaultToolbar' ) ).to.eql( [ 'fake_button' ] );
|
|
|
|
|
+ expect( button.label ).to.equal( 'fake button' );
|
|
|
|
|
+
|
|
|
|
|
+ newEditor.destroy();
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
it( 'should add BalloonPanelView to view body', () => {
|
|
it( 'should add BalloonPanelView to view body', () => {
|
|
|
expect( panel ).to.be.instanceOf( BalloonPanelView );
|
|
expect( panel ).to.be.instanceOf( BalloonPanelView );
|
|
|
} );
|
|
} );
|
|
@@ -164,4 +187,14 @@ describe( 'ImageToolbar', () => {
|
|
|
} );
|
|
} );
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ class AlterDefaultConfig extends Plugin {
|
|
|
|
|
+ init() {
|
|
|
|
|
+ const defaultImageToolbarConfig = this.editor.config.get( 'image.defaultToolbar' );
|
|
|
|
|
+
|
|
|
|
|
+ if ( defaultImageToolbarConfig ) {
|
|
|
|
|
+ defaultImageToolbarConfig.push( 'fake_button' );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
} );
|
|
} );
|