mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-06 12:50:16 +01:00
🎨 https://github.com/siyuan-note/siyuan/pull/16727
Some checks failed
Release Docker Image / build (push) Has been cancelled
Some checks failed
Release Docker Image / build (push) Has been cancelled
This commit is contained in:
parent
c38f48158c
commit
d5d10dd41b
1 changed files with 21 additions and 6 deletions
|
|
@ -360,15 +360,32 @@ export const copyTab = (app: App, tab: Tab) => {
|
|||
});
|
||||
};
|
||||
|
||||
const getRootID = (item: Tab) => {
|
||||
if (item.model instanceof Editor) {
|
||||
return item.model.editor.protyle.block.rootID;
|
||||
} else if (!item.model) {
|
||||
const initTab = item.headElement.getAttribute("data-initdata");
|
||||
if (initTab) {
|
||||
try {
|
||||
const initTabData = JSON.parse(initTab);
|
||||
if (initTabData && initTabData.instance === "Editor" && initTabData.rootId) {
|
||||
return initTabData.rootId;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Failed to parse tab init data:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const closeTabByType = (tab: Tab, type: "closeOthers" | "closeAll" | "other", tabs?: Tab[]) => {
|
||||
const rootIDs: string[] = [];
|
||||
if (type === "closeOthers") {
|
||||
for (let index = 0; index < tab.parent.children.length; index++) {
|
||||
const item = tab.parent.children[index];
|
||||
if (item.id !== tab.id && !item.headElement.classList.contains("item--pin")) {
|
||||
if (item.model instanceof Editor) {
|
||||
rootIDs.push(item.model.editor.protyle.block.rootID);
|
||||
}
|
||||
rootIDs.push(getRootID(item));
|
||||
item.parent.removeTab(item.id, true, false);
|
||||
index--;
|
||||
}
|
||||
|
|
@ -377,9 +394,7 @@ export const closeTabByType = (tab: Tab, type: "closeOthers" | "closeAll" | "oth
|
|||
for (let index = 0; index < tab.parent.children.length; index++) {
|
||||
const item = tab.parent.children[index];
|
||||
if (!item.headElement.classList.contains("item--pin")) {
|
||||
if (item.model instanceof Editor) {
|
||||
rootIDs.push(item.model.editor.protyle.block.rootID);
|
||||
}
|
||||
rootIDs.push(getRootID(item));
|
||||
item.parent.removeTab(item.id, true);
|
||||
index--;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue