import {HtmlNode, HtmlNodeModel} from '@logicflow/core'
class DataView extends HtmlNode {
setHtml(rootEl) {
super.setHtml(rootEl);
const {properties: {name = "实体对象", props = []}} = this.props.model
const el = document.createElement('div');
el.className = 'modelElement';
el.innerHTML = `
${name}
${props.map(e => `
${e.prop} ${e.name}
`).join('')}
`;
rootEl.innerHTML = ''
rootEl.appendChild(el);
this.props.model.height = el.offsetHeight
}
}
class DataModel extends HtmlNodeModel {
setAttributes() {
this.text.editable = false
this.width = 160
}
}
export class ModelElement {
static pluginName = "modelElement";
constructor({lf}) {
this.lf = lf
lf.register({type: "model", model: DataModel, view: DataView})
}
}