Vanessa 2024-05-16 18:01:11 +08:00
parent 3cb8bb2288
commit 4108dce018
3 changed files with 40 additions and 20 deletions

View file

@ -17,6 +17,7 @@ import {getInstanceById} from "../../../layout/util";
import {closeTabByType, getActiveTab, getDockByType, switchTabByIndex} from "../../../layout/tabUtil";
import {openSetting} from "../../../config";
import {Tab} from "../../../layout/Tab";
import {Files} from "../../../layout/dock/Files";
/// #endif
import {App} from "../../../index";
import {Constants} from "../../../constants";
@ -24,6 +25,33 @@ import {setReadOnly} from "../../../config/util/setReadOnly";
import {lockScreen} from "../../../dialog/processSystem";
import {newFile} from "../../../util/newFile";
import {openCard} from "../../../card/openCard";
import {syncGuide} from "../../../sync/syncGuide";
const selectOpenTab = () => {
/// #if MOBILE
if (window.siyuan.mobile.editor?.protyle) {
openDock("file");
window.siyuan.mobile.files.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
@ -261,6 +289,12 @@ export const globalCommand = (command: string, app: App) => {
case "riffCard":
openCard(app);
return true;
case "selectOpen1":
selectOpenTab();
return true;
case "syncNow":
syncGuide(app);
return true;
}
return false;

View file

@ -50,22 +50,17 @@ export const commandPanel = (app: App) => {
let keys;
/// #if MOBILE
keys = ["addToDatabase", "fileTree", "outline", "bookmark", "tag", "dailyNote", "inbox", "backlinks",
"dataHistory", "editReadonly", "enter", "enterBack", "globalSearch",
"lockScreen", "mainMenu", "move", "newFile", "recentDocs", "replace", "riffCard", "search",
"selectOpen1",
"splitLR", "splitMoveB", "splitMoveR", "splitTB", "stickSearch", "syncNow", "tabToWindow",
"toggleDock", "toggleWin"];
"dataHistory", "editReadonly", "enter", "enterBack", "globalSearch", "lockScreen", "mainMenu", "move",
"newFile", "recentDocs", "replace", "riffCard", "search", "selectOpen1", "syncNow"];
/// #else
keys = ["addToDatabase", "fileTree", "outline", "bookmark", "tag", "dailyNote", "inbox", "backlinks",
"graphView", "globalGraph", "closeAll", "closeLeft", "closeOthers", "closeRight", "closeTab",
"closeUnmodified", "config", "dataHistory", "editReadonly", "enter", "enterBack", "globalSearch", "goBack",
"goForward", "goToEditTabNext", "goToEditTabPrev", "goToTab1", "goToTab2", "goToTab3", "goToTab4",
"goToTab5", "goToTab6", "goToTab7", "goToTab8", "goToTab9", "goToTabNext", "goToTabPrev", "lockScreen",
"mainMenu", "move", "newFile", "recentDocs", "replace", "riffCard", "search",
"mainMenu", "move", "newFile", "recentDocs", "replace", "riffCard", "search", "selectOpen1", "syncNow",
"selectOpen1",
"splitLR", "splitMoveB", "splitMoveR", "splitTB", "stickSearch", "syncNow", "tabToWindow",
"splitLR", "splitMoveB", "splitMoveR", "splitTB", "stickSearch", "tabToWindow",
"toggleDock", "toggleWin"];
/// #endif

View file

@ -74,6 +74,7 @@ import {commandPanel, execByCommand} from "./command/panel";
import {filterHotkey} from "./commonHotkey";
import {setReadOnly} from "../../config/util/setReadOnly";
import {copyPNGByLink} from "../../menus/util";
import {globalCommand} from "./command/global";
const switchDialogEvent = (app: App, event: MouseEvent) => {
event.preventDefault();
@ -526,17 +527,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => {
if (matchHotKey(window.siyuan.config.keymap.general.selectOpen1.custom, event)) {
event.preventDefault();
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);
globalCommand("selectOpen1", app);
return;
}