SVeditor Docs
Data Persistence & Sync

Version History

Snapshot-based document versioning for local and auto-save demo workflows.

Version History

SVeditor can store document snapshots in localStorage for local trials and lightweight single-user workflows. Version history works alongside auto-save for undo-friendly local editing.

Local Version History

Local snapshots are stored in localStorage. Use the editor right sidebar Version history entry to list, restore, and create snapshots; configure storage with extensionsOptions.versionHistory.

SVeditor.create({
  el: "#editor",
  extensionsOptions: {
    versionHistory: {
      enabled: true,
      local: {
        storageKey: "my-doc-v1",
        maxEntries: 50,
        debounceMs: 2000,
      },
    },
  },
});

With Auto-save

Auto-save persists the latest body to your backend. Version history keeps snapshots separately, so users can recover earlier local states while onSaveContent continues to save the current document.

SVeditor.create({
  el: "#editor",
  extensionsOptions: {
    autoSave: {
      onFetch: () => fetchContent(docId),
      onSaveContent: (json) => saveContent(docId, json),
    },
    versionHistory: {
      enabled: true,
      local: {
        storageKey: `doc:${docId}:snapshots`,
        maxEntries: 50,
      },
    },
  },
});

Configuration

interface VersionHistoryOptions {
  enabled: boolean;

  /** Local storage key */
  storageKey?: string;

  /** Max local snapshots to retain. Default: 50 */
  maxEntries?: number;

  /** Auto-snapshot debounce in ms. Default: 2000 */
  debounceMs?: number;
}

Notes

  1. Use a stable storageKey per document to avoid mixing snapshots.
  2. Keep maxEntries bounded; snapshots may be large for media-heavy documents.
  3. Local snapshots are browser-local. They are useful for recovery, but they are not a replacement for server persistence.

On this page

MuseCanto

Creator ops workspace from inspiration to publishing and review.

Explore MuseCanto