History
Description
The History API provides components that can be used to access and manage the page history for backends that support it. It is required to display the "History" tab on a Cristal page.
Details
A PageRevisionManager is a component that offers one method:
* Returns the revisions for a given page.
*
* @param pageData - the page for which to get the revisions
* @param limit - the number of revisions to fetch
* @param offset - the number of revisions to skip
* @returns the page revisions
*/
getRevisions(
pageData: PageData,
limit?: number,
offset?: number,
): Promise<Array<PageRevision>>;
A PageRevision is a simple data structure that stores all the metadata of a specific revision for a given page:
* Description of a revision for a given page.
*/
type PageRevision = {
version: string;
date: Date;
user: UserDetails;
comment: string;
url: string;
};
It is expected that any backend supporting versioning should implement their own PageRevisionManager. E.g.,
* Implementation of PageRevisionManager for the XWiki backend.
**/
@injectable()
class XWikiPageRevisionManager implements PageRevisionManager {
// XWiki specific implementation.
}
Each backend-specific implementation should be registered with the name of the backend that they support, and will then be available through DefaultPageRevisionManagerProvider.get() whenever the backend is in use. At the same time, if DefaultPageRevisionManagerProvider.has() returns false for a given backend, some features (such as the "History" tab) will be disabled for this backend.