added: preventDefault to allow overriding browser key bindings #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "prevent-default"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We are building a link creation/editing experience. Most editing experiences use the command
Mod-kto create/edit links. e.g. Gmail, Gdocs, Medium, etc... But some OS/browsers (e.g. Ubuntu/Firefox) defaultMod-kto highlighting the browser url input. Therefore it's necessary to prevent the default behavior so once our link editing modal opens we can focus on the modal input for the ProseMirror editor link url.Focusing within a modal is a concrete example I currently have but imagine user intent when providing a key binding would be to override any default browser behavior.
Giving this a second thought. It might be better if the event was provided to the key binding callback as a fourth argument and leave it up to the implementer to determine if they want to cancel the event. Any thoughts on that?
Returning true from the handler (which it does for handled keys) will cause the editor to call
preventDefault. CallingpreventDefaultfor all keys, as your patch is doing, doesn't seem like a good idea at all.Thanks! Didn't catch that in the docs. Found it here, https://prosemirror.net/docs/guide/#commands
Would love to setup a pull request in ProseMirror/website for the reference section but I'm having a difficult time understanding how that content gets added in the build step.
Pull request closed