Edit your tldraw diagrams directly in Slidev
Add a new slide with the following content:
---
# New tldraw diagram
<tldraw class="w-200 h-140" />
---
Make sure the diagram has a fixed width and height. Check the Slidev UnoCSS docs on which classes are available.
Now, start the slideshow in development mode. Navigate to the slide, add new
shapes etc. The diagram content will be saved under the public
folder and a
reference is created automatically in the existing slide.
Create a public
folder, store the tldraw diagram in it and reference it in the
slide:
---
# Existing tldraw diagram
<tldraw class="w-200 h-140" doc="tldraw/example1.json" />
---
Note that the visible area is fixed to 800x800 for now.
If you want to cover the entire slide with a tldraw diagram, use the following style:
---
# Diagram covering entire slide
<tldraw class="inset-0 w-full h-full" />
---
public/tldraw/assets
folder after uploading.Other tldraw
options, such as multi-page diagrams are disabled (for now). The
addon makes a tradeoff between features and simplicity.
Use your favorite package manager to install the addon:
pnpm add slidev-addon-tldraw
Then define this addon in the frontmatter of the slidedeck or in the slidev
field of the package.json
:
---
addons:
- tldraw
---
or
"slidev": {
"addons": [
"tldraw"
]
},
This addon is licensed MIT. Note that tldraw has a custom license, see their license page for more information.