json-canvas

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

JSON Canvas Skill

JSON Canvas 技能

This skill enables skills-compatible agents to create and edit valid JSON Canvas files (
.canvas
) used in Obsidian and other applications.
本技能支持兼容技能的Agent创建和编辑Obsidian及其他应用中使用的有效JSON Canvas文件(
.canvas
)。

Overview

概述

JSON Canvas is an open file format for infinite canvas data. Canvas files use the
.canvas
extension and contain valid JSON following the JSON Canvas Spec 1.0.
JSON Canvas是一种用于无限画布数据的开放文件格式。Canvas文件使用
.canvas
扩展名,遵循JSON Canvas Spec 1.0的规范,包含有效的JSON内容。

File Structure

文件结构

A canvas file contains two top-level arrays:
json
{
  "nodes": [],
  "edges": []
}
  • nodes
    (optional): Array of node objects
  • edges
    (optional): Array of edge objects connecting nodes
一个canvas文件包含两个顶层数组:
json
{
  "nodes": [],
  "edges": []
}
  • nodes
    (可选):节点对象数组
  • edges
    (可选):连接节点的边对象数组

Nodes

节点

Nodes are objects placed on the canvas. There are four node types:
  • text
    - Text content with Markdown
  • file
    - Reference to files/attachments
  • link
    - External URL
  • group
    - Visual container for other nodes
节点是放置在画布上的对象。共有四种节点类型:
  • text
    - 包含Markdown格式的文本内容
  • file
    - 指向文件/附件的引用
  • link
    - 外部URL链接
  • group
    - 用于组织其他节点的可视化容器

Z-Index Ordering

Z轴层级排序

Nodes are ordered by z-index in the array:
  • First node = bottom layer (displayed below others)
  • Last node = top layer (displayed above others)
节点在数组中的顺序决定了Z轴层级:
  • 数组中的第一个节点位于最底层(显示在其他节点下方)
  • 数组中的最后一个节点位于最顶层(显示在其他节点上方)

Generic Node Attributes

通用节点属性

All nodes share these attributes:
AttributeRequiredTypeDescription
id
YesstringUnique identifier for the node
type
YesstringNode type:
text
,
file
,
link
, or
group
x
YesintegerX position in pixels
y
YesintegerY position in pixels
width
YesintegerWidth in pixels
height
YesintegerHeight in pixels
color
NocanvasColorNode color (see Color section)
所有节点都具备以下属性:
属性是否必填类型描述
id
string节点的唯一标识符
type
string节点类型:
text
file
link
group
x
integer节点在画布上的X坐标(像素)
y
integer节点在画布上的Y坐标(像素)
width
integer节点宽度(像素)
height
integer节点高度(像素)
color
canvasColor节点颜色(参考颜色章节)

Text Nodes

文本节点

Text nodes contain Markdown content.
json
{
  "id": "6f0ad84f44ce9c17",
  "type": "text",
  "x": 0,
  "y": 0,
  "width": 400,
  "height": 200,
  "text": "# Hello World\n\nThis is **Markdown** content."
}
文本节点包含Markdown格式的内容。
json
{
  "id": "6f0ad84f44ce9c17",
  "type": "text",
  "x": 0,
  "y": 0,
  "width": 400,
  "height": 200,
  "text": "# Hello World\n\nThis is **Markdown** content."
}

Newline Escaping (Common Pitfall)

换行符转义(常见误区)

In JSON, newline characters inside strings must be represented as
\n
. Do not use the literal sequence
\\n
in a
.canvas
file—Obsidian will render it as the characters
\
and
n
instead of a line break.
Examples:
json
{ "type": "text", "text": "Line 1\nLine 2" }
json
{ "type": "text", "text": "Line 1\\nLine 2" }
AttributeRequiredTypeDescription
text
YesstringPlain text with Markdown syntax
在JSON中,字符串内的换行符必须
\n
表示。请勿在.canvas文件中使用字面量
\\n
——Obsidian会将其渲染为字符
\
n
,而非换行符。
示例:
json
{ "type": "text", "text": "Line 1\nLine 2" }
json
{ "type": "text", "text": "Line 1\\nLine 2" }
属性是否必填类型描述
text
string包含Markdown语法的纯文本

File Nodes

文件节点

