Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
obsidian-api/canvas.d.ts
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
70 lines (61 sloc)
1.95 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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[]; | |
| } | |
| // 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; | |
| } | |
| 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; | |
| } | |
| // A node that represents a group. | |
| export interface CanvasGroupData extends CanvasNodeData { | |
| type: 'group'; | |
| label?: string; | |
| } | |
| // The side of the node that a connection is connected to | |
| export type NodeSide = 'top' | 'right' | 'bottom' | 'left'; | |
| // 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 node ID and side where this edge ends | |
| toNode: string; | |
| toSide: NodeSide; | |
| // The color of this edge | |
| color?: CanvasColor; | |
| // The text label of this edge, if available | |
| label?: string; | |
| } |