Skip to main content

Introduction

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.

Setup

  1. Create the ShortCutFormatter Class: Define the ShortCutFormatter class by extending the CometChatTextFormatter class.
  1. Constructor: Initialize the messageShortcuts map and shortcuts list in the constructor.
  1. Prepare Shortcuts: Implement the prepareShortCuts() method to fetch shortcuts from the server using CometChat extension.
  1. Override Search Method: Override the search() method to search for shortcuts based on the entered query.
  1. Handle Scroll to Bottom: Override the onScrollToBottom() method if needed.

Usage

  1. Initialization: Initialize an instance of ShortCutFormatter in your application.
  1. Integration: Integrating the ShortCutFormatter into your CometChat application involves incorporating it within your project to handle message shortcuts. If you’re utilizing the CometChatConversationsWithMessages component, you can seamlessly integrate the ShortCutFormatter to manage shortcut functionalities within your application.

Example