Excalidraw diagram

From Gerstep/cybos · View interactive version

Excalidraw diagram is an AI agent skill from the GitHub repository Gerstep/cybos. Generate Excalidraw diagrams from text content. Supports three output modes - Obsidian (.md), Standard (.excalidraw), and Animated (.excalidraw with animation order). Triggers on "Excalidraw", "画图", "流程图", "思维导图", "可视化", "diagram", "标准Excalidraw", "standard excalidraw", "Excalidraw动画", "动画图", "anima

How to use this skill

Skill file

Excalidraw Diagram Generator

Create Excalidraw diagrams from text content with multiple output formats.

Output Modes

根据用户的触发词选择输出模式:

| 触发词 | 输出模式 | 文件格式 | 用途 |

|--------|----------|----------|------|

| Excalidraw、画图、流程图、思维导图 | Obsidian(默认) | .md | 在 Obsidian 中直接打开 |

| 标准Excalidraw、standard excalidraw | Standard | .excalidraw | 在 excalidraw.com 打开/编辑/分享 |

| Excalidraw动画、动画图、animate | Animated | .excalidraw | 拖到 excalidraw-animate 生成动画 |

Workflow

  1. Detect output mode from trigger words (see Output Modes table above)
  2. Analyze content - identify concepts, relationships, hierarchy
  3. Choose diagram type (see Diagram Types below)
  4. Generate Excalidraw JSON (add animation order if Animated mode)
  5. Output in correct format based on mode
  6. Automatically save to current working directory
  7. Notify user with file path and usage instructions

Output Formats

Mode 1: Obsidian Format (Default)

严格按照以下结构输出,不得有任何修改:

---
excalidraw-plugin: parsed
tags: [excalidraw]
---
==⚠  Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠== You can decompress Drawing data with the command palette: 'Decompress current Excalidraw file'. For more info check in plugin settings under 'Saving'

# Excalidraw Data

