-
Notifications
You must be signed in to change notification settings - Fork 201
/
canvas.d.ts
97 lines (82 loc) · 2.9 KB
/
canvas.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* A color used to encode color data for nodes and edges
* can be a number (like '1') representing one of the (currently 6) supported colors.
* or can be a custom color using the hex format '#FFFFFFF'.
*/
export type CanvasColor = string;
/** The overall canvas file's JSON */
export interface CanvasData {
nodes: AllCanvasNodeData[];
edges: CanvasEdgeData[];
/** Support arbitrary keys for forward compatibility */
[key: string]: any;
}
/** A node */
export interface CanvasNodeData {
/** The unique ID for this node */
id: string;
// The positional data
x: number;
y: number;
width: number;
height: number;
/** The color of this node */
color?: CanvasColor;
// Support arbitrary keys for forward compatibility
[key: string]: any;
}
export type AllCanvasNodeData = CanvasFileData | CanvasTextData | CanvasLinkData | CanvasGroupData;
/** A node that is a file, where the file is located somewhere in the vault. */
export interface CanvasFileData extends CanvasNodeData {
type: 'file';
file: string;
/** An optional subpath which links to a heading or a block. Always starts with a `#`. */
subpath?: string;
}
/** A node that is plaintext. */
export interface CanvasTextData extends CanvasNodeData {
type: 'text';
text: string;
}
/** A node that is an external resource. */
export interface CanvasLinkData extends CanvasNodeData {
type: 'link';
url: string;
}
/** The background image rendering style */
export type BackgroundStyle = 'cover' | 'ratio' | 'repeat';
/** A node that represents a group. */
export interface CanvasGroupData extends CanvasNodeData {
type: 'group';
/** Optional label to display on top of the group. */
label?: string;
/** Optional background image, stores the path to the image file in the vault. */
background?: string;
/** Optional background image rendering style; defaults to 'cover'. */
backgroundStyle?: BackgroundStyle;
}
/** The side of the node that a connection is connected to */
export type NodeSide = 'top' | 'right' | 'bottom' | 'left';
/** What to display at the end of an edge */
export type EdgeEnd = 'none' | 'arrow';
/** An edge */
export interface CanvasEdgeData {
/** The unique ID for this edge */
id: string;
/** The node ID and side where this edge starts */
fromNode: string;
fromSide?: NodeSide;
/** The starting edge end; defaults to 'none' */
fromEnd?: EdgeEnd;
/** The node ID and side where this edge ends */
toNode: string;
toSide?: NodeSide;
/** The ending edge end; defaults to 'arrow' */
toEnd?: EdgeEnd;
/** The color of this edge */
color?: CanvasColor;
/** The text label of this edge, if available */
label?: string;
// Support arbitrary keys for forward compatibility
[key: string]: any;
}