1.0.3 • Published 5 years ago

mxgraph-editor v1.0.3

Weekly downloads
22
License
-
Repository
github
Last release
5 years ago

mxgraph-editor

A mxGraph editor support 3 types of shapes, svg/image/card.

npm.io

development

npm install

npm start

install

npm install --save mxgraph-editor

demo

See the detail in ./demo .

start the demo

// start the demo
npm start

code

import Sidebar from './sidebar';
import Toolbar from './toolbar';

import IMAGE_SHAPES from './shape-config/image-shape';
import CARD_SHAPES from './shape-config/card-shape';
import SVG_SHAPES from './shape-config/svg-shape.xml';

import Editor from 'mxgraph-editor';

const editor = new Editor({
    container: '.graph-content',
    clickFunc: this.clickFunc,
    doubleClickFunc: this.doubleClickFunc,
    autoSaveFunc: this.autoSaveFunc,
    cellCreatedFunc: this.cellCreatedFunc,
    deleteFunc: this.deleteFunc,
    valueChangeFunc: this.valueChangeFunc,
    IMAGE_SHAPES,
    CARD_SHAPES,
    SVG_SHAPES
  });

 render() {
    return (
      <div className="editor-container">
        <Layout>
          <Sider width="235" theme="light">
            <Sidebar key="sidebar" graph={this.editor} />
          </Sider>
          <Content>
            <div className="graph-inner-container">
              <Toolbar
                graph={this.editor}
                updateDiagramData={this.updateDiagramData}
              />
              <div className="graph-content" key="graphcontent" />
            </div>
          </Content>
        </Layout>
      </div>
    );
  }

api

propertydescriptiontypedefault
SVG_SHAPESSVG shapes configArray[]
CARD_SHAPEScard shapes configArray[]
IMAGE_SHAPESimage shapes configArray[]
containercontainer dom selectorselector
clickFuncclick event callbackfunction(cell)
doubleClickFuncdouble click event callbackfunction(cell)
autoSaveFuncauto save callbackfunction(xml)
cellCreatedFunccell created callbackfunction(cell)
deleteFunccell delete callbackfunction(e)
valueChangeFunccell value change callbackfunction(value)
initSidebarinit the sidebarfunction(elements)
initCustomPortthe custom port, 10x10pxfunction((picture))
zoomzoomfunction(type),input params:in(zoom in)、out(zoom out)、actual(zoom actual)
updateStyleupdate stylefunction(cell, key, value),input params:cell,key (the key of style),value (the value of style)
groupCellsgroup cellsfunction(groupId, labelName),input params:groupId(group id),name (group label)
ungroupCellsungroup cellsfunction(cells)
getCellsSelectedget all cells selectedfunction()
getGraphXmlget the xml of graphfunction()
createVertexcreate vertexfunction(shapeLabel, x, y, width, height, shapeStyle)
insertEdgeinsert edgefunction(vertex1, vertex2)
getCellByIdget cell by idfunction(id)
getAllCellsget all cellsfunction()
refreshrefresh the graphfunction()
clearSelectionclear the selection in the graphfunction()
startPanningstart panningfunction()
stopPanningstop panningfunction()