Skip to main content

Overview

The ShortCutFormatter class extends the CometChatTextFormatter class to provide a mechanism for handling shortcuts within messages. This guide will walk you through the process of using ShortCutFormatter to implement shortcut extensions in your CometChat application.

Usage

Here are the steps to create a ShortCutFormatter for CometChat using the CometChatTextFormatter:
  1. Firstly, you need to import CometChatTextFormatter from the CometChat UI Kit angular library.
  1. Now, extend the CometChatTextFormatter class to create your custom text formatter class. In this case, let’s create a HashTagTextFormatter.
  1. Set up the trackCharacter and define any necessary private fields.
  1. Implement the onKeyDown method to handle key events and trigger actions based on defined shortcuts.
  1. Implement any additional methods required for your custom formatter, such as opening and closing dialogs, handling button clicks, and formatting text.

Example

Below is an example demonstrating how to use a custom formatter class in components such as CometChatConversations, CometChatMessageList, CometChatMessageComposer.