Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.tsdraw.com/llms.txt

Use this file to discover all available pages before exploring further.

tsdraw tracks document changes so users can undo and redo their actions. The system works by capturing full document snapshots at key moments.

Using undo/redo

From the UI, the default toolbar includes undo and redo buttons. Users can also use keyboard shortcuts:
  • Undo: Ctrl/Cmd + Z
  • Redo: Ctrl/Cmd + Shift + Z
On touch devices, two-finger tap triggers undo and three-finger tap triggers redo. Programmatically:
editor.undo()
editor.redo()
Check availability:
editor.canUndo() // true if there's history to undo
editor.canRedo() // true if there's a future state to restore

How it works

The editor maintains a stack of document snapshots. Each user action that modifies the document (drawing a shape, erasing, moving) pushes a new snapshot to the stack. When the user undoes an action, the editor restores the previous snapshot. Redo moves forward through the stack.

History limits

The history stack is capped at 100 entries. Once the limit is reached, the oldest entry is discarded when a new one is added.

Batching

Multiple rapid changes (like dragging to move shapes) are batched into a single undo entry. This means undoing a drag restores the shapes to their position before the drag started, not to each intermediate position.

Touch gestures

On mobile and tablet:
GestureAction
Two-finger tapUndo
Three-finger tapRedo
These gestures can be disabled through touchOptions:
<Tsdraw touchOptions={{ tapUndoRedo: false }} />