An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: fix https://github.com/siyuan-note/siyuan/issues/6520
Vanessa8a4d4ab3c953
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex 557ce80ba9..0db4b0fec7 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -23,13 +23,10 @@ import {readText, writeText} from "../protyle/util/compatibility";import {preventScroll} from "../protyle/scroll/preventScroll";import {onGet} from "../protyle/util/onGet";import {getAllModels} from "../layout/getAll";-import {pasteText} from "../protyle/util/paste";+import {pasteAsPlainText, pasteText} from "../protyle/util/paste";/// #if !MOBILEimport {openFileById, updateBacklinkGraph} from "../editor/util";/// #endif-/// #if !BROWSER-import {getCurrentWindow} from "@electron/remote";-/// #endifimport {isMobile} from "../util/functions";import {removeFoldHeading} from "../protyle/util/heading";import {lineNumberRender} from "../protyle/markdown/highlightRender";@@ -364,7 +361,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {accelerator: "⇧⌘V",click() {focusByRange(getEditorRange(nodeElement));- getCurrentWindow().webContents.pasteAndMatchStyle();+ pasteAsPlainText(protyle);}}).element);/// #endifdiff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.tsindex d853def848..ca3e45e41d 100644--- a/app/src/protyle/util/paste.ts+++ b/app/src/protyle/util/paste.ts@@ -4,6 +4,7 @@ import {processPasteCode, processRender} from "./processCode";import {writeText} from "./compatibility";/// #if !BROWSERimport {clipboard} from "electron";+import {getCurrentWindow} from "@electron/remote";/// #endifimport {hasClosestBlock} from "./hasClosest";import {focusByWbr, getEditorRange} from "./selection";@@ -29,6 +30,31 @@ const filterClipboardHint = (protyle: IProtyle, textPlain: string) => {}};+export const pasteAsPlainText = async (protyle: IProtyle) => {+ /// #if !BROWSER && !MOBILE+ let localFiles: string[] = [];+ if ("darwin" === window.siyuan.config.system.os) {+ const xmlString = clipboard.read("NSFilenamesPboardType");+ const domParser = new DOMParser();+ const xmlDom = domParser.parseFromString(xmlString, "application/xml");+ Array.from(xmlDom.getElementsByTagName("string")).forEach(item => {+ localFiles.push(item.childNodes[0].nodeValue);+ });+ } else {+ const xmlString = await fetchSyncPost("/api/clipboard/readFilePaths", {});+ if (xmlString.data.length > 0) {+ localFiles = xmlString.data;+ }+ }+ if (localFiles.length > 0) {+ uploadLocalFiles(localFiles, protyle, false);+ writeText("");+ } else {+ getCurrentWindow().webContents.pasteAndMatchStyle();+ }+ /// #endif+};+export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Element) => {const range = getEditorRange(protyle.wysiwyg.element);if (nodeElement.getAttribute("data-type") === "NodeCodeBlock") {diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 8bf7e78f79..7efd01275a 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -42,9 +42,6 @@ import {isLocalPath} from "../../util/pathName";/// #if !MOBILEimport {openBy, openFileById} from "../../editor/util";/// #endif-/// #if !BROWSER-import {getCurrentWindow} from "@electron/remote";-/// #endifimport {commonHotkey, downSelect, getStartEndElement, upSelect} from "./commonHotkey";import {linkMenu, refMenu, setFold, zoomOut} from "../../menus/protyle";import {removeEmbed} from "./removeEmbed";@@ -60,6 +57,7 @@ import {highlightRender} from "../markdown/highlightRender";import {countBlockWord} from "../../layout/status";import {openMobileFileById} from "../../mobile/editor";import {moveToDown, moveToUp} from "./move";+import {pasteAsPlainText} from "../util/paste";export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {editorElement.addEventListener("keydown", (event: KeyboardEvent & { target: HTMLElement }) => {@@ -1583,7 +1581,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {event.returnValue = false;event.preventDefault();event.stopPropagation();- getCurrentWindow().webContents.pasteAndMatchStyle();+ pasteAsPlainText(protyle);return;}