-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Make it possible to change keyboard binding priorities #2423
Comments
I ran into a similar problem but found it is possible to prioritize your own handlers by using the configuration rather than
|
Have you actually gotten this to work? I've found that I can overwrite a default binding if I give it the same name (although it actually merges the bindings, so additional options like prefix and modifier keys get set unintentionally if they were present in the original). But I can't get my binding to run before a default as the documentation implies you can. Looking through the source code I can see the problem. The ordering the bindings get applied relies on the ordering of Object.keys, which puts them in the order they got added to the object. As the user configs are added after the defaults as overrides using The workaround I've found is naming the binding an integer or an integer string ie Really I think there should be flag on the binding that tells quill to add it first. And when you overwrite an existing binding, ideally it should just use the new binding and not merge them. It should also probably give a warning when you do this, similar to when you replace an existing format or module. |
I got bit by this in another angle - between this and #1940 (comment). If someone in this issue (or other issues) wants to do a refactor of There are many cases where having better API access to keyboard events (adding, removing, switching/updating handlers) would make sense after initialization. Also another one would be avoiding adding keybindings in the constructor, or pulling them out of the class and making them available in the exports to tweak. In my case I was updating |
` var keys = [{ key: 13 }, { key: 38 }, { key: 40 }, { key: 27 }, { key: 32 }];
is ok ,set enter key first item using jquery |
Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide 🙏 |
Currently when you use the documented addBinding function there are some key handlers that are impossible to implement. Take the following example.
I want to implement a handler that makes it so that shift + enter on a list item creates an indent instead of another list item (similar to OneNote).
However, this handler never runs. By digging into the code I found out that the reason is that my handler is inserted with a lower priority than the default handlers.
My handler is at the end of the list and the handler above is less specific.
If I manually insert my handler at the top of the list it works fine.
But this is undocumented and may break in the future.
I think that you should either sort handlers by specificity (so more specific handlers are inserted before less specific handlers) or add an API to insert a handler at a specific position.
The text was updated successfully, but these errors were encountered: