chatscope / chat-ui-kit-react

Build your own chat UI with React components in few minutes. Chat UI Kit from chatscope is an open source UI toolkit for developing web chat applications.
https://chatscope.io
MIT License
1.34k stars 116 forks source link

Is it possible to detect clickable link in message list? #58

Closed iRaM-sAgOr closed 2 years ago

iRaM-sAgOr commented 3 years ago
  1. If any incoming or outgoing message contains any link, is it possible to make this link clickable?
  2. Normally https://www.npmjs.com/package/react-linkify this can be used for any string.
supersnager commented 3 years ago

@iRaM-sAgOr Thank you for your question.

Sure you can use react-linkify.

Here is the example:

<Message model={{  direction: "incoming"}}>
  <Message.CustomContent>
    <Linkify componentDecorator={(decoratedHref, decoratedText, key) => 
      <a target="blank" rel="noopener" href={decoratedHref} key={key}>{decoratedText}</a>}>
                    This message contains link to the https://chatscope.io website.<br />
                    This link is clickable thanks to the https://github.com/tasti/react-linkify library. 
    </Linkify>
   </Message.CustomContent>
</Message>

Storybook example: Chat message with clickable links using react-linkify