Documentation Index
Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
AI Integration Quick Reference
| Field | Value |
|---|---|
| Package | @cometchat/chat-uikit-angular |
| Key class | CometChatTextFormatter (abstract base class for custom formatters) |
| Required setup | CometChatUIKit.init(uiKitSettings) then CometChatUIKit.login("UID") |
| Purpose | Extend to create custom inline text patterns with regex, styling, and callbacks |
| Features | Text formatting, customizable styles, dynamic text replacement, input field integration, key event callbacks |
| Related | ShortCut Formatter | Mentions Formatter | All Guides |
CometChatTextFormatter is an abstract class for formatting text in the message composer and message bubbles. Extend it to build custom formatters — hashtags, keywords, or any regex-based pattern.
| Capability | Description |
|---|---|
| Text formatting | Auto-format text based on regex patterns and styles |
| Custom styles | Set colors, fonts, and backgrounds for matched text |
| Dynamic replacement | Regex-based find-and-replace in user input |
| Input integration | Real-time monitoring of the composer input field |
| Key event callbacks | Hooks for keyUp and keyDown events |
Steps
1. Import the base class
2. Extend it
3. Implement the regex pattern
Return the regex that matches your target pattern fromgetRegex():
4. Implement the format method
Theformat() method receives the raw text and returns formatted HTML:
5. Optionally implement shouldFormat
Control when the formatter is applied:Example
A hashtag formatter used withcometchat-message-list and cometchat-message-composer.

- HashTagTextFormatter.ts
- Component Usage
Methods Reference
| Field | Type | Description |
|---|---|---|
id | abstract readonly string | Unique identifier for the formatter instance |
priority | number | Execution order in the pipeline (lower = earlier, default 100) |
getRegex() | abstract method | Returns the regex pattern for detecting formattable content |
format(text) | abstract method | Applies formatting transformations and returns formatted text |
getFormattedText() | method | Returns the stored formatted text after format() is called |
getOriginalText() | method | Returns the original text before formatting |
getMetadata() | method | Returns metadata extracted during formatting |
reset() | method | Clears original text, formatted text, and metadata |
shouldFormat(text, message?) | method | Returns whether this formatter should process the given text (default: true) |
Override Methods
- format
- getRegex
- shouldFormat
- reset
The core method that applies formatting. Store original text, apply transformations, store metadata, and return the result.
Next Steps
Mentions Formatter
Add @mentions with styled tokens.
Message Composer
Customize the message input component.
All Guides
Browse all feature and formatter guides.
ShortCut Formatter
Implement text expansion shortcuts.