import nodeImages from "../../nodeIconSetting";
export default function registerEnd(lf) {
  lf.register("end", ({ HtmlNode, HtmlNodeModel, h }) => {
    class UmlModel extends HtmlNodeModel {
      setAttributes() {
        this.text.editable = false; // 禁止节点文本编辑
        this.text.value = "";
        // 设置节点宽高和锚点
        const width = 92;
        const height = 37;
        this.width = width;
        this.height = height;
        this.anchorsOffset = [
          [width / 2, 0],
          [0, height / 2],
          [-width / 2, 0],
          [0, -height / 2],
        ];
      }
    }
    class UmlNode extends HtmlNode {
      setHtml(rootEl) {
        const { properties } = this.props.model;
        console.log(properties);
        const el = document.createElement("div");
        el.className = "uml-wrapper";
        const html = `
        <img src=${
          nodeImages[properties.type].hover
        } width="17px" height="16px"/>
        <div class="uml-name">结束
        </div>
    `;
        el.innerHTML = html;
        // 需要先把之前渲染的子节点清除掉。
        rootEl.innerHTML = "";
        rootEl.appendChild(el);
      }
    }
    return {
      view: UmlNode,
      model: UmlModel,
    };
  });
}