File nodes reference files or attachments (images, videos, PDFs, notes, etc.).
json
{
  "id": "a1b2c3d4e5f67890",
  "type": "file",
  "x": 500,
  "y": 0,
  "width": 400,
  "height": 300,
  "file": "Attachments/diagram.png"
}
json
{
  "id": "b2c3d4e5f6789012",
  "type": "file",
  "x": 500,
  "y": 400,
  "width": 400,
  "height": 300,
  "file": "Notes/Project Overview.md",
  "subpath": "#Implementation"
}
AttributeRequiredTypeDescription
file
YesstringPath to file within the system
subpath
NostringLink to heading or block (starts with
#
)
文件节点指向文件或附件(图片、视频、PDF、笔记等)。
json
{
  "id": "a1b2c3d4e5f67890",
  "type": "file",
  "x": 500,
  "y": 0,
  "width": 400,
  "height": 300,
  "file": "Attachments/diagram.png"
}
json
{
  "id": "b2c3d4e5f6789012",
  "type": "file",
  "x": 500,
  "y": 400,
  "width": 400,
  "height": 300,
  "file": "Notes/Project Overview.md",
  "subpath": "#Implementation"
}
属性是否必填类型描述
file
string系统内的文件路径
subpath
string指向标题或块的链接(以
#
开头)

Link Nodes

链接节点

Link nodes display external URLs.
json
{
  "id": "c3d4e5f678901234",
  "type": "link",
  "x": 1000,
  "y": 0,
  "width": 400,
  "height": 200,
  "url": "https://obsidian.md"
}
AttributeRequiredTypeDescription
url
YesstringExternal URL
链接节点显示外部URL。
json
{
  "id": "c3d4e5f678901234",
  "type": "link",
  "x": 1000,
  "y": 0,
  "width": 400,
  "height": 200,
  "url": "https://obsidian.md"
}
属性是否必填类型描述
url
string外部URL地址

Group Nodes

组节点

Group nodes are visual containers for organizing other nodes.
json
{
  "id": "d4e5f6789012345a",
  "type": "group",
  "x": -50,
  "y": -50,
  "width": 1000,
  "height": 600,
  "label": "Project Overview",
  "color": "4"
}
json
{
  "id": "e5f67890123456ab",
  "type": "group",
  "x": 0,
  "y": 700,
  "width": 800,
  "height": 500,
  "label": "Resources",
  "background": "Attachments/background.png",
  "backgroundStyle": "cover"
}
AttributeRequiredTypeDescription
label
NostringText label for the group
background
NostringPath to background image
backgroundStyle
NostringBackground rendering style
组节点是用于组织其他节点的可视化容器。
json
{
  "id": "d4e5f6789012345a",
  "type": "group",
  "x": -50,
  "y": -50,
  "width": 1000,
  "height": 600,
  "label": "Project Overview",
  "color": "4"
}
json
{
  "id": "e5f67890123456ab",
  "type": "group",
  "x": 0,
  "y": 700,
  "width": 800,
  "height": 500,
  "label": "Resources",
  "background": "Attachments/background.png",
  "backgroundStyle": "cover"
}
属性是否必填类型描述
label
string组的文本标签
background
string背景图片的路径
backgroundStyle
string背景图片的渲染样式

Background Styles

背景样式

ValueDescription
cover
Fills entire width and height of node
ratio
Maintains aspect ratio of background image
repeat
Repeats image as pattern in both directions
描述
cover
填充节点的整个宽高
ratio
保持背景图片的宽高比
repeat
在水平和垂直方向重复图片作为图案

Edges

Edges are lines connecting nodes.
json
{
  "id": "f67890123456789a",
  "fromNode": "6f0ad84f44ce9c17",
  "toNode": "a1b2c3d4e5f67890"
}
json
{
  "id": "0123456789abcdef",
  "fromNode": "6f0ad84f44ce9c17",
  "fromSide": "right",
  "fromEnd": "none",
  "toNode": "b2c3d4e5f6789012",
  "toSide": "left",
  "toEnd": "arrow",
  "color": "1",
  "label": "leads to"
}
AttributeRequiredTypeDefaultDescription
id
Yesstring-Unique identifier for the edge
fromNode
Yesstring-Node ID where connection starts
fromSide
Nostring-Side where edge starts
fromEnd
Nostring
none
Shape at edge start
toNode
Yesstring-Node ID where connection ends
toSide
Nostring-Side where edge ends
toEnd
Nostring
arrow
Shape at edge end
color
NocanvasColor-Line color
label
Nostring-Text label for the edge
边是连接节点的线条。
json
{
  "id": "f67890123456789a",
  "fromNode": "6f0ad84f44ce9c17",
  "toNode": "a1b2c3d4e5f67890"
}
json
{
  "id": "0123456789abcdef",
  "fromNode": "6f0ad84f44ce9c17",
  "fromSide": "right",
  "fromEnd": "none",
  "toNode": "b2c3d4e5f6789012",
  "toSide": "left",
  "toEnd": "arrow",
  "color": "1",
  "label": "leads to"
}
属性是否必填类型默认值描述
id
string-边的唯一标识符
fromNode
string-连接起始节点的ID
fromSide
string-边的起始侧
fromEnd
string
none
边起始端的形状
toNode
string-连接目标节点的ID
toSide
string-边的目标侧
toEnd
string
arrow
边目标端的形状
color
canvasColor-线条颜色
label
string-边的文本标签

