mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Fix Ctrl+S in the config editor trying to save each config you've viewed in the tab
This commit is contained in:
parent
64d6bb81fe
commit
553fb57c46
1 changed files with 14 additions and 6 deletions
|
@ -37,6 +37,8 @@
|
||||||
|
|
||||||
import AceEditor from "vue2-ace-editor";
|
import AceEditor from "vue2-ace-editor";
|
||||||
|
|
||||||
|
let editorKeybindListener;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
AceEditor,
|
AceEditor,
|
||||||
|
@ -62,10 +64,12 @@
|
||||||
this.editableConfig = this.config || "";
|
this.editableConfig = this.config || "";
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeRouteLeave(to, from, next) {
|
||||||
if (this.shortcutKeydownListener) {
|
if (editorKeybindListener) {
|
||||||
window.removeEventListener("keydown", this.shortcutKeydownListener);
|
window.removeEventListener("keydown", editorKeybindListener);
|
||||||
|
editorKeybindListener = null;
|
||||||
}
|
}
|
||||||
|
next();
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -77,7 +81,6 @@
|
||||||
editorWidth: 900,
|
editorWidth: 900,
|
||||||
editorHeight: 600,
|
editorHeight: 600,
|
||||||
savedTimeout: null,
|
savedTimeout: null,
|
||||||
shortcutKeydownListener: null,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -107,7 +110,12 @@
|
||||||
const nonModKeyPressed = (ev: KeyboardEvent) => (isMac ? ev.ctrlKey : ev.metaKey);
|
const nonModKeyPressed = (ev: KeyboardEvent) => (isMac ? ev.ctrlKey : ev.metaKey);
|
||||||
const shortcutModifierPressed = (ev: KeyboardEvent) => modKeyPressed(ev) && !nonModKeyPressed(ev) && !ev.altKey;
|
const shortcutModifierPressed = (ev: KeyboardEvent) => modKeyPressed(ev) && !nonModKeyPressed(ev) && !ev.altKey;
|
||||||
|
|
||||||
this.shortcutKeydownListener = (ev: KeyboardEvent) => {
|
if (editorKeybindListener) {
|
||||||
|
// Make sure we clean up any potentially leftover event listeners
|
||||||
|
window.removeEventListener("keydown", editorKeybindListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
editorKeybindListener = (ev: KeyboardEvent) => {
|
||||||
if (shortcutModifierPressed(ev) && ev.key === "s") {
|
if (shortcutModifierPressed(ev) && ev.key === "s") {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
this.save();
|
this.save();
|
||||||
|
@ -120,7 +128,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.addEventListener("keydown", this.shortcutKeydownListener);
|
window.addEventListener("keydown", editorKeybindListener);
|
||||||
|
|
||||||
this.fitEditorToWindow();
|
this.fitEditorToWindow();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue