Vanessa 2025-02-06 13:11:14 +08:00
parent 0ba7a47472
commit 1b3173d6f4
2 changed files with 8 additions and 7 deletions

View file

@ -504,13 +504,13 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
event.preventDefault();
return true;
}
if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockRef.custom, event)) {
if (range && !isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockRef.custom, event)) {
event.preventDefault();
event.stopPropagation();
if (hasClosestByClassName(range?.startContainer, "protyle-title")) {
if (hasClosestByClassName(range.startContainer, "protyle-title")) {
copyTextByType([protyle.block.rootID], "ref");
} else {
const nodeElement = hasClosestBlock(range?.startContainer);
const nodeElement = hasClosestBlock(range.startContainer);
if (!nodeElement) {
return false;
}
@ -519,9 +519,9 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
copyPNGByLink(selectImgElement.querySelector("img").getAttribute("src"));
return true;
}
const selectBlocks = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");
if (selectBlocks.length !== 0) {
copyTextByType(Array.from(selectBlocks).map(item => item.getAttribute("data-node-id")), "ref");
const ids = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select")).map(item => item.getAttribute("data-node-id"));
if (ids.length > 0) {
copyTextByType(ids, "ref");
return true;
}
if (range.toString() !== "") {