Side Values

侧边取值

ValueDescription
top
Top edge of node
right
Right edge of node
bottom
Bottom edge of node
left
Left edge of node
描述
top
节点的顶部边缘
right
节点的右侧边缘
bottom
节点的底部边缘
left
节点的左侧边缘

End Shapes

端点形状

ValueDescription
none
No endpoint shape
arrow
Arrow endpoint
描述
none
无端点形状
arrow
箭头端点

Colors

颜色

The
canvasColor
type can be specified in two ways:
canvasColor
类型有两种指定方式:

Hex Colors

十六进制颜色

json
{
  "color": "#FF0000"
}
json
{
  "color": "#FF0000"
}

Preset Colors

预设颜色

json
{
  "color": "1"
}
PresetColor
"1"
Red
"2"
Orange
"3"
Yellow
"4"
Green
"5"
Cyan
"6"
Purple
Note: Specific color values for presets are intentionally undefined, allowing applications to use their own brand colors.
json
{
  "color": "1"
}
预设值颜色
"1"
红色
"2"
橙色
"3"
黄色
"4"
绿色
"5"
青色
"6"
紫色
注意:预设颜色的具体取值并未明确定义,允许应用程序使用自身的品牌颜色。

Complete Examples

完整示例

Simple Canvas with Text and Connections

包含文本和连接的简单画布

json
{
  "nodes": [
    {
      "id": "8a9b0c1d2e3f4a5b",
      "type": "text",
      "x": 0,
      "y": 0,
      "width": 300,
      "height": 150,
      "text": "# Main Idea\n\nThis is the central concept."
    },
    {
      "id": "1a2b3c4d5e6f7a8b",
      "type": "text",
      "x": 400,
      "y": -100,
      "width": 250,
      "height": 100,
      "text": "## Supporting Point A\n\nDetails here."
    },
    {
      "id": "2b3c4d5e6f7a8b9c",
      "type": "text",
      "x": 400,
      "y": 100,
      "width": 250,
      "height": 100,
      "text": "## Supporting Point B\n\nMore details."
    }
  ],
  "edges": [
    {
      "id": "3c4d5e6f7a8b9c0d",
      "fromNode": "8a9b0c1d2e3f4a5b",
      "fromSide": "right",
      "toNode": "1a2b3c4d5e6f7a8b",
      "toSide": "left"
    },
    {
      "id": "4d5e6f7a8b9c0d1e",
      "fromNode": "8a9b0c1d2e3f4a5b",
      "fromSide": "right",
      "toNode": "2b3c4d5e6f7a8b9c",
      "toSide": "left"
    }
  ]
}
json
{
  "nodes": [
    {
      "id": "8a9b0c1d2e3f4a5b",
      "type": "text",
      "x": 0,
      "y": 0,
      "width": 300,
      "height": 150,
      "text": "# Main Idea\n\nThis is the central concept."
    },
    {
      "id": "1a2b3c4d5e6f7a8b",
      "type": "text",
      "x": 400,
      "y": -100,
      "width": 250,
      "height": 100,
      "text": "## Supporting Point A\n\nDetails here."
    },
    {
      "id": "2b3c4d5e6f7a8b9c",
      "type": "text",
      "x": 400,
      "y": 100,
      "width": 250,
      "height": 100,
      "text": "## Supporting Point B\n\nMore details."
    }
  ],
  "edges": [
    {
      "id": "3c4d5e6f7a8b9c0d",
      "fromNode": "8a9b0c1d2e3f4a5b",
      "fromSide": "right",
      "toNode": "1a2b3c4d5e6f7a8b",
      "toSide": "left"
    },
    {
      "id": "4d5e6f7a8b9c0d1e",
      "fromNode": "8a9b0c1d2e3f4a5b",
      "fromSide": "right",
      "toNode": "2b3c4d5e6f7a8b9c",
      "toSide": "left"
    }
  ]
}

