Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/17518

Vanessa4f4c19954cf1
diff --git a/app/src/boot/globalEvent/commonHotkey.ts b/app/src/boot/globalEvent/commonHotkey.ts
index fc9231146c..fdc7c49912 100644
--- a/app/src/boot/globalEvent/commonHotkey.ts
+++ b/app/src/boot/globalEvent/commonHotkey.ts
@@ -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");
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 5f7377fde9..e0ea73c834 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -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"},
diff --git a/app/src/index.ts b/app/src/index.ts
index bac9bc214e..281590b91b 100644
--- a/app/src/index.ts
+++ b/app/src/index.ts
@@ -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(() => {
diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts
index d9d1693a68..25ab9bef10 100644
--- a/app/src/mobile/index.ts
+++ b/app/src/mobile/index.ts
@@ -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);
diff --git a/app/src/mobile/util/onMessage.ts b/app/src/mobile/util/onMessage.ts
index 2b512e46ae..060b0a76b7 100644
--- a/app/src/mobile/util/onMessage.ts
+++ b/app/src/mobile/util/onMessage.ts
@@ -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;
diff --git a/app/src/protyle/util/hotKey.ts b/app/src/protyle/util/hotKey.ts
index 07f07a9c94..1225511df0 100644
--- a/app/src/protyle/util/hotKey.ts
+++ b/app/src/protyle/util/hotKey.ts
@@ -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";
- }
- }
-};
diff --git a/app/src/window/index.ts b/app/src/window/index.ts
index 14a45b002f..cf88eeb2ff 100644
--- a/app/src/window/index.ts
+++ b/app/src/window/index.ts
@@ -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(() => {