apps/docs/content/releases/v2.4.0.mdx
This release introduces our sync engine as a general-use library, new animation options for shapes, support for image flipping, and many bug fixes and developer experience enhancements.
For the first time, we're releasing our real-time collaboration engine—the one we developed for tldraw.com—as a general library. The SDK still supports any backend for collaboration, but we hope this will be the easiest option for developers. See the new sync package in the repository and the multiplayer-demo example.
You can use Editor.animateShapes to animate shapes on the canvas. Previously only position and rotation would animate. Now you can implement ShapeUtil.getInterpolatedProps to describe how your custom shape's other properties should animate.
override getInterpolatedProps(
startShape: Shape,
endShape: Shape,
t: number
): Shape['props'] {
return {
...endShape.props,
w: lerp(startShape.props.w, endShape.props.w, t),
h: lerp(startShape.props.h, endShape.props.h, t),
}
}
The new Editor.run method runs a function within additional context. By default, the function runs inside a transaction, meaning all changes settle at once—improving performance and avoiding unnecessary renders. You can also use options to ignore history or ignore locked shapes.
editor.run(
() => {
editor.createShapes(myShapes)
editor.sendToBack(myShapes)
editor.selectNone()
},
{ history: 'ignore' }
)
As part of our work on sync, we have a new system for handling large assets like images and videos. Provide a TLAssetStore to control how assets are uploaded and retrieved. Use Editor.uploadAsset and Editor.resolveAssetURL in your shapes and tools.
editor.history.ignore(cb) replaced with editor.run(cb, {history: 'ignore'}).editor.batch deprecated, replaced with editor.run.@tldraw/state imports: If you're importing from @tldraw/state directly, the track function and all hooks (e.g. useValue) have moved to @tldraw/state-react. (#4170)DefaultMenuPanel export. (#4193)fileSize property of TLImageAsset and TLVideoAsset optional. (#4206)TLEditorSnapshot to TldrawImage and useTLStore. (#4190)EffectScheduler and useStateTracking public. (#4155)setDefaultValue to StyleProp. (#4044)ShapeUtil.getInterpolatedProps. (#4162)Editor.run, replacing Editor.batch. (#4042)ShapeIndicators component for custom logic about when to display indicators. (#4083)force flag for camera methods. (#4214)cameraOptions via React causing editor to re-mount. (#4089)snapshots prop in createTLStore. (#4233)InFrontOfTheCanvas component stack order. (#4024)assets prop on <Tldraw /> and <TldrawEditor /> components not being respected. (#4285)