Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/16379

Vanessa63f2d726739f
diff --git a/app/src/boot/globalEvent/searchKeydown.ts b/app/src/boot/globalEvent/searchKeydown.ts
index e089102517..2fa1280efd 100644
--- a/app/src/boot/globalEvent/searchKeydown.ts
+++ b/app/src/boot/globalEvent/searchKeydown.ts
@@ -99,12 +99,13 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
if (searchType !== "asset") {
if (matchHotKey(window.siyuan.config.keymap.editor.general.insertRight.custom, event)) {
const id = currentList.getAttribute("data-node-id");
- checkFold(id, (zoomIn, action) => {
+ checkFold(id, (zoomIn) => {
openFileById({
app,
id,
position: "right",
- action: [...action, Constants.CB_GET_HL],
+ action: zoomIn ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HL] :
+ [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_HL],
zoomIn,
scrollPosition: "center"
});
@@ -222,11 +223,12 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
replace(element, config, edit, false);
} else {
const id = currentList.getAttribute("data-node-id");
- checkFold(id, (zoomIn, action) => {
+ checkFold(id, (zoomIn) => {
openFileById({
app,
id,
- action: [...action, Constants.CB_GET_HL],
+ action: zoomIn ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HL] :
+ [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_HL],
zoomIn,
scrollPosition: "center"
});
diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts
index dfb8c2e5e6..4e6f49a1b7 100644
--- a/app/src/editor/util.ts
+++ b/app/src/editor/util.ts
@@ -339,6 +339,7 @@ const getUnInitTab = (options: IOpenFileOptions) => {
} else {
initObj.action = options.action;
}
+ initObj.scrollPosition = options.scrollPosition;
item.headElement.setAttribute("data-initdata", JSON.stringify(initObj));
item.parent.switchTab(item.headElement);
return true;
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index 7f2a8136aa..102d38d589 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -750,6 +750,7 @@ export const newModelByInitData = (app: App, tab: Tab, json: any) => {
rootId: json.rootId,
blockId: json.blockId,
mode: json.mode,
+ scrollPosition: json.scrollPosition,
action: typeof json.action === "string" ? (json.action ? [json.action, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS]) : json.action.concat(Constants.CB_GET_FOCUS),
});
}
diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts
index a0874e0da0..c7a6683810 100644
--- a/app/src/protyle/util/onGet.ts
+++ b/app/src/protyle/util/onGet.ts
@@ -464,6 +464,9 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr
}
});
}
+ if (!focusElement && protyle.block.id === protyle.block.rootID) {
+ focusElement = protyle.title.editElement;
+ }
if (protyle.block.mode === 4) {
preventScroll(protyle);
focusElement = protyle.wysiwyg.element.lastElementChild;
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index d9c1d2aa39..b88725200a 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -815,11 +815,12 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
} else {
if (event.altKey) {
const id = target.getAttribute("data-node-id");
- checkFold(id, (zoomIn, action) => {
+ checkFold(id, (zoomIn) => {
openFileById({
app,
id,
- action: [...action, Constants.CB_GET_HL],
+ action: zoomIn ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HL] :
+ [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_HL],
zoomIn,
position: "right",
scrollPosition: "center"
@@ -856,11 +857,12 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
/// #endif
} else {
const id = target.getAttribute("data-node-id");
- checkFold(id, (zoomIn, action) => {
+ checkFold(id, (zoomIn) => {
openFileById({
app,
id,
- action: [...action, Constants.CB_GET_HL],
+ action: zoomIn ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HL] :
+ [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_HL],
zoomIn,
scrollPosition: "center"
});