That makes sense and I did wonder whether that was how it worked, but the interaction between keymaps and DOM keydown event handlers added via a view plugin is confusing to me. Also, I’m now certain that it has changed since version 6.0.0.
Here is a series of examples. In each case, there is a keymap extension and a DOM keydown handler extension, and in each case I’m recording which one “wins” (i.e. runs first).
[domKeydownExt, keymapExt]
: DOM keydown wins
[keymapExt, domKeydownExt]
: keymap wins
So far, as I’d expect.
[Prec.low(domKeydownExt), keymapExt]
: keymap wins
OK…
[keymapExt, Prec.high(domKeydownExt)]
: DOM keydown wins
[domKeydownExt, Prec.high(keymapExt)]
: DOM keydown wins
This seems inconsistent, and this last case has definitely changed since the 6.0.0 release (example).
I’m really not sure what the behaviour should be but it would be good if it was documented, because there are definitely cases where you might want to use both keymaps and DOM keydown
handlers. The @replit/codemirror-vim
and @replit/codemirror-emacs
packages both use a custom keydown
handler, for example.