[lexical] Feature: add commands for beforeinput, input, compositionstart/end events#7964
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
d29e790 to
97a253b
Compare
etrepum
left a comment
There was a problem hiding this comment.
I think this is probably right and I'll give it a closer look later but one thing to think about here is that with nested editors there's this weird "feature" where commands from one editor can bubble to the parent editor if no handler (at any priority) returns true. A thorough review to make sure that the way these events are handled in nested editor situations in the same way with the old method and this new command based method are equivalent.
etrepum
left a comment
There was a problem hiding this comment.
This looks good to me, since all of these new command listeners are unconditionally returning true and the manner in which the DOM events are being listened to doesn't change there doesn't seem to be any risk of different behavior for editor propagation
|
This broke KEY_DOWN_COMMAND for me. Was able to resolve it by changing the priority to COMMAND_PRIORITY_HIGH instead of COMMAND_PRIORITY_EDITOR. Sharing in case it's helpful. |
|
thanks @code-alexander , for me |
Description
In order to any sort of track changes/suggestion mode feature, consumers need to be able to intercept/override events that mutate editor state. This is already the case for many operations, but not for input and composition events.
This PR adds commands for
beforeinput,input,compositionstartandcompositionend. The existing functions for these events have been repurposed into command handlers which are registered when creating a new editor instance.Test plan
One test was relying on
editor._commandsbeing empty by default; updated that test to be slightly more targeted.