mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
732c0805ca
commit
f2d015267d
6 changed files with 49 additions and 34 deletions
|
|
@ -28,6 +28,7 @@ import {objEquals} from "../util/functions";
|
|||
import {resize} from "../protyle/util/resize";
|
||||
import {Search} from "../search";
|
||||
import {App} from "../index";
|
||||
import {newCardModel} from "../card/newCardTab";
|
||||
|
||||
export const openFileById = async (options: {
|
||||
app: App,
|
||||
|
|
@ -100,7 +101,7 @@ export const openFile = (options: IOpenFileOptions) => {
|
|||
}
|
||||
} else if (options.custom) {
|
||||
const custom = allModels.custom.find((item) => {
|
||||
if (objEquals(item.data, options.custom.data)) {
|
||||
if (objEquals(item.data, options.custom.data) && (!options.custom.id || options.custom.id === item.type)) {
|
||||
if (!pdfIsLoading(item.parent.parent.element)) {
|
||||
item.parent.parent.switchTab(item.parent.headElement);
|
||||
item.parent.parent.showHeading();
|
||||
|
|
@ -427,11 +428,32 @@ const newTab = (options: IOpenFileOptions) => {
|
|||
icon: options.custom.icon,
|
||||
title: options.custom.title,
|
||||
callback(tab) {
|
||||
tab.addModel(options.custom.fn({
|
||||
app: options.app,
|
||||
tab,
|
||||
data: options.custom.data
|
||||
}));
|
||||
if (options.custom.id) {
|
||||
if (options.custom.id === "siyuan-card") {
|
||||
tab.addModel(newCardModel({
|
||||
app: options.app,
|
||||
tab,
|
||||
data: options.custom.data
|
||||
}));
|
||||
} else {
|
||||
options.app.plugins.find(p => {
|
||||
if (p.models[options.custom.id]) {
|
||||
tab.addModel(p.models[options.custom.id]({
|
||||
tab,
|
||||
data: options.custom.data
|
||||
}));
|
||||
return true;
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// plugin 0.8.3 历史兼容
|
||||
console.warn("0.8.3 将移除 custom.fn 参数,请参照 https://github.com/siyuan-note/plugin-sample/blob/91a716358941791b4269241f21db25fd22ae5ff5/src/index.ts 将其修改为 custom.id");
|
||||
tab.addModel(options.custom.fn({
|
||||
tab,
|
||||
data: options.custom.data
|
||||
}));
|
||||
}
|
||||
setPanelFocus(tab.panelElement.parentElement.parentElement);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue