An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:zap:
Vanessa2b3b78485d7e
diff --git a/app/src/boot/globalEvent/event.ts b/app/src/boot/globalEvent/event.tsindex b35f90dda3..098a91f6be 100644--- a/app/src/boot/globalEvent/event.ts+++ b/app/src/boot/globalEvent/event.ts@@ -13,7 +13,8 @@ import {initTabMenu} from "../../menus/tab";import {getInstanceById} from "../../layout/util";import {Tab} from "../../layout/Tab";import {hideTooltip} from "../../dialog/tooltip";-import {checkFold, openFileById} from "../../editor/util";+import {openFileById} from "../../editor/util";+import {checkFold} from "../../util/noRelyPCFunction";export const initWindowEvent = (app: App) => {document.body.addEventListener("mouseleave", () => {diff --git a/app/src/boot/globalEvent/searchKeydown.ts b/app/src/boot/globalEvent/searchKeydown.tsindex b473324b8b..13b42beab0 100644--- a/app/src/boot/globalEvent/searchKeydown.ts+++ b/app/src/boot/globalEvent/searchKeydown.ts@@ -3,7 +3,7 @@ import * as path from "path";/// #endifimport {matchHotKey} from "../../protyle/util/hotKey";import {fetchPost} from "../../util/fetch";-import {checkFold, openFileById} from "../../editor/util";+import {openFileById} from "../../editor/util";import {Constants} from "../../constants";import {newFileByName} from "../../util/newFile";import {App} from "../../index";@@ -15,6 +15,7 @@ import {showFileInFolder} from "../../util/pathName";import {assetInputEvent, renderPreview, toggleAssetHistory} from "../../search/assets";import {initSearchMenu} from "../../menus/search";import {writeText} from "../../protyle/util/compatibility";+import {checkFold} from "../../util/noRelyPCFunction";export const searchKeydown = (app: App, event: KeyboardEvent) => {if (getSelection().rangeCount === 0) {diff --git a/app/src/boot/onGetConfig.ts b/app/src/boot/onGetConfig.tsindex 9f726c631b..f002d7ca8e 100644--- a/app/src/boot/onGetConfig.ts+++ b/app/src/boot/onGetConfig.ts@@ -13,7 +13,7 @@ import {appearance} from "../config/appearance";import {fetchPost, fetchSyncPost} from "../util/fetch";import {addGA, initAssets, setInlineStyle} from "../util/assets";import {renderSnippet} from "../config/util/snippets";-import {checkFold, openFile, openFileById} from "../editor/util";+import {openFile, openFileById} from "../editor/util";import {focusByRange} from "../protyle/util/selection";import {exitSiYuan} from "../dialog/processSystem";import {isWindow} from "../util/functions";@@ -28,6 +28,7 @@ import {App} from "../index";import {initWindowEvent} from "./globalEvent/event";import {sendGlobalShortcut} from "./globalEvent/keydown";import {closeWindow} from "../window/closeWin";+import {checkFold} from "../util/noRelyPCFunction";const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {if (key1 === "general") {diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex d29a7fccd6..3286fa26b3 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -29,15 +29,6 @@ import {App} from "../index";import {newCardModel} from "../card/newCardTab";import {preventScroll} from "../protyle/scroll/preventScroll";-export const checkFold = (id: string, cb: (zoomIn: boolean, action: string[]) => void) => {- if (!id) {- return;- }- fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {- cb(foldResponse.data, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);- });-};-export const openFileById = async (options: {app: App,id: string,diff --git a/app/src/layout/dock/Bookmark.ts b/app/src/layout/dock/Bookmark.tsindex 1914f7efeb..3989fd5991 100644--- a/app/src/layout/dock/Bookmark.ts+++ b/app/src/layout/dock/Bookmark.ts@@ -5,11 +5,12 @@ import {setPanelFocus} from "../util";import {getDockByType} from "../tabUtil";import {fetchPost} from "../../util/fetch";import {updateHotkeyTip} from "../../protyle/util/compatibility";-import {checkFold, openFileById} from "../../editor/util";+import {openFileById} from "../../editor/util";import {hasClosestByClassName} from "../../protyle/util/hasClosest";import {openBookmarkMenu} from "../../menus/bookmark";import {App} from "../../index";import {Constants} from "../../constants";+import {checkFold} from "../../util/noRelyPCFunction";export class Bookmark extends Model {private openNodes: string[];diff --git a/app/src/layout/dock/Graph.ts b/app/src/layout/dock/Graph.tsindex 8a86ded89e..f2991a94d3 100644--- a/app/src/layout/dock/Graph.ts+++ b/app/src/layout/dock/Graph.ts@@ -7,10 +7,11 @@ import {addScript} from "../../protyle/util/addScript";import {BlockPanel} from "../../block/Panel";import {fullscreen} from "../../protyle/breadcrumb/action";import {fetchPost} from "../../util/fetch";-import {checkFold, isCurrentEditor, openFileById} from "../../editor/util";+import {isCurrentEditor, openFileById} from "../../editor/util";import {updateHotkeyTip} from "../../protyle/util/compatibility";import {openGlobalSearch} from "../../search/util";import {App} from "../../index";+import {checkFold} from "../../util/noRelyPCFunction";declare const vis: any;diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.tsindex bf377d43e4..801c806bde 100644--- a/app/src/layout/dock/Outline.ts+++ b/app/src/layout/dock/Outline.ts@@ -7,13 +7,14 @@ import {fetchPost} from "../../util/fetch";import {getAllModels} from "../getAll";import {hasClosestBlock, hasClosestByClassName, hasTopClosestByClassName} from "../../protyle/util/hasClosest";import {updateHotkeyTip} from "../../protyle/util/compatibility";-import {checkFold, openFileById} from "../../editor/util";+import {openFileById} from "../../editor/util";import {Constants} from "../../constants";import {escapeHtml} from "../../util/escape";import {unicode2Emoji} from "../../emoji";import {onGet} from "../../protyle/util/onGet";import {getPreviousBlock} from "../../protyle/wysiwyg/getBlock";import {App} from "../../index";+import {checkFold} from "../../util/noRelyPCFunction";export class Outline extends Model {public tree: Tree;diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex 146d259e49..20f9f81b75 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -30,7 +30,7 @@ import {onGet} from "../protyle/util/onGet";import {getAllModels} from "../layout/getAll";import {pasteAsPlainText, pasteEscaped, pasteText} from "../protyle/util/paste";/// #if !MOBILE-import {checkFold, openFileById, updateBacklinkGraph} from "../editor/util";+import {openFileById, updateBacklinkGraph} from "../editor/util";import {openGlobalSearch} from "../search/util";import {openNewWindowById} from "../window/openNewWindow";/// #endif@@ -45,7 +45,7 @@ import {pushBack} from "../mobile/util/MobileBackFoward";import {copyPNG, exportAsset} from "./util";import {removeInlineType} from "../protyle/toolbar/util";import {alignImgCenter, alignImgLeft} from "../protyle/wysiwyg/commonHotkey";-import {renameTag} from "../util/noRelyPCFunction";+import {checkFold, renameTag} from "../util/noRelyPCFunction";import {hideElements} from "../protyle/ui/hideElements";import {emitOpenMenu} from "../plugin/EventBus";import {openMobileFileById} from "../mobile/editor";diff --git a/app/src/menus/util.ts b/app/src/menus/util.tsindex e3f036c5c7..ba2bf0d625 100644--- a/app/src/menus/util.ts+++ b/app/src/menus/util.ts@@ -4,12 +4,13 @@ import * as path from "path";/// #endifimport {fetchPost} from "../util/fetch";import {getAssetName, pathPosix, showFileInFolder} from "../util/pathName";-import {checkFold, openFileById} from "../editor/util";+import {openFileById} from "../editor/util";import {Constants} from "../constants";import {openNewWindowById} from "../window/openNewWindow";import {MenuItem} from "./Menu";import {App} from "../index";import {isInAndroid, updateHotkeyTip} from "../protyle/util/compatibility";+import {checkFold} from "../util/noRelyPCFunction";export const exportAsset = (src: string) => {/// #if !BROWSERdiff --git a/app/src/mobile/dock/MobileBookmarks.ts b/app/src/mobile/dock/MobileBookmarks.tsindex 5806da57f7..f82aa65188 100644--- a/app/src/mobile/dock/MobileBookmarks.ts+++ b/app/src/mobile/dock/MobileBookmarks.ts@@ -5,7 +5,7 @@ import {hasClosestByClassName} from "../../protyle/util/hasClosest";import {openMobileFileById} from "../editor";import {openBookmarkMenu} from "../../menus/bookmark";import {App} from "../../index";-import {checkFold} from "../../editor/util";+import {checkFold} from "../../util/noRelyPCFunction";export class MobileBookmarks {public element: HTMLElement;diff --git a/app/src/mobile/dock/MobileOutline.ts b/app/src/mobile/dock/MobileOutline.tsindex f3ef805250..4de1c9067d 100644--- a/app/src/mobile/dock/MobileOutline.ts+++ b/app/src/mobile/dock/MobileOutline.ts@@ -5,7 +5,7 @@ import {Constants} from "../../constants";import {getEventName} from "../../protyle/util/compatibility";import {App} from "../../index";import {closePanel} from "../util/closePanel";-import {checkFold} from "../../editor/util";+import {checkFold} from "../../util/noRelyPCFunction";export class MobileOutline {private tree: Tree;diff --git a/app/src/mobile/menu/search.ts b/app/src/mobile/menu/search.tsindex 5f0c915951..24dda8fc46 100644--- a/app/src/mobile/menu/search.ts+++ b/app/src/mobile/menu/search.ts@@ -24,7 +24,7 @@ import {renderPreview,} from "../../search/assets";import {addClearButton} from "../../util/addClearButton";-import {checkFold} from "../../editor/util";+import {checkFold} from "../../util/noRelyPCFunction";const replace = (element: Element, config: ISearchOption, isAll: boolean) => {if (config.method === 1 || config.method === 2) {diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.tsindex 1e48b10629..34d7e4ef41 100644--- a/app/src/mobile/util/initFramework.ts+++ b/app/src/mobile/util/initFramework.ts@@ -20,7 +20,7 @@ import {syncGuide} from "../../sync/syncGuide";import {Inbox} from "../../layout/dock/Inbox";import {App} from "../../index";import {setTitle} from "../../dialog/processSystem";-import {checkFold} from "../../editor/util";+import {checkFold} from "../../util/noRelyPCFunction";export const initFramework = (app: App, isStart: boolean) => {setInlineStyle();diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 6cba55206a..05538bfffc 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -58,7 +58,7 @@ import {blockRender} from "../render/blockRender";/// #if !MOBILEimport {getAllModels} from "../../layout/getAll";import {pushBack} from "../../util/backForward";-import {checkFold, openAsset, openBy, openFileById} from "../../editor/util";+import {openAsset, openBy, openFileById} from "../../editor/util";import {openGlobalSearch} from "../../search/util";/// #elseimport {popSearch} from "../../mobile/menu/search";@@ -80,6 +80,7 @@ import {stickyRow, updateHeader} from "../render/av/row";import {showColMenu} from "../render/av/col";import {openViewMenu} from "../render/av/view";import {avRender} from "../render/av/render";+import {checkFold} from "../../util/noRelyPCFunction";export class WYSIWYG {public lastHTMLs: { [key: string]: string } = {};diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex f2e41df449..0fd19146b6 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -39,7 +39,7 @@ import {newFileContentBySelect, rename, replaceFileName} from "../../editor/renaimport {insertEmptyBlock, jumpToParentNext} from "../../block/util";import {isLocalPath, pathPosix} from "../../util/pathName";/// #if !MOBILE-import {checkFold, openBy, openFileById} from "../../editor/util";+import {openBy, openFileById} from "../../editor/util";/// #endifimport {alignImgCenter, alignImgLeft,@@ -68,6 +68,7 @@ import {escapeHtml} from "../../util/escape";import {insertHTML} from "../util/insertHTML";import {removeSearchMark} from "../toolbar/util";import {avKeydown} from "../render/av/keydown";+import {checkFold} from "../../util/noRelyPCFunction";export const getContentByInlineHTML = (range: Range, cb: (content: string) => void) => {let html = "";diff --git a/app/src/search/util.ts b/app/src/search/util.tsindex 7531d40419..58190d1c55 100644--- a/app/src/search/util.ts+++ b/app/src/search/util.ts@@ -5,7 +5,7 @@ import * as path from "path";import {Constants} from "../constants";import {escapeAriaLabel, escapeGreat, escapeHtml} from "../util/escape";import {fetchPost} from "../util/fetch";-import {checkFold, openFile, openFileById} from "../editor/util";+import {openFile, openFileById} from "../editor/util";import {showMessage} from "../dialog/message";import {reloadProtyle} from "../protyle/util/reload";import {MenuItem} from "../menus/Menu";@@ -40,6 +40,7 @@ import {import {resize} from "../protyle/util/resize";import {Menu} from "../plugin/Menu";import {addClearButton} from "../util/addClearButton";+import {checkFold} from "../util/noRelyPCFunction";export const toggleReplaceHistory = (searchElement: Element) => {const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];diff --git a/app/src/util/noRelyPCFunction.ts b/app/src/util/noRelyPCFunction.tsindex 9ef8b2ace1..48a47fdabc 100644--- a/app/src/util/noRelyPCFunction.ts+++ b/app/src/util/noRelyPCFunction.ts@@ -1,6 +1,7 @@import {Dialog} from "../dialog";import {fetchPost} from "./fetch";import {isMobile} from "./functions";+import {Constants} from "../constants";// 需独立出来,否则移动端引用的时候会引入 pc 端大量无用代码export const renameTag = (labelName: string) => {@@ -31,3 +32,12 @@ export const renameTag = (labelName: string) => {export const getWorkspaceName = () => {return window.siyuan.config.system.workspaceDir.replace(/^.*[\\\/]/, "");};++export const checkFold = (id: string, cb: (zoomIn: boolean, action: string[]) => void) => {+ if (!id) {+ return;+ }+ fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {+ cb(foldResponse.data, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);+ });+};