RevisionTracker (revision-history)



Creates and updates revisions based on changes of the editor content.

There are always at least two revisions available for the document: the initial revision and the current revision. If those revisions have not been created for the document yet, they are created when the editor data is loaded.

The initial revision contains the initial document data from when the document was loaded for the first time.

The current revision contains all the unsaved document changes, that is changes which have not been saved yet as a specific revision. The current revision is always available and it is always the "top" revision (most recent).



  • adapter : RevisionHistoryAdapter

    An adapter object that should communicate with the data source to fetch or save the revisions data.

    This property is also set through adapter.


  • addRevisionData( revisionData ) → Revision

    Creates a revision basing on given revision data and adds it to the revision tracker and revision repository.


    revisionData : Object

    Revision data.



    The created revision.

  • saveRevision( [ revisionData ] = { [], [], [revisionData.attributes] }, [ version ] ) → Promise

    Creates and saves a new revision.

    // Saves all the unsaved changes as a revision without a name.
    const myRevision = await revisionTracker.saveRevision();
    // Saves all the unsaved changes as a revision named 'My revision'.
    const myRevision = await revisionTracker.saveRevision( { name: 'My revision' } );
    // Saves a revision named 'My revision'.
    // It will include document data with all the changes up to document version `30`.
    // The revision will be on "top" of the closest revision with a lower document version.
    // The revision diff will include all the changes since the previous revision up to document version `30`.
    const myRevision = await revisionTracker.saveRevision( { name: 'My revision' }, 30 );

    A new revision can be created in the middle of the revision history. In such case, already existing revisions will be appropriately updated.


    [ revisionData ] : Object

    Revision data to set on the created revision.

    [ ] : String

    Revision name.

    [ ] : String

    Revision id.

    [ revisionData.attributes ] : Object

    Revision attributes.

    [ version ] : Number

    Document version on which the revision is saved. If not set, the revision will be saved for the current (most recent) document state.



    Promise that resolves with the created revision after it is saved locally (the promise does not wait for the adapter update).

  • update() → Promise

    Adds the new document changes to the current revision.

    This method should be called before document data and revision data is saved (for example, in the autosave callback).



    Promise that is resolved after the revision is updated locally (the promise does not wait for the adapter update).