Project Board with Groups

包含组的项目看板

json
{
  "nodes": [
    {
      "id": "5e6f7a8b9c0d1e2f",
      "type": "group",
      "x": 0,
      "y": 0,
      "width": 300,
      "height": 500,
      "label": "To Do",
      "color": "1"
    },
    {
      "id": "6f7a8b9c0d1e2f3a",
      "type": "group",
      "x": 350,
      "y": 0,
      "width": 300,
      "height": 500,
      "label": "In Progress",
      "color": "3"
    },
    {
      "id": "7a8b9c0d1e2f3a4b",
      "type": "group",
      "x": 700,
      "y": 0,
      "width": 300,
      "height": 500,
      "label": "Done",
      "color": "4"
    },
    {
      "id": "8b9c0d1e2f3a4b5c",
      "type": "text",
      "x": 20,
      "y": 50,
      "width": 260,
      "height": 80,
      "text": "## Task 1\n\nImplement feature X"
    },
    {
      "id": "9c0d1e2f3a4b5c6d",
      "type": "text",
      "x": 370,
      "y": 50,
      "width": 260,
      "height": 80,
      "text": "## Task 2\n\nReview PR #123",
      "color": "2"
    },
    {
      "id": "0d1e2f3a4b5c6d7e",
      "type": "text",
      "x": 720,
      "y": 50,
      "width": 260,
      "height": 80,
      "text": "## Task 3\n\n~~Setup CI/CD~~"
    }
  ],
  "edges": []
}
json
{
  "nodes": [
    {
      "id": "5e6f7a8b9c0d1e2f",
      "type": "group",
      "x": 0,
      "y": 0,
      "width": 300,
      "height": 500,
      "label": "To Do",
      "color": "1"
    },
    {
      "id": "6f7a8b9c0d1e2f3a",
      "type": "group",
      "x": 350,
      "y": 0,
      "width": 300,
      "height": 500,
      "label": "In Progress",
      "color": "3"
    },
    {
      "id": "7a8b9c0d1e2f3a4b",
      "type": "group",
      "x": 700,
      "y": 0,
      "width": 300,
      "height": 500,
      "label": "Done",
      "color": "4"
    },
    {
      "id": "8b9c0d1e2f3a4b5c",
      "type": "text",
      "x": 20,
      "y": 50,
      "width": 260,
      "height": 80,
      "text": "## Task 1\n\nImplement feature X"
    },
    {
      "id": "9c0d1e2f3a4b5c6d",
      "type": "text",
      "x": 370,
      "y": 50,
      "width": 260,
      "height": 80,
      "text": "## Task 2\n\nReview PR #123",
      "color": "2"
    },
    {
      "id": "0d1e2f3a4b5c6d7e",
      "type": "text",
      "x": 720,
      "y": 50,
      "width": 260,
      "height": 80,
      "text": "## Task 3\n\n~~Setup CI/CD~~"
    }
  ],
  "edges": []
}

Research Canvas with Files and Links

包含文件和链接的研究画布

