This commit is contained in:
Vanessa 2023-11-17 11:13:53 +08:00
parent 2e8463949f
commit c0266ffeb4
4 changed files with 20 additions and 14 deletions

View file

@ -874,6 +874,9 @@ export class Wnd {
}
tab.parent = this;
hideAllElements(["toolbar"]);
/// #if !BROWSER
setTabPosition();
/// #endif
}
public split(direction: TDirection) {

View file

@ -11,6 +11,7 @@ import {Bookmark} from "./dock/Bookmark";
import {Tag} from "./dock/Tag";
import {Custom} from "./dock/Custom";
import {Protyle} from "../protyle";
import {Wnd} from "./Wnd";
export const getAllEditor = () => {
const models = getAllModels();
@ -96,6 +97,17 @@ export const getAllModels = () => {
return models;
};
export const getAllWnds = (layout: Layout, wnds: Wnd[]) => {
for (let i = 0; i < layout.children.length; i++) {
const item = layout.children[i];
if (item instanceof Wnd) {
wnds.push(item);
} else if (item instanceof Layout) {
getAllWnds(item, wnds);
}
}
};
export const getAllTabs = () => {
const tabs: Tab[] = [];
const getTabs = (layout: Layout) => {

View file

@ -9,6 +9,7 @@ import {copySubMenu} from "./commonMenuItem";
import {App} from "../index";
import {Layout} from "../layout";
import {Wnd} from "../layout/Wnd";
import {getAllWnds} from "../layout/getAll";
const closeMenu = (tab: Tab) => {
const unmodifiedTabs: Tab[] = [];
@ -130,7 +131,9 @@ const splitSubMenu = (app: App, tab: Tab) => {
}
});
}
if (tab.parent.parent.children.length > 1) {
const wndsTemp: Wnd[] = [];
getAllWnds(window.siyuan.layout.layout, wndsTemp);
if (wndsTemp.length > 1) {
subMenus.push({
label: window.siyuan.languages.unsplit,
click: () => {

View file

@ -1,23 +1,11 @@
import {isWindow} from "../util/functions";
import {Wnd} from "../layout/Wnd";
import {Layout} from "../layout";
import {getAllTabs} from "../layout/getAll";
import {getAllTabs, getAllWnds} from "../layout/getAll";
import {Editor} from "../editor";
import {Asset} from "../asset";
import {Constants} from "../constants";
import { ipcRenderer } from "electron";
const getAllWnds = (layout: Layout, wnds: Wnd[]) => {
for (let i = 0; i < layout.children.length; i++) {
const item = layout.children[i];
if (item instanceof Wnd) {
wnds.push(item);
} else if (item instanceof Layout) {
getAllWnds(item, wnds);
}
}
};
export const setTabPosition = () => {
if (!isWindow()) {
return;