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

Introduced disabling API for the WidgetToolbarRepository class #113

Merged
merged 6 commits into from
Dec 17, 2019

Conversation

mlewand
Copy link
Contributor

@mlewand mlewand commented Dec 16, 2019

Suggested merge commit message (convention)

Feature: Introduced API to disable the WidgetToolbarRepository plugin. Closes ckeditor/ckeditor5#5964.


Additional information

Since this is already used in the Command class, there was an option to implement this as an interface and add a common mixin to avoid code duplication. However during an offline meeting we decided to go with easier option and just copy'n'paste it from the Command class.

@Reinmar
Copy link
Member

Reinmar commented Dec 17, 2019

I tested those changes with the below addition:

(i/5964 86ed3af M1) p@m ~/...ckeditor5/packages/ckeditor5-widget> git diff
diff --git a/src/widgetresize.js b/src/widgetresize.js
index cd1ebae..5ede5b1 100644
--- a/src/widgetresize.js
+++ b/src/widgetresize.js
@@ -80,6 +80,7 @@ export default class WidgetResize extends Plugin {
             this._activeResizer = this._getResizerByHandle( resizeHandle );

             if ( this._activeResizer ) {
+                this.editor.plugins.get( 'WidgetToolbarRepository' ).forceDisabled( 'WidgetResize' );
                 this._activeResizer.begin( resizeHandle );
             }
         } );
@@ -93,6 +94,7 @@ export default class WidgetResize extends Plugin {
         this._observer.listenTo( domDocument, 'mouseup', () => {
             if ( this._activeResizer ) {
                 this._activeResizer.commit();
+                this.editor.plugins.get( 'WidgetToolbarRepository' ).clearForceDisabled( 'WidgetResize' );

                 this._activeResizer = null;
             }

And it worked beautifully. Performance is much much better.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

It should be possible to hide/disable a widget toolbar
2 participants