mirror of
https://github.com/siyuan-note/siyuan
synced 2026-04-21 13:37:52 +00:00
This commit is contained in:
parent
0f83e59272
commit
4f4c19954c
7 changed files with 19 additions and 61 deletions
|
|
@ -96,6 +96,14 @@ const hasKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "edito
|
|||
};
|
||||
|
||||
export const correctHotkey = (app: App) => {
|
||||
if (!["darwin", "ios"].includes(window.siyuan.config.system.os)) {
|
||||
["fileTree", "outline", "bookmark", "tag", "dailyNote", "inbox", "backlinks",
|
||||
"graphView", "globalGraph", "riffCard"].forEach(key => {
|
||||
Constants.SIYUAN_KEYMAP.general[key].custom = Constants.SIYUAN_KEYMAP.general[key].default =
|
||||
Constants.SIYUAN_KEYMAP.general[key].default.replace("⌃", "⌥");
|
||||
});
|
||||
Constants.SIYUAN_KEYMAP.editor.general.redo.custom = Constants.SIYUAN_KEYMAP.editor.general.redo.default = "⌘Y";
|
||||
}
|
||||
const matchKeymap1 = matchKeymap(Constants.SIYUAN_KEYMAP.general, "general");
|
||||
const matchKeymap2 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.general, "editor", "general");
|
||||
const matchKeymap3 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.insert, "editor", "insert");
|
||||
|
|
|
|||
|
|
@ -6,11 +6,6 @@ declare const NODE_ENV: string;
|
|||
const _SIYUAN_VERSION = SIYUAN_VERSION;
|
||||
const _NODE_ENV = NODE_ENV;
|
||||
|
||||
|
||||
const isInMac = navigator.platform.toUpperCase().indexOf("MAC") > -1;
|
||||
const altNumber = isInMac ? "⌃" : "⌥";
|
||||
const redoHotkey = isInMac ? "⇧⌘Z" : "⌘Y";
|
||||
|
||||
const getFunctionKey = () => {
|
||||
const fData: { [key: number]: string } = {};
|
||||
for (let i = 1; i <= 32; i++) {
|
||||
|
|
@ -443,16 +438,16 @@ export abstract class Constants {
|
|||
stickSearch: {default: "⇧⌘F", custom: "⇧⌘F"},
|
||||
replace: {default: "⌘R", custom: "⌘R"},
|
||||
closeTab: {default: "⌘W", custom: "⌘W"},
|
||||
fileTree: {default: altNumber + "1", custom: altNumber + "1"},
|
||||
outline: {default: altNumber + "2", custom: altNumber + "2"},
|
||||
bookmark: {default: altNumber + "3", custom: altNumber + "3"},
|
||||
tag: {default: altNumber + "4", custom: altNumber + "4"},
|
||||
dailyNote: {default: altNumber + "5", custom: altNumber + "5"},
|
||||
inbox: {default: altNumber + "6", custom: altNumber + "6"},
|
||||
backlinks: {default: altNumber + "7", custom: altNumber + "7"},
|
||||
graphView: {default: altNumber + "8", custom: altNumber + "8"},
|
||||
globalGraph: {default: altNumber + "9", custom: altNumber + "9"},
|
||||
riffCard: {default: altNumber + "0", custom: altNumber + "0"},
|
||||
fileTree: {default: "⌃1", custom: "⌃1"},
|
||||
outline: {default: "⌃2", custom: "⌃2"},
|
||||
bookmark: {default: "⌃3", custom: "⌃3"},
|
||||
tag: {default: "⌃4", custom: "⌃4"},
|
||||
dailyNote: {default: "⌃5", custom: "⌃5"},
|
||||
inbox: {default: "⌃6", custom: "⌃6"},
|
||||
backlinks: {default: "⌃7", custom: "⌃7"},
|
||||
graphView: {default: "⌃8", custom: "⌃8"},
|
||||
globalGraph: {default: "⌃9", custom: "⌃9"},
|
||||
riffCard: {default: "⌃0", custom: "⌃0"},
|
||||
config: {default: "⌥P", custom: "⌥P"},
|
||||
dataHistory: {default: "⌥H", custom: "⌥H"},
|
||||
toggleWin: {default: "⌥M", custom: "⌥M"},
|
||||
|
|
@ -508,7 +503,7 @@ export abstract class Constants {
|
|||
copyBlockEmbed: {default: "⇧⌘E", custom: "⇧⌘E"},
|
||||
copyHPath: {default: "⇧⌘P", custom: "⇧⌘P"},
|
||||
undo: {default: "⌘Z", custom: "⌘Z"},
|
||||
redo: {default: redoHotkey, custom: redoHotkey},
|
||||
redo: {default: "⇧⌘Z", custom: "⇧⌘Z"},
|
||||
rename: {default: "F2", custom: "F2"},
|
||||
newNameFile: {default: "F3", custom: "F3"},
|
||||
newContentFile: {default: "F4", custom: "F4"},
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import {ipcRenderer} from "electron";
|
|||
/// #endif
|
||||
import {getDockByType} from "./layout/tabUtil";
|
||||
import {Tag} from "./layout/dock/Tag";
|
||||
import {handleCrossPlatformKey} from "./protyle/util/hotKey";
|
||||
import {updateAppearance} from "./config/util/updateAppearance";
|
||||
import {renderSnippet} from "./config/util/snippets";
|
||||
|
||||
|
|
@ -121,7 +120,6 @@ export class App {
|
|||
break;
|
||||
case "setConf":
|
||||
window.siyuan.config = data.data;
|
||||
handleCrossPlatformKey();
|
||||
break;
|
||||
case "setPublish":
|
||||
window.siyuan.config.publish = data.data;
|
||||
|
|
@ -220,7 +218,6 @@ export class App {
|
|||
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
|
||||
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
|
||||
window.siyuan.config = response.data.conf;
|
||||
handleCrossPlatformKey();
|
||||
window.siyuan.isPublish = response.data.isPublish;
|
||||
await loadPlugins(this);
|
||||
getLocalStorage(() => {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import {updateCardHV} from "../card/util";
|
|||
import {mobileKeydown} from "./util/keydown";
|
||||
import {correctHotkey} from "../boot/globalEvent/commonHotkey";
|
||||
import {processIOSPurchaseResponse} from "../util/iOSPurchase";
|
||||
import {handleCrossPlatformKey} from "../protyle/util/hotKey";
|
||||
import {nbsp2space} from "../protyle/util/normalizeText";
|
||||
import {callMobileAppShowKeyboard, canInput, setWebViewFocusable} from "./util/mobileAppUtil";
|
||||
import {hideAllElements} from "../protyle/ui/hideElements";
|
||||
|
|
@ -141,7 +140,6 @@ class App {
|
|||
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
|
||||
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
|
||||
window.siyuan.config = confResponse.data.conf;
|
||||
handleCrossPlatformKey();
|
||||
window.siyuan.isPublish = confResponse.data.isPublish;
|
||||
correctHotkey(siyuanApp);
|
||||
await loadPlugins(this);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import {App} from "../../index";
|
|||
import {reloadPlugin} from "../../plugin/loader";
|
||||
import {reloadEmoji} from "../../emoji";
|
||||
import {setLocalShorthandCount} from "../../util/noRelyPCFunction";
|
||||
import {handleCrossPlatformKey} from "../../protyle/util/hotKey";
|
||||
import {renderSnippet} from "../../config/util/snippets";
|
||||
import {redirectToCheckAuth} from "../../util/pathName";
|
||||
|
||||
|
|
@ -67,7 +66,6 @@ export const onMessage = (app: App, data: IWebSocketData) => {
|
|||
break;
|
||||
case "setConf":
|
||||
window.siyuan.config = data.data;
|
||||
handleCrossPlatformKey();
|
||||
break;
|
||||
case "setPublish":
|
||||
window.siyuan.config.publish = data.data;
|
||||
|
|
|
|||
|
|
@ -216,38 +216,3 @@ export const isIncludesHotKey = (hotKey: string) => {
|
|||
|
||||
return isInclude;
|
||||
};
|
||||
|
||||
export const handleCrossPlatformKey = () => {
|
||||
if (!window.siyuan.config.keymap.general) {
|
||||
return;
|
||||
}
|
||||
if (isMac()) {
|
||||
["fileTree", "outline", "bookmark", "tag", "dailyNote", "inbox", "backlinks",
|
||||
"graphView", "globalGraph", "riffCard"].forEach(key => {
|
||||
window.siyuan.config.keymap.general[key].default = Constants.SIYUAN_KEYMAP.general[key].default.replace("⌥", "⌃");
|
||||
if (window.siyuan.config.keymap.general[key].custom === Constants.SIYUAN_KEYMAP.general[key].default ||
|
||||
window.siyuan.config.keymap.general[key].custom === Constants.SIYUAN_KEYMAP.general[key].default.replace("⌃", "⌥")) {
|
||||
window.siyuan.config.keymap.general[key].custom = window.siyuan.config.keymap.general[key].default;
|
||||
}
|
||||
});
|
||||
window.siyuan.config.keymap.editor.general.redo.default = "⇧⌘Z";
|
||||
if (window.siyuan.config.keymap.editor.general.redo.custom === Constants.SIYUAN_KEYMAP.editor.general.redo.default ||
|
||||
window.siyuan.config.keymap.editor.general.redo.custom === "⌘Y") {
|
||||
window.siyuan.config.keymap.editor.general.redo.custom = "⇧⌘Z";
|
||||
}
|
||||
} else {
|
||||
["fileTree", "outline", "bookmark", "tag", "dailyNote", "inbox", "backlinks",
|
||||
"graphView", "globalGraph", "riffCard"].forEach(key => {
|
||||
window.siyuan.config.keymap.general[key].default = Constants.SIYUAN_KEYMAP.general[key].default.replace("⌃", "⌥");
|
||||
if (window.siyuan.config.keymap.general[key].custom === Constants.SIYUAN_KEYMAP.general[key].default ||
|
||||
window.siyuan.config.keymap.general[key].custom === Constants.SIYUAN_KEYMAP.general[key].default.replace("⌥", "⌃")) {
|
||||
window.siyuan.config.keymap.general[key].custom = window.siyuan.config.keymap.general[key].default;
|
||||
}
|
||||
});
|
||||
window.siyuan.config.keymap.editor.general.redo.default = "⌘Y";
|
||||
if (window.siyuan.config.keymap.editor.general.redo.custom === Constants.SIYUAN_KEYMAP.editor.general.redo.default ||
|
||||
window.siyuan.config.keymap.editor.general.redo.custom === "⇧⌘Z") {
|
||||
window.siyuan.config.keymap.editor.general.redo.custom = "⌘Y";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import {init} from "./init";
|
|||
import {loadPlugins, reloadPlugin} from "../plugin/loader";
|
||||
import {hideAllElements} from "../protyle/ui/hideElements";
|
||||
import {reloadEmoji} from "../emoji";
|
||||
import {handleCrossPlatformKey} from "../protyle/util/hotKey";
|
||||
import {updateAppearance} from "../config/util/updateAppearance";
|
||||
import {renderSnippet} from "../config/util/snippets";
|
||||
|
||||
|
|
@ -92,7 +91,6 @@ class App {
|
|||
break;
|
||||
case "setConf":
|
||||
window.siyuan.config = data.data;
|
||||
handleCrossPlatformKey();
|
||||
break;
|
||||
case "progress":
|
||||
progressLoading(data);
|
||||
|
|
@ -171,7 +169,6 @@ class App {
|
|||
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
|
||||
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
|
||||
window.siyuan.config = response.data.conf;
|
||||
handleCrossPlatformKey();
|
||||
window.siyuan.isPublish = response.data.isPublish;
|
||||
await loadPlugins(this);
|
||||
getLocalStorage(() => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue