mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
This commit is contained in:
parent
502d38891b
commit
0664aebe15
2 changed files with 9 additions and 20 deletions
|
|
@ -1417,7 +1417,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (matchHotKey(window.siyuan.config.keymap.general.closeOthers.custom, event) && !event.repeat) {
|
if (matchHotKey(window.siyuan.config.keymap.general.closeOthers.custom, event) && !event.repeat) {
|
||||||
const tab = getActiveTab();
|
const tab = getActiveTab(false);
|
||||||
if (tab) {
|
if (tab) {
|
||||||
closeTabByType(tab, "closeOthers");
|
closeTabByType(tab, "closeOthers");
|
||||||
}
|
}
|
||||||
|
|
@ -1425,7 +1425,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (matchHotKey(window.siyuan.config.keymap.general.closeAll.custom, event) && !event.repeat) {
|
if (matchHotKey(window.siyuan.config.keymap.general.closeAll.custom, event) && !event.repeat) {
|
||||||
const tab = getActiveTab();
|
const tab = getActiveTab(false);
|
||||||
if (tab) {
|
if (tab) {
|
||||||
closeTabByType(tab, "closeAll");
|
closeTabByType(tab, "closeAll");
|
||||||
}
|
}
|
||||||
|
|
@ -1433,7 +1433,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (matchHotKey(window.siyuan.config.keymap.general.closeUnmodified.custom, event) && !event.repeat) {
|
if (matchHotKey(window.siyuan.config.keymap.general.closeUnmodified.custom, event) && !event.repeat) {
|
||||||
const tab = getActiveTab();
|
const tab = getActiveTab(false);
|
||||||
if (tab) {
|
if (tab) {
|
||||||
const unmodifiedTabs: Tab[] = []
|
const unmodifiedTabs: Tab[] = []
|
||||||
tab.parent.children.forEach((item: Tab) => {
|
tab.parent.children.forEach((item: Tab) => {
|
||||||
|
|
@ -1451,13 +1451,12 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||||
}
|
}
|
||||||
if ((matchHotKey(window.siyuan.config.keymap.general.closeLeft.custom, event) || matchHotKey(window.siyuan.config.keymap.general.closeRight.custom, event)) &&
|
if ((matchHotKey(window.siyuan.config.keymap.general.closeLeft.custom, event) || matchHotKey(window.siyuan.config.keymap.general.closeRight.custom, event)) &&
|
||||||
!event.repeat) {
|
!event.repeat) {
|
||||||
const tab = getActiveTab();
|
const tab = getActiveTab(false);
|
||||||
if (tab) {
|
if (tab) {
|
||||||
const leftTabs: Tab[] = [];
|
const leftTabs: Tab[] = [];
|
||||||
const rightTabs: Tab[] = [];
|
const rightTabs: Tab[] = [];
|
||||||
let midIndex = -1;
|
let midIndex = -1;
|
||||||
tab.parent.children.forEach((item: Tab, index: number) => {
|
tab.parent.children.forEach((item: Tab, index: number) => {
|
||||||
const editor = item.model as Editor;
|
|
||||||
if (item.id === tab.id) {
|
if (item.id === tab.id) {
|
||||||
midIndex = index;
|
midIndex = index;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -329,23 +329,19 @@ export const closeTabByType = async (tab: Tab, type: "closeOthers" | "closeAll"
|
||||||
if (type === "closeOthers") {
|
if (type === "closeOthers") {
|
||||||
for (let index = 0; index < tab.parent.children.length; index++) {
|
for (let index = 0; index < tab.parent.children.length; index++) {
|
||||||
if (tab.parent.children[index].id !== tab.id && !tab.parent.children[index].headElement.classList.contains("item--pin")) {
|
if (tab.parent.children[index].id !== tab.id && !tab.parent.children[index].headElement.classList.contains("item--pin")) {
|
||||||
tab.parent.children[index].parent.removeTab(tab.parent.children[index].id, true, true, false);
|
await tab.parent.children[index].parent.removeTab(tab.parent.children[index].id, true, true, false);
|
||||||
|
index--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!tab.headElement.parentElement.querySelector(".item--focus")) {
|
return;
|
||||||
tab.parent.switchTab(tab.headElement, true);
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if (type === "closeAll") {
|
if (type === "closeAll") {
|
||||||
for (let index = 0; index < tab.parent.children.length; index++) {
|
for (let index = 0; index < tab.parent.children.length; index++) {
|
||||||
if (!tab.parent.children[index].headElement.classList.contains("item--pin")) {
|
if (!tab.parent.children[index].headElement.classList.contains("item--pin")) {
|
||||||
await tab.parent.children[index].parent.removeTab(tab.parent.children[index].id, true);
|
await tab.parent.children[index].parent.removeTab(tab.parent.children[index].id, true);
|
||||||
|
index--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tab.parent.children[0].headElement.parentElement) {
|
|
||||||
tab.parent.children[0].parent.switchTab(tab.parent.children[0].headElement, true);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tabs.length > 0) {
|
if (tabs.length > 0) {
|
||||||
|
|
@ -354,11 +350,5 @@ export const closeTabByType = async (tab: Tab, type: "closeOthers" | "closeAll"
|
||||||
await tabs[index].parent.removeTab(tabs[index].id);
|
await tabs[index].parent.removeTab(tabs[index].id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tab.headElement.parentElement && !tab.headElement.parentElement.querySelector(".item--focus")) {
|
|
||||||
tab.parent.switchTab(tab.headElement, true);
|
|
||||||
} else if (tab.parent.children[0].headElement.parentElement) {
|
|
||||||
tab.parent.children[0].parent.switchTab(tab.parent.children[0].headElement, true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue