Sidebar-ControlComponent.js 1.52 KB
(function () {
  Sidebar.prototype.addThingsKitControlComponentsPalette = function () {
    this.addControlComponentsPalette()
  }

  const { COMPONENT_KEY, CATEGORY } = window.CellAttributeKeyEnum

  const dt = 'controlComponents'

  Sidebar.prototype.addControlComponentsPalette = function () {

    function createUserObject(attribute) {
      attribute = Object.assign({ [COMPONENT_KEY]: '', [CATEGORY]: '' }, attribute || {})
      var xmlElement = mxUtils.createXmlDocument().createElement('UserObject');

      Object.keys(attribute).forEach(key => {
        xmlElement.setAttribute(key, attribute[key]);
      })
      return xmlElement
    }

    this.setCurrentSearchEntryLibrary(dt);

    this.addPaletteFunctions(dt, mxResources.get(dt), false,
      [
        // 开关
        this.createVertexTemplateEntry("shape=mxgraph.thingskit/switchComponent;text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;", 60, 60, createUserObject({ label: '', [COMPONENT_KEY]: 'Switch', [CATEGORY]: 'CONTROL' }), "开关", null, !0, "text textbox textarea label"),

        // 参数设置
        this.createVertexTemplateEntry("text;html=1;strokeColor=#1890ff;fillColor=#1890ff;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;fontColor=#FFFFFF;rounded=1;shadow=0;fontSize=12;", 60, 32, createUserObject({ label: '参数设置', [COMPONENT_KEY]: 'ParameterSettings', [CATEGORY]: 'CONTROL' }), "参数设置", null, !0, "text textbox textarea label"),


      ]
    );
  };

})();