Hi, thanks for this great library!
In my use case, I want to capture Ctrl-S
(or Mod-S
) to do a “save”/“compile” action.
It seems that Codemirror 5 had this possibility: CodeMirror 5 User Manual
save
Ctrl-S (PC), Cmd-S (Mac)
Not defined by the core library, only referred to in key maps. Intended to provide an easy way for user code to define a save command.
How to do this with v6?
I tried
Prec.highest(keymap.of([{
key: "Mod-S",
run({ state }) { console.log(state.doc); on_compile(); return true }
}])),
but if I press Ctrl+S, it opens the default save dialog of the browser.
How can I do the equivalent of preventDefault
for this case, to make my handler work?
Similarly, can I also do this for Ctrl-L or F5?
Originally I wanted to use Ctrl-Space, but that is already used with Prec.highest
by the autocompletion
extension, and even if I put my binding also with Prec.highest
before basicSetup
in the extensions array, it still doesn’t run my handler for some reason.