Changelog

Collaboration connection state and edit attribution

Know when a collaboration room drops and recovers, and tell edits made in the editor from edits made by code.

Collaboration connection state and edit attribution

A collaboration room depends on a network connection. When it drops, your application needs to know, and it needs to know again when the room is back in sync. On the server, a room update does not say whether a person typed it or your own code wrote it. That difference matters when you decide when to save a version.

From 2.18.0, SuperDoc reports both.

Follow the connection

onCollaborationConnectionChange and the collaboration-connection-change event report every change in the room's connection. getCollaborationConnectionState() returns the latest report, or null before a room has reported one:

superdoc.on('collaboration-connection-change', ({ kind }) => {
  if (kind === 'lost' || kind === 'reconnecting') showStatus('Reconnecting');
  if (kind === 'recovered') showStatus('Back in sync');
  if (kind === 'failed') showStatus('Connection failed. Reopen the document.');
});

const current = superdoc.getCollaborationConnectionState();

Each report has a state (connecting, synced, degraded, or failed) and a kind that says what happened:

kindMeaning
initialThe first connection, from opening through the first sync.
lostThe connection dropped after the room had synced.
reconnectingThe provider is retrying.
recoveredThe room synced again after an outage.
failedA terminal transport or authentication failure.

Use state to know when the room is ready: the first sync arrives as kind: 'initial' with state: 'synced'. recovered is reported only after synchronization succeeds. A short outage does not reach onException. Your application decides what to show.

Tell human edits from code

SuperDoc now writes lastEditActorType into each story's metadata in the room, with the value human or code. Edits made through SuperDoc's built-in UI, such as typing, pasting, and toolbar formatting, are human. Document API calls and application commands are code, even when a person clicked the button that ran them.

Your server can read it to decide when to save a version. The value classifies where an edit came from. It does not authenticate a user. Use your server's own authentication to know who made a change.

Other collaboration fixes

  • A rejected room creation no longer fires the ready event.
  • An interrupted room setup cannot write to the room before it is rejected.
  • Undo works after inserting an image in a shared room.
  • Content controls that already exist in the document can be changed in collaboration.
  • Room upgrades report an outcome for each room.

Current guides