json
{
  "nodes": [
    {
      "id": "1e2f3a4b5c6d7e8f",
      "type": "text",
      "x": 300,
      "y": 200,
      "width": 400,
      "height": 200,
      "text": "# Research Topic\n\n## Key Questions\n\n- How does X affect Y?\n- What are the implications?",
      "color": "5"
    },
    {
      "id": "2f3a4b5c6d7e8f9a",
      "type": "file",
      "x": 0,
      "y": 0,
      "width": 250,
      "height": 150,
      "file": "Literature/Paper A.pdf"
    },
    {
      "id": "3a4b5c6d7e8f9a0b",
      "type": "file",
      "x": 0,
      "y": 200,
      "width": 250,
      "height": 150,
      "file": "Notes/Meeting Notes.md",
      "subpath": "#Key Insights"
    },
    {
      "id": "4b5c6d7e8f9a0b1c",
      "type": "link",
      "x": 0,
      "y": 400,
      "width": 250,
      "height": 100,
      "url": "https://example.com/research"
    },
    {
      "id": "5c6d7e8f9a0b1c2d",
      "type": "file",
      "x": 750,
      "y": 150,
      "width": 300,
      "height": 250,
      "file": "Attachments/diagram.png"
    }
  ],
  "edges": [
    {
      "id": "6d7e8f9a0b1c2d3e",
      "fromNode": "2f3a4b5c6d7e8f9a",
      "fromSide": "right",
      "toNode": "1e2f3a4b5c6d7e8f",
      "toSide": "left",
      "label": "supports"
    },
    {
      "id": "7e8f9a0b1c2d3e4f",
      "fromNode": "3a4b5c6d7e8f9a0b",
      "fromSide": "right",
      "toNode": "1e2f3a4b5c6d7e8f",
      "toSide": "left",
      "label": "informs"
    },
    {
      "id": "8f9a0b1c2d3e4f5a",
      "fromNode": "4b5c6d7e8f9a0b1c",
      "fromSide": "right",
      "toNode": "1e2f3a4b5c6d7e8f",
      "toSide": "left",
      "toEnd": "arrow",
      "color": "6"
    },
    {
      "id": "9a0b1c2d3e4f5a6b",
      "fromNode": "1e2f3a4b5c6d7e8f",
      "fromSide": "right",
      "toNode": "5c6d7e8f9a0b1c2d",
      "toSide": "left",
      "label": "visualized by"
    }
  ]
}
json
{
  "nodes": [
    {
      "id": "1e2f3a4b5c6d7e8f",
      "type": "text",
      "x": 300,
      "y": 200,
      "width": 400,
      "height": 200,
      "text": "# Research Topic\n\n## Key Questions\n\n- How does X affect Y?\n- What are the implications?",
      "color": "5"
    },
    {
      "id": "2f3a4b5c6d7e8f9a",
      "type": "file",
      "x": 0,
      "y": 0,
      "width": 250,
      "height": 150,
      "file": "Literature/Paper A.pdf"
    },
    {
      "id": "3a4b5c6d7e8f9a0b",
      "type": "file",
      "x": 0,
      "y": 200,
      "width": 250,
      "height": 150,
      "file": "Notes/Meeting Notes.md",
      "subpath": "#Key Insights"
    },
    {
      "id": "4b5c6d7e8f9a0b1c",
      "type": "link",
      "x": 0,
      "y": 400,
      "width": 250,
      "height": 100,
      "url": "https://example.com/research"
    },
    {
      "id": "5c6d7e8f9a0b1c2d",
      "type": "file",
      "x": 750,
      "y": 150,
      "width": 300,
      "height": 250,
      "file": "Attachments/diagram.png"
    }
  ],
  "edges": [
    {
      "id": "6d7e8f9a0b1c2d3e",
      "fromNode": "2f3a4b5c6d7e8f9a",
      "fromSide": "right",
      "toNode": "1e2f3a4b5c6d7e8f",
      "toSide": "left",
      "label": "supports"
    },
    {
      "id": "7e8f9a0b1c2d3e4f",
      "fromNode": "3a4b5c6d7e8f9a0b",
      "fromSide": "right",
      "toNode": "1e2f3a4b5c6d7e8f",
      "toSide": "left",
      "label": "informs"
    },
    {
      "id": "8f9a0b1c2d3e4f5a",
      "fromNode": "4b5c6d7e8f9a0b1c",
      "fromSide": "right",
      "toNode": "1e2f3a4b5c6d7e8f",
      "toSide": "left",
      "toEnd": "arrow",
      "color": "6"
    },
    {
      "id": "9a0b1c2d3e4f5a6b",
      "fromNode": "1e2f3a4b5c6d7e8f",
      "fromSide": "right",
      "toNode": "5c6d7e8f9a0b1c2d",
      "toSide": "left",
      "label": "visualized by"
    }
  ]
}

Flowchart

流程图

