superdoc.upgradeToCollaboration() when you want to render a document locally first and turn that same SuperDoc instance into a collaborative room later.
This is useful for flows like:
- A user opens a document privately, then clicks
Share - You only provision collaboration infrastructure when someone requests it
- You want the document visible immediately, then enable real-time editing on demand
Before you start
- Wait until the SuperDoc instance is ready
- Call it only on a local instance that is not already collaborative
- The current implementation supports a single DOCX document
- Provide a matching
{ ydoc, provider }pair for the room you want to create - You do not need to wait for provider sync yourself; SuperDoc waits internally
Example
This example starts with a local editor and upgrades it when the user clicks a button.What happens during the upgrade
- SuperDoc waits for the collaboration provider to connect and sync
- The current local document state is written into the target room
- Comments and lock state are copied into the room
- The editor runtime is rebuilt in collaboration mode
- The same
superdocinstance continues running, now backed by Yjs
Constructor-time collaboration vs late upgrade
Start collaborative immediately
Create the provider first, then pass
{ ydoc, provider } in
modules.collaboration when you construct SuperDoc.Start local, upgrade later
Create a local
SuperDoc first, then call
superdoc.upgradeToCollaboration({ ydoc, provider }) when you want to
create a shared room.
