diff --git a/app/src/constants.ts b/app/src/constants.ts index 7e999d81a..b4ae6c753 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 7ea91cc2c..89c2265c4 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 924abde00..a1179957a 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 dbc466b1a..39cd07b10 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 c130ac8f2..fcd473353 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;