An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: fix https://github.com/siyuan-note/siyuan/issues/9476
Vanessae34d1a140138
diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.tsindex 8faa3c2e8c..e9a5f8ba5b 100644--- a/app/src/boot/globalEvent/keydown.ts+++ b/app/src/boot/globalEvent/keydown.ts@@ -1,4 +1,4 @@-import {isCtrl, isMac, updateHotkeyTip} from "../../protyle/util/compatibility";+import {isCtrl, isMac, updateHotkeyTip, writeText} from "../../protyle/util/compatibility";import {matchHotKey} from "../../protyle/util/hotKey";import {openSearch} from "../../search/spread";import {@@ -60,6 +60,8 @@ import {Custom} from "../../layout/dock/Custom";import {Protyle} from "../../protyle";import {transaction} from "../../protyle/wysiwyg/transaction";import {quickMakeCard} from "../../card/makeCard";+import {copyPNG} from "../../menus/util";+import {getContentByInlineHTML} from "../../protyle/wysiwyg/keydown";const switchDialogEvent = (app: App, event: MouseEvent) => {event.preventDefault();@@ -336,6 +338,42 @@ const editKeydown = (app: App, event: KeyboardEvent) => {event.preventDefault();return true;}+ if (matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockRef.custom, event)) {+ event.preventDefault();+ event.stopPropagation();+ if (hasClosestByClassName(range.startContainer, "protyle-title")) {+ fetchPost("/api/block/getRefText", {id: protyle.block.rootID}, (response) => {+ writeText(`((${protyle.block.rootID} '${response.data}'))`);+ });+ } else {+ const nodeElement = hasClosestBlock(range.startContainer);+ if (!nodeElement) {+ return false;+ }+ const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");+ let actionElement;+ if (selectElements.length === 1) {+ actionElement = selectElements[0];+ } else {+ const selectImgElement = nodeElement.querySelector(".img--select");+ if (selectImgElement) {+ copyPNG(selectImgElement.querySelector("img"));+ return true;+ }+ actionElement = nodeElement;+ }+ const actionElementId = actionElement.getAttribute("data-node-id");+ if (range.toString() !== "") {+ getContentByInlineHTML(range, (content) => {+ writeText(`((${actionElementId} "${Lute.EscapeHTMLStr(content.trim())}"))`);+ });+ } else {+ fetchPost("/api/block/getRefText", {id: actionElementId}, (response) => {+ writeText(`((${actionElementId} '${response.data}'))`);+ });+ }+ }+ }if (hasClosestByClassName(target, "protyle-title__input")) {return false;}diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex caf9087279..33f2b17e13 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -134,12 +134,6 @@ export class Title {getEditorRange(this.editElement).selectNodeContents(this.editElement);event.preventDefault();event.stopPropagation();- } else if (matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockRef.custom, event)) {- fetchPost("/api/block/getRefText", {id: protyle.block.rootID}, (response) => {- writeText(`((${protyle.block.rootID} '${response.data}'))`);- });- event.preventDefault();- event.stopPropagation();} else if (matchHotKey(window.siyuan.config.keymap.editor.general.copyID.custom, event)) {writeText(protyle.block.rootID);event.preventDefault();diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex c49276b0ee..9206a4801d 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -73,7 +73,7 @@ import {avKeydown} from "../render/av/keydown";import {resizeAV} from "../util/resize";-const getContentByInlineHTML = (range: Range, cb: (content: string) => void) => {+export const getContentByInlineHTML = (range: Range, cb: (content: string) => void) => {let html = "";Array.from(range.cloneContents().childNodes).forEach((item: HTMLElement) => {if (item.nodeType === 3) {@@ -1009,33 +1009,6 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {event.stopPropagation();return true;}- if (matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockRef.custom, event)) {- event.preventDefault();- event.stopPropagation();- const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");- let actionElement;- if (selectElements.length === 1) {- actionElement = selectElements[0];- } else {- const selectImgElement = nodeElement.querySelector(".img--select");- if (selectImgElement) {- copyPNG(selectImgElement.querySelector("img"));- return true;- }- actionElement = nodeElement;- }- const actionElementId = actionElement.getAttribute("data-node-id");- if (selectText !== "") {- getContentByInlineHTML(range, (content) => {- writeText(`((${actionElementId} "${Lute.EscapeHTMLStr(content.trim())}"))`);- });- } else {- fetchPost("/api/block/getRefText", {id: actionElementId}, (response) => {- writeText(`((${actionElementId} '${response.data}'))`);- });- }- return true;- }if (matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockEmbed.custom, event)) {const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");let actionElement;