@cometchat/chat-uikit-react
Version:
Ready-to-use Chat UI Components for React
45 lines (41 loc) • 1.22 kB
JavaScript
;
require('./index.css');
// src/formatters/CometChatTextFormatter.ts
var CometChatTextFormatter = class {
constructor() {
/** Formatter priority (lower = earlier in pipeline). Default is 100. */
this.priority = 100;
/** The original unformatted text. */
this.originalText = "";
/** The formatted text after applying transformations. */
this.formattedText = "";
/** Metadata extracted during formatting (e.g., mentions, URLs). */
this.metadata = {};
}
/** Get the formatted text after format() has been called. */
getFormattedText() {
return this.formattedText;
}
/** Get the original unformatted text. */
getOriginalText() {
return this.originalText;
}
/** Get metadata extracted during formatting. */
getMetadata() {
return this.metadata;
}
/** Reset the formatter state. */
reset() {
this.originalText = "";
this.formattedText = "";
this.metadata = {};
}
/**
* Check if this formatter should process the given text.
* Override to conditionally skip formatting. Default: always format.
*/
shouldFormat(_text, _message) {
return true;
}
};
exports.CometChatTextFormatter = CometChatTextFormatter;