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

Vanessa358dd34b681f
diff --git a/app/src/constants.ts b/app/src/constants.ts
index fe516c81dd..5f7377fde9 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -6,7 +6,10 @@ declare const NODE_ENV: string;
const _SIYUAN_VERSION = SIYUAN_VERSION;
const _NODE_ENV = NODE_ENV;
-const altNumber = navigator.platform.toUpperCase().indexOf("MAC") > -1 ? "⌃" : "⌥";
+
+const isInMac = navigator.platform.toUpperCase().indexOf("MAC") > -1;
+const altNumber = isInMac ? "⌃" : "⌥";
+const redoHotkey = isInMac ? "⇧⌘Z" : "⌘Y";
const getFunctionKey = () => {
const fData: { [key: number]: string } = {};
@@ -505,7 +508,7 @@ export abstract class Constants {
copyBlockEmbed: {default: "⇧⌘E", custom: "⇧⌘E"},
copyHPath: {default: "⇧⌘P", custom: "⇧⌘P"},
undo: {default: "⌘Z", custom: "⌘Z"},
- redo: {default: "⌘Y", custom: "⌘Y"},
+ redo: {default: redoHotkey, custom: redoHotkey},
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 cc86cfe782..bac9bc214e 100644
--- a/app/src/index.ts
+++ b/app/src/index.ts
@@ -40,7 +40,7 @@ import {ipcRenderer} from "electron";
/// #endif
import {getDockByType} from "./layout/tabUtil";
import {Tag} from "./layout/dock/Tag";
-import {updateControlAlt} from "./protyle/util/hotKey";
+import {handleCrossPlatformKey} from "./protyle/util/hotKey";
import {updateAppearance} from "./config/util/updateAppearance";
import {renderSnippet} from "./config/util/snippets";
@@ -121,7 +121,7 @@ export class App {
break;
case "setConf":
window.siyuan.config = data.data;
- updateControlAlt();
+ handleCrossPlatformKey();
break;
case "setPublish":
window.siyuan.config.publish = data.data;
@@ -220,7 +220,7 @@ 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;
- updateControlAlt();
+ 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 3f4844c221..d9d1693a68 100644
--- a/app/src/mobile/index.ts
+++ b/app/src/mobile/index.ts
@@ -35,7 +35,7 @@ import {updateCardHV} from "../card/util";
import {mobileKeydown} from "./util/keydown";
import {correctHotkey} from "../boot/globalEvent/commonHotkey";
import {processIOSPurchaseResponse} from "../util/iOSPurchase";
-import {updateControlAlt} from "../protyle/util/hotKey";
+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 +141,7 @@ 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;
- updateControlAlt();
+ 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 3b80dcc877..2b512e46ae 100644
--- a/app/src/mobile/util/onMessage.ts
+++ b/app/src/mobile/util/onMessage.ts
@@ -11,7 +11,7 @@ import {App} from "../../index";
import {reloadPlugin} from "../../plugin/loader";
import {reloadEmoji} from "../../emoji";
import {setLocalShorthandCount} from "../../util/noRelyPCFunction";
-import {updateControlAlt} from "../../protyle/util/hotKey";
+import {handleCrossPlatformKey} from "../../protyle/util/hotKey";
import {renderSnippet} from "../../config/util/snippets";
import {redirectToCheckAuth} from "../../util/pathName";
@@ -67,7 +67,7 @@ export const onMessage = (app: App, data: IWebSocketData) => {
break;
case "setConf":
window.siyuan.config = data.data;
- updateControlAlt();
+ 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 b5ae07a492..07f07a9c94 100644
--- a/app/src/protyle/util/hotKey.ts
+++ b/app/src/protyle/util/hotKey.ts
@@ -217,24 +217,37 @@ export const isIncludesHotKey = (hotKey: string) => {
return isInclude;
};
-export const updateControlAlt = () => {
+export const handleCrossPlatformKey = () => {
if (!window.siyuan.config.keymap.general) {
return;
}
- Object.keys(window.siyuan.config.keymap.general).forEach(key => {
- if (["fileTree", "outline", "bookmark", "tag", "dailyNote", "inbox", "backlinks",
- "graphView", "globalGraph", "riffCard"].includes(key)) {
- if (navigator.platform.toUpperCase().indexOf("MAC") > -1) {
- window.siyuan.config.keymap.general[key].default = window.siyuan.config.keymap.general[key].default.replace("⌥", "⌃");
- if (window.siyuan.config.keymap.general[key].default === window.siyuan.config.keymap.general[key].custom) {
- window.siyuan.config.keymap.general[key].custom = window.siyuan.config.keymap.general[key].default.replace("⌥", "⌃");
- }
- } else {
- window.siyuan.config.keymap.general[key].default = window.siyuan.config.keymap.general[key].default.replace("⌃", "⌥");
- if (window.siyuan.config.keymap.general[key].default === window.siyuan.config.keymap.general[key].custom) {
- window.siyuan.config.keymap.general[key].custom = window.siyuan.config.keymap.general[key].default.replace("⌃", "⌥");
- }
+ 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 db7c26637d..14a45b002f 100644
--- a/app/src/window/index.ts
+++ b/app/src/window/index.ts
@@ -26,7 +26,7 @@ import {init} from "./init";
import {loadPlugins, reloadPlugin} from "../plugin/loader";
import {hideAllElements} from "../protyle/ui/hideElements";
import {reloadEmoji} from "../emoji";
-import {updateControlAlt} from "../protyle/util/hotKey";
+import {handleCrossPlatformKey} from "../protyle/util/hotKey";
import {updateAppearance} from "../config/util/updateAppearance";
import {renderSnippet} from "../config/util/snippets";
@@ -92,7 +92,7 @@ class App {
break;
case "setConf":
window.siyuan.config = data.data;
- updateControlAlt();
+ handleCrossPlatformKey();
break;
case "progress":
progressLoading(data);
@@ -171,7 +171,7 @@ 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;
- updateControlAlt();
+ handleCrossPlatformKey();
window.siyuan.isPublish = response.data.isPublish;
await loadPlugins(this);
getLocalStorage(() => {