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