dashboard: allow ctrl+s and ctrl+f to work outside the config editor
This commit is contained in:
parent
6326e44856
commit
26902af54e
1 changed files with 20 additions and 10 deletions
|
@ -62,6 +62,11 @@
|
||||||
this.editableConfig = this.config || "";
|
this.editableConfig = this.config || "";
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
if (this.shortcutKeydownListener) {
|
||||||
|
window.removeEventListener("keydown", this.shortcutKeydownListener);
|
||||||
|
}
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: true,
|
loading: true,
|
||||||
|
@ -71,7 +76,8 @@
|
||||||
errors: [],
|
errors: [],
|
||||||
editorWidth: 900,
|
editorWidth: 900,
|
||||||
editorHeight: 600,
|
editorHeight: 600,
|
||||||
savedTimeout: null
|
savedTimeout: null,
|
||||||
|
shortcutKeydownListener: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -96,16 +102,20 @@
|
||||||
tabSize: 2
|
tabSize: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$refs.aceEditor.editor.commands.addCommand({
|
this.shortcutKeydownListener = (ev: KeyboardEvent) => {
|
||||||
name: 'save',
|
if (ev.ctrlKey && !ev.altKey && ev.key === "s") {
|
||||||
bindKey: {
|
ev.preventDefault();
|
||||||
win: "Ctrl-S",
|
|
||||||
mac: "Cmd-S"
|
|
||||||
},
|
|
||||||
exec: editor => {
|
|
||||||
this.save();
|
this.save();
|
||||||
},
|
return;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if (ev.ctrlKey && !ev.altKey && ev.key === "f") {
|
||||||
|
ev.preventDefault();
|
||||||
|
this.$refs.aceEditor.editor.execCommand("find");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.addEventListener("keydown", this.shortcutKeydownListener);
|
||||||
|
|
||||||
this.fitEditorToWindow();
|
this.fitEditorToWindow();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue