Commit 0f6272f
feat(tldraw): add allowVideoAutoplay option to TldrawOptions (tldraw#8943)
In order to let SDK consumers disable video autoplay across the board
without subclassing `VideoShapeUtil`, this PR adds a top-level
`allowVideoAutoplay` option to `TldrawOptions`. The host opt-out acts as
a ceiling, not a floor: when `false`, no video autoplays regardless of
its per-shape `autoplay` prop; when `true` (the default, preserving
existing behavior), each shape's per-shape `autoplay` prop is respected.
The `prefers-reduced-motion` check at the render site continues to apply
independently.
```tsx
<Tldraw options={{ allowVideoAutoplay: false }} />
```
### Behavior matrix
| `TldrawOptions.allowVideoAutoplay` | `shape.props.autoplay` | Result |
| ---------------------------------- | ---------------------- |
--------------- |
| `true` (default) | `true` | Autoplays |
| `true` (default) | `false` | Does not play |
| `false` | `true` | Does not play |
| `false` | `false` | Does not play |
So `allowVideoAutoplay: false` is a global opt-out for the host app — it
never forces every video to play. The per-shape prop remains the way
users opt individual shapes in or out when autoplay is allowed at the
host level.
Closes [tldraw#8915](tldraw#8915).
### Change type
- [x] \`feature\`
### Test plan
1. Create a tldraw editor with \`<Tldraw options={{ allowVideoAutoplay:
false }} />\`.
2. Drop a video file onto the canvas — confirm it does not start playing
automatically.
3. Click into the video to edit, press play — confirm the user can still
play it manually.
4. With the default option (or \`allowVideoAutoplay: true\`), drop a
video and confirm it still autoplays as before.
5. With the default option, set \`shape.props.autoplay = false\` on an
individual video — confirm only that shape stops autoplaying while
others still autoplay.
### Release notes
- Add an \`allowVideoAutoplay\` option to \`TldrawOptions\`. When set to
\`false\`, no video shape autoplays regardless of its per-shape
\`autoplay\` prop — including pasted and restored shapes. Defaults to
\`true\`.
### API changes
- Added \`TldrawOptions.allowVideoAutoplay: boolean\` (default
\`true\`).
### Code changes
| Section | LOC change |
| --------------- | ---------- |
| Core code | +18 / -1 |
| Automated files | +2 / -0 |
| Documentation | +7 / -0 |
---------
Co-authored-by: Max Drake <maxdrake46@gmail.com>1 parent a8199ec commit 0f6272f
5 files changed
Lines changed: 26 additions & 1 deletion
File tree
- apps/docs/content/sdk-features
- packages
- editor
- src/lib
- tldraw/src/lib/shapes/video
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
327 | 333 | | |
328 | 334 | | |
329 | 335 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
718 | 718 | | |
719 | 719 | | |
720 | 720 | | |
| 721 | + | |
721 | 722 | | |
722 | 723 | | |
723 | 724 | | |
| |||
3754 | 3755 | | |
3755 | 3756 | | |
3756 | 3757 | | |
| 3758 | + | |
3757 | 3759 | | |
3758 | 3760 | | |
3759 | 3761 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
212 | 223 | | |
213 | 224 | | |
214 | 225 | | |
| |||
347 | 358 | | |
348 | 359 | | |
349 | 360 | | |
| 361 | + | |
350 | 362 | | |
351 | 363 | | |
352 | 364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
214 | 218 | | |
215 | 219 | | |
216 | 220 | | |
| |||
0 commit comments