index.js 677 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
import React from 'react';
import { RegisterNode } from 'gg-editor';

class KoniCustomNode extends React.Component {
  render() {
    const config = {
      draw(item) {
        const keyShape = this.drawKeyShape(item);

        // draw label
        this.drawLabel(item);

        // draw image
        const group = item.getGraphicGroup();
        const model = item.getModel();

        group.addShape('image', {
          attrs: {
            x: -7,
            y: -7,
            img: model.icon,
          },
        });

        return keyShape;
      },
    };

    return <RegisterNode name="koni-custom-node" config={config} />;
  }
}

export default KoniCustomNode;