This commit is contained in:
Vanessa 2023-12-21 11:24:53 +08:00
parent 698615473e
commit aa1a2728b0
6 changed files with 104 additions and 11 deletions

View file

@ -5,10 +5,12 @@ import {isMobile, isWindow} from "../util/functions";
/// #if !MOBILE
import {Custom} from "../layout/dock/Custom";
import {getAllModels} from "../layout/getAll";
/// #endif
import {Tab} from "../layout/Tab";
import {setPanelFocus} from "../layout/util";
import {getDockByType} from "../layout/tabUtil";
///#else
import {MobileCustom} from "../mobile/dock/MobileCustom";
/// #endif
import {hasClosestByAttribute} from "../protyle/util/hasClosest";
import {BlockPanel} from "../block/Panel";
import {Setting} from "./Setting";
@ -45,12 +47,14 @@ export class Plugin {
/// #endif
} = {};
public docks: {
/// #if !MOBILE
[key: string]: {
config: IPluginDockTab,
/// #if !MOBILE
model: (options: { tab: Tab }) => Custom
/// #else
mobileModel: (element: Element) => MobileCustom
/// #endif
}
/// #endif
} = {};
constructor(options: {
@ -238,13 +242,25 @@ export class Plugin {
update?: () => void,
init: () => void
}) {
/// #if !MOBILE
const type2 = this.name + options.type;
if (typeof options.config.index === "undefined") {
options.config.index = 1000;
}
this.docks[type2] = {
config: options.config,
/// #if MOBILE
mobileModel: (element) => {
const customObj = new MobileCustom({
element,
type: type2,
data: options.data,
init: options.init,
update: options.update,
destroy: options.destroy,
});
return customObj;
},
/// #else
model: (arg: { tab: Tab }) => {
const customObj = new Custom({
app: this.app,
@ -265,9 +281,9 @@ export class Plugin {
customObj.element.classList.add("sy__" + type2);
return customObj;
}
/// #endif
};
return this.docks[type2];
/// #endif
}
public addFloatLayer = (options: {