Any details on the canvas API?

Has any details on a canvas API been released?

I know we’ve got the four commands: New file, Export as image, Jump to group and Convert to file…, but I’m more wanting to know if someone knows of other ways to interact with the commands through some internal API stuff?

Like is there any function calls to add new cards, or link notes, or similar to an open canvas? Is this kind of API exposed (and ready for use) by our scripts somehow?

(Part of the reason for asking, is that I’m thinking of using a canvas to do a visual reordering of a task list, and it would be really neat to “toss” every task onto a canvas (as cards), do a visual re-order or grouping, and then have some function to export these cards again as a task list. )

8 Likes

For anyone wondering, you can inspect the Canvas methods by opening a canvas file in Obsidian and typing app.workspace.getLeavesOfType('canvas')[0].view.canvas in the dev console.

6 Likes

@demeneer, thank you for the starting point.
I’ve created a plugin with features like copying styles, merging and splitting cards, custom shapes, and hotkeys.
There are various bugs and glitches, but perhaps someone will find it useful.

ec-features

2 Likes

Requesting changes in Canvas API

  • There are plugins for make Canvases really cool — ex: Advanced Canvas
  • There is a way to introspect canvas object methods.

But it is not enough:

While editing the canvases we cannot get even Editor object, to retrieve selected text, a ppend some text etc.

This change need to be done by Obsidian itself.

World needs the Canvas API! (… and Graph API)

It is relatively easy to work with more conventional UIs - lists, grids, etc.
But node-based UI is something that typical HTML+CSS doesn’t lend to naturally.
The help from Obsidian developers can help a lot with visualizing our second brains in more organic way!

Obsidian team previously open-sourced the canvas format: https://jsoncanvas.org/
Would’ve been nice if Obsidian allowed to draw a navigable (not necessarily editable) Canvas from in-memory JSON.

Related: