2023-04-27 20:03:00 +08:00
|
|
|
import {Tab} from "../Tab";
|
|
|
|
|
import {setPanelFocus} from "../util";
|
|
|
|
|
import {Model} from "../Model";
|
|
|
|
|
|
|
|
|
|
export class Custom extends Model {
|
|
|
|
|
private element: Element;
|
|
|
|
|
|
|
|
|
|
constructor(options: {
|
|
|
|
|
tab: Tab,
|
|
|
|
|
data: any,
|
2023-04-28 10:30:27 +08:00
|
|
|
destroy?: () => void,
|
|
|
|
|
resize?: () => void,
|
2023-04-27 20:03:00 +08:00
|
|
|
type: string, // 同一类型的唯一标识
|
2023-04-28 10:30:27 +08:00
|
|
|
init: (element: Element) => void
|
2023-04-27 20:03:00 +08:00
|
|
|
}) {
|
|
|
|
|
super({id: options.tab.id});
|
|
|
|
|
if (window.siyuan.config.fileTree.openFilesUseCurrentTab) {
|
|
|
|
|
options.tab.headElement.classList.add("item--unupdate");
|
|
|
|
|
}
|
|
|
|
|
this.element = options.tab.panelElement;
|
|
|
|
|
options.init(this.element);
|
|
|
|
|
this.element.addEventListener("click", () => {
|
|
|
|
|
setPanelFocus(this.element.parentElement.parentElement);
|
|
|
|
|
});
|
2023-04-28 10:30:27 +08:00
|
|
|
this.data = options.data;
|
|
|
|
|
this.destroy = options.destroy;
|
|
|
|
|
this.resize = options.resize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public destroy() {
|
|
|
|
|
if (this.destroy) {
|
|
|
|
|
this.destroy();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public resize() {
|
|
|
|
|
if (this.resize) {
|
|
|
|
|
this.resize();
|
|
|
|
|
}
|
2023-04-27 20:03:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private update() {
|
2023-04-28 10:30:27 +08:00
|
|
|
// TODO
|
2023-04-27 20:03:00 +08:00
|
|
|
}
|
|
|
|
|
}
|