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() !== "") {

View file

@ -2158,7 +2158,8 @@ export class WYSIWYG {
}
// 按下方向键后块高亮跟随光标移动 https://github.com/siyuan-note/siyuan/issues/8918
if ((event.key === "ArrowLeft" || event.key === "ArrowRight") &&
if ((event.key === "ArrowLeft" || event.key === "ArrowRight" ||
event.key === "Alt" || event.key === "Shift") && // 选中后 alt+shift+arrowRight 会导致光标和选中块不一致
nodeElement && !nodeElement.classList.contains("protyle-wysiwyg--select")) {
const selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
let containRange = false;