logo
  • Docs
  • API Reference
    Introduction
    What is Lix?
    Getting Started
    Comparison to Git
    Lix for AI Agents
    Essentials
    How Lix Works
    Querying Changes
    Data Model
    Plugins
    Persistence
    Guides
    Versions (Branching)
    History
    Diffs
    Attribution (Blame)
    Change Proposals
    Validation Rules
    Undo/Redo
    Restore
    Conversations
    Labels
    Key-Value Store
    Environment API
    Testing
    React Integration
    Logging & Debugging
    Deterministic Mode
    Metadata
    Writer Key
    Architecture
    Lix as File Format
    Previous pageValidation RulesNext pageRestore

    #Undo/Redo

    Undo and redo are fundamental features for any application that involves editing. Lix provides simple undo() and redo() commands that are built on top of its robust history and restore capabilities.

    This makes it easy to implement reliable undo/redo functionality in your application, allowing users to step backward and forward through their changes with confidence. You can even undo or redo multiple steps at once.

    Undo/Redo

    #Examples

    import { openLix } from "@lix-js/sdk";
    // Basic undo operation
    await undo({ lix });
    console.log("Performed undo operation");
    
    // Undo with a specific number of steps
    await undo({ lix, steps: 3 });
    console.log("Performed undo with 3 steps");
    
    // Basic redo operation
    await redo({ lix });
    console.log("Performed redo operation");