MMEditor

MMEditor 是一个基于 SVG 的流程图编辑器,适合承载节点编排、依赖关系展示、流程配置和图形化编辑场景。

项目定位

快速开始

npm 集成

npm install mmeditor
import MMEditor from "mmeditor";

const editor = new MMEditor({
  dom: document.getElementById("root") as HTMLDivElement,
  showMiniMap: true,
});

await editor.schema.setInitData({
  nodes: [
    {
      uuid: "start",
      type: "default",
      name: "Start",
      x: 40,
      y: 40,
    },
    {
      uuid: "end",
      type: "default",
      name: "End",
      x: 260,
      y: 180,
    },
  ],
  lines: [
    {
      from: "start",
      to: "end",
      fromPoint: 1,
      toPoint: 0,
    },
  ],
});

editor.schema.format();
editor.controller.autoFit();

console.log(editor.schema.getData());

浏览器脚本方式

npm install
npm run build:browser
open public/basic.html

public/basic.html 会直接加载 dist/MMEditor.browser.js,适合验证全局变量接入链路。

核心概念

文档入口

示例入口

典型工作流

  1. 创建编辑器实例并挂载容器。
  2. 通过 schema.setInitData 或 graph.node.addNode / graph.line.addLine 写入图数据。
  3. 通过 schema.format 和 controller.autoFit 完成布局与视口定位。
  4. 通过 graph.on 或 editor.on 监听交互事件,接入业务状态。
  5. 通过 schema.getData 导出结果,或用 undo / redo 管理历史。

集成方式

二次开发方式

构建与开发

npm install
npm start
npm run lint
npm test
npm run build
npm run build:browser
npm run makeDts
npm run build:all

迁移说明

已知边界

License

ISC