UNPKG

@cometchat/chat-uikit-react-native

Version:

Ready-to-use Chat UI Components for React Native

172 lines (171 loc) 4.95 kB
import { CometChat } from "@cometchat/chat-sdk-react-native"; import { SuggestionItem } from "../views/CometChatSuggestionList"; import { JSX } from "react"; /** * CometChatTextFormatter * Abstract class for text formatter. */ export declare abstract class CometChatTextFormatter { /** * The regex patterns to find specific text pattern in the user input text. */ protected regexPattern: RegExp; /** * List of users for suggestion item. */ protected SuggestionItems: Array<SuggestionItem>; /** * The message object in context. */ protected messageObject: CometChat.BaseMessage; /** * List of searched data. */ protected searchData: Array<SuggestionItem>; /** * The user in context. */ protected user: CometChat.User; /** * The group in context. */ protected group: CometChat.Group; /** * The composer ID. */ protected composerId: string | number; /** * The formatter id. */ protected id: string | number; /** * The character to track once typed in the text input field. */ protected trackCharacter: string; /** * The user who is currently logged in. */ protected loggedInUser?: CometChat.User; /** * Sets the regex patterns to match. * @param regexPattern - The regex patterns. */ setRegexPatterns(regexPattern: RegExp): void; /** * Gets the regex pattern for matching text. * @returns The regex pattern. */ getRegexPattern: () => RegExp; /** * Gets the composer ID. * @returns The composer ID. */ getComposerId: () => string | number; /** * Gets the formatter ID. * @returns The formatter ID. */ getId: () => string | number; /** * Sets the tracking character. * @param trackCharacter - The character to track. */ setTrackingCharacter(trackCharacter: string): void; /** * Sets the composer ID. * @param composerId - The composer ID. */ setComposerId(composerId: string | number): void; /** * Sets the formatter ID. * @param id - The formatter ID. */ setId(id: string | number): void; /** * Search function used to call an API with searched text. * @param searchKey - The search key. */ search(searchKey: string): void; /** * Sets the search data. * @param data - The search data. */ setSearchData(data: Array<SuggestionItem>): void; /** * Sets the message object. * @param messageObject - The message object to be set. */ setMessage(messageObject: CometChat.BaseMessage): void; /** * Retrieves the message object. * @returns The current message object. */ getMessage(): CometChat.BaseMessage; /** * Fetches the next set of data. */ fetchNext(): void; /** * Sets the user. * @param user - The user to set. */ setUser(user: CometChat.User): void; /** * Retrieves the user. * @returns The current user. */ getUser(): CometChat.User; /** * Sets the group. * @param group - The group to set. */ setGroup(group: CometChat.Group): void; /** * Retrieves the group. * @returns The current group. */ getGroup(): CometChat.Group; /** * Retrieves the currently logged in user. * @returns The currently logged in user. */ getLoggedInUser(): CometChat.User | undefined; /** * Sets the currently logged in user. * @param loggedInUser - The user to set as currently logged in. */ setLoggedInUser(loggedInUser: CometChat.User): void; /** * If the input text is provided, it returns the formatted text. Otherwise, it edits the text using the current cursor position. * @param inputText - The text to format. * @returns The formatted text. */ getFormattedText(inputText: string | null | JSX.Element): string | null | JSX.Element; /** * Handles the message before sending it. * @param message - The message to handle. * @returns The message after handling. */ handlePreMessageSend(message: CometChat.TextMessage): CometChat.TextMessage; /** * Handles the message before editing it. * @param message - The message to handle. * @returns The message after handling. */ handleComposerPreview(message: CometChat.TextMessage): void; /** * Gets the tracking character. * @returns The tracking character. */ getTrackingCharacter(): string; /** * Retrieves the suggestion items. * @returns The current suggestion items. */ getSuggestionItems(): Array<SuggestionItem>; /** * Sets the suggestion items. * @param SuggestionItems - The suggestion items to be set. */ setSuggestionItems(SuggestionItems: Array<SuggestionItem>): void; }