-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BubblingEmitterMixin #9023
BubblingEmitterMixin #9023
Conversation
# Conflicts: # packages/ckeditor5-list/src/todolistediting.js
…ot implement _addEventListener method.
Notes from F2F talk with @Reinmar:
|
import { isArrowKeyCode } from '@ckeditor/ckeditor5-utils'; | ||
|
||
/** | ||
* Arrow keys observer introduces the {@link module:engine/view/document~Document#event:arrowKey} event. |
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.
Please align it a bit to match other observers' docs.
|
||
import EventInfo from '@ckeditor/ckeditor5-utils/src/eventinfo'; | ||
|
||
describe( 'EventInfo', () => { |
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.
Update the name :d
view.scrollToTheSelection(); | ||
}, { priority: 'low' } ); |
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.
I'd keep this. We listened on low
to make sure that if someone didn't pass any priority (and want to override this), that they don't have to do anything else.
Same in: shift enter, delete and perhaps somewhere else.
@@ -68,6 +68,6 @@ export default class ShiftEnter extends Plugin { | |||
|
|||
editor.execute( 'shiftEnter' ); | |||
view.scrollToTheSelection(); | |||
}, { priority: 'low' } ); |
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.
Same here.
if ( emitter._addEventListener ) { | ||
emitter._addEventListener( event, callback, options ); | ||
} else { | ||
// Allow listening on objects that do not implement Emitter interface. |
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.
Clarify that the use cases is in the tests.
if ( emitter._removeEventListener ) { | ||
emitter._removeEventListener( event, callback ); | ||
} else { | ||
// Allow listening on objects that do not implement Emitter interface. |
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.
Clarify that the use cases is in the tests.
BREAKING CHANGE: We introduced bubbling of |
@ckeditor/qa-team could you please test it? This is a massive change in event handling. Please focus on the custom enter/delete/delete forward/arrow keys handling in the context of blockquotes, lists, to-do lists, block widgets (widget type around), tables, links (2 step caret movement) |
I'd add that it's a lot about nesting. Nesting things inside other things. Like blockquotes in tables, images in block quotes, etc. Those are the most tricky cases. But the PR could've affected also more typical ones with flat structures. |
# Conflicts: # packages/ckeditor5-list/tests/todolistediting.js
I've tested it and haven't noticed any weird behaviours. It seems to be fine 👍 |
# Conflicts: # packages/ckeditor5-widget/package.json
Suggested merge commit message (convention)
Feature (engine): Introducing
BubblingEmitterMixin
andArrowKeysObserver
. Closes #8640.Fix (utils): The
EmitterMixin#listenTo()
method is split into listener and emitter parts. TheObservableMixin
decorated methods reverted to the original method while destroying an observable.Other (typing): The
TwoStepCaretMovement
is now using bubbling events. Closes #7437.BREAKING CHANGE: We introduced bubbling of
view.Document
events, similar to how bubbling works in the DOM. That allowed us to reprioritize many listeners that previously had to rely onpriority
. However, it means that existing listeners that use priorities may now be executed in a wrong moment. The listeners to such events should be reviewed in terms of when they should be executed (in what context/element/phase). You can find more information regarding bubbling in the documentation: [TODO].Internal (widget): The enter, delete and arrow key events handling moved to the usage of the bubbling observer.
Internal (block-quote): The enter and delete events handling moved to the usage of the bubbling observer.
Internal (code-block): The enter event handling moved to the usage of the bubbling observer.
Internal (list): The enter and delete events handling moved to the usage of the bubbling observer.
Internal (table): The arrow keys handling moved to the usage of the bubbling observer.
Additional information