An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
https://github.com/siyuan-note/siyuan/issues/11981
Vanessa141889f058a0
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.tsindex c136c1d72c..eed0ee9f3c 100644--- a/app/src/dialog/processSystem.ts+++ b/app/src/dialog/processSystem.ts@@ -105,6 +105,7 @@ export const reloadSync = (} else if (item.type !== "local" || data.upsertRootIDs.includes(item.blockId)) {fetchPost("/api/outline/getDocOutline", {id: item.blockId,+ preview: item.isPreview}, response => {item.update(response);});diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex 61a329c634..26a47bc5bb 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -578,23 +578,29 @@ export const isCurrentEditor = (blockId: string) => {export const updateOutline = (models: IModels, protyle: IProtyle, reload = false) => {models.outline.find(item => {- if (protyle && item.blockId === protyle.block.rootID && item.type === "pin") {- item.isPreview = !protyle.preview.element.classList.contains("fn__none");- }- if (reload || (item.type === "pin" && (!protyle || item.blockId !== protyle.block?.rootID))) {+ if (reload ||+ (item.type === "pin" &&+ (!protyle || item.blockId !== protyle.block?.rootID ||+ item.isPreview === protyle.preview.element.classList.contains("fn__none"))+ )+ ) {let blockId = "";if (protyle && protyle.block) {blockId = protyle.block.rootID;}- if (blockId === item.blockId && !reload) {+ if (blockId === item.blockId && !reload && item.isPreview !== protyle.preview.element.classList.contains("fn__none")) {return;}+fetchPost("/api/outline/getDocOutline", {id: blockId,+ preview: !protyle.preview.element.classList.contains("fn__none")}, response => {- if (!reload && (!isCurrentEditor(blockId) || item.blockId === blockId)) {+ if (!reload && (!isCurrentEditor(blockId) || item.blockId === blockId) &&+ item.isPreview !== protyle.preview.element.classList.contains("fn__none")) {return;}+ item.isPreview = !protyle.preview.element.classList.contains("fn__none");item.update(response, blockId);if (protyle) {item.updateDocTitle(protyle.background.ial);diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.tsindex 63e533cd18..fa3978d3b7 100644--- a/app/src/layout/dock/Outline.ts+++ b/app/src/layout/dock/Outline.ts@@ -182,7 +182,7 @@ export class Outline extends Model {openFileById({app: options.app,id: this.blockId,- afterOpen: (model: Editor) =>{+ afterOpen: (model: Editor) => {if (model) {if (this.isPreview) {model.editor.protyle.preview.element.querySelector(".b3-typography").scrollTop = 0;@@ -206,22 +206,13 @@ export class Outline extends Model {}});this.bindSort();- if (this.isPreview) {- if (this.blockId) {- fetchPost("/api/export/preview", {- id: this.blockId,- }, response => {- response.data = response.data.outline;- this.update(response);- });- }- } else {- fetchPost("/api/outline/getDocOutline", {- id: this.blockId,- }, response => {- this.update(response);- });- }++ fetchPost("/api/outline/getDocOutline", {+ id: this.blockId,+ preview: this.isPreview+ }, response => {+ this.update(response);+ });}private bindSort() {@@ -368,7 +359,7 @@ export class Outline extends Model {}private onTransaction(data: IWebSocketData) {- if (this.isPreview || data.data.rootID !== this.blockId) {+ if (data.data.rootID !== this.blockId) {return;}let needReload = false;@@ -397,6 +388,7 @@ export class Outline extends Model {if (needReload) {fetchPost("/api/outline/getDocOutline", {id: this.blockId,+ preview: this.isPreview}, response => {this.update(response);// https://github.com/siyuan-note/siyuan/issues/8372diff --git a/app/src/mobile/dock/MobileOutline.ts b/app/src/mobile/dock/MobileOutline.tsindex 78aaae5e31..e544885b80 100644--- a/app/src/mobile/dock/MobileOutline.ts+++ b/app/src/mobile/dock/MobileOutline.ts@@ -71,6 +71,7 @@ export class MobileOutline {}fetchPost("/api/outline/getDocOutline", {id: window.siyuan.mobile.editor.protyle.block.rootID,+ preview: !window.siyuan.mobile.editor.protyle.preview.element.classList.contains("fn__none")}, response => {let currentId;let currentElement = this.element.querySelector(".b3-list-item--focus");diff --git a/app/src/protyle/preview/index.ts b/app/src/protyle/preview/index.tsindex 74a5b36b1d..a8413be5f2 100644--- a/app/src/protyle/preview/index.ts+++ b/app/src/protyle/preview/index.ts@@ -10,7 +10,7 @@ import {getSearch, isMobile} from "../../util/functions";import {shell} from "electron";/// #endif/// #if !MOBILE-import {openAsset, openBy} from "../../editor/util";+import {openAsset, openBy, updateOutline} from "../../editor/util";import {getAllModels} from "../../layout/getAll";/// #endifimport {fetchPost} from "../../util/fetch";@@ -164,7 +164,7 @@ export class Preview {this.previewElement = previewElement;}- public render(protyle: IProtyle, cb?: (outlineData: IBlockTree[]) => void) {+ public render(protyle: IProtyle) {if (this.element.style.display === "none") {return;}@@ -191,21 +191,8 @@ export class Preview {avRender(protyle.preview.previewElement, protyle);speechRender(protyle.preview.previewElement, protyle.options.lang);protyle.preview.previewElement.scrollTop = oldScrollTop;- /// #if MOBILE- if (cb) {- cb(response.data.outline);- }- /// #else- response.data = response.data.outline;- getAllModels().outline.forEach(item => {- if (item.type === "pin" || (item.type === "local" && item.blockId === protyle.block.rootID)) {- item.isPreview = true;- item.update(response, protyle.block.rootID);- if (item.type === "pin") {- item.updateDocTitle(protyle.background.ial);- }- }- });+ /// #if !MOBILE+ updateOutline(getAllModels(), protyle);/// #endifloadingElement.remove();});