Skip to content

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

:bug: fix https://github.com/siyuan-note/siyuan/issues/5367

Vanessa739af3c44679
diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts
index c3c9c207ae..8bdeb4dbcb 100644
--- a/app/src/editor/util.ts
+++ b/app/src/editor/util.ts
@@ -248,27 +248,17 @@ const openFile = (options: {
}
});
}
- if (options.position === "right" && wnd.children[0].model) {
+ if ((options.position === "right" || options.position === "bottom") && wnd.children[0].model) {
+ const direction = options.position === "right" ? "lr" : "tb";
let targetWnd: Wnd;
- if (wnd.parent.children.length > 1 && wnd.parent instanceof Layout && wnd.parent.direction === "lr") {
+ if (wnd.parent.children.length > 1 && wnd.parent instanceof Layout && wnd.parent.direction === direction) {
wnd.parent.children.find((item, index) => {
if (item.id === wnd.id) {
- targetWnd = wnd.parent.children[index + 1] as Wnd;
- return true;
- }
- });
- }
- if (targetWnd) {
- targetWnd.addTab(tab);
- } else {
- wnd.split("lr").addTab(tab);
- }
- } else if (options.position === "bottom" && wnd.children[0].model) {
- let targetWnd: Wnd;
- if (wnd.parent.children.length > 1 && wnd.parent instanceof Layout && wnd.parent.direction === "tb") {
- wnd.parent.children.find((item, index) => {
- if (item.id === wnd.id) {
- targetWnd = wnd.parent.children[index + 1] as Wnd;
+ let nextWnd = wnd.parent.children[index + 1];
+ while (nextWnd instanceof Layout) {
+ nextWnd = nextWnd.children[0];
+ }
+ targetWnd = nextWnd;
return true;
}
});
@@ -276,7 +266,7 @@ const openFile = (options: {
if (targetWnd) {
targetWnd.addTab(tab);
} else {
- wnd.split("tb").addTab(tab);
+ wnd.split(direction).addTab(tab);
}
} else if (options.keepCursor && wnd.children[0].model) {
tab.headElement.setAttribute("keep-cursor", options.id);