Edit history

Plugins Info

After moving elements, editing text, or changing connectors, open history to inspect earlier versions, compare changes, and restore a version when permitted. History reads the versions that the server persists. Undo and redo apply to the current editing session and do not require the history service.

Prepare collaboration and history services

Set up collaboration integration and license configuration. Then verify that two sessions can edit the same Boards document and that changes survive a reload.

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

Add the history plugins

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

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

Plugin configuration

UniverEditHistoryPlugin

  • historyServerUrl
    stringDefault: '/universer-api/history'
    History service base URL.

UniverBoardsHistoryUIPlugin

  • historyServerUrl
    stringDefault: '/universer-api/history'
    History service base URL.
  • univerContainerId
    string
    DOM ID of the editor container.
  • viewerPlugins
    [PluginCtor, object?][]
    Additional plugins for the history viewer.
    • [0]
      PluginCtor
      Plugin constructor.
    • [1]
      object
      Options accepted by that plugin’s constructor.

Replace /api/history with the history endpoint of your application and verify that its API matches the requests the client sends. Keep both historyServerUrl values identical. Set univerContainerId to the DOM ID of the editor container, and load the locale that matches the editor.

The history viewer creates a separate read-only editor. When the document contains custom content, use viewerPlugins to add the plugins that the viewer does not include. Do not register the built-in viewer plugins again.

View and restore versions

Open history from the editor menu and select a version to inspect its content and changes. Restoring a version modifies the shared document, so only users with restore permission should be able to do so, and the server must enforce that permission.

To verify the integration, move elements, edit text, or change connectors, wait for collaboration confirmation, then inspect the history list and version content. Reopen the application and restart the service to confirm that the data persists. Restore an earlier version and confirm that another browser session receives the restored state.

If the list is empty, check whether history was recorded for this document, then check the document ID and service URL. If viewing works but restoration fails, check 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 provide changes to an AI Agent, use compareUnitData(), or compute the comparison once with prepareUnitComparison(). Register the product 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: it requires no history service and does not restore or merge 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_BOARD,  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)

scopes lists the available views. Pass a selected scope to query() to filter the result without rerunning the comparison. A page returns 100 items by default and accepts up to 1,000. Use page.hasMore with offset to retrieve further items. summary describes the whole comparison even when 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.