## Text Elements
%%
## Drawing
\`\`\`json
{JSON 完整数据}
\`\`\`
%%

关键要点:

Mode 2: Standard Excalidraw Format

直接输出纯 JSON 文件,可在 excalidraw.com 打开:

{
  "type": "excalidraw",
  "version": 2,
  "source": "https://excalidraw.com",
  "elements": [...],
  "appState": {
    "gridSize": null,
    "viewBackgroundColor": "#ffffff"
  },
  "files": {}
}

关键要点:

Mode 3: Animated Excalidraw Format

与 Standard 格式相同,但每个元素添加 customData.animate 字段控制动画顺序:

{
  "id": "element-1",
  "type": "rectangle",
  "customData": {
    "animate": {
      "order": 1,
      "duration": 500
    }
  },
  ...其他标准字段
}

动画顺序规则:

使用方法:

  1. 生成 .excalidraw 文件
  2. 拖到 https://dai-shi.github.io/excalidraw-animate/
  3. 点击 Animate 预览,然后导出 SVG 或 WebM

文件扩展名:.excalidraw


Diagram Types & Selection Guide

选择合适的图表形式,以提升理解力与视觉吸引力。

| 类型 | 英文 | 使用场景 | 做法 |

|------|------|---------|------|

| 流程图 | Flowchart | 步骤说明、工作流程、任务执行顺序 | 用箭头连接各步骤,清晰表达流程走向 |

| 思维导图 | Mind Map | 概念发散、主题分类、灵感捕捉 | 以中心为核心向外发散,放射状结构 |

| 层级图 | Hierarchy | 组织结构、内容分级、系统拆解 | 自上而下或自左至右构建层级节点 |

| 关系图 | Relationship | 要素之间的影响、依赖、互动 | 图形间用连线表示关联,箭头与说明 |

| 对比图 | Comparison | 两种以上方案或观点的对照分析 | 左右两栏或表格形式,标明比较维度 |

| 时间线图 | Timeline | 事件发展、项目进度、模型演化 | 以时间为轴,标出关键时间点与事件 |

| 矩阵图 | Matrix | 双维度分类、任务优先级、定位 | 建立 X 与 Y 两个维度,坐标平面安置 |

| 自由布局 | Freeform | 内容零散、灵感记录、初步信息收集 | 无需结构限制,自由放置图块与箭头 |

Design Rules

Text & Format

Layout & Design

Color Palette

参考:references/excalidraw-schema.md

JSON Structure

Obsidian 模式:

{
  "type": "excalidraw",
  "version": 2,
  "source": "https://github.com/zsviczian/obsidian-excalidraw-plugin",
  "elements": [...],
  "appState": { "gridSize": null, "viewBackgroundColor": "#ffffff" },
  "files": {}
}

Standard / Animated 模式:

{
  "type": "excalidraw",
  "version": 2,
  "source": "https://excalidraw.com",
  "elements": [...],
  "appState": { "gridSize": null, "viewBackgroundColor": "#ffffff" },
  "files": {}
}

Element Template

Each element requires these fields (do NOT add extra fields like frameId, index, versionNonce, strokeStyle, rawText -- they cause "invalid file" errors on excalidraw.com v0.17.0+):

{
  "id": "unique-id",
  "type": "rectangle",
  "x": 100, "y": 100,
  "width": 200, "height": 50,
  "angle": 0,
  "strokeColor": "#1e1e1e",
  "backgroundColor": "transparent",
  "fillStyle": "solid",
  "strokeWidth": 2,
  "roughness": 1,
  "opacity": 100,
  "groupIds": [],
  "roundness": {"type": 3},
  "seed": 123456789,
  "version": 1,
  "isDeleted": false,
  "boundElements": null,
  "updated": 1,
  "link": null,
  "locked": false
}

Text elements add:

{
  "text": "显示文本",
  "fontSize": 20,
  "fontFamily": 5,
  "textAlign": "center",
  "verticalAlign": "middle",
  "containerId": null,
  "originalText": "显示文本",
  "autoResize": true,
  "lineHeight": 1.25
}

Animated 模式额外添加 customData 字段:

{
  "id": "title-1",
  "type": "text",
  "customData": {
    "animate": {
      "order": 1,
      "duration": 500
    }
  },
  ...其他字段
}

See references/excalidraw-schema.md for all element types.


Additional Technical Requirements

Text Elements 处理

坐标与布局

Required Fields for All Elements

IMPORTANT: Do NOT include frameId, index, versionNonce, strokeStyle, or rawText fields. These cause "Error: invalid file" on excalidraw.com v0.17.0+. Use boundElements: null (not []), and updated: 1 (not timestamps).

{
  "id": "unique-identifier",
  "type": "rectangle|text|arrow|ellipse|diamond",
  "x": 100, "y": 100,
  "width": 200, "height": 50,
  "angle": 0,
  "strokeColor": "#color-hex",
  "backgroundColor": "transparent|#color-hex",
  "fillStyle": "solid",
  "strokeWidth": 2,
  "roughness": 1,
  "opacity": 100,
  "groupIds": [],
  "roundness": {"type": 3},
  "seed": 123456789,
  "version": 1,
  "isDeleted": false,
  "boundElements": null,
  "updated": 1,
  "link": null,
  "locked": false
}

Text-Specific Properties

文本元素 (type: "text") 需要额外属性(do NOT include rawText):

{
  "text": "显示文本",
  "fontSize": 20,
  "fontFamily": 5,
  "textAlign": "center",
  "verticalAlign": "middle",
  "containerId": null,
  "originalText": "显示文本",
  "autoResize": true,
  "lineHeight": 1.25
}

appState 配置

"appState": {
  "gridSize": null,
  "viewBackgroundColor": "#ffffff"
}

files 字段

"files": {}

Implementation Notes

Auto-save & File Generation Workflow

当生成 Excalidraw 图表时,必须自动执行以下步骤:

1. 选择合适的图表类型
2. 生成有意义的文件名

根据输出模式选择文件扩展名:

| 模式 | 文件名格式 | 示例 |

|------|-----------|------|

| Obsidian | [主题].[类型].md | 商业模式.relationship.md |

| Standard | [主题].[类型].excalidraw | 商业模式.relationship.excalidraw |

| Animated | [主题].[类型].animate.excalidraw | 商业模式.relationship.animate.excalidraw |

3. 使用 Write 工具自动保存文件
4. 确保 Markdown 结构完全正确

必须按以下格式生成(不能有任何修改):

---
excalidraw-plugin: parsed
tags: [excalidraw]
---
==⚠  Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠== You can decompress Drawing data with the command palette: 'Decompress current Excalidraw file'. For more info check in plugin settings under 'Saving'

# Excalidraw Data

## Text Elements
%%
## Drawing
\`\`\`json
{完整的 JSON 数据}
\`\`\`
%%
5. JSON 数据要求
6. 用户反馈与确认

向用户报告:

Example Output Messages

Obsidian 模式:

Excalidraw 图已生成!

保存位置:商业模式.relationship.md

使用方法:
1. 在 Obsidian 中打开此文件
2. 点击右上角 MORE OPTIONS 菜单
3. 选择 Switch to EXCALIDRAW VIEW

Standard 模式:

Excalidraw 图已生成!

保存位置:商业模式.relationship.excalidraw

使用方法:
1. 打开 https://excalidraw.com
2. 点击左上角菜单 → Open → 选择此文件
3. 或直接拖拽文件到 excalidraw.com 页面

Animated 模式:

Excalidraw 动画图已生成!

保存位置:商业模式.relationship.animate.excalidraw

动画顺序:标题(1) → 主框架(2-4) → 连接线(5-7) → 说明文字(8-10)

生成动画:
1. 打开 https://dai-shi.github.io/excalidraw-animate/
2. 点击 Load File 选择此文件
3. 预览动画效果
4. 点击 Export 导出 SVG 或 WebM
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.