@print-one/grapesjs
Version:
Free and Open Source Web Builder Framework
42 lines (36 loc) • 1.09 kB
text/typescript
import DomainViews from '../../domain_abstract/view/DomainViews';
import EditorModel from '../../editor/model/Editor';
import TraitView from './TraitView';
export default class TraitsView extends DomainViews {
reuseView = true;
em: EditorModel;
pfx: string;
ppfx: string;
constructor(o: any = {}, itemsView: any) {
super(o);
this.itemsView = itemsView;
const config = o.config || {};
const em = o.editor;
this.config = config;
this.em = em;
this.ppfx = config.pStylePrefix || '';
this.pfx = this.ppfx + config.stylePrefix || '';
this.className = `${this.pfx}traits`;
this.listenTo(em, 'component:toggled', this.updatedCollection);
this.updatedCollection();
}
/**
* Update view collection
* @private
*/
updatedCollection() {
const { ppfx, className, em } = this;
const comp = em.getSelected();
this.el.className = `${className} ${ppfx}one-bg ${ppfx}two-color`;
// @ts-ignore
this.collection = comp ? comp.traits : [];
this.render();
}
}
// @ts-ignore
TraitsView.prototype.itemView = TraitView;