This commit is contained in:
Vanessa 2022-08-14 22:39:41 +08:00
parent 3c0be0faaa
commit ebbf05a712
5 changed files with 14 additions and 1 deletions

View file

@ -119,6 +119,7 @@ export abstract class Constants {
},
editor: {
general: {
copyID: {default: "", custom: ""},
netImg2LocalAsset: {default: "", custom: ""},
hLayout: {default: "", custom: ""},
vLayout: {default: "", custom: ""},

View file

@ -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) {

View file

@ -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();

View file

@ -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", {

View file

@ -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;