mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-05 12:20:16 +01:00
This commit is contained in:
parent
16727cd8af
commit
8a2122c276
6 changed files with 63 additions and 3 deletions
|
|
@ -7,6 +7,8 @@ import {openNewWindow} from "../window/openNewWindow";
|
|||
/// #endif
|
||||
import {copySubMenu} from "./commonMenuItem";
|
||||
import {App} from "../index";
|
||||
import {Layout} from "../layout";
|
||||
import {Wnd} from "../layout/Wnd";
|
||||
|
||||
const closeMenu = (tab: Tab) => {
|
||||
const unmodifiedTabs: Tab[] = [];
|
||||
|
|
@ -73,7 +75,7 @@ const closeMenu = (tab: Tab) => {
|
|||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.closeRight,
|
||||
accelerator: window.siyuan.config.keymap.general.closeRight.custom,
|
||||
click () {
|
||||
click() {
|
||||
closeTabByType(tab, "other", rightTabs);
|
||||
}
|
||||
}).element);
|
||||
|
|
@ -128,6 +130,33 @@ const splitSubMenu = (app: App, tab: Tab) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
let wndCounter = 0;
|
||||
tab.parent.parent.children.find(item => {
|
||||
if (item instanceof Wnd) {
|
||||
wndCounter++;
|
||||
}
|
||||
if (wndCounter > 1) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (wndCounter > 1) {
|
||||
subMenus.push({
|
||||
label: window.siyuan.languages.unsplit,
|
||||
click: () => {
|
||||
unsplitWnd(tab.parent.parent.children[0], tab.parent.parent);
|
||||
resizeTabs();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (tab.parent.parent.children.length > 1) {
|
||||
subMenus.push({
|
||||
label: window.siyuan.languages.unsplitAll,
|
||||
click: () => {
|
||||
unsplitWnd(window.siyuan.layout.centerLayout, window.siyuan.layout.centerLayout);
|
||||
resizeTabs();
|
||||
}
|
||||
});
|
||||
}
|
||||
return subMenus;
|
||||
};
|
||||
|
||||
|
|
@ -187,3 +216,24 @@ export const initTabMenu = (app: App, tab: Tab) => {
|
|||
/// #endif
|
||||
return window.siyuan.menus.menu;
|
||||
};
|
||||
|
||||
const unsplitWnd = (target: Wnd | Layout, layout: Layout) => {
|
||||
let wnd: Wnd = target as Wnd;
|
||||
while (wnd instanceof Layout) {
|
||||
wnd = wnd.children[0] as Wnd;
|
||||
}
|
||||
for (let i = 0; i < layout.children.length; i++) {
|
||||
const item = layout.children[i];
|
||||
if (item instanceof Layout) {
|
||||
unsplitWnd(wnd, item);
|
||||
} else if (item instanceof Wnd && item.id !== wnd.id && item.children.length > 0) {
|
||||
for (let j = 0; j < item.children.length; j++) {
|
||||
const tab = item.children[j];
|
||||
wnd.headersElement.append(tab.headElement);
|
||||
wnd.moveTab(tab);
|
||||
j--;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue