Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui-kit/react/plugins/custom-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
description: "Build a custom message plugin for rendering, context menus, and conversation previews, plus the plugin interface and context reference."
---

Custom plugins let you handle any message type with your own rendering logic. This walkthrough builds a complete "Location" plugin that renders a map preview, provides context menu options, and shows a conversation preview.

Check warning on line 7 in ui-kit/react/plugins/custom-plugin.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/custom-plugin.mdx#L7

Did you really mean 'walkthrough'?

## Step 1: Define the Plugin

Expand Down Expand Up @@ -121,7 +121,7 @@
}
```

Your plugin is appended after the default plugins. Since resolution is first-match, default plugins handle their types first, and your plugin handles `"location"` messages.
Your plugin is prepended before the default plugins. Since resolution is first-match, your custom plugins take precedence for the types they declare — here the plugin handles `"location"` messages, a type no built-in plugin claims. To override a built-in type instead, declare the same `messageTypes`/`messageCategories` as the default plugin.

Check warning on line 124 in ui-kit/react/plugins/custom-plugin.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/custom-plugin.mdx#L124

Did you really mean 'prepended'?

## Step 3: Send a Location Message

Expand Down Expand Up @@ -213,7 +213,7 @@
| `onMarkAsUnread` | `(msg) => void` | Mark as unread |
| `onFlagMessage` | `(msg) => void` | Open flag/report dialog |
| `showToast` | `(text) => void` | Show a toast notification |
| `getTextFormatters` | `() => Formatter[]` | Get text formatters for caption rendering |

Check warning on line 216 in ui-kit/react/plugins/custom-plugin.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/custom-plugin.mdx#L216

Did you really mean 'formatters'?
| `publish` | `(event) => void` | Publish a UI event |

## Tips
Expand Down
8 changes: 6 additions & 2 deletions ui-kit/react/plugins/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
| `renderBubble` | `(message, context) => ReactNode` | Yes | Render the inner bubble content (the outer wrapper is handled by `CometChatMessageBubble`) |
| `getOptions` | `(message, context) => CometChatMessageOption[]` | Optional | Context menu options for the message (return `[]` for none) |
| `getLastMessagePreview` | `(message, loggedInUser, t?) => string` | Optional | Plain-text subtitle shown in the Conversations list |
| `getTextFormatters` | `() => CometChatTextFormatter[]` | Optional | Text formatters this plugin provides (only the text plugin uses this) |

Check warning on line 44 in ui-kit/react/plugins/overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/overview.mdx#L44

Did you really mean 'formatters'?
| `renderLeadingView` | `(message, context) => ReactNode` | Optional | Override the leading view (avatar area) |
| `renderHeaderView` | `(message, context) => ReactNode` | Optional | Override the header view (sender name area) |
| `renderFooterView` | `(message, context) => ReactNode` | Optional | Override the footer view (reactions area) |
Expand All @@ -60,7 +60,7 @@

1. If the message is deleted (`getDeletedAt() !== null`), the Delete plugin handles it
2. Otherwise, the registry finds the first plugin whose `messageTypes` includes the message's type AND whose `messageCategories` includes the message's category
3. First match wins — plugin order matters
3. First match wins — plugin order matters. Custom plugins passed via the `plugins` prop are placed **before** the defaults, so a custom plugin can override a built-in one for the same type

```
Message { type: "image", category: "message" }
Expand All @@ -69,11 +69,15 @@
→ ImagePlugin.renderBubble() is called
```

<Note>
Precedence is determined by **plugin order** (your custom plugins first, defaults after) and matched by `messageTypes` + `messageCategories` — **not** by `id`. The `id` field is a required unique identifier for the plugin; it is not the override mechanism.
</Note>

---

## Adding Plugins

All default plugins are always included. To add your own custom plugins, pass them via the `plugins` prop on `CometChatProvider`. They are appended after the defaults, so default plugins keep priority for their message types:
All default plugins are always included. To add your own custom plugins, pass them via the `plugins` prop on `CometChatProvider`. They are **prepended before the defaults**, so a custom plugin takes priority for its message types (first match wins) — letting you override a built-in plugin by declaring the same `messageTypes`/`messageCategories`:

Check warning on line 80 in ui-kit/react/plugins/overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/overview.mdx#L80

Did you really mean 'prepended'?

```tsx
import { CometChatProvider } from "@cometchat/chat-uikit-react";
Expand All @@ -97,8 +101,8 @@
| Plugin | Message type(s) | Category | What it renders | Component |
| --- | --- | --- | --- | --- |
| **Text** | `text` | `message` | Formatted text with @mentions, clickable URLs, and markdown | [Text Bubble](/ui-kit/react/components/text-bubble) |
| **Image** | `image` | `message` | Responsive image grid with captions, batch grouping, and a fullscreen gallery | [Image Bubble](/ui-kit/react/components/image-bubble) |

