3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-20 16:25:03 +00:00

dashboard: use cmd+s/cmd+f on mac

This commit is contained in:
Dragory 2021-04-10 13:38:51 +03:00
parent f781a8c8d7
commit 7f19e7e49e

View file

@ -102,14 +102,19 @@
tabSize: 2 tabSize: 2
}); });
const isMac = /mac/i.test(navigator.platform);
const modKeyPressed = (ev: KeyboardEvent) => (isMac ? ev.metaKey : ev.ctrlKey);
const nonModKeyPressed = (ev: KeyboardEvent) => (isMac ? ev.ctrlKey : ev.metaKey);
const shortcutModifierPressed = (ev: KeyboardEvent) => modKeyPressed(ev) && !nonModKeyPressed(ev) && !ev.altKey;
this.shortcutKeydownListener = (ev: KeyboardEvent) => { this.shortcutKeydownListener = (ev: KeyboardEvent) => {
if (ev.ctrlKey && !ev.altKey && ev.key === "s") { if (shortcutModifierPressed(ev) && ev.key === "s") {
ev.preventDefault(); ev.preventDefault();
this.save(); this.save();
return; return;
} }
if (ev.ctrlKey && !ev.altKey && ev.key === "f") { if (shortcutModifierPressed(ev) && ev.key === "f") {
ev.preventDefault(); ev.preventDefault();
this.$refs.aceEditor.editor.execCommand("find"); this.$refs.aceEditor.editor.execCommand("find");
return; return;