enableSingleEditorMode
Enables single editor mode, allowing only one user to edit the document at a time while others remain in read-only mode. Paramsconfig
: (object
, optional). Configuration object for controlling single editor mode behaviorcustomMode
: (boolean
, optional). When true, SDK won’t automatically make HTML elements read-only for viewers. You need to handle this manually with the help of other APIs listed here. (default:false
)singleTabEditor
: (boolean
, optional). When enabled, restricts the editor to edit in only one browser tab at a time, preventing them from making changes across multiple tabs simultaneously (default:true
)
- React / Next.js
- Other Frameworks
disableSingleEditorMode
Disables single editor mode and returns to normal editing.- React / Next.js
- Other Frameworks
Define Single Editor Mode Elements
Restrict to specific containers
- Restrict Single Editor Mode to specific containers.
- By default Single Editor Mode is enabled at the entire DOM level. You can restrict this feature to only certain HTML containers & their children by using this.
- React / Next.js
- Other Frameworks
Fine tune elements control
Control which elements are controlled by Single Editor Mode.You must add the data-velt-sync-access-* attributes to native HTML elements (e.g. button, input). It will not work directly on React components.
- React / Next.js
- Other Frameworks
Timeout Configuration
setEditorAccessTimeout
- Configure automatic editor access timeout.
- Default:
5 seconds
.
- React / Next.js
- Other Frameworks
enableEditorAccessTransferOnTimeOut
- When editor access timeout is reached, automatically transfer editor access to the next user in the queue.
- Enabled by default.
- React / Next.js
- Other Frameworks
disableEditorAccessTransferOnTimeOut
- When editor access timeout is reached, do not automatically transfer editor access to the next user in the queue.
- Enabled by default.
- React / Next.js
- Other Frameworks
getEditorAccessTimer
Track the state of editor access request timeout. ReturnsEditorAccessTimer
object:state
('idle'
|'inProgress'
|'completed'
)durationLeft
(number
)
- React / Next.js
Auto-Sync Text Elements
- Enable automatic syncing of text element contents across all users.
- Supported elements:
<input>
<textarea>
- ContentEditable
<div>
- First enable the feature and then define which elements should sync realtime.
- React / Next.js
- Other Frameworks
Editor
setUserAsEditor
Sets the current user as the editor, making all other users read-only.- React / Next.js
- Other Frameworks
Error handling
setUserAsEditor
includes validations to prevent assigning an editor when one already exists. It returns a promise that resolves to an optional error object.
- React / Next.js
- Other Frameworks
isUserEditor
- Get the current user’s editor status.
null
: When the state is not available yet.undefined
: When there are no current editors available in single editor mode.UserEditorAccess
: When there is at least one editor available in single editor mode.isEditor
(boolean
) - Whether the user is the editorisEditorOnCurrentTab
(boolean
) - Whether the user is editor on current tab
- React / Next.js
- Other Frameworks
getEditor
Get information about the current editor. ReturnsUser
object:email
(string
) - Editor’s emailname
(string
) - Editor’s namephotoUrl
(string
) - Editor’s photo URLuserId
(string
) - Editor’s unique ID
- React / Next.js
- Other Frameworks
isEditorAccessRequested
Check if any viewer has requested editor access. Returnsnull
- User is not editor or request was canceledEditorRequest
object:requestStatus
(string
) - ‘requested’ for active requestsrequestedBy
(User
) - User object of the requester
- React / Next.js
- Other Frameworks
acceptEditorAccessRequest
Accept editor access requests.- React / Next.js
- Other Frameworks
rejectEditorAccessRequest
Reject editor access requests.- React / Next.js
- Other Frameworks
editCurrentTab
Make current tab editable when editor has multiple tabs open.- React / Next.js
- Other Frameworks
Viewer
requestEditorAccess
Request editor access from the current editor. Returnsnull
- Request is pendingtrue
- Request acceptedfalse
- Request rejected
- React / Next.js
- Other Frameworks
cancelEditorAccessRequest
Cancel the editor access request.- React / Next.js
- Other Frameworks
Heartbeat
The heartbeat mechanism provides more reliable presence detection in single editor mode scenarios. This feature is enabled by default when single editor mode is enabled.If you want to disable heartbeat functionality, you must disable it before enabling single editor mode.
enableHeartbeat
Enables/Disables the heartbeat mechanism for Single Editor Mode presence detection. Default:enabled
- React / Next.js
- Other Frameworks
Presence Heartbeat
updateUserPresence
Send a lightweight heartbeat from your host app to Velt. Velt will use that as a fallback in rare edge cases if it fails to detect multi‑tab/device presence. Most apps don’t need this; use only if you see ambiguity in who’s the active editor.- React / Next.js
- Other Frameworks
resetUserAccess
Reset editor access for all users.- React / Next.js
- Other Frameworks
UI
enableDefaultSingleEditorUI
- Control the visibility of the default Single Editor Mode System UI.
- The default UI shows:
- Current user’s editor/viewer status
- Editor access requests
- Request timeout countdown
- Request rejection options
- If you disable the default UI, you’ll need to implement your own UI for these features.
- React / Next.js
- Other Frameworks
Embed Single Editor Mode Panel
- Embed the Single Editor Mode Panel into your UI.
- React / Next.js
- Other Frameworks
Event Subscription
on
Subscribe to Single Editor Mode Events. Here is the list of events you can subscribe to and the event objects you will receive.Category | Event Type | Description | Event Object |
---|---|---|---|
Editor | accessRequested | When a user requests editor access. Editor will get this event. | AccessRequestEvent |
Editor | accessRequestCanceled | When a user cancels their request for editor access. Editor will get this event. | AccessRequestEvent |
Viewer | accessAccepted | When a user’s request for editor access is accepted. Requesting Viewer will get this event. | AccessRequestEvent |
Viewer | accessRejected | When a user’s request for editor access is rejected. Requesting Viewer will get this event. | AccessRequestEvent |
Access Assignment | editorAssigned | When a user is assigned as the editor. | SEMEvent |
Access Assignment | viewerAssigned | When a user is assigned as a viewer. | SEMEvent |
Editor | editorOnDifferentTabDetected | When the editor opens the same document in a different browser tab. Editor will get this event. | SEMEvent |
- React / Next.js
- Other Frameworks
Using Hooks:Using API:
Best Practices
- Use
singleTabEditor
to prevent confusion when users have multiple tabs open - Add IDs to HTML elements with sync attributes for more robust syncing
- Only apply sync attributes to native HTML elements, not framework components