json
{
  "nodes": [
    {
      "id": "a0b1c2d3e4f5a6b7",
      "type": "text",
      "x": 200,
      "y": 0,
      "width": 150,
      "height": 60,
      "text": "**Start**",
      "color": "4"
    },
    {
      "id": "b1c2d3e4f5a6b7c8",
      "type": "text",
      "x": 200,
      "y": 100,
      "width": 150,
      "height": 60,
      "text": "Step 1:\nGather data"
    },
    {
      "id": "c2d3e4f5a6b7c8d9",
      "type": "text",
      "x": 200,
      "y": 200,
      "width": 150,
      "height": 80,
      "text": "**Decision**\n\nIs data valid?",
      "color": "3"
    },
    {
      "id": "d3e4f5a6b7c8d9e0",
      "type": "text",
      "x": 400,
      "y": 200,
      "width": 150,
      "height": 60,
      "text": "Process data"
    },
    {
      "id": "e4f5a6b7c8d9e0f1",
      "type": "text",
      "x": 0,
      "y": 200,
      "width": 150,
      "height": 60,
      "text": "Request new data",
      "color": "1"
    },
    {
      "id": "f5a6b7c8d9e0f1a2",
      "type": "text",
      "x": 400,
      "y": 320,
      "width": 150,
      "height": 60,
      "text": "**End**",
      "color": "4"
    }
  ],
  "edges": [
    {
      "id": "a6b7c8d9e0f1a2b3",
      "fromNode": "a0b1c2d3e4f5a6b7",
      "fromSide": "bottom",
      "toNode": "b1c2d3e4f5a6b7c8",
      "toSide": "top"
    },
    {
      "id": "b7c8d9e0f1a2b3c4",
      "fromNode": "b1c2d3e4f5a6b7c8",
      "fromSide": "bottom",
      "toNode": "c2d3e4f5a6b7c8d9",
      "toSide": "top"
    },
    {
      "id": "c8d9e0f1a2b3c4d5",
      "fromNode": "c2d3e4f5a6b7c8d9",
      "fromSide": "right",
      "toNode": "d3e4f5a6b7c8d9e0",
      "toSide": "left",
      "label": "Yes",
      "color": "4"
    },
    {
      "id": "d9e0f1a2b3c4d5e6",
      "fromNode": "c2d3e4f5a6b7c8d9",
      "fromSide": "left",
      "toNode": "e4f5a6b7c8d9e0f1",
      "toSide": "right",
      "label": "No",
      "color": "1"
    },
    {
      "id": "e0f1a2b3c4d5e6f7",
      "fromNode": "e4f5a6b7c8d9e0f1",
      "fromSide": "top",
      "fromEnd": "none",
      "toNode": "b1c2d3e4f5a6b7c8",
      "toSide": "left",
      "toEnd": "arrow"
    },
    {
      "id": "f1a2b3c4d5e6f7a8",
      "fromNode": "d3e4f5a6b7c8d9e0",
      "fromSide": "bottom",
      "toNode": "f5a6b7c8d9e0f1a2",
      "toSide": "top"
    }
  ]
}
json
{
  "nodes": [
    {
      "id": "a0b1c2d3e4f5a6b7",
      "type": "text",
      "x": 200,
      "y": 0,
      "width": 150,
      "height": 60,
      "text": "**Start**",
      "color": "4"
    },
    {
      "id": "b1c2d3e4f5a6b7c8",
      "type": "text",
      "x": 200,
      "y": 100,
      "width": 150,
      "height": 60,
      "text": "Step 1:\nGather data"
    },
    {
      "id": "c2d3e4f5a6b7c8d9",
      "type": "text",
      "x": 200,
      "y": 200,
      "width": 150,
      "height": 80,
      "text": "**Decision**\n\nIs data valid?",
      "color": "3"
    },
    {
      "id": "d3e4f5a6b7c8d9e0",
      "type": "text",
      "x": 400,
      "y": 200,
      "width": 150,
      "height": 60,
      "text": "Process data"
    },
    {
      "id": "e4f5a6b7c8d9e0f1",
      "type": "text",
      "x": 0,
      "y": 200,
      "width": 150,
      "height": 60,
      "text": "Request new data",
      "color": "1"
    },
    {
      "id": "f5a6b7c8d9e0f1a2",
      "type": "text",
      "x": 400,
      "y": 320,
      "width": 150,
      "height": 60,
      "text": "**End**",
      "color": "4"
    }
  ],
  "edges": [
    {
      "id": "a6b7c8d9e0f1a2b3",
      "fromNode": "a0b1c2d3e4f5a6b7",
      "fromSide": "bottom",
      "toNode": "b1c2d3e4f5a6b7c8",
      "toSide": "top"
    },
    {
      "id": "b7c8d9e0f1a2b3c4",
      "fromNode": "b1c2d3e4f5a6b7c8",
      "fromSide": "bottom",
      "toNode": "c2d3e4f5a6b7c8d9",
      "toSide": "top"
    },
    {
      "id": "c8d9e0f1a2b3c4d5",
      "fromNode": "c2d3e4f5a6b7c8d9",
      "fromSide": "right",
      "toNode": "d3e4f5a6b7c8d9e0",
      "toSide": "left",
      "label": "Yes",
      "color": "4"
    },
    {
      "id": "d9e0f1a2b3c4d5e6",
      "fromNode": "c2d3e4f5a6b7c8d9",
      "fromSide": "left",
      "toNode": "e4f5a6b7c8d9e0f1",
      "toSide": "right",
      "label": "No",
      "color": "1"
    },
    {
      "id": "e0f1a2b3c4d5e6f7",
      "fromNode": "e4f5a6b7c8d9e0f1",
      "fromSide": "top",
      "fromEnd": "none",
      "toNode": "b1c2d3e4f5a6b7c8",
      "toSide": "left",
      "toEnd": "arrow"
    },
    {
      "id": "f1a2b3c4d5e6f7a8",
      "fromNode": "d3e4f5a6b7c8d9e0",
      "fromSide": "bottom",
      "toNode": "f5a6b7c8d9e0f1a2",
      "toSide": "top"
    }
  ]
}

