tldraw / tldraw

SDK for creating whiteboards and canvas experiences on the web.
https://tldraw.dev
Other
35.04k stars 2.12k forks source link

[Feature]: CLI export application #1491

Closed DhruvaSambrani closed 1 month ago

DhruvaSambrani commented 1 year ago

What's the feature?

I would like to export a tldr file as an svg/png using the command line. I need this as an intermediate step before embed those files into a document.

I intend to write a pandoc filter which looks for markdown images with the image url as filename.tldr#pagename.type and uses pagename.type after exporting the pages of filename.tldr. Thus you can use hand-drawn images from tldraw in documents with the images being up to date. This can also be used with quarto.

Contact Details

No response

Code of Conduct

steveruizok commented 1 year ago

tldraw currently requires a browser context in order or create images. We could have an endpoint for this, ie send us the tldr file and we’ll send back an image that we’ve created, though thats probably not what you’d be after.

It might be worth spiking to see how much of the shape toSvg content could be extracted from the shape utils into its own library.

kitschpatrol commented 7 months ago

In case it's helpful to others who find this issue, I've implemented an unofficial tldraw command line tool that uses Puppeteer to export tldraw sketches to SVG and other formats.

It's not super fast, but it works: https://github.com/kitschpatrol/tldraw-cli

Also wrote a Vite plugin on top of this to allow .tldr module imports: https://github.com/kitschpatrol/vite-plugin-tldraw

mimecuvalo commented 1 month ago

The example above using Puppeteer is a reasonable solution for this for folks that need this kind of functionality. We don't plan on officially supporting a CLI at the moment but the tooling above does lend itself to be malleable (and let you do things like using it with Puppeteer). Thanks @kitschpatrol for the example :)