const NODE_COLOR = "red";
import nodeImages from "../../nodeIconSetting";
export default function registeralgorithm(lf) {
  lf.register("algorithm", ({ HtmlNode, HtmlNodeModel }) => {
    class UmlModel extends HtmlNodeModel {
      setAttributes() {
        console.log(this.text,"text")
        this.text.editable = false; // 禁止节点文本编辑
        this.text.value = "";
        // 设置节点宽高和锚点
        const width = 132;
        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;
        const el = document.createElement("div");
        el.className = "uml-wrapper";
        const html = `
        <img src=${
          nodeImages[properties.breif].hover
        } width="17px" height="16px"/>
        <div class="uml-name">${properties.algName}
        </div>
    `;
        el.innerHTML = html;
        // 需要先把之前渲染的子节点清除掉。
        rootEl.innerHTML = "";
        rootEl.appendChild(el);
      }
    }
    return {
      view: UmlNode,
      model: UmlModel,
    };
  });
}
