An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
fix: 选中块之后无法通过快捷键复制块引用 (#13980)
Jeffrey Chen0ba7a474723a
diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.tsindex fe9acb3ef3..fec1306fca 100644--- a/app/src/boot/globalEvent/keydown.ts+++ b/app/src/boot/globalEvent/keydown.ts@@ -507,10 +507,10 @@ const editKeydown = (app: App, event: KeyboardEvent) => {if (!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,16 +519,17 @@ 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");+ return true;+ }if (range.toString() !== "") {getContentByInlineHTML(range, (content) => {writeText(`((${nodeElement.getAttribute("data-node-id")} "${content.trim()}"))`);});} else {- const ids = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select")).map(item => item.getAttribute("data-node-id"));- if (ids.length === 0) {- ids.push(nodeElement.getAttribute("data-node-id"));- }- copyTextByType(ids, "ref");+ copyTextByType([nodeElement.getAttribute("data-node-id")], "ref");}}return true;diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 932b921d2c..38ed4fdc37 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -2157,9 +2157,8 @@ export class WYSIWYG {event.stopPropagation();}- // https://github.com/siyuan-note/siyuan/issues/8918- if ((event.key === "ArrowLeft" || event.key === "ArrowRight" ||- event.key === "Alt" || event.key === "Shift") && // 选中后 alt+shift+arrowRight 会导致光标和选中块不一致+ // 按下方向键后块高亮跟随光标移动 https://github.com/siyuan-note/siyuan/issues/8918+ if ((event.key === "ArrowLeft" || event.key === "ArrowRight") &&nodeElement && !nodeElement.classList.contains("protyle-wysiwyg--select")) {const selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));let containRange = false;