This commit is contained in:
Vanessa 2023-05-24 20:06:32 +08:00
parent 1744d6b5cd
commit 580fb4007e
6 changed files with 37 additions and 33 deletions

View file

@ -434,7 +434,7 @@ export class Wnd {
if (currentTab && currentTab.headElement) {
const initData = currentTab.headElement.getAttribute("data-initdata");
if (initData) {
currentTab.addModel(newModelByInitData(this.app, currentTab, JSON.parse(initData)))
currentTab.addModel(newModelByInitData(this.app, currentTab, JSON.parse(initData)));
currentTab.headElement.removeAttribute("data-initdata");
return;
}

View file

@ -65,23 +65,23 @@ export class Dock {
this.position = options.position;
this.pin = options.data.pin;
this.data = {};
let showDock = false
let showDock = false;
if (options.data.data.length !== 0) {
if (!showDock) {
options.data.data[0].find(item => {
if (TYPES.includes(item.type)) {
showDock = true
return true
showDock = true;
return true;
}
})
});
}
if (!showDock && options.data.data[1]) {
options.data.data[1].find(item => {
if (TYPES.includes(item.type)) {
showDock = true
return true
showDock = true;
return true;
}
})
});
}
}
if (!showDock) {

View file

@ -408,20 +408,20 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
});
// 移除没有插件的 tab
document.querySelectorAll('li[data-type="tab-header"]').forEach((item: HTMLElement) => {
const initData = item.getAttribute("data-initdata")
const initData = item.getAttribute("data-initdata");
if (initData) {
const initDataObj = JSON.parse(initData);
if (initDataObj.instance === "Custom") {
let hasPlugin = false;
app.plugins.find(plugin => {
if (Object.keys(plugin.models).includes(initDataObj.customModelType)) {
hasPlugin = true
return true
hasPlugin = true;
return true;
}
});
if (!hasPlugin) {
const tabId = item.getAttribute("data-id")
const tab = getInstanceById(tabId) as Tab
const tabId = item.getAttribute("data-id");
const tab = getInstanceById(tabId) as Tab;
if (tab) {
tab.parent.removeTab(tabId, false, false, false);
}
@ -440,7 +440,7 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
} else {
document.querySelectorAll('li[data-type="tab-header"][data-init-active="true"]').forEach((item: HTMLElement) => {
item.removeAttribute("data-init-active");
const tab = getInstanceById(item.getAttribute("data-id")) as Tab
const tab = getInstanceById(item.getAttribute("data-id")) as Tab;
tab.parent.switchTab(item, false, false);
});
}
@ -719,14 +719,14 @@ export const copyTab = (app: App, tab: Tab) => {
};
export const newModelByInitData = (app: App, tab: Tab, json: any) => {
let model: Model
let model: Model;
if (json.instance === "Custom") {
if (json.customModelType === "siyuan-card") {
model = newCardModel({
app,
tab: tab,
data: json.customModelData
})
});
} else {
app.plugins.find(item => {
if (item.models[json.customModelType]) {
@ -749,7 +749,7 @@ export const newModelByInitData = (app: App, tab: Tab, json: any) => {
});
}
return model;
}
};
export const pdfIsLoading = (element: HTMLElement) => {
const isLoading = element.querySelector('.layout-tab-container > [data-loading="true"]') ? true : false;