json-canvas by kepano/obsidian-skills
npx skills add https://github.com/kepano/obsidian-skills --skill json-canvas一个画布文件(.canvas)包含两个遵循 JSON Canvas Spec 1.0 的顶级数组:
{
"nodes": [],
"edges": []
}
nodes(可选):节点对象数组edges(可选):连接节点的边对象数组{"nodes": [], "edges": []} 的 .canvas 文件"6f0ad84f44ce9c17")广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
id、type、x、y、width、heightfromNode 和 toNode 添加引用有效节点 ID 的边fromNode/toNode 值都存在于节点数组中.canvas 文件x, y)(留出 50-100px 间距)nodes 数组fromNode 和 toNode 分别设置为源 ID 和目标 IDfromSide/toSide(top, right, bottom, left)以指定锚点label 作为边上的描述性文本edges 数组fromNode 和 toNode 都引用了现有的节点 ID.canvas 文件作为 JSON 读取并解析id 定位目标节点或边节点是放置在画布上的对象。数组顺序决定了 z-index:第一个节点 = 底层,最后一个节点 = 顶层。
| 属性 | 必需 | 类型 | 描述 |
|---|---|---|---|
id | 是 | string | 唯一的 16 字符十六进制标识符 |
type | 是 | string | text、file、link 或 group |
x | 是 | integer | X 坐标(像素) |
y | 是 | integer | Y 坐标(像素) |
width | 是 | integer | 宽度(像素) |
height | 是 | integer | 高度(像素) |
color | 否 | canvasColor | 预设值 "1"-"6" 或十六进制值(例如 "#FF0000") |
| 属性 | 必需 | 类型 | 描述 |
|---|---|---|---|
text | 是 | string | 包含 Markdown 语法的纯文本 |
{
"id": "6f0ad84f44ce9c17",
"type": "text",
"x": 0,
"y": 0,
"width": 400,
"height": 200,
"text": "# Hello World\n\nThis is **Markdown** content."
}
换行符陷阱:在 JSON 字符串中使用 \n 表示换行。不要使用字面量 \\n —— Obsidian 会将其渲染为字符 \ 和 n。
| 属性 | 必需 | 类型 | 描述 |
|---|---|---|---|
file | 是 | string | 系统内的文件路径 |
subpath | 否 | string | 指向标题或块的链接(以 # 开头) |
{
"id": "a1b2c3d4e5f67890",
"type": "file",
"x": 500,
"y": 0,
"width": 400,
"height": 300,
"file": "Attachments/diagram.png"
}
| 属性 | 必需 | 类型 | 描述 |
|---|---|---|---|
url | 是 | string | 外部 URL |
{
"id": "c3d4e5f678901234",
"type": "link",
"x": 1000,
"y": 0,
"width": 400,
"height": 200,
"url": "https://obsidian.md"
}
分组是用于组织其他节点的视觉容器。将子节点放置在分组边界内。
| 属性 | 必需 | 类型 | 描述 |
|---|---|---|---|
label | 否 | string | 分组的文本标签 |
background | 否 | string | 背景图片路径 |
backgroundStyle | 否 | string | cover、ratio 或 repeat |
{
"id": "d4e5f6789012345a",
"type": "group",
"x": -50,
"y": -50,
"width": 1000,
"height": 600,
"label": "Project Overview",
"color": "4"
}
边通过 fromNode 和 toNode ID 连接节点。
| 属性 | 必需 | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
id | 是 | string | - | 唯一标识符 |
fromNode | 是 | string | - | 源节点 ID |
fromSide | 否 | string | - | top、right、bottom 或 left |
fromEnd | 否 | string | none | none 或 arrow |
toNode | 是 | string | - | 目标节点 ID |
toSide | 否 | string | - | top、right、bottom 或 left |
toEnd | 否 | string | arrow | none 或 arrow |
color | 否 | canvasColor | - | 线条颜色 |
label | 否 | string | - | 文本标签 |
{
"id": "0123456789abcdef",
"fromNode": "6f0ad84f44ce9c17",
"fromSide": "right",
"toNode": "a1b2c3d4e5f67890",
"toSide": "left",
"toEnd": "arrow",
"label": "leads to"
}
canvasColor 类型接受十六进制字符串或预设数字:
| 预设值 | 颜色 |
|---|---|
"1" | 红色 |
"2" | 橙色 |
"3" | 黄色 |
"4" | 绿色 |
"5" | 青色 |
"6" | 紫色 |
预设颜色值是故意未定义的——应用程序使用其自身的品牌颜色。
生成 16 字符小写十六进制字符串(64 位随机值):
"6f0ad84f44ce9c17"
"a3b2c1d0e9f8a7b6"
x 向右增加,y 向下增加;位置是左上角| 节点类型 | 建议宽度 | 建议高度 |
|---|---|---|
| 小型文本 | 200-300 | 80-150 |
| 中型文本 | 300-450 | 150-300 |
| 大型文本 | 400-600 | 300-500 |
| 文件预览 | 300-500 | 200-400 |
| 链接预览 | 250-400 | 100-200 |
创建或编辑画布文件后,请验证:
id 值在节点和边中都是唯一的fromNode 和 toNode 都引用了一个现有的节点 IDtext,文件节点有 file,链接节点有 url)type 是以下之一:text、file、link、groupfromSide/toSide 值是以下之一:top、right、bottom、leftfromEnd/toEnd 值是以下之一:none、arrow"1" 到 "6" 或有效的十六进制值(例如 "#FF0000")如果验证失败,请检查重复的 ID、悬空的边引用或格式错误的 JSON 字符串(尤其是文本内容中未转义的换行符)。
查看 references/EXAMPLES.md 以获取完整的画布示例,包括思维导图、项目看板、研究画布和流程图。
每周安装量
6.2K
仓库
GitHub 星标数
16.4K
首次出现
2026年1月20日
安全审计
安装于
opencode5.6K
codex5.5K
gemini-cli5.4K
github-copilot5.2K
cursor5.1K
kimi-cli4.9K
A canvas file (.canvas) contains two top-level arrays following the JSON Canvas Spec 1.0:
{
"nodes": [],
"edges": []
}
nodes (optional): Array of node objectsedges (optional): Array of edge objects connecting nodes.canvas file with the base structure {"nodes": [], "edges": []}"6f0ad84f44ce9c17")id, type, x, y, width, heightfromNode and toNodefromNode/toNode values exist in the nodes array.canvas filex, y) that avoids overlapping existing nodes (leave 50-100px spacing)nodes arrayfromNode and toNode to the source and target IDsfromSide/toSide (top, right, bottom, left) for anchor pointslabel for descriptive text on the edgeedges arrayfromNode and toNode reference existing node IDs.canvas file as JSONidNodes are objects placed on the canvas. Array order determines z-index: first node = bottom layer, last node = top layer.
| Attribute | Required | Type | Description |
|---|---|---|---|
id | Yes | string | Unique 16-char hex identifier |
type | Yes | string | text, file, link, or group |
x |
| Attribute | Required | Type | Description |
|---|---|---|---|
text | Yes | string | Plain text with Markdown syntax |
{
"id": "6f0ad84f44ce9c17",
"type": "text",
"x": 0,
"y": 0,
"width": 400,
"height": 200,
"text": "# Hello World\n\nThis is **Markdown** content."
}
Newline pitfall : Use \n for line breaks in JSON strings. Do not use the literal \\n -- Obsidian renders that as the characters \ and n.
| Attribute | Required | Type | Description |
|---|---|---|---|
file | Yes | string | Path to file within the system |
subpath | No | string | Link to heading or block (starts with #) |
{
"id": "a1b2c3d4e5f67890",
"type": "file",
"x": 500,
"y": 0,
"width": 400,
"height": 300,
"file": "Attachments/diagram.png"
}
| Attribute | Required | Type | Description |
|---|---|---|---|
url | Yes | string | External URL |
{
"id": "c3d4e5f678901234",
"type": "link",
"x": 1000,
"y": 0,
"width": 400,
"height": 200,
"url": "https://obsidian.md"
}
Groups are visual containers for organizing other nodes. Position child nodes inside the group's bounds.
| Attribute | Required | Type | Description |
|---|---|---|---|
label | No | string | Text label for the group |
background | No | string | Path to background image |
backgroundStyle | No | string | cover, ratio, or repeat |
{
"id": "d4e5f6789012345a",
"type": "group",
"x": -50,
"y": -50,
"width": 1000,
"height": 600,
"label": "Project Overview",
"color": "4"
}
Edges connect nodes via fromNode and toNode IDs.
| Attribute | Required | Type | Default | Description |
|---|---|---|---|---|
id | Yes | string | - | Unique identifier |
fromNode | Yes | string | - | Source node ID |
fromSide | No | string | - | top, right, , or |
{
"id": "0123456789abcdef",
"fromNode": "6f0ad84f44ce9c17",
"fromSide": "right",
"toNode": "a1b2c3d4e5f67890",
"toSide": "left",
"toEnd": "arrow",
"label": "leads to"
}
The canvasColor type accepts either a hex string or a preset number:
| Preset | Color |
|---|---|
"1" | Red |
"2" | Orange |
"3" | Yellow |
"4" | Green |
"5" | Cyan |
"6" | Purple |
Preset color values are intentionally undefined -- applications use their own brand colors.
Generate 16-character lowercase hexadecimal strings (64-bit random value):
"6f0ad84f44ce9c17"
"a3b2c1d0e9f8a7b6"
x increases right, y increases down; position is the top-left corner| Node Type | Suggested Width | Suggested Height |
|---|---|---|
| Small text | 200-300 | 80-150 |
| Medium text | 300-450 | 150-300 |
| Large text | 400-600 | 300-500 |
| File preview | 300-500 | 200-400 |
| Link preview | 250-400 | 100-200 |
After creating or editing a canvas file, verify:
id values are unique across both nodes and edgesfromNode and toNode references an existing node IDtext for text nodes, file for file nodes, url for link nodes)type is one of: text, file, link, groupIf validation fails, check for duplicate IDs, dangling edge references, or malformed JSON strings (especially unescaped newlines in text content).
See references/EXAMPLES.md for full canvas examples including mind maps, project boards, research canvases, and flowcharts.
Weekly Installs
6.2K
Repository
GitHub Stars
16.4K
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode5.6K
codex5.5K
gemini-cli5.4K
github-copilot5.2K
cursor5.1K
kimi-cli4.9K
97,600 周安装
| Yes |
| integer |
| X position in pixels |
y | Yes | integer | Y position in pixels |
width | Yes | integer | Width in pixels |
height | Yes | integer | Height in pixels |
color | No | canvasColor | Preset "1"-"6" or hex (e.g., "#FF0000") |
bottomleftfromEnd | No | string | none | none or arrow |
toNode | Yes | string | - | Target node ID |
toSide | No | string | - | top, right, bottom, or left |
toEnd | No | string | arrow | none or arrow |
color | No | canvasColor | - | Line color |
label | No | string | - | Text label |
fromSide/toSide values are one of: top, right, bottom, leftfromEnd/toEnd values are one of: none, arrow"1" through "6" or valid hex (e.g., "#FF0000")