This commit is contained in:
Vanessa 2023-10-25 17:34:45 +08:00
parent 0664aebe15
commit e32c8f8c1c
2 changed files with 13 additions and 13 deletions

View file

@ -178,7 +178,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
} }
}); });
} }
const activeTab = getActiveTab() const activeTab = getActiveTab();
if (!protyle && activeTab) { if (!protyle && activeTab) {
if (activeTab.model instanceof Editor) { if (activeTab.model instanceof Editor) {
protyle = activeTab.model.editor.protyle; protyle = activeTab.model.editor.protyle;
@ -1435,7 +1435,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
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(false); 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) => {
const editor = item.model as Editor; const editor = item.model as Editor;
if (!editor || (editor.editor?.protyle && !editor.editor?.protyle.updated)) { if (!editor || (editor.editor?.protyle && !editor.editor?.protyle.updated)) {

View file

@ -43,21 +43,21 @@ export const getActiveTab = (wndActive = true) => {
export const switchTabByIndex = (index: number) => { export const switchTabByIndex = (index: number) => {
const activeDockIcoElement = document.querySelector(".dock .dock__item--activefocus"); const activeDockIcoElement = document.querySelector(".dock .dock__item--activefocus");
if (activeDockIcoElement) { if (activeDockIcoElement) {
let indexElement = activeDockIcoElement.parentElement.children[index] let indexElement = activeDockIcoElement.parentElement.children[index];
if (index === -1) { if (index === -1) {
// 最后一个 // 最后一个
indexElement = activeDockIcoElement.parentElement.lastElementChild indexElement = activeDockIcoElement.parentElement.lastElementChild;
if (!indexElement.getAttribute("data-type")) { if (!indexElement.getAttribute("data-type")) {
indexElement = indexElement.previousElementSibling indexElement = indexElement.previousElementSibling;
} }
} else if (index === -2) { } else if (index === -2) {
// 上一个 // 上一个
indexElement = activeDockIcoElement.previousElementSibling indexElement = activeDockIcoElement.previousElementSibling;
} else if (index === -3) { } else if (index === -3) {
// 下一个 // 下一个
indexElement = activeDockIcoElement.nextElementSibling indexElement = activeDockIcoElement.nextElementSibling;
} }
const type = indexElement?.getAttribute("data-type") const type = indexElement?.getAttribute("data-type");
if (type) { if (type) {
getDockByType(type)?.toggleModel(type, true, false); getDockByType(type)?.toggleModel(type, true, false);
} }
@ -65,23 +65,23 @@ export const switchTabByIndex = (index: number) => {
} }
const tab = getActiveTab(false); const tab = getActiveTab(false);
if (tab) { if (tab) {
let indexElement = tab.parent.headersElement.children[index] let indexElement = tab.parent.headersElement.children[index];
if (index === -1) { if (index === -1) {
// 最后一个 // 最后一个
indexElement = tab.parent.headersElement.lastElementChild indexElement = tab.parent.headersElement.lastElementChild;
} else if (index === -2) { } else if (index === -2) {
// 上一个 // 上一个
indexElement = tab.headElement.previousElementSibling indexElement = tab.headElement.previousElementSibling;
} else if (index === -3) { } else if (index === -3) {
// 下一个 // 下一个
indexElement = tab.headElement.nextElementSibling indexElement = tab.headElement.nextElementSibling;
} }
if (indexElement) { if (indexElement) {
tab.parent.switchTab(indexElement as HTMLElement, true); tab.parent.switchTab(indexElement as HTMLElement, true);
tab.parent.showHeading(); tab.parent.showHeading();
} }
} }
} };
let resizeTimeout: number; let resizeTimeout: number;
export const resizeTabs = () => { export const resizeTabs = () => {