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/5605

Vanessaebbf05a71210
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 7e999d81a8..b4ae6c753a 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -119,6 +119,7 @@ export abstract class Constants {
},
editor: {
general: {
+ copyID: {default: "", custom: ""},
netImg2LocalAsset: {default: "", custom: ""},
hLayout: {default: "", custom: ""},
vLayout: {default: "", custom: ""},
diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts
index 7ea91cc2c2..89c2265c41 100644
--- a/app/src/menus/commonMenuItem.ts
+++ b/app/src/menus/commonMenuItem.ts
@@ -603,7 +603,8 @@ export const copySubMenu = (id: string, name: string, accelerator = true, focusE
});
}
}, {
- label: window.siyuan.languages.copy + " ID",
+ label: window.siyuan.languages.copyID,
+ accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyID.custom : undefined,
click: () => {
writeText(id);
if (focusElement) {
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts
index 924abde00e..a1179957a9 100644
--- a/app/src/protyle/header/Title.ts
+++ b/app/src/protyle/header/Title.ts
@@ -105,6 +105,10 @@ export class Title {
writeText(`((${protyle.block.rootID} '${this.editElement.textContent}'))`);
event.preventDefault();
event.stopPropagation();
+ } else if (matchHotKey(window.siyuan.config.keymap.editor.general.copyID.custom, event)) {
+ writeText(protyle.block.rootID);
+ event.preventDefault();
+ event.stopPropagation();
} else if (matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockEmbed.custom, event)) {
writeText(`{{select * from blocks where id='${protyle.block.rootID}'}}`);
event.preventDefault();
diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.ts
index dbc466b1ab..39cd07b10c 100644
--- a/app/src/protyle/wysiwyg/commonHotkey.ts
+++ b/app/src/protyle/wysiwyg/commonHotkey.ts
@@ -21,6 +21,7 @@ export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {
event.stopPropagation();
return true;
}
+
if (matchHotKey(window.siyuan.config.keymap.editor.general.refresh.custom, event)) {
addLoading(protyle);
fetchPost("/api/filetree/getDoc", {
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index c130ac8f2a..fcd473353e 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -866,6 +866,12 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return true;
}
/// #endif
+ if (matchHotKey(window.siyuan.config.keymap.editor.general.copyID.custom, event)) {
+ writeText(nodeElement.getAttribute("data-node-id"));
+ event.preventDefault();
+ event.stopPropagation();
+ return true;
+ }
if (matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockRef.custom, event)) {
const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");
let actionElement;