Skip to content
项目

excalidraw/mermaid-to-excalidraw

在 GitHub 查看

关于

从 Mermaid 生成 Excalidraw 图表

设计与媒体

这些数字如何统计

可以做什么

  • ✏️ Editable result: nodes become shapes, edges become arrows bound to them, labels stay where the layout put them.
  • 📊 Many diagram types: flowcharts (including swimlane-beta), sequence, class, ER and state diagrams, Gantt charts, quadrant charts and timelines. Other types are inserted as an image.
  • 🎨 Styles carry over: style, classDef and class colors, click links, and edges as elbow arrows on request.
  • ⚡ No Mermaid runtime: Pele parses and lays diagrams out without rendering them into the page, and each diagram type's code loads on first use.

实测星标增长

24小时
+1
7天
+1
15天
+3
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Mermaid to Excalidraw: turn Mermaid diagrams into shapes, arrows and text you can keep editing

Documentation · Playground · npm · Excalidraw+ · Excalidraw

npm license

Convert Mermaid diagram definitions into Excalidraw elements: shapes, arrows and text you can keep editing, not a picture of the diagram. It's what excalidraw.com runs when you paste a Mermaid definition onto the canvas.

Features

  • ✏️ Editable result: nodes become shapes, edges become arrows bound to them, labels stay where the layout put them.
  • 📊 Many diagram types: flowcharts (including swimlane-beta), sequence, class, ER and state diagrams, Gantt charts, quadrant charts and timelines. Other types are inserted as an image.
  • 🎨 Styles carry over: style, classDef and class colors, click links, and edges as elbow arrows on request.
  • ⚡ No Mermaid runtime: Pele parses and lays diagrams out without rendering them into the page, and each diagram type's code loads on first use.

Install

npm install @excalidraw/mermaid-to-excalidraw @excalidraw/excalidraw

It needs DOM APIs (DOMParser), so run it in a browser or with jsdom.

Quick start

import { parseMermaidToExcalidraw } from "@excalidraw/mermaid-to-excalidraw";
import { convertToExcalidrawElements } from "@excalidraw/excalidraw";

const definition = `flowchart LR
  A[Write the definition] --> B{Valid?}
  B -->|yes| C[Excalidraw elements]
  B -->|no| D[Parse error]`;

try {
  const { elements, files } = await parseMermaidToExcalidraw(definition, {
    elbow: true, // optional: draw edges as elbow arrows
  });

  excalidrawAPI.updateScene({
    elements: convertToExcalidrawElements(elements),
  });
  if (files) {
    excalidrawAPI.addFiles(Object.values(files));
  }
} catch (error) {
  // Not valid Mermaid syntax: show the error to the user
}

No code needed? The Excalidraw CLI runs it from your terminal: npx @excalidraw/cli mermaid flow.mmd --out flow.excalidraw.

Documentation

📚 plus.excalidraw.com/docs/mermaid-to-excalidraw

What changed in each release is in the changelog.

Contributing

See CONTRIBUTING.md for running the playground and the tests.

License

MIT

探索相关项目

加载中…