Interface

RevisionHistoryAdapter (revision-history)

@ckeditor/ckeditor5-revision-history/src/revisionhistory

interface

The revision history adapter.

The revision history adapter is an object that communicates asynchronously with the data source to fetch or save the revisions data. It is used internally by the revision history feature whenever revision data is required, a revision is created, or updated.

The adapter is optional. See the Revision history feature integration guide to learn more.

To set the adapter, overwrite the RevisionHistory#adapter property.

Filtering

Methods

  • addRevision( data = { data.channelId, data.id, data.name, data.creatorId, data.data, data.createdAt, data.attributes } ) → Promise

    Called when a new revision is added.

    The method should make a query that adds a new revision in the data source and it should return a promise that will be resolved when the query is completed.

    Parameters

    data : Object
    Properties
    data.channelId : String

    The ID of the document.

    data.id : String

    The ID of the revision.

    data.name : String | null

    The name of the revision. Can be empty (null).

    data.creatorId : String

    The ID of the user who created the revision.

    data.data : Object

    The revision data (content). This is an object with all root names as keys (except of the $graveyard root) and strings as values.

    data.createdAt : Date

    The date when the revision was created.

    data.attributes : Object

    Custom revision attributes.

    Returns

    Promise
  • getRevision( data = { data.revisionId } ) → Promise

    Called when the full revision data is required.

    It should return a promise that resolves with the whole revision data.

    The returned object should include the data property.

    Parameters

    data : Object
    Properties
    data.revisionId : String

    The ID of the revision for which the data should be loaded.

    Returns

    Promise
  • getRevisions( data = { data.channelId } ) → Promise

    Called when initializing the editor to get the revisions created for the document.

    It should return a promise that resolves with the revisions objects.

    The returned objects should not include the data property, which will be fetched when needed. This ensures faster loading times and better user experience.

    However, if the document is small and there are not many revisions for that document, you may provide the data property in this call and in that case it will not be fetched later for the second time.

    Parameters

    data : Object
    Properties
    data.channelId : String

    The ID of the document for which the revisions should be loaded.

    Returns

    Promise
  • updateRevision( data = { data.revisionId, [data.name], [data.attributes] } ) → Promise

    Called when revision data is updated.

    The method should make a query that updates a given revision in the data source and it should return a promise that will be resolved when the update is completed.

    Keep in mind that the data parameter only contains the properties of a revision that have changed.

    Parameters

    data : Object
    Properties
    data.revisionId : String

    The ID of the revision to update.

    [ data.name ] : String | null

    The name of the revision. Can be empty (null).

    [ data.attributes ] : Object

    Custom revision attributes.

    Returns

    Promise