import ModuleCollection from './ModuleCollection'; import ModuleModel from './ModuleModel'; import { IBaseModule } from './Module'; import { View } from '../common'; import EditorModel from '../editor/model/Editor'; type ModuleFromModel = TModel extends ModuleModel ? M : unknown; type ModuleModelExt = TItem extends ModuleCollection ? ModuleFromModel : TItem extends ModuleModel ? M : unknown; // type TCollection = TItem extends ModuleCollection ? TItem : unknown; export default class ModuleView< TModel extends ModuleModel | ModuleCollection = ModuleModel, TElement extends Element = HTMLElement > extends View { protected get pfx() { return this.ppfx + (this.config as any).stylePrefix || ''; } protected get ppfx() { return this.em.config.stylePrefix || ''; } collection!: TModel extends ModuleModel ? ModuleCollection : TModel; protected get module(): ModuleModelExt { return (this.model as any)?.module ?? this.collection.module; } protected get em(): EditorModel { return this.module.em; } protected get config(): ModuleModelExt extends IBaseModule ? C : unknown { return this.module.config as any; } public className!: string; preinitialize(options?: any) { this.className = ''; } }