2023-04-27 20:03:00 +08:00
|
|
|
import {Tab} from "../Tab";
|
|
|
|
|
import {Model} from "../Model";
|
2023-05-18 19:27:21 +08:00
|
|
|
import {App} from "../../index";
|
2024-04-20 23:40:29 +08:00
|
|
|
import {Protyle} from "../../protyle";
|
2023-04-27 20:03:00 +08:00
|
|
|
|
|
|
|
|
export class Custom extends Model {
|
2023-05-12 17:11:43 +08:00
|
|
|
public element: Element;
|
2023-05-23 19:29:10 +08:00
|
|
|
public tab: Tab;
|
2023-04-28 12:02:08 +08:00
|
|
|
public data: any;
|
2023-05-10 00:01:47 +08:00
|
|
|
public type: string;
|
2023-12-21 11:24:53 +08:00
|
|
|
public init: (custom: Custom) => void;
|
2023-04-28 12:02:08 +08:00
|
|
|
public destroy: () => void;
|
2023-06-13 00:08:05 +08:00
|
|
|
public beforeDestroy: () => void;
|
2023-04-28 12:02:08 +08:00
|
|
|
public resize: () => void;
|
|
|
|
|
public update: () => void;
|
2024-04-20 23:40:29 +08:00
|
|
|
public editors: Protyle[] = [];
|
2023-04-27 20:03:00 +08:00
|
|
|
|
|
|
|
|
constructor(options: {
|
2023-05-18 19:27:21 +08:00
|
|
|
app: App,
|
2023-05-10 00:01:47 +08:00
|
|
|
type: string,
|
2023-04-27 20:03:00 +08:00
|
|
|
tab: Tab,
|
|
|
|
|
data: any,
|
2023-04-28 10:30:27 +08:00
|
|
|
destroy?: () => void,
|
2023-06-13 00:08:05 +08:00
|
|
|
beforeDestroy?: () => void,
|
2023-04-28 10:30:27 +08:00
|
|
|
resize?: () => void,
|
2023-04-28 12:02:08 +08:00
|
|
|
update?: () => void,
|
2023-12-21 11:24:53 +08:00
|
|
|
init: (custom: Custom) => void
|
2023-04-27 20:03:00 +08:00
|
|
|
}) {
|
2023-05-18 19:27:21 +08:00
|
|
|
super({app: options.app, id: options.tab.id});
|
2023-04-27 20:03:00 +08:00
|
|
|
if (window.siyuan.config.fileTree.openFilesUseCurrentTab) {
|
2023-05-26 22:03:24 +08:00
|
|
|
options.tab.headElement?.classList.add("item--unupdate");
|
2023-04-27 20:03:00 +08:00
|
|
|
}
|
2023-05-23 19:29:10 +08:00
|
|
|
|
2023-04-27 20:03:00 +08:00
|
|
|
this.element = options.tab.panelElement;
|
2023-05-23 19:29:10 +08:00
|
|
|
this.tab = options.tab;
|
2023-04-28 12:02:08 +08:00
|
|
|
this.data = options.data;
|
2023-05-23 19:29:10 +08:00
|
|
|
this.type = options.type;
|
2023-04-28 12:02:08 +08:00
|
|
|
this.init = options.init;
|
2023-04-28 10:30:27 +08:00
|
|
|
this.destroy = options.destroy;
|
2023-06-13 00:08:05 +08:00
|
|
|
this.beforeDestroy = options.beforeDestroy;
|
2023-04-28 10:30:27 +08:00
|
|
|
this.resize = options.resize;
|
2023-04-28 12:02:08 +08:00
|
|
|
this.update = options.update;
|
2023-12-21 11:24:53 +08:00
|
|
|
this.init(this);
|
2023-04-27 20:03:00 +08:00
|
|
|
}
|
|
|
|
|
}
|