editor

Docs › Saving and output

Revisions

Versions kept every minute while writing; compare and restore.

While you write, the editor keeps earlier states of the post as versions. The revisions button lists them, shows what changed against the current text, and restores the one you pick. Use it when undo would have to go back too far.

Try it

Code for this demo

createEditor('#editor', {
  toolbar: 'heading | bold italic | bulletList | revisions',
  revisions: { key: 'docs-revisions-demo', interval: 5000 },
});

Behavior

  • Every interval (default one minute), and when the editor loses focus, it checks for changes. If there are any, the state before them is kept as a version.
  • Only the latest max versions (default 20) are kept.
  • The list shows time and length. Picking one shows, word by word, what was deleted since (struck through) and what was added (underlined).
  • Restore this version is an ordinary undoable change: Ctrl+Z brings the text back.

Where versions live

With only the revisions toolbar item, versions last for this page view (gone on reload). With revisions: true or an object, they are stored in localStorage under e82:rev: + key and survive a reload; without key the page path is used.

createEditor('#editor', {
  toolbar: 'board',              // board and full have it under the ⋯ menu
  revisions: { key: 'post-' + postId, max: 30 },
});

The toolbar item is revisions. It sits in the ⋯ menu of the board (default) and full presets, not in minimal or basic.

Options

NameTypeDefaultDescription
revisionstoolbar item-Opens the revisions dialog
revisionsboolean | objectthis page viewtrue or an object stores versions in localStorage
revisions.keystringpage pathStorage key (after e82:rev:)
revisions.maxnumber20Versions kept
revisions.intervalnumber60000Milliseconds between checks