mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-03 11:20:16 +01:00
🚨
This commit is contained in:
parent
1744d6b5cd
commit
580fb4007e
6 changed files with 37 additions and 33 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue