An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:recycle: https://github.com/siyuan-note/siyuan/pull/16774
Vanessa5577d1b585fb
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 7a07df2fef..a155e766fc 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -14,6 +14,7 @@ import {copyPlainText,isInAndroid,isInHarmony,+ isInIOS,isMac,isOnlyMeta,openByMobile,@@ -1578,77 +1579,42 @@ export class Gutter {});}}, {- /// #if !MOBILEid: "saveCodeBlockAsFile",iconHTML: "",+ ignore: !!isInIOS() || !!isInAndroid() || !!isInHarmony(),label: window.siyuan.languages.saveCodeBlockAsFile,- async bind(element) {+ bind(element) {element.addEventListener("click", async () => {- const hljsElement = nodeElement.querySelector(".hljs") as HTMLElement;- let code = hljsElement?.textContent || "";- code = nbsp2space(code);// https://github.com/siyuan-note/siyuan/issues/14800- code = code.replace(/\u200D```/g, "```");-- let docName = window.siyuan.languages._kernel[16];- if (protyle.block?.rootID) {- try {- const docInfo = await fetchSyncPost("/api/block/getDocInfo", {- id: protyle.block.rootID- });- if (docInfo?.data?.name) {- docName = replaceLocalPath(docInfo.data.name);- let truncatedDocName = "";- let byteCount = 0;- const encoder = new TextEncoder();- for (const char of docName) {- const charBytes = encoder.encode(char).length;- if (byteCount + charBytes > 170) { // 189 - 19(-YYYYMMDDHHmmss.txt)- break;- }- truncatedDocName += char;- byteCount += charBytes;- }- docName = truncatedDocName;- }- } catch {- console.warn("Failed to fetch document info for code block export.");- }- }-- const fileName = `${docName}-${dayjs().format("YYYYMMDDHHmmss")}.txt`;-+ const code = nbsp2space(getContenteditableElement(nodeElement)?.textContent || "").replace(/\u200D```/g, "```");+ const docInfo = await fetchSyncPost("/api/block/getDocInfo", {+ id: protyle.block.rootID+ });+ const fileName = `${replaceLocalPath(docInfo.data?.name || window.siyuan.languages._kernel[16])}.${nodeElement.querySelector(".protyle-action__language").textContent || "txt"}`;/// #if BROWSER- const blob = new Blob([code], {type: "text/plain;charset=utf-8"});- const url = URL.createObjectURL(blob);- const link = document.createElement("a");- link.href = url;- link.download = fileName;- document.body.appendChild(link);- link.click();- link.remove();+ const url = URL.createObjectURL(new Blob([code], {type: "text/plain;charset=utf-8"}));+ const linkElement = document.createElement("a");+ linkElement.href = url;+ linkElement.download = fileName;+ document.body.appendChild(linkElement);+ linkElement.click();+ linkElement.remove();URL.revokeObjectURL(url);showMessage(window.siyuan.languages.exported);/// #else-const result = await ipcRenderer.invoke(Constants.SIYUAN_GET, {cmd: "showSaveDialog",defaultPath: fileName,properties: ["showOverwriteConfirmation"],});if (!result.canceled && result.filePath) {- try {- fs.writeFileSync(result.filePath, code, "utf-8");- showMessage(window.siyuan.languages.exported);- } catch (error) {- showMessage(window.siyuan.languages._kernel[14].replace("%s", (error instanceof Error ? error.message : String(error))));- }+ fs.writeFileSync(result.filePath, code, "utf-8");+ showMessage(window.siyuan.languages.exported);}/// #endifwindow.siyuan.menus.menu.remove();});}- /// #endif}]}).element);} else if (type === "NodeCodeBlock" && !protyle.disabled && ["echarts", "mindmap"].includes(nodeElement.getAttribute("data-subtype"))) {diff --git a/app/src/util/functions.ts b/app/src/util/functions.tsindex abb0abb1c3..09e32c9e30 100644--- a/app/src/util/functions.ts+++ b/app/src/util/functions.ts@@ -1,14 +1,9 @@const CONTAINER_BACKEND_SET = new Set(["docker", "ios", "android", "harmony"]);-const MOBILE_BACKEND_SET = new Set(["ios", "android", "harmony"]);export const isKernelInContainer = (): boolean => {return CONTAINER_BACKEND_SET.has(window.siyuan.config.system.container);};-export const isKernelInMobile = (): boolean => {- return MOBILE_BACKEND_SET.has(window.siyuan.config.system.container);-};-export const isMobile = () => {return document.getElementById("sidebar") ? true : false;};@@ -22,7 +17,6 @@ export const getBackend = () => {}};-// "desktop" | "desktop-window" | "mobile" | "browser-desktop" | "browser-mobile"export const getFrontend = () => {/// #if MOBILE