Skip to content

Instantly share code, notes, and snippets.

@egeozcan
Created March 11, 2024 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egeozcan/27db06f6771dcf214f0f92bce8c4fe79 to your computer and use it in GitHub Desktop.
Save egeozcan/27db06f6771dcf214f0f92bce8c4fe79 to your computer and use it in GitHub Desktop.
type CanvasColor = string | 1 | 2 | 3 | 4 | 5 | 6;
interface Canvas {
nodes?: Node[];
edges?: Edge[];
}
type Node = TextNode | FileNode | LinkNode | GroupNode;
interface BaseNode {
id: string;
type: string;
x: number;
y: number;
width: number;
height: number;
color?: CanvasColor;
}
interface TextNode extends BaseNode {
type: "text";
text: string;
}
interface FileNode extends BaseNode {
type: "file";
file: string;
subpath?: string;
}
interface LinkNode extends BaseNode {
type: "link";
url: string;
}
interface GroupNode extends BaseNode {
type: "group";
label?: string;
background?: string;
backgroundStyle?: "cover" | "ratio" | "repeat";
}
interface Edge {
id: string;
fromNode: string;
fromSide?: "top" | "right" | "bottom" | "left";
fromEnd?: "none" | "arrow";
toNode: string;
toSide?: "top" | "right" | "bottom" | "left";
toEnd?: "none" | "arrow";
color?: CanvasColor;
label?: string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment