-
Notifications
You must be signed in to change notification settings - Fork 18
Added beforeShow event to the ContextualToolbar plugin #226
Conversation
There was a problem hiding this 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' ); |
There was a problem hiding this comment.
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 ) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't. Fixing...
Suggested merge commit message (convention)
Feature: Added
beforeShow
event to theContextualToolbar
plugin. Closes ckeditor/ckeditor5#5353.