Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: pushed new JSON-Schema #5

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sample.canvas
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "./schema.json",
"nodes":[
{"id":"8132d4d894c80022","type":"file","file":"readme.md","x":-280,"y":-200,"width":570,"height":560,"color":"6"},
{"id":"7efdbbe0c4742315","type":"file","file":"_site/logo.svg","x":-280,"y":-440,"width":217,"height":80},
Expand Down
314 changes: 314 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"default": {
"edges": [],
"nodes": []
},
"properties": {
"edges": {
"description": "Edges are lines that connect one node to another",
"items": {
"$ref": "#/definitions/JSONCanvasEdge"
},
"type": "array"
},
"nodes": {
"description": "Nodes are objects within the canvas. Nodes may be text, files, links, or groups",
"items": {
"$ref": "#/definitions/JSONCanvasNode"
},
"type": "array"
}
},
"$defs": {
"JSONCanvasColor": {
"anyOf": [
{
"description": "A color in hex format, e.g. #ff0000",
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
{
"$ref": "#/definitions/JSONCanvasColorPreset"
}
]
},
"JSONCanvasColorPreset": {
"title": "A preset color.",
"description": "Six preset colors exist, mapped to the following numbers:\n1 red\n2 orange\n3 yellow\n4 green\n5 cyan\n6 purple",
"enum": ["1", "2", "3", "4", "5", "6"],
"type": "string"
},
"JSONCanvasEdge": {
"additionalProperties": false,
"properties": {
"color": {
"$ref": "#/definitions/JSONCanvasColor"
},
"fromNode": {
"description": "The ID of the node that the edge starts from",
"type": "string"
},
"fromSide": {
"description": "The side of the node that the edge connects from",
"$ref": "#/definitions/JSONCanvasEdgeSide"
},
"id": {
"description": "The ID for the edge",
"type": "string"
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define a NodeId schema. That will help to give semantic info to properties like fromNode.

"label": {
"description": "The text label for the edge",
"type": "string"
},
"toEnd": {
"$ref": "#/definitions/JSONCanvasEdgeEnd"
},
"toNode": {
"description": "The ID of the node that the edge ends at",
"type": "string"
},
"toSide": {
"description": "The side of the node that the edge connects to",
"$ref": "#/definitions/JSONCanvasEdgeSide"
}
},
"required": ["id", "fromNode", "toNode"],
"type": "object"
},
"JSONCanvasEdgeEnd": {
"description": "The rendering style of the end of the edge line",
"enum": ["none", "arrow"],
"type": "string"
},
"JSONCanvasEdgeSide": {
"description": "The side of the node that the edge connects to",
"enum": ["top", "right", "bottom", "left"],
"type": "string"
},
"JSONCanvasFileNode": {
"additionalProperties": false,
"properties": {
"color": {
"$ref": "#/definitions/JSONCanvasColor"
},
"file": {
"description": "The path to the file within the system",
"type": "string",
"minLength": 1
},
"height": {
"description": "The height of the node in pixels",
"type": "integer"
},
"id": {
"description": "Unique ID for the node",
"type": "string"
},
"subpath": {
"description": "The subpath that may link to a heading or a block. Always starts with a #",
"type": "string"
},
"type": {
"description": "The node type",
"const": "file",
"type": "string"
},
"width": {
"description": "The width of the node in pixels",
"type": "integer"
},
"x": {
"description": "The x position of the node in pixels",
"type": "integer"
},
"y": {
"description": "The y position of the node in pixels",
"type": "integer"
}
},
"required": ["file", "height", "id", "type", "width", "x", "y"],
"type": "object"
},
"JSONCanvasGroupNode": {
"additionalProperties": false,
"properties": {
"background": {
"description": "The path to the background image",
"type": "string"
},
"backgroundStyle": {
"title": "The rendering style of a background image.",
"description": "Options are:\ncover - fills the entire width and height of the node.\nratio - maintains the aspect ratio of the background image.\nrepeat - repeats the image as a pattern in both x/y directions.",
"enum": ["cover", "ratio", "repeat"],
"type": "string"
},
"color": {
"$ref": "#/definitions/JSONCanvasColor"
},
"height": {
"description": "The height of the node in pixels",
"type": "integer"
},
"id": {
"description": "Unique ID for the node",
"type": "string"
},
"label": {
"description": "The text label for the group",
"type": "string"
},
"type": {
"description": "The node type",
"const": "group",
"type": "string"
},
"width": {
"description": "The width of the node in pixels",
"type": "integer"
},
"x": {
"description": "The x position of the node in pixels",
"type": "integer"
},
"y": {
"description": "The y position of the node in pixels",
"type": "integer"
}
},
"required": ["height", "id", "type", "width", "x", "y"],
"type": "object"
},
"JSONCanvasLinkNode": {
"additionalProperties": false,
"properties": {
"color": {
"$ref": "#/definitions/JSONCanvasColor"
},
"height": {
"description": "The height of the node in pixels",
"type": "integer"
},
"id": {
"description": "Unique ID for the node",
"type": "string"
},
"type": {
"description": "The node type",
"const": "link",
"type": "string"
},
"url": {
"type": "string"
},
"width": {
"description": "The width of the node in pixels",
"type": "number"
chainlist marked this conversation as resolved.
Show resolved Hide resolved
},
"x": {
"description": "The x position of the node in pixels",
"type": "number"
chainlist marked this conversation as resolved.
Show resolved Hide resolved
},
"y": {
"description": "The y position of the node in pixels",
"type": "integer"
}
},
"required": ["height", "id", "type", "url", "width", "x", "y"],
"type": "object"
},
"JSONCanvasNode": {
"anyOf": [
{
"$ref": "#/definitions/JSONCanvasNodeGeneric"
},
{
"$ref": "#/definitions/JSONCanvasTextNode"
},
{
"$ref": "#/definitions/JSONCanvasFileNode"
},
{
"$ref": "#/definitions/JSONCanvasLinkNode"
},
{
"$ref": "#/definitions/JSONCanvasGroupNode"
}
]
},
"JSONCanvasNodeGeneric": {
"additionalProperties": false,
"properties": {
"color": {
"$ref": "#/definitions/JSONCanvasColor"
},
"height": {
"description": "The height of the node in pixels",
"type": "integer"
},
"id": {
"description": "Unique ID for the node",
"type": "string"
},
"type": {
"description": "The node type",
"enum": ["text", "file", "link", "group"],
"type": "string"
},
"width": {
"description": "The width of the node in pixels",
"type": "integer"
},
"x": {
"description": "The x position of the node in pixels",
"type": "integer"
},
"y": {
"description": "The y position of the node in pixels",
"type": "integer"
}
},
"required": ["id", "type", "x", "y", "width", "height"],
"type": "object"
},
"JSONCanvasTextNode": {
"additionalProperties": false,
"properties": {
"color": {
"$ref": "#/definitions/JSONCanvasColor"
},
"height": {
"description": "The height of the node in pixels",
"type": "number"
chainlist marked this conversation as resolved.
Show resolved Hide resolved
},
"id": {
"description": "Unique ID for the node",
"type": "string"
},
"text": {
"description": "Plain text with Markdown syntax",
"type": "string"
},
"type": {
"description": "The node type",
"const": "text",
"type": "string"
},
"width": {
"description": "The width of the node in pixels",
"type": "number"
chainlist marked this conversation as resolved.
Show resolved Hide resolved
},
"x": {
"description": "The x position of the node in pixels",
"type": "number"
chainlist marked this conversation as resolved.
Show resolved Hide resolved
},
"y": {
"description": "The y position of the node in pixels",
"type": "number"
chainlist marked this conversation as resolved.
Show resolved Hide resolved
}
},
"required": ["height", "id", "text", "type", "width", "x", "y"],
"type": "object"
}
}
}