Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/9082

Vanessaa21831eb9aaa
diff --git a/app/src/block/Panel.ts b/app/src/block/Panel.ts
index 15486d2f8d..01c8f61fbc 100644
--- a/app/src/block/Panel.ts
+++ b/app/src/block/Panel.ts
@@ -159,7 +159,11 @@ export class BlockPanel {
const action = [];
if (response.data.rootID !== this.nodeIds[index]) {
action.push(Constants.CB_GET_ALL);
+ } else {
+ action.push(Constants.CB_GET_SCROLL);
+ action.push(Constants.CB_GET_HL);
}
+
if (this.isBacklink) {
action.push(Constants.CB_GET_BACKLINK);
}
diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts
index ec110e139e..386f1bb7b9 100644
--- a/app/src/protyle/index.ts
+++ b/app/src/protyle/index.ts
@@ -216,11 +216,17 @@ export class Protyle {
return;
}
if (options.scrollAttr ||
+ mergedOptions.action.includes(Constants.CB_GET_CONTEXT) ||
(mergedOptions.action.includes(Constants.CB_GET_SCROLL) && this.protyle.options.mode !== "preview")) {
if (!options.scrollAttr) {
fetchPost("/api/block/getDocInfo", {
id: options.blockId
}, (response) => {
+ if (response.data.rootID !== options.blockId && mergedOptions.action.includes(Constants.CB_GET_CONTEXT)) {
+ // 搜索打开文档等情况需保持上一次历史 https://github.com/siyuan-note/siyuan/issues/9082
+ this.getDoc(mergedOptions);
+ return;
+ }
let scrollObj;
if (response.data.ial.scroll) {
try {
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index dddf7db847..ca15db2e9c 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -756,7 +756,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
openFileById({
app,
id,
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
zoomIn: foldResponse.data,
position: "right"
});
@@ -796,7 +796,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
openFileById({
app,
id,
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
zoomIn: foldResponse.data
});
if (closeCB) {
@@ -855,7 +855,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
app,
id,
position: "right",
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
zoomIn: foldResponse.data
});
if (closeCB) {
@@ -884,7 +884,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
openFileById({
app,
id,
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL],
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
zoomIn: foldResponse.data
});
if (closeCB) {