Remote document states

The Fonto editor edits documents that are loaded from the CMS. The state of a document in the CMS can change while it is being edited in the Fonto Editor. A document may get locked, it may get removed, and many more things can happen. Also, the connection with the CMS itself may temporarily drop out. This concept page describes how the Fonto Editor reacts to changes of the remote document state and how you can add new UI to reflect the remote document state.

The remote document state is a state tracked by the Fonto editor. This is tracked for every loaded document. There are four CMS endpoints which responses can change the remote document state. These are:

The GET /document endpoint

For loading a document

The PUT /document/lock endpoint

For changing a document's lock state

The POST /document endpoint

For saving a document

the POST /document/state endpoint

For reporting changes to the document state

These endpoints can all affect one or more properties of the RemoteDocumentState object. Some of these properties also affect the edit-ability of a document. For example, when a document can no longer be found, the document is no longer editable.

The following flowchart can help you determine whether a document will be editable and how the UI responds to a new remote document state.

Remote document state flowchart

Some responses from different endpoints have the same result. For example, a 404 or a 403 response from one of the endpoints will make the document uneditable, represented by the inaccessible state in the flowchart. The isInSync property will turn to false and the outOfSyncReason will be set to OutOfSyncReasons.NOT_FOUND or OutOfSyncReasons.ACCESS_FORBIDDEN.

The 412 response is only valid for the save / lock endpoints. A 412 response indicates that the information in the editor lags behind to the information in the CMS. This will result in a out of sync document. When a 412 response is returned, make sure that either the revisionId or the lockState is changed.

A common place to visualize any custom states a document can have is the Sheetframe header. Please use the flowchart above when configuring a custom sheetframe header to ensure all the applicable 'default' states are still visualized correctly.