Check warning on line 104 in ui-kit/react/plugins/overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/overview.mdx#L104

Did you really mean 'fullscreen'?
| **Video** | `video` | `message` | Video grid with poster thumbnails, duration overlays, and a fullscreen viewer | [Video Bubble](/ui-kit/react/components/video-bubble) |

Check warning on line 105 in ui-kit/react/plugins/overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/overview.mdx#L105

Did you really mean 'fullscreen'?
| **File** | `file` | `message` | Stacked file cards with type icons, size, and download | [File Bubble](/ui-kit/react/components/file-bubble) |
| **Audio** | `audio` | `message` | Attached audio as stacked player cards; recorded voice notes as a waveform player | [Audio Bubble](/ui-kit/react/components/audio-bubble) |
| **Polls** | `extension_poll` | `custom` | Interactive poll with voting and live results | [Poll Bubble](/ui-kit/react/components/poll-bubble) |
Expand Down Expand Up @@ -138,9 +142,9 @@
| `toolArguments` | "Tool call" |
| `toolResults` | "Tool result" |

### Preloading

Check warning on line 145 in ui-kit/react/plugins/overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/overview.mdx#L145

Did you really mean 'Preloading'?

The AI Assistant Chat panel can be preloaded on hover/focus to reduce perceived latency:

Check warning on line 147 in ui-kit/react/plugins/overview.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/overview.mdx#L147

Did you really mean 'preloaded'?

```tsx
import { preloadAIAssistantChat } from "@cometchat/chat-uikit-react";
Expand Down
2 changes: 1 addition & 1 deletion ui-kit/react/plugins/text-formatters.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: "Text Formatters"
sidebarTitle: "Text Formatters"

Check warning on line 3 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L3

Did you really mean 'Formatters'?
description: "Transform plain text into formatted HTML in message bubbles, with built-in URL, mention, and markdown formatters plus custom formatters."

Check warning on line 4 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L4

Did you really mean 'formatters'?

Check warning on line 4 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L4

Did you really mean 'formatters'?
---

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, and you can add your own.

Check warning on line 7 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L7

Did you really mean 'formatters'?

Check warning on line 7 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L7

Did you really mean 'formatters'?

## Built-in Formatters

Check warning on line 9 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L9

Did you really mean 'Formatters'?

| Formatter | Priority | Detects | Output |
| --- | --- | --- | --- |
Expand All @@ -26,7 +26,7 @@

## The Formatter Interface

All formatters extend the abstract `CometChatTextFormatter` class:

Check warning on line 29 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L29

Did you really mean 'formatters'?

```typescript
abstract class CometChatTextFormatter {
Expand Down Expand Up @@ -99,9 +99,9 @@
}
```

## Registering Custom Formatters

Check warning on line 102 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L102

Did you really mean 'Formatters'?

Custom formatters are registered by creating a custom text plugin that provides them:

Check warning on line 104 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L104

Did you really mean 'formatters'?

```typescript title="src/plugins/CustomTextPlugin.ts"
import { CometChatTextPlugin } from "@cometchat/chat-uikit-react";
Expand Down Expand Up @@ -139,13 +139,13 @@
</CometChatProvider>
```

Since user plugins are prepended before the defaults in the registry, your custom text plugin takes precedence over the built-in one (first match wins)
Since user plugins are prepended before the defaults in the registry, your custom text plugin takes precedence over the built-in one (first match wins).

Check warning on line 142 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L142

Did you really mean 'prepended'?

## Formatter Details

### CometChatMarkdownFormatter

Converts markdown syntax to HTML. Runs first (priority 10) so subsequent formatters operate on HTML output.

Check warning on line 148 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L148

Did you really mean 'formatters'?

- `**bold**` → `<b>bold</b>`
- `_italic_` → `<i>italic</i>`
Expand All @@ -159,7 +159,7 @@

### 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.

Check warning on line 162 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L162

Did you really mean 'UIDs'?

### CometChatUrlFormatter

Expand All @@ -168,7 +168,7 @@
## 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

Check warning on line 171 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L171

Did you really mean 'formatters'?
- **Keep it fast** — formatters run on every text message render; avoid expensive operations

Check warning on line 172 in ui-kit/react/plugins/text-formatters.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

ui-kit/react/plugins/text-formatters.mdx#L172

Did you really mean 'formatters'?
- **Use `shouldFormat()`** — override to skip formatting for specific messages
- **Store metadata** — use `this.metadata` to expose extracted data (URLs, hashtags, mentions) to consumers