Edit history

After you edit cell values, formulas, or formatting, open the history panel to review earlier versions, compare changes, and restore a version when you have the corresponding permission. History reads the versions persisted on the server. Undo and redo apply only to the current editing session and do not require the history service.

Prepare collaboration and history services

Complete collaboration integration and license configuration first, then verify that two sessions can edit the same Sheets document and that changes survive a reload.

Office collaboration extensions and the History example describe how to connect history storage and permissions. Core collaboration does not enable history on its own. The backend must also provide history lists, version content, and restoration.

Add this configuration to the existing product, license, and collaboration setup. If a preset or an existing configuration already registers these plugins, update that configuration instead of registering them a second time.

Plugin mode

Installation

Shell
pnpm add @univerjs-pro/edit-history @univerjs-pro/edit-history-ui @univerjs-pro/sheets-history @univerjs-pro/sheets-history-ui

Usage

TypeScript
import { UniverEditHistoryPlugin } from '@univerjs-pro/edit-history'import EditHistoryLocale from '@univerjs-pro/edit-history-ui/locale/en-US'import { UniverSheetsHistoryPlugin } from '@univerjs-pro/sheets-history'import { UniverSheetsHistoryUIPlugin } from '@univerjs-pro/sheets-history-ui'import HistoryLocale from '@univerjs-pro/sheets-history-ui/locale/en-US'import { LocaleType, mergeLocales } from '@univerjs/core'import '@univerjs-pro/edit-history-ui/lib/index.css'import '@univerjs-pro/sheets-history-ui/lib/index.css'const historyServerUrl = '/api/history'univerAPI.loadLocales(LocaleType.EN_US, mergeLocales(EditHistoryLocale, HistoryLocale))univer.registerPlugin(UniverEditHistoryPlugin, { historyServerUrl })univer.registerPlugin(UniverSheetsHistoryPlugin)univer.registerPlugin(UniverSheetsHistoryUIPlugin, {  univerContainerId: 'app',  historyServerUrl,})

Plugin configuration

UniverEditHistoryPlugin

  • historyServerUrl
    stringDefault: '/universer-api/history'
    Base URL of the history service.

UniverSheetsHistoryUIPlugin

  • historyServerUrl
    stringDefault: '/universer-api/history'
    Base URL of the history service.
  • univerContainerId
    string
    DOM ID of the editor container.

Replace /api/history with the application's actual history endpoint, and ensure that the endpoint matches the requests the client sends. Both historyServerUrl values must be identical. Set univerContainerId to the DOM ID of the editor container, and load the locale that the editor uses.

Sheets history also requires the UniverCollaborationClientUIPlugin to be registered in the collaboration setup.

Mobile support

Set up the mobile editor first. In the plugin-mode setup on this page, replace the desktop registrations below with the mobile exports from the same packages, and do so before opening a document. Keep the model plugins, styles, locales, and Facade imports, and register only one variant.

PackageDesktop registrationMobile registration
@univerjs-pro/sheets-history-uiUniverSheetsHistoryUIPluginUniverSheetsHistoryMobileUIPlugin

Preset mode

Installation

Shell
pnpm add @univerjs/preset-sheets-collaboration

Usage

UniverSheetsCollaborationPreset includes the history UI and the plugins it depends on. Keep the existing editor and license setup. If the preset is already registered, update it rather than registering the preset or the history plugins a second time.

TypeScript
import { UniverSheetsCollaborationPreset } from '@univerjs/preset-sheets-collaboration'import CollaborationLocale from '@univerjs/preset-sheets-collaboration/locales/en-US'import '@univerjs/preset-sheets-collaboration/lib/index.css'const collaborationPreset = UniverSheetsCollaborationPreset({  universerEndpoint: 'https://your-server.example',  univerContainerId: 'app',})

Preset configuration

UniverSheetsCollaborationPreset

  • universerEndpoint
    stringDefault: window.location.origin
    Base URL of the collaboration server.
  • univerContainerId
    stringDefault: 'app'
    DOM ID of the editor container.

Add collaborationPreset to the presets array of the existing createUniver() call, and merge CollaborationLocale into the matching locale entry. Set universerEndpoint to the base URL of the server and univerContainerId to the editor container ID. The preset composes the history URL as {universerEndpoint}/universer-api/history, so use Plugin Mode when a custom historyServerUrl or viewerPlugins is required. The backend services described above remain required.

View and restore versions

Open the history panel from the editor menu and select a version to inspect its content and changes. Restoration rewrites the current shared document, so only users with the restore permission should be able to perform it, and the server must enforce that permission.

To verify the integration, edit a cell value, a formula, or some formatting, wait for collaboration to confirm the change, and then inspect the history list and the version content. Reopen the application and restart the service to confirm that all data persisted. Restore an earlier version and confirm that another browser session receives the restored state.

If the list is empty, first check whether history was recorded for this document at all, then check the document ID and the service URL. If viewing works but restoration fails, check the restore permissions and the collaboration connection. Reading history also requires authorization, because older versions may contain data that has since been deleted.

Compare snapshots

To build a review screen or pass changes to an AI Agent, call compareUnitData(), or compute the comparison once with prepareUnitComparison() and query it repeatedly. Register the product's History plugin and import the Facade entry, then pass two fully materialized snapshots of the same unit as beforeSnapshot and afterSnapshot. The comparison is read-only, requires no history service, and neither restores nor merges content.

TypeScript
import { UnitComparisonDetailLevel, UnitComparisonFidelity } from '@univerjs-pro/edit-history'import { UniverInstanceType } from '@univerjs/core'import '@univerjs-pro/edit-history/facade'const comparison = univerAPI.prepareUnitComparison({  comparisonId: 'review-1',  unitId: beforeSnapshot.id,  type: UniverInstanceType.UNIVER_SHEET,  fidelity: UnitComparisonFidelity.SNAPSHOT,  leftData: beforeSnapshot,  rightData: afterSnapshot,})const overview = comparison.query({ detail: UnitComparisonDetailLevel.SUMMARY })const scope = overview.scopes[0]const page = comparison.query({ scope, offset: 0, limit: 100 })console.log(page.items, page.page.hasMore, page.diagnostics)

Read scopes to discover the available views, then pass one of them to query() to filter the result without rerunning the comparison. A page returns 100 items by default and up to 1,000. Use page.hasMore together with offset to retrieve the remaining items. summary describes the entire comparison even when the items are filtered. Check diagnostics.readiness and diagnostics.codes before treating the result as a complete comparison. For Node.js or CLI usage without an editor, see the headless comparison API.

How is this guide?

© 2026 DreamNum Co., Ltd.