CometChatUrlTextFormatter
is a specialized subclass of CometChatTextFormatter
designed to automatically detect URLs in text messages and convert them into clickable links, allowing users to navigate to the web addresses effortlessly within your CometChat application.
CometChatUrlTextFormatter
utilizes regular expressions to identify URLs and applies styles to make them visually distinct as clickable links. Here’s an example of how to extend the CometChatTextFormatter
to create a URL text formatter:
CometChatUrlTextFormatter
, you can customize the appearance of links and the behavior when clicked:
onRegexMatch
method to wrap detected URLs in a span
element with custom classes for styling.registerEventListeners
, define the onUrlClick
method to handle opening URLs, tracking analytics, or other custom behavior upon click.onUrlClick
method within your formatter class to define custom logic for when a link is clicked:
CometChatUrlTextFormatter
component.
Attributes | Type | Description |
---|---|---|
rightAlignedLinkColor | string | Sets color for links for right aligned messages |
rightAlignedLinkFont | string | Sets font for links for right aligned messages |
leftAlignedLinkColor | string | Sets color for links for left aligned messages |
leftAlignedLinkFont | string | Sets font for links for left aligned messages |