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: https://github.com/siyuan-note/siyuan/issues/16024
Vanessac8a0314d74e8
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex d4e7e0dc07..87f913f40f 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -91,7 +91,7 @@ export class Title {event.stopPropagation();event.preventDefault();});- this.editElement.addEventListener("keydown", (event: KeyboardEvent) => {+ this.editElement.addEventListener("keydown", async (event: KeyboardEvent) => {if (event.isComposing) {return;}@@ -100,7 +100,10 @@ export class Title {return true;}if (matchHotKey("⇧⌘V", event)) {- navigator.clipboard.readText().then(textPlain => {+ event.preventDefault();+ event.stopPropagation();+ let textPlain = await readText() || "";+ if (textPlain) {// 对 HTML 标签进行内部转义,避免被 Lute 解析以后变为小写 https://github.com/siyuan-note/siyuan/issues/10620textPlain = textPlain.replace(/</g, ";;;lt;;;").replace(/>/g, ";;;gt;;;");enableLuteMarkdownSyntax(protyle);@@ -110,9 +113,8 @@ export class Title {content = content.replace(/;;;lt;;;[^;]+;;;gt;;;/g, "");document.execCommand("insertText", false, replaceFileName(content));this.rename(protyle);- });- event.preventDefault();- event.stopPropagation();+ }+ return;}if (matchHotKey(window.siyuan.config.keymap.general.enterBack.custom, event)) {const ids = protyle.path.split("/");@@ -255,7 +257,7 @@ export class Title {document.execCommand("paste");} else {try {- const text = await readText();+ const text = await readText() || "";document.execCommand("insertText", false, replaceFileName(text));this.rename(protyle);} catch (e) {@@ -269,16 +271,15 @@ export class Title {label: window.siyuan.languages.pasteAsPlainText,accelerator: "⇧⌘V",click: async () => {- navigator.clipboard.readText().then(textPlain => {- textPlain = textPlain.replace(/</g, ";;;lt;;;").replace(/>/g, ";;;gt;;;");- enableLuteMarkdownSyntax(protyle);- let content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain));- restoreLuteMarkdownSyntax(protyle);- // 移除 ;;;lt;;; 和 ;;;gt;;; 转义及其包裹的内容- content = content.replace(/;;;lt;;;[^;]+;;;gt;;;/g, "");- document.execCommand("insertText", false, replaceFileName(content));- this.rename(protyle);- });+ let textPlain = await readText() || "";+ textPlain = textPlain.replace(/</g, ";;;lt;;;").replace(/>/g, ";;;gt;;;");+ enableLuteMarkdownSyntax(protyle);+ let content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain));+ restoreLuteMarkdownSyntax(protyle);+ // 移除 ;;;lt;;; 和 ;;;gt;;; 转义及其包裹的内容+ content = content.replace(/;;;lt;;;[^;]+;;;gt;;;/g, "");+ document.execCommand("insertText", false, replaceFileName(content));+ this.rename(protyle);}}).element);window.siyuan.menus.menu.append(new MenuItem({diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.tsindex 75bd37c020..6ccd02d1f0 100644--- a/app/src/protyle/util/compatibility.ts+++ b/app/src/protyle/util/compatibility.ts@@ -98,7 +98,9 @@ export const readText = () => {} else if (isInHarmony()) {return window.JSHarmony.readClipboard();}- return navigator.clipboard.readText();+ return navigator.clipboard.readText().catch((err) => {+ alert(err);+ }) || "";};/// #if !BROWSERdiff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.tsindex c3f3549e6a..3c5a65c085 100644--- a/app/src/protyle/util/paste.ts+++ b/app/src/protyle/util/paste.ts@@ -100,7 +100,7 @@ export const getPlainText = (blockElement: HTMLElement, isNested = false) => {export const pasteEscaped = async (protyle: IProtyle, nodeElement: Element) => {try {- let clipText = await readText();+ let clipText = await readText() || "";// 删掉 <span data-type\="text".*>text</span> 标签,只保留文本clipText = clipText.replace(/<span data-type="text".*?>(.*?)<\/span>/g, "$1");@@ -150,7 +150,7 @@ export const pasteAsPlainText = async (protyle: IProtyle) => {/// #endifif (localFiles.length === 0) {// Inline-level elements support pasted as plain text https://github.com/siyuan-note/siyuan/issues/8010- let textPlain = await readText();+ let textPlain = await readText() || "";if (getSelection().rangeCount > 0) {const range = getSelection().getRangeAt(0);if (hasClosestByAttribute(range.startContainer, "data-type", "code") || hasClosestByClassName(range.startContainer, "hljs")) {