From e465fe5f9775acce1462887909f85f6a20681d27 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 15 Sep 2024 17:14:19 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/11981 --- app/src/editor/util.ts | 10 ++++------ app/src/layout/dock/Outline.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts index a9134386f..cb1f97bd8 100644 --- a/app/src/editor/util.ts +++ b/app/src/editor/util.ts @@ -45,7 +45,7 @@ export const openFileById = async (options: { keepCursor?: boolean zoomIn?: boolean removeCurrentTab?: boolean - afterOpen?: (model:Model) => void + afterOpen?: (model: Model) => void }) => { const response = await fetchSyncPost("/api/block/getBlockInfo", {id: options.id}); if (response.code === -1) { @@ -575,6 +575,9 @@ 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))) { let blockId = ""; if (protyle && protyle.block) { @@ -583,17 +586,12 @@ export const updateOutline = (models: IModels, protyle: IProtyle, reload = false if (blockId === item.blockId && !reload) { return; } - if (protyle && !protyle.preview.element.classList.contains("fn__none")) { - protyle.preview.render(protyle); - return; - } fetchPost("/api/outline/getDocOutline", { id: blockId, }, response => { if (!reload && (!isCurrentEditor(blockId) || item.blockId === blockId)) { return; } - item.isPreview = false; 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.ts index d6198c087..63e533cd1 100644 --- a/app/src/layout/dock/Outline.ts +++ b/app/src/layout/dock/Outline.ts @@ -182,9 +182,13 @@ export class Outline extends Model { openFileById({ app: options.app, id: this.blockId, - afterOpen(model: Editor) { + afterOpen: (model: Editor) =>{ if (model) { - goHome(model.editor.protyle); + if (this.isPreview) { + model.editor.protyle.preview.element.querySelector(".b3-typography").scrollTop = 0; + } else { + goHome(model.editor.protyle); + } } } });