ID Generation

ID生成

Node and edge IDs must be unique strings. Obsidian generates 16-character hexadecimal IDs:
json
"id": "6f0ad84f44ce9c17"
"id": "a3b2c1d0e9f8g7h6"
"id": "1234567890abcdef"
This format is a 16-character lowercase hex string (64-bit random value).
节点和边的ID必须是唯一的字符串。Obsidian会生成16位的十六进制ID:
json
"id": "6f0ad84f44ce9c17"
"id": "a3b2c1d0e9f8g7h6"
"id": "1234567890abcdef"
这种格式是16位的小写十六进制字符串(64位随机值)。

Layout Guidelines

布局指南

Positioning

定位

  • Coordinates can be negative (canvas extends infinitely)
  • x
    increases to the right
  • y
    increases downward
  • Position refers to top-left corner of node
  • 坐标可以为负数(画布是无限延伸的)
  • x
    值越大,节点越靠右
  • y
    值越大,节点越靠下
  • 坐标指的是节点的左上角位置

Recommended Sizes

推荐尺寸

Node TypeSuggested WidthSuggested Height
Small text200-30080-150
Medium text300-450150-300
Large text400-600300-500
File preview300-500200-400
Link preview250-400100-200
GroupVariesVaries
节点类型推荐宽度推荐高度
小型文本200-30080-150
中型文本300-450150-300
大型文本400-600300-500
文件预览300-500200-400
链接预览250-400100-200
按需调整按需调整

Spacing

间距

  • Leave 20-50px padding inside groups
  • Space nodes 50-100px apart for readability
  • Align nodes to grid (multiples of 10 or 20) for cleaner layouts
  • 组内节点保留20-50px的内边距
  • 节点之间保留50-100px的间距以保证可读性
  • 将节点对齐到网格(坐标为10或20的倍数)以获得更整洁的布局

Validation Rules

验证规则

  1. All
    id
    values must be unique across nodes and edges
  2. fromNode
    and
    toNode
    must reference existing node IDs
  3. Required fields must be present for each node type
  4. type
    must be one of:
    text
    ,
    file
    ,
    link
    ,
    group
  5. backgroundStyle
    must be one of:
    cover
    ,
    ratio
    ,
    repeat
  6. fromSide
    ,
    toSide
    must be one of:
    top
    ,
    right
    ,
    bottom
    ,
    left
  7. fromEnd
    ,
    toEnd
    must be one of:
    none
    ,
    arrow
  8. Color presets must be
    "1"
    through
    "6"
    or valid hex color
  1. 所有
    id
    值在节点和边中必须唯一
  2. fromNode
    toNode
    必须指向已存在的节点ID
  3. 每种节点类型必须包含必填字段
  4. type
    必须是以下值之一:
    text
    file
    link
    group
  5. backgroundStyle
    必须是以下值之一:
    cover
    ratio
    repeat
  6. fromSide
    toSide
    必须是以下值之一:
    top
    right
    bottom
    left
  7. fromEnd
    toEnd
    必须是以下值之一:
    none
    arrow
  8. 颜色预设值必须是
    "1"
    "6"
    或有效的十六进制颜色

References

参考资料