返回顶部
j

json-canvasJSON画布

Create and edit JSON Canvas files (.canvas) with nodes, edges, groups, and connections. Use when working with .canvas files, creating visual canvases, mind maps, flowcharts, or when the user mentions Canvas files in Obsidian.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
689
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

json-canvas

JSON Canvas 技能

文件结构

画布文件(.canvas)包含两个遵循 JSON Canvas 规范 1.0 的顶级数组:

json
{
nodes: [],
edges: []
}

  • - nodes(可选):节点对象数组
  • edges(可选):连接节点的边对象数组

常见工作流程

1. 创建新画布

  1. 1. 创建包含基础结构 {nodes: [], edges: []} 的 .canvas 文件
  2. 为每个节点生成唯一的16字符十六进制ID(例如 6f0ad84f44ce9c17)
  3. 添加包含必填字段的节点:id、type、x、y、width、height
  4. 通过 fromNode 和 toNode 添加引用有效节点ID的边
  5. 验证:解析JSON以确认其有效性。验证所有 fromNode/toNode 值都存在于节点数组中

2. 向现有画布添加节点

  1. 1. 读取并解析现有的 .canvas 文件
  2. 生成不与现有节点或边ID冲突的唯一ID
  3. 选择避免与现有节点重叠的位置(x、y)(保留50-100px间距)
  4. 将新节点对象追加到 nodes 数组
  5. 可选地添加连接新节点与现有节点的边
  6. 验证:确认所有ID唯一且所有边引用都解析到现有节点

3. 连接两个节点

  1. 1. 确定源节点和目标节点ID
  2. 生成唯一的边ID
  3. 将 fromNode 和 toNode 设置为源ID和目标ID
  4. 可选地设置 fromSide/toSide(上、右、下、左)作为锚点
  5. 可选地设置 label 作为边上的描述文本
  6. 将边追加到 edges 数组
  7. 验证:确认 fromNode 和 toNode 都引用现有节点ID

4. 编辑现有画布

  1. 1. 以JSON格式读取并解析 .canvas 文件
  2. 通过 id 定位目标节点或边
  3. 修改所需属性(文本、位置、颜色等)
  4. 将更新后的JSON写回文件
  5. 验证:编辑后重新检查所有ID唯一性和边引用完整性

节点

节点是放置在画布上的对象。数组顺序决定z-index:第一个节点=底层,最后一个节点=顶层。

通用节点属性

属性必填类型描述
id字符串唯一的16字符十六进制标识符
type
是 | 字符串 | text、file、link 或 group | | x | 是 | 整数 | X位置(像素) | | y | 是 | 整数 | Y位置(像素) | | width | 是 | 整数 | 宽度(像素) | | height | 是 | 整数 | 高度(像素) | | color | 否 | canvasColor | 预设 1-6 或十六进制(例如 #FF0000) |

文本节点

属性必填类型描述
text字符串包含Markdown语法的纯文本

json
{
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字符串系统内的文件路径
subpath
否 | 字符串 | 指向标题或块的链接(以 # 开头) |

json
{
id: a1b2c3d4e5f67890,
type: file,
x: 500,
y: 0,
width: 400,
height: 300,
file: Attachments/diagram.png
}

链接节点

属性必填类型描述
url字符串外部URL

json
{
id: c3d4e5f678901234,
type: link,
x: 1000,
y: 0,
width: 400,
height: 200,
url: https://obsidian.md
}

组节点

组是用于组织其他节点的视觉容器。将子节点放置在组的边界内。

属性必填类型描述
label字符串组的文本标签
background
否 | 字符串 | 背景图片路径 |
| backgroundStyle | 否 | 字符串 | cover、ratio 或 repeat |

json
{
id: d4e5f6789012345a,
type: group,
x: -50,
y: -50,
width: 1000,
height: 600,
label: Project Overview,
color: 4
}

边通过 fromNode 和 toNode ID连接节点。

属性必填类型默认值描述
id字符串-唯一标识符
fromNode
是 | 字符串 | - | 源节点ID |
| fromSide | 否 | 字符串 | - | top、right、bottom 或 left |
| fromEnd | 否 | 字符串 | none | none 或 arrow |
| toNode | 是 | 字符串 | - | 目标节点ID |
| toSide | 否 | 字符串 | - | top、right、bottom 或 left |
| toEnd | 否 | 字符串 | arrow | none 或 arrow |
| color | 否 | canvasColor | - | 线条颜色 |
| label | 否 | 字符串 | - | 文本标签 |

json
{
id: 0123456789abcdef,
fromNode: 6f0ad84f44ce9c17,
fromSide: right,
toNode: a1b2c3d4e5f67890,
toSide: left,
toEnd: arrow,
label: leads to
}

颜色

canvasColor 类型接受十六进制字符串或预设数字:

预设颜色
1红色
2
橙色 |
| 3 | 黄色 |
| 4 | 绿色 |
| 5 | 青色 |
| 6 | 紫色 |

预设颜色值有意未定义——应用程序使用自己的品牌颜色。

ID生成

生成16字符小写十六进制字符串(64位随机值):

6f0ad84f44ce9c17
a3b2c1d0e9f8a7b6

布局指南

  • - 坐标可以为负数(画布无限延伸)
  • x 向右增加,y 向下增加;位置为左上角
  • 节点间距50-100px;组内保留20-50px内边距
  • 对齐网格(10或20的倍数)以获得更整洁的布局
节点类型建议宽度建议高度
小文本200-30080-150
中文本
300-450

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 json-canvas-1776209393 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 json-canvas-1776209393 技能

通过命令行安装

skillhub install json-canvas-1776209393

下载

⬇ 下载 json-canvas v1.0.0(免费)

文件大小: 4.71 KB | 发布时间: 2026-4-15 13:50

v1.0.0 最新 2026-4-15 13:50
- Initial release of the json-canvas skill.
- Enables creation and editing of JSON Canvas (.canvas) files with support for nodes, edges, groups, and connections.
- Includes detailed workflows for creating canvases, adding nodes, connecting nodes, and editing structures.
- Supports all node types: text, file, link, and group, following JSON Canvas Spec 1.0.
- Provides comprehensive validation guidelines to ensure file integrity.
- Offers layout suggestions, example structures, and references for further learning.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部