The CometChatCollaborativeDocumentBubble component renders collaborative document messages within chat. It displays a banner image, title, subtitle, and an action button that opens the document in a new fullscreen window.
Overview
The Collaborative Document Bubble component processes CometChat.CustomMessage objects of type extension_document to display collaborative document content:
- Message Object Processing: Extracts document URL from message metadata
- Theme-aware Banner Images: Automatically selects light/dark banner images based on current theme
- Localized Text: Displays title, subtitle, and button text using localization keys
- Sender/Receiver Styling: Supports outgoing (right-aligned) and incoming (left-aligned) visual variants
- Action Button: Opens the document URL in a new fullscreen window
- Accessibility: Full keyboard navigation and screen reader support
Basic Usage
Simple Document Message
Incoming vs Outgoing Messages
With Event Handler
Properties
| Property | Type | Default | Description |
|---|
message | CometChat.CustomMessage | required | The CometChat.CustomMessage object containing collaborative document metadata |
alignment | MessageBubbleAlignment | MessageBubbleAlignment.LEFT | The alignment of the message bubble. LEFT for incoming/receiver messages, RIGHT for outgoing/sender messages |
disableInteraction | boolean | false | When true, disables the action button and other interactive elements within the bubble |
Events
| Event | Payload Type | Description |
|---|
buttonClick | string | Emitted when the action button is clicked. Contains the document URL string |
The component extracts the document URL from the following metadata path:
Advanced Usage
Complete Chat Message Component
Message List with Document Bubbles
Customization
Styling with CSS Variables
The Collaborative Document Bubble component uses CSS variables exclusively for easy customization:
Available CSS Variables
| Variable | Purpose | Default |
|---|
--cometchat-spacing-1 to --cometchat-spacing-4 | Padding, margin, gap | 4px to 16px |
--cometchat-font-heading4-medium | Title font | 500 16px Roboto |
--cometchat-font-body-regular | Subtitle font | 400 14px Roboto |
--cometchat-font-button-medium | Button text font | 500 14px Roboto |
--cometchat-background-color-01 | Bubble background | #FFFFFF |
--cometchat-background-color-02 | Body section background | #F5F5F5 |
--cometchat-text-color-primary | Title color | #141414 |
--cometchat-text-color-secondary | Subtitle color | #666666 |
--cometchat-primary-button-background | Button background | #6852D6 |
--cometchat-primary-button-text | Button text color | #FFFFFF |
--cometchat-radius-2 | Border radius | 8px |
--cometchat-border-color-light | Border color | #E0E0E0 |
Custom Color Schemes
Accessibility
The Collaborative Document Bubble component is fully accessible and follows WCAG 2.1 Level AA guidelines.
WCAG 2.1 Compliance
- ✅ 1.1.1 Non-text Content (Level A): Banner image has empty alt attribute (decorative)
- ✅ 1.3.1 Info and Relationships (Level A): Proper semantic structure with button element
- ✅ 2.1.1 Keyboard (Level A): All functionality available via keyboard
- ✅ 2.4.7 Focus Visible (Level AA): Clear focus indicators on action button
- ✅ 4.1.2 Name, Role, Value (Level A): Action button has accessible name via aria-label
Keyboard Support
| Key | Action | Context |
|---|
Tab | Navigate to action button | When component is in focus order |
Shift + Tab | Navigate backwards | When button is focused |
Enter | Activate button | When button is focused |
Space | Activate button | When button is focused |
ARIA Attributes
| Attribute | Element | Value | Purpose |
|---|
aria-label | Action button | Localized button text | Provides accessible name |
alt | Banner image | Empty string | Marks image as decorative |
Screen Reader Behavior
Screen readers announce the component with:
- Banner image: Skipped (decorative)
- Title: “Collaborative Document” (or localized equivalent)
- Subtitle: “Open document to edit content together” (or localized equivalent)
- Button: “Open Document, button” (or localized equivalent)
Best Practices
Always provide the complete CometChat.CustomMessage object to ensure the document URL is correctly extracted from metadata.
The component expects the document URL at metadata["@injected"]["extensions"]["document"]["document_url"]. Ensure your message objects have this structure.
Use the alignment property to distinguish between incoming and outgoing messages for proper visual styling.
Handle the buttonClick event if you need custom behavior beyond opening the URL in a new window.
The action button is automatically disabled when the document URL is missing or empty.
The component automatically selects the appropriate banner image based on the current theme (light/dark).
- CometChatCollaborativeWhiteboardBubble: Displays collaborative whiteboard messages
- CometChatFileBubble: Displays file attachment messages
- CometChatMessageBubble: Parent component for message bubbles
- CometChatMessageList: Displays lists of messages
Technical Details
- Standalone Component: Can be imported and used independently
- Change Detection: Uses OnPush change detection strategy for optimal performance
- Dependencies:
- Angular CommonModule
- CometChat SDK for message types
- TranslatePipe for localization
- BEM CSS: Follows Block Element Modifier naming convention
- Accessibility: WCAG 2.1 Level AA compliant