mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
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 {openRecentDocs} from "../../../business/openRecentDocs";
|
||||||
import {openSearch} from "../../../search/spread";
|
import {openSearch} from "../../../search/spread";
|
||||||
import {goBack, goForward} from "../../../util/backForward";
|
import {goBack, goForward} from "../../../util/backForward";
|
||||||
import {getAllTabs} from "../../../layout/getAll";
|
import {getAllTabs, getAllWnds} from "../../../layout/getAll";
|
||||||
import {getInstanceById} from "../../../layout/util";
|
import {getInstanceById} from "../../../layout/util";
|
||||||
import {
|
import {
|
||||||
closeTabByType,
|
closeTabByType,
|
||||||
|
|
@ -39,6 +39,8 @@ import {lockScreen} from "../../../dialog/processSystem";
|
||||||
import {newFile} from "../../../util/newFile";
|
import {newFile} from "../../../util/newFile";
|
||||||
import {openCard} from "../../../card/openCard";
|
import {openCard} from "../../../card/openCard";
|
||||||
import {syncGuide} from "../../../sync/syncGuide";
|
import {syncGuide} from "../../../sync/syncGuide";
|
||||||
|
import {Wnd} from "../../../layout/Wnd";
|
||||||
|
import {unsplitWnd} from "../../../menus/tab";
|
||||||
|
|
||||||
const selectOpenTab = () => {
|
const selectOpenTab = () => {
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
|
|
@ -234,6 +236,29 @@ export const globalCommand = (command: string, app: App) => {
|
||||||
}
|
}
|
||||||
return true;
|
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") {
|
if (command === "closeTab") {
|
||||||
const activeTabElement = document.querySelector(".layout__tab--active");
|
const activeTabElement = document.querySelector(".layout__tab--active");
|
||||||
if (activeTabElement && activeTabElement.getBoundingClientRect().width > 0) {
|
if (activeTabElement && activeTabElement.getBoundingClientRect().width > 0) {
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,8 @@ export const commandPanel = (app: App) => {
|
||||||
"goForward", "goToEditTabNext", "goToEditTabPrev", "goToTab1", "goToTab2", "goToTab3", "goToTab4",
|
"goForward", "goToEditTabNext", "goToEditTabPrev", "goToTab1", "goToTab2", "goToTab3", "goToTab4",
|
||||||
"goToTab5", "goToTab6", "goToTab7", "goToTab8", "goToTab9", "goToTabNext", "goToTabPrev", "lockScreen",
|
"goToTab5", "goToTab6", "goToTab7", "goToTab8", "goToTab9", "goToTabNext", "goToTabPrev", "lockScreen",
|
||||||
"mainMenu", "move", "newFile", "recentDocs", "replace", "riffCard", "search", "selectOpen1", "syncNow",
|
"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
|
/// #if !BROWSER
|
||||||
keys.push("toggleWin");
|
keys.push("toggleWin");
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
|
||||||
|
|
@ -1563,6 +1563,16 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return;
|
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)) {
|
if (editKeydown(app, event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -349,6 +349,8 @@ export abstract class Constants {
|
||||||
closeRight: {default: "", custom: ""},
|
closeRight: {default: "", custom: ""},
|
||||||
tabToWindow: {default: "", custom: ""},
|
tabToWindow: {default: "", custom: ""},
|
||||||
addToDatabase: {default: "", custom: ""},
|
addToDatabase: {default: "", custom: ""},
|
||||||
|
unsplit: {default: "", custom: ""},
|
||||||
|
unsplitAll: {default: "", custom: ""},
|
||||||
},
|
},
|
||||||
editor: {
|
editor: {
|
||||||
general: {
|
general: {
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@ const splitSubMenu = (app: App, tab: Tab) => {
|
||||||
if (wndsTemp.length > 1) {
|
if (wndsTemp.length > 1) {
|
||||||
subMenus.push({
|
subMenus.push({
|
||||||
label: window.siyuan.languages.unsplit,
|
label: window.siyuan.languages.unsplit,
|
||||||
|
accelerator: window.siyuan.config.keymap.general.unsplit.custom,
|
||||||
click: () => {
|
click: () => {
|
||||||
let layout = tab.parent.parent;
|
let layout = tab.parent.parent;
|
||||||
while (layout.id !== window.siyuan.layout.centerLayout.id) {
|
while (layout.id !== window.siyuan.layout.centerLayout.id) {
|
||||||
|
|
@ -153,6 +154,7 @@ const splitSubMenu = (app: App, tab: Tab) => {
|
||||||
});
|
});
|
||||||
subMenus.push({
|
subMenus.push({
|
||||||
label: window.siyuan.languages.unsplitAll,
|
label: window.siyuan.languages.unsplitAll,
|
||||||
|
accelerator: window.siyuan.config.keymap.general.unsplitAll.custom,
|
||||||
click: () => {
|
click: () => {
|
||||||
unsplitWnd(window.siyuan.layout.centerLayout, window.siyuan.layout.centerLayout, false);
|
unsplitWnd(window.siyuan.layout.centerLayout, window.siyuan.layout.centerLayout, false);
|
||||||
resizeTabs();
|
resizeTabs();
|
||||||
|
|
@ -220,7 +222,7 @@ export const initTabMenu = (app: App, tab: Tab) => {
|
||||||
return window.siyuan.menus.menu;
|
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;
|
let wnd: Wnd = target as Wnd;
|
||||||
while (wnd instanceof Layout) {
|
while (wnd instanceof Layout) {
|
||||||
wnd = wnd.children[0] as Wnd;
|
wnd = wnd.children[0] as Wnd;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue