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动画", "动画图", "animate".
==⚠ 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'
%%
\
`json
{JSON 完整数据}
\
`
%%
关键要点:
Frontmatter 必须包含
tags: [excalidraw]
警告信息必须完整
JSON 必须被
%%
标记包围
不能使用
excalidraw-plugin: parsed
以外的其他 frontmatter 设置
文件扩展名
:
.md
Mode 2: Standard Excalidraw Format
直接输出纯 JSON 文件,可在 excalidraw.com 打开:
{
"type"
:
"excalidraw"
,
"version"
:
2
,
"source"
:
"https://excalidraw.com"
,
"elements"
:
[
...
]
,
"appState"
:
{
"gridSize"
:
null
,
"viewBackgroundColor"
:
"#ffffff"
}
,
"files"
:
{
}
}
关键要点:
source
使用
https://excalidraw.com
(不是 Obsidian 插件)
纯 JSON,无 Markdown 包装
文件扩展名
:
.excalidraw
Mode 3: Animated Excalidraw Format
与 Standard 格式相同,但每个元素添加
customData.animate
字段控制动画顺序:
{
"id"
:
"element-1"
,
"type"
:
"rectangle"
,
"customData"
:
{
"animate"
:
{
"order"
:
1
,
"duration"
:
500
}
}
,
...其他标准字段
}
动画顺序规则:
order
: 动画播放顺序(1, 2, 3...),数字越小越先出现
duration
: 该元素的绘制时长(毫秒),默认 500
相同
order
的元素同时出现
建议顺序:标题 → 主要框架 → 连接线 → 细节文字
使用方法:
生成
.excalidraw
文件
拖到
https://dai-shi.github.io/excalidraw-animate/
点击 Animate 预览,然后导出 SVG 或 WebM
文件扩展名
:
.excalidraw
Diagram Types & Selection Guide
选择合适的图表形式,以提升理解力与视觉吸引力。
类型
英文
使用场景
做法
流程图
Flowchart
步骤说明、工作流程、任务执行顺序
用箭头连接各步骤,清晰表达流程走向
思维导图
Mind Map
概念发散、主题分类、灵感捕捉
以中心为核心向外发散,放射状结构
层级图
Hierarchy
组织结构、内容分级、系统拆解
自上而下或自左至右构建层级节点
关系图
Relationship
要素之间的影响、依赖、互动
图形间用连线表示关联,箭头与说明
对比图
Comparison
两种以上方案或观点的对照分析
左右两栏或表格形式,标明比较维度
时间线图
Timeline
事件发展、项目进度、模型演化
以时间为轴,标出关键时间点与事件
矩阵图
Matrix
双维度分类、任务优先级、定位
建立 X 与 Y 两个维度,坐标平面安置
自由布局
Freeform
内容零散、灵感记录、初步信息收集
无需结构限制,自由放置图块与箭头
Design Rules
Text & Format
所有文本元素必须使用
fontFamily: 5
(Excalifont 手写字体)
文本中的双引号替换规则
:
"
替换为
『』
文本中的圆括号替换规则
:
()
替换为
「」
字体大小规则
(硬性下限,低于此值在正常缩放下不可读):
标题:20-28px(最小 20px)
副标题:18-20px
正文/标签:16-18px(最小 16px)
次要注释:14px(仅限不重要的辅助说明,慎用)
绝对禁止低于 14px
行高
:所有文本使用
lineHeight: 1.25
文字居中估算
:独立文本元素没有自动居中,需手动计算 x 坐标:
估算文字宽度:
estimatedWidth = text.length * fontSize * 0.5
(CJK 字符用
部分在 Markdown 中 必须留空 ,仅用 %% 作为分隔符 Obsidian ExcaliDraw 插件会根据 JSON 数据 自动填充文本元素 不需要手动列出所有文本内容 坐标与布局 坐标系统 :左上角为原点 (0,0) 推荐范围 :所有元素在 0-1200 x 0-800 像素范围内 元素 ID :每个元素需要唯一的 id (可以是字符串,如「title」「box1」等) Required Fields for All Elements IMPORTANT : Do NOT include frameId , index , versionNonce , or rawText fields. 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 , "strokeStyle" : "solid|dashed|dotted" , "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" : { } Common Mistakes to Avoid 文字偏移 — 独立 text 元素的 x 是左边缘,不是中心。必须用居中公式手动计算,否则文字会偏到一边 元素重叠 — y 坐标相近的元素容易堆叠。放置新元素前检查与周围元素是否有至少 20px 间距 画布留白不足 — 内容不要贴着画布边缘。在四周留 50-80px 的 padding 标题没有居中于图表 — 标题应居中于下方图表的整体宽度,不是固定在 x=0 箭头标签溢出 — 长文字标签(如 "ATP + NADPH")会超出短箭头。保持标签简短或加大箭头长度 对比度不够 — 浅色文字在白底上几乎不可见。文字颜色不低于 #757575 ,有色文字用深色变体 字号太小 — 低于 14px 在正常缩放下不可读,正文最小 16px Implementation Notes Auto-save & File Generation Workflow 当生成 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'
%%
\
`json
{完整的 JSON 数据}
\
`
%%
5. JSON 数据要求
包含完整的 Excalidraw JSON 结构
所有文本元素使用
fontFamily: 5
文本中的
"
替换为
『』
文本中的
()
替换为
「」
JSON 格式必须有效,通过语法检查
所有元素有唯一的
id
包含
appState
和
files: {}
字段
6. 用户反馈与确认
向用户报告:
图表已生成
精确的保存位置
如何在 Obsidian 中查看
图表的设计选择说明(选择了什么类型的图表、为什么)
是否需要调整或修改
Example Output Messages
Obsidian 模式:
Excalidraw 图已生成!
保存位置:商业模式.relationship.md
使用方法:
保存位置:商业模式.relationship.excalidraw
使用方法:
保存位置:商业模式.relationship.animate.excalidraw
动画顺序:标题(1) → 主框架(2-4) → 连接线(5-7) → 说明文字(8-10)
生成动画: