mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
parent
e996975722
commit
efffe304e0
1 changed files with 33 additions and 17 deletions
|
|
@ -76,23 +76,39 @@ export const updateHotkeyTip = (hotkey: string) => {
|
||||||
if (/Mac/.test(navigator.platform) || navigator.platform === "iPhone") {
|
if (/Mac/.test(navigator.platform) || navigator.platform === "iPhone") {
|
||||||
return hotkey;
|
return hotkey;
|
||||||
}
|
}
|
||||||
if (hotkey.startsWith("⌘")) {
|
|
||||||
hotkey = hotkey.replace("⌘", "⌘+");
|
const KEY_MAP = new Map(Object.entries({
|
||||||
} else if (hotkey.startsWith("⌥") && hotkey.substr(1, 1) !== "⌘") {
|
"⌘": "Ctrl",
|
||||||
hotkey = hotkey.replace("⌥", "⌥+");
|
"⇧": "Shift",
|
||||||
} else if (hotkey.startsWith("⇧⌘") || hotkey.startsWith("⌥⌘")) {
|
"⌥": "Alt",
|
||||||
hotkey = hotkey.replace("⇧⌘", "⌘+⇧+").replace("⌥⌘", "⌘+⌥+");
|
"⇥": "Tab",
|
||||||
} else if (hotkey.startsWith("⇧")) {
|
"⌫": "Backspace",
|
||||||
hotkey = hotkey.replace("⇧", "⇧+");
|
"⌦": "Delete",
|
||||||
|
"↩": "Enter",
|
||||||
|
}));
|
||||||
|
const SHIFT_KEY_MAP = new Map(Object.entries({
|
||||||
|
";": ":",
|
||||||
|
"=": "+",
|
||||||
|
"-": "_",
|
||||||
|
".": ">",
|
||||||
|
}));
|
||||||
|
|
||||||
|
let keys = [];
|
||||||
|
|
||||||
|
if (hotkey.indexOf("⌘") > -1) keys.push(KEY_MAP.get("⌘"));
|
||||||
|
if (hotkey.indexOf("⇧") > -1) keys.push(KEY_MAP.get("⇧"));
|
||||||
|
if (hotkey.indexOf("⌥") > -1) keys.push(KEY_MAP.get("⌥"));
|
||||||
|
|
||||||
|
const lastKey = hotkey.charAt(hotkey.length - 1);
|
||||||
|
if ("⌘⇧⌥".indexOf(lastKey) < 0) {
|
||||||
|
keys.push(
|
||||||
|
KEY_MAP.get(lastKey)
|
||||||
|
|| (hotkey.indexOf("⇧") > -1 && SHIFT_KEY_MAP.get(lastKey))
|
||||||
|
|| lastKey
|
||||||
|
);
|
||||||
}
|
}
|
||||||
hotkey = hotkey.replace("⌘", "Ctrl").replace("⇧", "Shift")
|
|
||||||
.replace("⌥", "Alt").replace("⇥", "Tab")
|
return keys.join("+");
|
||||||
.replace("⌫", "Backspace").replace("⌦", "Delete")
|
|
||||||
.replace("↩", "Enter");
|
|
||||||
if (hotkey.indexOf("Shift") > -1) {
|
|
||||||
hotkey = hotkey.replace(";", ":").replace("=", "+").replace("-", "_").replace(".", ">");
|
|
||||||
}
|
|
||||||
return hotkey;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const hotKey2Electron = (key: string) => {
|
export const hotKey2Electron = (key: string) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue