import { MessageBubbleAlignment } from "@cometchat/uikit-resources"; import { ComposerId } from "../../Configuration/MessageComposerConfiguration"; /** * Abstract class that provides methods for formatting text in CometChat. */ export declare abstract class CometChatTextFormatter { /** * An ID for tracking the timeout. */ protected timeoutID?: any; /** * A flag to start tracking once a specific keyboard event occurs. */ protected startTracking: boolean; /** * Current position/type of the text selection or cursor in the text input field. */ protected currentCaretPosition?: Selection; /** * Represents the text range that the user has selected or the cursor position in the text input field. */ protected currentRange?: Range; /** * Reference to the text input field DOM element. */ protected inputElementReference?: HTMLElement; /** * The regex patterns to find specific text pattern in the user input text. */ protected regexPatterns: RegExp[]; /** * The regex patterns to replace text formatting in the user input text. */ protected regexToReplaceFormatting: RegExp[]; /** * Mapping of CSS classes for styling the text. */ protected cssClassMapping: Array; /** * The character to track once typed in the text input field. */ protected trackCharacter: string; /** * Callback function to be triggered on the 'keyup' event. */ protected keyUpCallBack: Function; /** * Callback function to be triggered on the 'keydown' event. */ protected keyDownCallBack: Function; protected classes: string[]; /** * Function reference to trigger a re-render of the component. */ reRender: Function; messageBubbleAlignment: MessageBubbleAlignment; /** * The message object in context. */ protected messageObject: CometChat.BaseMessage; user?: CometChat.User; group?: CometChat.Group; composerId?: ComposerId; /** * The user who is currently logged in. */ protected loggedInUser?: CometChat.User | null; protected id?: string; protected textStyle: { [key: string]: string; }; /** * Sets the current caret position and selection range. * * @param {Selection} currentCaretPosition - The current caret position. * @param {Range} currentRange - The current selection range. */ setCaretPositionAndRange(currentCaretPosition: Selection, currentRange: Range): void; /** * Set css class to be applied on format spans */ setClasses(classes: string[]): void; /** * Sets the regex patterns to match. * @param regexPatterns - Array of regex patterns. */ setRegexPatterns(regexPatterns: Array): void; /** * Gets the regex patterns. */ getRegexPatterns(): RegExp[]; /** * Sets the regex patterns to replace formatting. * @param regexToReplaceFormatting - Array of regex patterns. */ setRegexToReplaceFormatting(regexToReplaceFormatting: Array): void; /** * Sets the tracking character. * @param trackCharacter - The character to track. */ setTrackingCharacter(trackCharacter: string): void; /** * Sets the input element reference. * @param inputElementReference - The reference to the input element. */ setInputElementReference(inputElementReference: any): void; /** * Sets the re-render function. * @param reRender - The function to call for re-rendering. */ setReRender(reRender: any): void; /** * Retrieves the keydown callback function. * @returns {Function} The keydown callback function. */ getKeyUpCallBack(): Function; /** * Sets the keydown callback function. * @param {Function} keyUpCallBack - The callback function for handling key down events. */ setKeyUpCallBack(keyUpCallBack: Function): void; /** * Retrieves the keydown callback function. * @returns {Function} The keydown callback function. */ getKeyDownCallBack(): Function; /** * Sets the keydown callback function. * @param {Function} keyDownCallBack - The keydown callback function. */ setKeyDownCallBack(keyDownCallBack: Function): void; /** * Retrieves the currently logged in user. * @returns The currently logged user. */ getLoggedInUser(): import("@cometchat/chat-sdk-javascript").User | null | undefined; /** * Sets the currently logged in user. * @param {CometChat.User} loggedInUser - The user to set as currently logged in. */ setLoggedInUser(loggedInUser: CometChat.User): void; /** * Sets the mapping of CSS classes. * @param cssClassesNames - Array of CSS class names. */ setCssClassMapping(cssClassesNames: string[]): void; /** * Sets the CSS style. * @param {Object} styleObject - The CSS style object. * @param {string} styleObject.formattedTextColor - The color to use for formatted text. */ setStyle(styleObject: { formattedTextColor: string; formattedTextFont: string; }): void; getStyle(): { [key: string]: string; }; setId(id: string): void; getId(): string | undefined; cleanup(): void; /** * If the input text is provided, it returns the formatted text. Otherwise, it edits the text using the current cursor position. * @param {string|null} inputText - The text to format. * @return {string|void} - The original or formatted input text, or void if editing was done based on cursor position. */ getFormattedText(inputText: string | null, params: any): string | void; /** * Sets the message object. * * @param {CometChat.BaseMessage} messageObject - The message object to be set. */ setMessage(messageObject: CometChat.BaseMessage): void; /** * Retrieves the message object. * * @returns {CometChat.BaseMessage} - The current message object. */ getMessage(): import("@cometchat/chat-sdk-javascript").BaseMessage; setMessageBubbleAlignment(messageBubbleAlignment: MessageBubbleAlignment): void; getMessageBubbleAlignment(): MessageBubbleAlignment; setComposerConfig(user?: CometChat.User, group?: CometChat.Group, composerId?: ComposerId): void; getComposerConfig(): { user: import("@cometchat/chat-sdk-javascript").User | undefined; group: import("@cometchat/chat-sdk-javascript").Group | undefined; composerId: ComposerId | undefined; }; /** * Formats the text on keyboard key down. * @param {string|void} inputText - The text to format. */ protected formatTextOnKeyUp: (inputText: string | void) => void; debouncedFormatTextOnKeyUp: (...args: any[]) => void; /** * Retrieves the preceding text from the given caret position. * @param {Selection} currentCaretPosition - The current caret position. * @param {Range} currentRange - The current selection range. * @return {string|null} - The preceding text or null. */ protected getPrecedingText(currentCaretPosition: any, currentRange: any): string | null; /** * Returns true if previous character is previousCharacterToCheck or if there is just one character * @param {string} previousCharacterToCheck * @param {Range} currentRange * @returns {boolean} */ protected checkPreviousCharacterUsingRange(previousCharacterToCheck?: string, currentRange?: Range): boolean; /** * Applies regex match on the input text and replaces matched instances. * @param {string|null} inputText - The text to apply regex match. * @return {string} - The replaced text. */ protected onRegexMatch(inputText?: string | null): string; /** * Debounce function. * @param {Function} func - The function to debounce. * @param {number} wait - The amount of delay before function invocation. * @return {Function} - The debounced function. */ debounce(func: Function, wait: number): (...args: any[]) => void; /** * Handles 'keydown' events. * @param {KeyboardEvent} event - The keyboard event. */ onKeyUp(event: KeyboardEvent): void; /** * Handles 'keydown' events. * @param {KeyboardEvent} event - The keyboard event. */ onKeyDown(event: KeyboardEvent): void; /** * Adds HTML at the current caret position. * @param {string} newHtml - The HTML to insert. * @param {Selection} currentCaretPosition - The current caret position. * @param {Range} currentRange - The current selection range. */ protected addAtCaretPosition(newHtml: string, currentCaretPosition: Selection, currentRange: Range): void; /** * Returns the original unformatted text from the input text. * @param {string|null|undefined} inputText - The input text to get original text from. * @return {string} - The original text. */ getOriginalText(inputText: string | null | undefined): string; /** * To inform formatter to stop keeping a track of characters */ stopTracking(): void; /** * To reset the formatter properties */ reset(): void; /** * This will be called by composer before sending the message. This can be used to set metadata, tags on message * @param {CometChat.BaseMessage} message * @return {CometChat.BaseMessage} - message with metadata added */ formatMessageForSending(message: CometChat.BaseMessage): CometChat.BaseMessage; /** * Registers event listeners on the given element. * @param {any} span - The HTML element to register event listeners. * @param {any} classList - The classList of the element. * @return {any} - The element with event listeners registered. */ registerEventListeners(span: any, classList: DOMTokenList): any; } //# sourceMappingURL=CometChatTextFormatter.d.ts.map