Selaa lähdekoodia

Align code to the latest changes in editor.plugin API.

Maciej Gołaszewski 7 vuotta sitten
vanhempi
commit
53306cf72a

+ 3 - 2
packages/ckeditor5-widget/src/widgettoolbarrepository.js

@@ -58,10 +58,11 @@ export default class WidgetToolbarRepository extends Plugin {
 	 */
 	init() {
 		const editor = this.editor;
-		const balloonToolbar = editor.plugins.get( 'BalloonToolbar' );
 
 		// Disables the default balloon toolbar for all widgets.
-		if ( balloonToolbar ) {
+		if ( editor.plugins.has( 'BalloonToolbar' ) ) {
+			const balloonToolbar = editor.plugins.get( 'BalloonToolbar' );
+
 			this.listenTo( balloonToolbar, 'show', evt => {
 				if ( isWidgetSelected( editor.editing.view.document.selection ) ) {
 					evt.stop();

+ 11 - 0
packages/ckeditor5-widget/tests/widgettoolbarrepository.js

@@ -56,6 +56,17 @@ describe( 'WidgetToolbarRepository', () => {
 		expect( editor.plugins.get( WidgetToolbarRepository ) ).to.be.instanceOf( WidgetToolbarRepository );
 	} );
 
+	it( 'should work if balloon toolbar is not available', () => {
+		editorElement.remove();
+		editor.destroy();
+
+		editorElement = document.createElement( 'div' );
+		document.body.appendChild( editorElement );
+
+		expect( editor.plugins.has( 'BalloonToolbar' ) ).to.be.false;
+		expect( editor.plugins.has( WidgetToolbarRepository ) ).to.be.true;
+	} );
+
 	describe( 'register()', () => {
 		it( 'should create a widget toolbar and add it to the collection', () => {
 			widgetToolbarRepository.register( 'fake', {