Add shortcuts for saving

This commit is contained in:
Thelonius Kort
2023-03-05 23:13:58 +01:00
parent 21b97bec6e
commit 459c8e6a57

View File

@ -4,6 +4,8 @@ let TranslationFormHook = {
this.el.addEventListener("keyup", this.keyupHandler.bind(this))
this.title_input = this.el.querySelector("#translation-form_title")
this.tunit_editor = this.el.querySelector("#tunit-editor-content")
this.save_edit_button = this.el.querySelector("#save-edit-button")
this.save_publish_button = this.el.querySelector("#save-publish-button")
},
keyupHandler(e) {
var push_event = true
@ -11,6 +13,13 @@ let TranslationFormHook = {
var postaction = () => { }
var payload = {}
if (e.altKey){
if (e.ctrlKey){
if (e.key == "s"){
this.save_edit_button.click()
} else if (e.key == "p"){
this.save_publish_button.click()
}
} else {
if (e.key == "ArrowDown" || e.key == "n"){
preaction = () => { this.title_input.focus() }
postaction = () => { this.tunit_editor.focus() }
@ -36,7 +45,7 @@ let TranslationFormHook = {
this.pushEventTo(this.el, handler, payload, postaction)
}
}
// console.info(["keyupHandler", e, this])
}
},
}