Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:mobile: preview outline

Vanessa9b6fe676ab90
diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts
index 2ca5d8850e..74cc44c912 100644
--- a/app/src/layout/dock/Outline.ts
+++ b/app/src/layout/dock/Outline.ts
@@ -4,7 +4,7 @@ import {Tree} from "../../util/Tree";
import {getDockByType, setPanelFocus} from "../util";
import {fetchPost} from "../../util/fetch";
import {getAllModels} from "../getAll";
-import {hasClosestBlock, hasClosestByClassName} from "../../protyle/util/hasClosest";
+import {hasClosestBlock, hasClosestByClassName, hasTopClosestByClassName} from "../../protyle/util/hasClosest";
import {updateHotkeyTip} from "../../protyle/util/compatibility";
import {openFileById} from "../../editor/util";
import {Constants} from "../../constants";
diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.ts
index c28561f818..498865c7f3 100644
--- a/app/src/protyle/breadcrumb/index.ts
+++ b/app/src/protyle/breadcrumb/index.ts
@@ -16,6 +16,7 @@ import {getEditorRange} from "../util/selection";
import {setPadding} from "../ui/initUI";
/// #if !MOBILE
import {openFileById} from "../../editor/util";
+import {setPanelFocus} from "../../layout/util";
/// #endif
/// #if !BROWSER
import {getCurrentWindow, systemPreferences} from "@electron/remote";
@@ -25,7 +26,6 @@ import {hideElements} from "../ui/hideElements";
import {confirmDialog} from "../../dialog/confirmDialog";
import {reloadProtyle} from "../util/reload";
import {deleteFile} from "../../editor/deleteFile";
-import {setPanelFocus} from "../../layout/util";
export class Breadcrumb {
public element: HTMLElement;
@@ -44,9 +44,11 @@ export class Breadcrumb {
<button class="b3-tooltips b3-tooltips__w block__icon block__icon--show fn__flex-center" data-menu="true" aria-label="${window.siyuan.languages.more}"><svg><use xlink:href="#iconMore"></use></svg></button>`;
this.element = element.firstElementChild as HTMLElement;
element.addEventListener("click", (event) => {
+ /// #if !MOBILE
if (protyle.model) {
setPanelFocus(protyle.model.element.parentElement.parentElement);
}
+ /// #endif
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(element)) {
const id = target.getAttribute("data-node-id");
diff --git a/app/src/protyle/preview/index.ts b/app/src/protyle/preview/index.ts
index 15bdb09735..9ebec93445 100644
--- a/app/src/protyle/preview/index.ts
+++ b/app/src/protyle/preview/index.ts
@@ -11,14 +11,14 @@ import {shell} from "electron";
/// #endif
/// #if !MOBILE
import {openAsset, openBy} from "../../editor/util";
+import {getAllModels} from "../../layout/getAll";
+import {setPanelFocus} from "../../layout/util";
/// #endif
import {fetchPost} from "../../util/fetch";
import {processRender} from "../util/processCode";
import {highlightRender} from "../render/highlightRender";
import {speechRender} from "../render/speechRender";
import {avRender} from "../render/av/render";
-import {setPanelFocus} from "../../layout/util";
-import {getAllModels} from "../../layout/getAll";
export class Preview {
public element: HTMLElement;
@@ -166,17 +166,18 @@ export class Preview {
avRender(protyle.preview.previewElement);
speechRender(protyle.preview.previewElement, protyle.options.lang);
protyle.preview.previewElement.scrollTop = oldScrollTop;
- getAllModels().outline.find(item => {
+ /// #if !MOBILE
+ response.data = response.data.outline;
+ getAllModels().outline.forEach(item => {
if (item.type === "pin" || (item.type === "local" && item.blockId === protyle.block.rootID)) {
- response.data = response.data.outline;
item.isPreview = true;
item.update(response, protyle.block.rootID);
if (item.type === "pin") {
item.updateDocTitle(protyle.background.ial);
}
- return;
}
});
+ /// #endif
});
}, protyle.options.preview.delay);
}
diff --git a/app/src/protyle/util/setEditMode.ts b/app/src/protyle/util/setEditMode.ts
index e1ad7a7396..2a3b3bd602 100644
--- a/app/src/protyle/util/setEditMode.ts
+++ b/app/src/protyle/util/setEditMode.ts
@@ -31,7 +31,9 @@ export const setEditMode = (protyle: IProtyle, type: TEditorMode) => {
protyle.breadcrumb?.element.classList.remove("fn__none");
protyle.breadcrumb.toggleExit(!protyle.block.showAll);
}
+ /// #if !MOBILE
updateOutline(getAllModels(), protyle, true);
+ /// #endif
}
hideElements(["gutter", "toolbar", "select", "hint", "util"], protyle);
};