Documentation Index
Fetch the complete documentation index at: https://cometchat-22654f5b-react-uikit-v7.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
AI Integration Quick Reference
| Field | Value |
|---|---|
| Base Class | CometChatTextFormatter |
| Package | @cometchat/chat-uikit-react |
| Built-in Formatters | CometChatMarkdownFormatter, CometChatMentionsFormatter, CometChatUrlFormatter |
| Pipeline Order | Sorted by priority (lower = first) |
| Used By | Text plugin (getTextFormatters()), media plugins (caption rendering) |
Overview
Text formatters detect patterns in message text and transform them into formatted HTML for display in bubbles. They run as a pipeline — each formatter receives the output of the previous one, sorted by priority (lower number = runs first). The Text plugin provides three built-in formatters. You can add custom formatters to extend the pipeline.Built-in Formatters
| Formatter | Priority | Detects | Output |
|---|---|---|---|
CometChatMarkdownFormatter | 10 | **bold**, _italic_, `code`, > quote, lists, links | HTML tags (<b>, <i>, <code>, etc.) |
CometChatMentionsFormatter | 50 | <@uid:xxx> tokens | Styled @DisplayName chips |
CometChatUrlFormatter | 100 | https://..., www. | Clickable <a> links |
Pipeline Flow
The Formatter Interface
All formatters extend the abstractCometChatTextFormatter class:
Creating a Custom Formatter
Here’s a hashtag formatter that wraps#word patterns in a styled span:
src/formatters/HashtagFormatter.ts
Registering Custom Formatters
Custom formatters are registered by creating a custom text plugin that extends the default one:src/plugins/CustomTextPlugin.ts
Formatter Details
CometChatMarkdownFormatter
Converts markdown syntax to HTML. Runs first (priority 10) so subsequent formatters operate on HTML output. Supported syntax:**bold**→<b>bold</b>_italic_→<i>italic</i>__underline__or++underline++→<u>underline</u>~~strikethrough~~→<s>strikethrough</s>`inline code`→<code>inline code</code>```code block```→<pre><code>code block</code></pre>> blockquote→<blockquote>blockquote</blockquote>[text](url)→<a href="url">text</a>1. item→ ordered list• itemor- item→ unordered list
CometChatMentionsFormatter
Resolves SDK mention tokens (<@uid:xxx> and <@all:label>) into styled mention chips. Requires the mentioned users list from the message to resolve UIDs to display names.
CometChatUrlFormatter
Detects bare URLs (https://... and www.) and wraps them in clickable <a> tags with target="_blank" and rel="noopener noreferrer". Protects existing markdown links and <a> tags from double-processing.
Tips
- Priority matters — markdown must run before mentions/URLs so it doesn’t break HTML tags
- Protect code blocks — formatters should skip content inside
<code>and<pre>tags - Keep it fast — formatters run on every text message render, avoid expensive operations
- Use
shouldFormat()— override to skip formatting for specific messages (e.g., skip hashtags in system messages) - Store metadata — use
this.metadatato expose extracted data (URLs, hashtags, mentions) to consumers