mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-01 18:30:16 +01:00
This commit is contained in:
parent
e14ca5799b
commit
73505073e6
12 changed files with 42 additions and 59 deletions
|
|
@ -682,7 +682,7 @@ export class Wnd {
|
|||
model.send("closews", {});
|
||||
}
|
||||
|
||||
private removeTabAction = (id: string, closeAll = false, hasSaveScroll = true, animate = true) => {
|
||||
private removeTabAction = (id: string, closeAll = false, animate = true) => {
|
||||
clearCounter();
|
||||
this.children.find((item, index) => {
|
||||
if (item.id === id) {
|
||||
|
|
@ -691,7 +691,7 @@ export class Wnd {
|
|||
item.model.beforeDestroy();
|
||||
}
|
||||
}
|
||||
if (item.model instanceof Editor && hasSaveScroll) {
|
||||
if (item.model instanceof Editor) {
|
||||
saveScroll(item.model.editor.protyle);
|
||||
}
|
||||
if (this.children.length === 1) {
|
||||
|
|
@ -787,7 +787,7 @@ export class Wnd {
|
|||
/// #endif
|
||||
};
|
||||
|
||||
public removeTab(id: string, closeAll = false, needSaveScroll = true, animate = true) {
|
||||
public removeTab(id: string, closeAll = false, animate = true) {
|
||||
for (let index = 0; index < this.children.length; index++) {
|
||||
const item = this.children[index];
|
||||
if (item.id === id) {
|
||||
|
|
@ -796,9 +796,9 @@ export class Wnd {
|
|||
showMessage(window.siyuan.languages.uploading);
|
||||
return;
|
||||
}
|
||||
this.removeTabAction(id, closeAll, needSaveScroll, animate);
|
||||
this.removeTabAction(id, closeAll, animate);
|
||||
} else {
|
||||
this.removeTabAction(id, closeAll, needSaveScroll, animate);
|
||||
this.removeTabAction(id, closeAll, animate);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -304,10 +304,6 @@ export const copyTab = (app: App, tab: Tab) => {
|
|||
} else if (!tab.model && tab.headElement) {
|
||||
const initData = JSON.parse(tab.headElement.getAttribute("data-initdata") || "{}");
|
||||
if (initData) {
|
||||
// 历史数据兼容 2023-05-24
|
||||
if (initData.scrollAttr) {
|
||||
initData.scrollAttr.rootId = initData.rootId;
|
||||
}
|
||||
model = newModelByInitData(app, newTab, initData);
|
||||
}
|
||||
}
|
||||
|
|
@ -320,7 +316,7 @@ export const closeTabByType = async (tab: Tab, type: "closeOthers" | "closeAll"
|
|||
if (type === "closeOthers") {
|
||||
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")) {
|
||||
await 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, false);
|
||||
index--;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
|
|||
if (window.siyuan.config.fileTree.closeTabsOnStart && isStart) {
|
||||
getAllTabs().forEach(item => {
|
||||
if (item.headElement && !item.headElement.classList.contains("item--pin")) {
|
||||
item.parent.removeTab(item.id, false, false, false);
|
||||
item.parent.removeTab(item.id, false, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -402,7 +402,7 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
|
|||
const tabId = item.getAttribute("data-id");
|
||||
const tab = getInstanceById(tabId) as Tab;
|
||||
if (tab) {
|
||||
tab.parent.removeTab(tabId, false, false, false);
|
||||
tab.parent.removeTab(tabId, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -643,10 +643,10 @@ export const newModelByInitData = (app: App, tab: Tab, json: any) => {
|
|||
model = new Editor({
|
||||
app,
|
||||
tab,
|
||||
rootId: json.rootId,
|
||||
blockId: json.blockId,
|
||||
mode: json.mode,
|
||||
action: typeof json.action === "string" ? [json.action] : json.action,
|
||||
scrollAttr: json.scrollAttr,
|
||||
});
|
||||
}
|
||||
return model;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue