Collaboration
Save, compare and restore versions
Edit a shared budget with a teammate, save a version, compare it with the approved budget and restore part of it.
Entry point @sheetwrite/core/history
- Authors
- You, Sam Lee
- Starts from
- Budget approved
Try it
How versions are kept
- The server records each committed change in the archive, with its author. Edits that are not committed yet never reach a version.
- Versions store each block of cells once and share the blocks that did not change, so a new version costs only what changed.
- A restore is one undoable change and one synced transaction, so Sam's client receives it like any other edit.
The first compare loads a small WebAssembly module.
The code behind it
import "@sheetwrite/core/styles.css";import {} from "@sheetwrite/core";
// The document to edit; a snapshot with a "budget" sheet and this documentIdconst documentId = "budget-2027";
// The server records every committed change, with its author, in the archive.// MemoryPersistenceAdapter stands in for your server here.
// Review › Version History and Save Version in the ribbon// The grid fills its host, so the host needs a heightconst host = document.querySelector<HTMLElement>("#grid");if (host === null) throw new Error("Missing #grid host");host.style.height = "480px";});});
// Name the committed head, compare it with the current document, restore a range { sync },);
// When the page removes the host: sync.destroy(); grid.destroy();