Overview
TheCollaborativeRoom component provides a complete collaborative editing experience with real-time presence, document title editing, and access control. It wraps the Editor component with Liveblocks RoomProvider for real-time synchronization.
Props
Unique identifier for the Liveblocks room. Used to connect collaborators to the same document.
Metadata about the room containing:
creatorId(string): User ID of the document creatoremail(string): Email of the creatortitle(string): Document title
Array of users who have access to the document. Each user object contains:
id(string): Unique user identifiername(string): User’s display nameemail(string): User’s email addressavatar(string): URL to user’s avatar imagecolor(string): User’s assigned color for presence indicatorsuserType(UserType): Optional access level (‘creator’ | ‘editor’ | ‘viewer’)
Access level of the current user. Determines editing permissions:
'creator': Full access including deletion'editor': Can edit document and title'viewer': Read-only access
Features
- Real-time Collaboration: Powered by Liveblocks for synchronized editing
- Editable Document Title: Editors can click to edit the document title
- Auto-save: Title changes save on Enter key or when clicking outside
- Access Control: UI adapts based on user permissions
- Active Collaborators: Shows who’s currently in the document
- Share Modal: Invite collaborators with specific permissions
Usage Example
TypeScript Interface
Component Structure
The component renders:- RoomProvider: Liveblocks room context
- Header: Contains logo, document title, collaborators, and share button
- Document Title Input: Editable when user is an editor
- ActiveCollaborators: Shows real-time presence
- ShareModal: For managing document access
- Editor: The main document editing area
Permissions Behavior
| Feature | Creator | Editor | Viewer |
|---|---|---|---|
| Edit Document | ✓ | ✓ | ✗ |
| Edit Title | ✓ | ✓ | ✗ |
| Share Document | ✓ | ✓ | ✗ |
| Delete Document | ✓ | ✗ | ✗ |
Related Components
- Editor - The rich text editor component
- Header - Header wrapper component
- ShareModal - Document sharing modal