Skip to content

Instantly share code, notes, and snippets.

@TfTHacker
Created December 6, 2022 04:29
Show Gist options
  • Save TfTHacker/52a6c3f3041a7043d152ef56af336ed6 to your computer and use it in GitHub Desktop.
Save TfTHacker/52a6c3f3041a7043d152ef56af336ed6 to your computer and use it in GitHub Desktop.
Obsidian Canvas JSON format (TypeScript definition)
export type Side = 'top' | 'right' | 'bottom' | 'left';
export interface CanvasData {
nodes: (CanvasFileData | CanvasTextData | CanvasLinkData)[];
edges: CanvasEdgeData[];
}
export interface CanvasNodeData {
id: string;
x: number;
y: number;
width: number;
height: number;
color: string;
}
export interface CanvasEdgeData {
id: string;
fromNode: string;
fromSide: Side;
toNode: string;
toSide: Side;
color: string;
label: string;
}
export interface CanvasFileData extends CanvasNodeData {
type: 'file';
file: string;
}
export interface CanvasTextData extends CanvasNodeData {
type: 'text';
text: string;
}
export interface CanvasLinkData extends CanvasNodeData {
type: 'link';
url: string;
}
@TfTHacker
Copy link
Author

@rstuven
Copy link

rstuven commented Mar 3, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment