This commit is contained in:
Vanessa 2023-11-17 10:39:25 +08:00
parent 16727cd8af
commit 8a2122c276
6 changed files with 63 additions and 3 deletions

View file

@ -1,4 +1,6 @@
{
"unsplit": "Unsplit",
"unsplitAll": "Unsplit All",
"resetCardTip": "Are you sure reset ${x} flashcards?",
"freezeCol": "Freeze column",
"unfreezeCol": "Unfreeze column",

View file

@ -1,4 +1,6 @@
{
"unsplit": "Desdividir",
"unsplitAll": "Desdividir Todo",
"resetCardTip": "¿Estás seguro de restablecer ${x} tarjetas?",
"freezeCol": "Congelar columna",
"unfreezeCol": "Descongelar columna",

View file

@ -1,4 +1,6 @@
{
"unsplit": "Unsplit",
"unsplitAll": "Tout dédiviser",
"resetCardTip": "Êtes-vous sûr de réinitialiser ${x} flashcards ?",
"freezeCol": "Geler la colonne",
"unfreezeCol": "Dégeler la colonne",

View file

@ -1,5 +1,7 @@
{
"resetCardTip": "確定重設 ${x} 條閃卡?",
"unsplit": "取消分割畫面",
"unsplitAll": "取消全部分螢幕",
"resetCardTip": "確定重設 ${x} 張閃卡?",
"freezeCol": "固定列",
"unfreezeCol": "取消列固定",
"snippetsTip": "程式碼片段已更新,是否儲存?",

View file

@ -1,5 +1,7 @@
{
"resetCardTip": "确定重置 ${x} 条闪卡?",
"unsplit": "取消分屏",
"unsplitAll": "取消全部分屏",
"resetCardTip": "确定重置 ${x} 张闪卡?",
"freezeCol": "固定列",
"unfreezeCol": "取消列固定",
"snippetsTip": "代码片段已更新,是否保存?",

View file

@ -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--;
}
}
}