This commit is contained in:
parent
957906283d
commit
d0e5d2189c
5 changed files with 43 additions and 3 deletions
|
@ -15,7 +15,7 @@ import {isWindow} from "../../../util/functions";
|
|||
import {openRecentDocs} from "../../../business/openRecentDocs";
|
||||
import {openSearch} from "../../../search/spread";
|
||||
import {goBack, goForward} from "../../../util/backForward";
|
||||
import {getAllTabs} from "../../../layout/getAll";
|
||||
import {getAllTabs, getAllWnds} from "../../../layout/getAll";
|
||||
import {getInstanceById} from "../../../layout/util";
|
||||
import {
|
||||
closeTabByType,
|
||||
|
@ -39,6 +39,8 @@ import {lockScreen} from "../../../dialog/processSystem";
|
|||
import {newFile} from "../../../util/newFile";
|
||||
import {openCard} from "../../../card/openCard";
|
||||
import {syncGuide} from "../../../sync/syncGuide";
|
||||
import {Wnd} from "../../../layout/Wnd";
|
||||
import {unsplitWnd} from "../../../menus/tab";
|
||||
|
||||
const selectOpenTab = () => {
|
||||
/// #if MOBILE
|
||||
|
@ -234,6 +236,29 @@ export const globalCommand = (command: string, app: App) => {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
if (command === "unsplitAll") {
|
||||
unsplitWnd(window.siyuan.layout.centerLayout, window.siyuan.layout.centerLayout, false);
|
||||
return true;
|
||||
}
|
||||
if (command === "unsplit") {
|
||||
const tab = getActiveTab(false);
|
||||
if (tab) {
|
||||
let wndsTemp: Wnd[] = [];
|
||||
let layout = tab.parent.parent;
|
||||
while (layout.id !== window.siyuan.layout.centerLayout.id) {
|
||||
wndsTemp = [];
|
||||
getAllWnds(layout, wndsTemp);
|
||||
if (wndsTemp.length > 1) {
|
||||
break;
|
||||
} else {
|
||||
layout = layout.parent;
|
||||
}
|
||||
}
|
||||
unsplitWnd(tab.parent.parent.children[0], layout, true);
|
||||
resizeTabs();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (command === "closeTab") {
|
||||
const activeTabElement = document.querySelector(".layout__tab--active");
|
||||
if (activeTabElement && activeTabElement.getBoundingClientRect().width > 0) {
|
||||
|
|
|
@ -59,7 +59,8 @@ 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", "tabToWindow", "stickSearch", "toggleDock"];
|
||||
"splitLR", "splitMoveB", "splitMoveR", "splitTB", "tabToWindow", "stickSearch", "toggleDock", "unsplitAll",
|
||||
"unsplit"];
|
||||
/// #if !BROWSER
|
||||
keys.push("toggleWin");
|
||||
/// #endif
|
||||
|
|
|
@ -1563,6 +1563,16 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
|||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.unsplit.custom, event) && !event.repeat) {
|
||||
event.preventDefault();
|
||||
globalCommand("unsplit", app);
|
||||
return;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.unsplitAll.custom, event) && !event.repeat) {
|
||||
event.preventDefault();
|
||||
globalCommand("unsplitAll", app);
|
||||
return;
|
||||
}
|
||||
if (editKeydown(app, event)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -349,6 +349,8 @@ export abstract class Constants {
|
|||
closeRight: {default: "", custom: ""},
|
||||
tabToWindow: {default: "", custom: ""},
|
||||
addToDatabase: {default: "", custom: ""},
|
||||
unsplit: {default: "", custom: ""},
|
||||
unsplitAll: {default: "", custom: ""},
|
||||
},
|
||||
editor: {
|
||||
general: {
|
||||
|
|
|
@ -136,6 +136,7 @@ const splitSubMenu = (app: App, tab: Tab) => {
|
|||
if (wndsTemp.length > 1) {
|
||||
subMenus.push({
|
||||
label: window.siyuan.languages.unsplit,
|
||||
accelerator: window.siyuan.config.keymap.general.unsplit.custom,
|
||||
click: () => {
|
||||
let layout = tab.parent.parent;
|
||||
while (layout.id !== window.siyuan.layout.centerLayout.id) {
|
||||
|
@ -153,6 +154,7 @@ const splitSubMenu = (app: App, tab: Tab) => {
|
|||
});
|
||||
subMenus.push({
|
||||
label: window.siyuan.languages.unsplitAll,
|
||||
accelerator: window.siyuan.config.keymap.general.unsplitAll.custom,
|
||||
click: () => {
|
||||
unsplitWnd(window.siyuan.layout.centerLayout, window.siyuan.layout.centerLayout, false);
|
||||
resizeTabs();
|
||||
|
@ -220,7 +222,7 @@ export const initTabMenu = (app: App, tab: Tab) => {
|
|||
return window.siyuan.menus.menu;
|
||||
};
|
||||
|
||||
const unsplitWnd = (target: Wnd | Layout, layout: Layout, onlyWnd: boolean) => {
|
||||
export const unsplitWnd = (target: Wnd | Layout, layout: Layout, onlyWnd: boolean) => {
|
||||
let wnd: Wnd = target as Wnd;
|
||||
while (wnd instanceof Layout) {
|
||||
wnd = wnd.children[0] as Wnd;
|
||||
|
|
Loading…
Add table
Reference in a new issue