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

Added beforeShow event to the ContextualToolbar plugin #226

Merged
merged 11 commits into from
May 10, 2017
Merged

Added beforeShow event to the ContextualToolbar plugin #226

merged 11 commits into from
May 10, 2017

Conversation

oskarwrobel
Copy link
Contributor

@oskarwrobel oskarwrobel commented May 9, 2017

Suggested merge commit message (convention)

Feature: Added beforeShow event to the ContextualToolbar plugin. Closes ckeditor/ckeditor5#5353.

@oskarwrobel oskarwrobel requested a review from oleq May 9, 2017 14:33
Copy link
Member

@oleq oleq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got some questions. The code is nasty but it will be fixed in https://github.com/ckeditor/ckeditor5-ui/issues/225.

}, { priority: 'lowest' } );

// Fire this event to inform interested plugins that `ContextualToolbar` is going to be shown.
this.fire( 'beforeShow' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we pass the stopping function along this event to avoid the additional stop method?

balloonClassName: 'ck-toolbar-container'
} );
// If `beforeShow` event is not stopped by any external code then panel will be displayed.
this.listenTo( this, 'beforeShow', ( evt ) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't once() mean that evt.off() at the end is gone?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once() uses on() but on() is not cleared on stopListening() (https://github.com/ckeditor/ckeditor5-utils/issues/144). That's why I used evt.off().

// If `beforeShow` event is not stopped by any external code then panel will be displayed.
this.once( 'beforeShow', () => {
if ( isStopped ) {
isStopped = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to reset the value of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't. Fixing...

@oleq oleq merged commit 835d0ac into master May 10, 2017
@Reinmar Reinmar deleted the t/222 branch May 11, 2017 07:54
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.

Prevent ContextualToolbar of being displayed in specific places
2 participants