This commit is contained in:
parent
4108dce018
commit
0f6a280513
3 changed files with 86 additions and 37 deletions
|
@ -7,6 +7,9 @@ import {popMenu} from "../../../mobile/menu";
|
|||
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 {openGlobalSearch} from "../../../search/util";
|
||||
import {workspaceMenu} from "../../../menus/workspace";
|
||||
import {isWindow} from "../../../util/functions";
|
||||
import {openRecentDocs} from "../../../business/openRecentDocs";
|
||||
|
@ -14,11 +17,21 @@ import {openSearch} from "../../../search/spread";
|
|||
import {goBack, goForward} from "../../../util/backForward";
|
||||
import {getAllTabs} from "../../../layout/getAll";
|
||||
import {getInstanceById} from "../../../layout/util";
|
||||
import {closeTabByType, getActiveTab, getDockByType, switchTabByIndex} from "../../../layout/tabUtil";
|
||||
import {
|
||||
closeTabByType,
|
||||
copyTab,
|
||||
getActiveTab,
|
||||
getDockByType,
|
||||
resizeTabs,
|
||||
switchTabByIndex
|
||||
} 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";
|
||||
/// #endif
|
||||
import {App} from "../../../index";
|
||||
import {Constants} from "../../../constants";
|
||||
import {setReadOnly} from "../../../config/util/setReadOnly";
|
||||
|
@ -51,7 +64,7 @@ const selectOpenTab = () => {
|
|||
}
|
||||
dockFile.toggleModel("file", true);
|
||||
/// #endif
|
||||
}
|
||||
};
|
||||
|
||||
export const globalCommand = (command: string, app: App) => {
|
||||
/// #if MOBILE
|
||||
|
@ -110,6 +123,9 @@ export const globalCommand = (command: string, app: App) => {
|
|||
key: (getSelection().rangeCount > 0 ? getSelection().getRangeAt(0) : document.createRange()).toString()
|
||||
});
|
||||
return true;
|
||||
case "stickSearch":
|
||||
openGlobalSearch(app, (getSelection().rangeCount > 0 ? getSelection().getRangeAt(0) : document.createRange()).toString(), true);
|
||||
return true;
|
||||
case "goBack":
|
||||
goBack(app);
|
||||
return true;
|
||||
|
@ -157,6 +173,15 @@ export const globalCommand = (command: string, app: App) => {
|
|||
case "recentDocs":
|
||||
openRecentDocs();
|
||||
return true;
|
||||
case "toggleDock":
|
||||
toggleDockBar(document.querySelector("#barDock use"));
|
||||
return true;
|
||||
case "toggleWin":
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, "hide");
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, "minimize");
|
||||
/// #endif
|
||||
return true;
|
||||
}
|
||||
if (command === "goToEditTabNext" || command === "goToEditTabPrev") {
|
||||
let currentTabElement = document.querySelector(".layout__wnd--active ul.layout-tab-bar > .item--focus");
|
||||
|
@ -265,6 +290,38 @@ export const globalCommand = (command: string, app: App) => {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
if (command === "splitLR") {
|
||||
const tab = getActiveTab(false);
|
||||
if (tab) {
|
||||
tab.parent.split("lr").addTab(copyTab(app, tab));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (command === "splitTB") {
|
||||
const tab = getActiveTab(false);
|
||||
if (tab) {
|
||||
tab.parent.split("tb").addTab(copyTab(app, tab));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (command === "splitMoveB" || command === "splitMoveR") {
|
||||
const tab = getActiveTab(false);
|
||||
if (tab && tab.parent.children.length > 1) {
|
||||
const newWnd = tab.parent.split(command === "splitMoveB" ? "tb" : "lr");
|
||||
newWnd.headersElement.append(tab.headElement);
|
||||
newWnd.headersElement.parentElement.classList.remove("fn__none");
|
||||
newWnd.moveTab(tab);
|
||||
resizeTabs();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (command === "tabToWindow") {
|
||||
const tab = getActiveTab(false);
|
||||
if (tab) {
|
||||
openNewWindow(tab);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// #endif
|
||||
|
||||
switch (command) {
|
||||
|
|
|
@ -59,10 +59,10 @@ export const commandPanel = (app: App) => {
|
|||
"goForward", "goToEditTabNext", "goToEditTabPrev", "goToTab1", "goToTab2", "goToTab3", "goToTab4",
|
||||
"goToTab5", "goToTab6", "goToTab7", "goToTab8", "goToTab9", "goToTabNext", "goToTabPrev", "lockScreen",
|
||||
"mainMenu", "move", "newFile", "recentDocs", "replace", "riffCard", "search", "selectOpen1", "syncNow",
|
||||
|
||||
"splitLR", "splitMoveB", "splitMoveR", "splitTB", "stickSearch", "tabToWindow",
|
||||
"toggleDock", "toggleWin"];
|
||||
|
||||
"splitLR", "splitMoveB", "splitMoveR", "splitTB", "tabToWindow", "stickSearch", "toggleDock"];
|
||||
/// #if !BROWSER
|
||||
keys.push("toggleWin");
|
||||
/// #endif
|
||||
/// #endif
|
||||
if (keys.includes(key)) {
|
||||
html += `<li class="b3-list-item" data-command="${key}">
|
||||
|
|
|
@ -1514,44 +1514,36 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
|||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if ((
|
||||
matchHotKey(window.siyuan.config.keymap.general.splitLR.custom, event) ||
|
||||
matchHotKey(window.siyuan.config.keymap.general.splitMoveR.custom, event) ||
|
||||
matchHotKey(window.siyuan.config.keymap.general.splitTB.custom, event) ||
|
||||
matchHotKey(window.siyuan.config.keymap.general.tabToWindow.custom, event) ||
|
||||
matchHotKey(window.siyuan.config.keymap.general.splitMoveB.custom, event)
|
||||
) && !event.repeat) {
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.splitLR.custom, event) && !event.repeat) {
|
||||
event.preventDefault();
|
||||
const tab = getActiveTab(false);
|
||||
if (tab) {
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.tabToWindow.custom, event)) {
|
||||
openNewWindow(tab);
|
||||
} else if (matchHotKey(window.siyuan.config.keymap.general.splitLR.custom, event)) {
|
||||
tab.parent.split("lr").addTab(copyTab(app, tab));
|
||||
} else if (matchHotKey(window.siyuan.config.keymap.general.splitTB.custom, event)) {
|
||||
tab.parent.split("tb").addTab(copyTab(app, tab));
|
||||
} else if (tab.parent.children.length > 1) {
|
||||
const newWnd = tab.parent.split(matchHotKey(window.siyuan.config.keymap.general.splitMoveB.custom, event) ? "tb" : "lr");
|
||||
newWnd.headersElement.append(tab.headElement);
|
||||
newWnd.headersElement.parentElement.classList.remove("fn__none");
|
||||
newWnd.moveTab(tab);
|
||||
resizeTabs();
|
||||
}
|
||||
}
|
||||
globalCommand("splitLR", app);
|
||||
return;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.splitMoveR.custom, event) && !event.repeat) {
|
||||
event.preventDefault();
|
||||
globalCommand("splitMoveR", app);
|
||||
return;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.splitTB.custom, event) && !event.repeat) {
|
||||
event.preventDefault();
|
||||
globalCommand("splitTB", app);
|
||||
return;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.tabToWindow.custom, event) && !event.repeat) {
|
||||
event.preventDefault();
|
||||
globalCommand("tabToWindow", app);
|
||||
return;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.splitMoveB.custom, event) && !event.repeat) {
|
||||
event.preventDefault();
|
||||
globalCommand("splitMoveB", app);
|
||||
return;
|
||||
}
|
||||
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.stickSearch.custom, event)) {
|
||||
if (getSelection().rangeCount > 0) {
|
||||
const range = getSelection().getRangeAt(0);
|
||||
openGlobalSearch(app, range.toString(), true);
|
||||
} else {
|
||||
openGlobalSearch(app, "", true);
|
||||
}
|
||||
globalCommand("stickSearch", app);
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
if (editKeydown(app, event)) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue