Vanessa 2025-09-29 19:21:07 +08:00
parent eb03fbb11c
commit 63c86becb1
4 changed files with 44 additions and 70 deletions

View file

@ -8,7 +8,7 @@ import {popSearch} from "../../../mobile/menu/search";
import {getRecentDocs} from "../../../mobile/menu/getRecentDocs";
/// #else
import {openNewWindow} from "../../../window/openNewWindow";
import {toggleDockBar} from "../../../layout/dock/util";
import {selectOpenTab, toggleDockBar} from "../../../layout/dock/util";
import {openGlobalSearch} from "../../../search/util";
import {workspaceMenu} from "../../../menus/workspace";
import {isWindow} from "../../../util/functions";
@ -27,7 +27,6 @@ import {
} from "../../../layout/tabUtil";
import {openSetting} from "../../../config";
import {Tab} from "../../../layout/Tab";
import {Files} from "../../../layout/dock/Files";
/// #endif
/// #if !BROWSER
import {ipcRenderer} from "electron";
@ -42,32 +41,6 @@ import {syncGuide} from "../../../sync/syncGuide";
import {Wnd} from "../../../layout/Wnd";
import {unsplitWnd} from "../../../menus/tab";
const selectOpenTab = () => {
/// #if MOBILE
if (window.siyuan.mobile.editor?.protyle) {
openDock("file");
window.siyuan.mobile.docks.file.selectItem(window.siyuan.mobile.editor.protyle.notebookId, window.siyuan.mobile.editor.protyle.path);
}
/// #else
const dockFile = getDockByType("file");
if (!dockFile) {
return false;
}
const files = dockFile.data.file as Files;
const element = document.querySelector(".layout__wnd--active > .fn__flex > .layout-tab-bar > .item--focus") ||
document.querySelector("ul.layout-tab-bar > .item--focus");
if (element) {
const tab = getInstanceById(element.getAttribute("data-id")) as Tab;
if (tab && tab.model instanceof Editor) {
tab.model.editor.protyle.wysiwyg.element.blur();
tab.model.editor.protyle.title.editElement.blur();
files.selectItem(tab.model.editor.protyle.notebookId, tab.model.editor.protyle.path);
}
}
dockFile.toggleModel("file", true);
/// #endif
};
export const globalCommand = (command: string, app: App) => {
/// #if MOBILE
switch (command) {

View file

@ -601,6 +601,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {
const liElement = files.element.querySelector(".b3-list-item");
if (liElement) {
liElement.classList.add("b3-list-item--focus");
files.lastSelectedElement = liElement;
}
event.preventDefault();
}
@ -863,6 +864,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {
item.classList.remove("b3-list-item--focus");
});
parentElement.classList.add("b3-list-item--focus");
files.lastSelectedElement = parentElement;
const parentRect = parentElement.getBoundingClientRect();
const fileRect = files.element.getBoundingClientRect();
if (parentRect.top < fileRect.top || parentRect.bottom > fileRect.bottom) {
@ -895,6 +897,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {
item.classList.remove("b3-list-item--focus");
});
nextElement.classList.add("b3-list-item--focus");
files.lastSelectedElement = nextElement;
const nextRect = nextElement.getBoundingClientRect();
const fileRect = files.element.getBoundingClientRect();
if (nextRect.top < fileRect.top || nextRect.bottom > fileRect.bottom) {
@ -928,6 +931,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {
item.classList.remove("b3-list-item--focus");
});
previousElement.classList.add("b3-list-item--focus");
files.lastSelectedElement = previousElement;
const previousRect = previousElement.getBoundingClientRect();
const fileRect = files.element.getBoundingClientRect();
if (previousRect.top < fileRect.top || previousRect.bottom > fileRect.bottom) {