Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/9392

Vanessaea00753f380f
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 896b9f3199..3c4a7a4d29 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -264,6 +264,7 @@ export abstract class Constants {
expandUp: {default: "⌥⇧↑", custom: "⌥⇧↑"},
copyPlainText: {default: "", custom: ""},
copyID: {default: "", custom: ""},
+ copyProtocolInMd: {default: "", custom: ""},
netImg2LocalAsset: {default: "", custom: ""},
optimizeTypography: {default: "", custom: ""},
hLayout: {default: "", custom: ""},
diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts
index e7ec9dd46d..1acb67644a 100644
--- a/app/src/menus/commonMenuItem.ts
+++ b/app/src/menus/commonMenuItem.ts
@@ -394,6 +394,7 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme
}
}, {
label: window.siyuan.languages.copyProtocolInMd,
+ accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyProtocolInMd.custom : undefined,
click: () => {
fetchPost("/api/block/getRefText", {id}, (response) => {
writeText(`[${response.data}](siyuan://blocks/${id})`);
diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.ts
index 180e344849..aa613d1cf1 100644
--- a/app/src/protyle/wysiwyg/commonHotkey.ts
+++ b/app/src/protyle/wysiwyg/commonHotkey.ts
@@ -21,7 +21,7 @@ import {onGet} from "../util/onGet";
import {Constants} from "../../constants";
import * as dayjs from "dayjs";
-export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {
+export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent, nodeElement?: HTMLElement) => {
const target = event.target as HTMLElement;
if (matchHotKey(window.siyuan.config.keymap.editor.general.copyHPath.custom, event)) {
fetchPost("/api/filetree/getHPathByID", {
@@ -56,6 +56,15 @@ export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {
event.preventDefault();
return true;
}
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.copyProtocolInMd.custom, event)) {
+ const id = nodeElement ? nodeElement.getAttribute("data-node-id") : protyle.block.rootID;
+ fetchPost("/api/block/getRefText", {id}, (response) => {
+ writeText(`[${response.data}](siyuan://blocks/${id})`);
+ });
+ event.preventDefault();
+ event.stopPropagation();
+ return true;
+ }
/// #if !MOBILE
if (protyle.model) {
if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 34b3d1a183..ba5cbe92a3 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -983,7 +983,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return true;
}
/// #if !MOBILE
- if (commonHotkey(protyle, event)) {
+ if (commonHotkey(protyle, event, nodeElement)) {
return true;
}
/// #endif