Files
owncast/web/components/chat/ChatSystemMessage/ChatSystemMessage.tsx
Dev Gupta 11a3a79032 FIX : Chat: words containing one or more dots are turned into links #2898 (#2903)
* FIX: Chat: words containing one or more dots are turned into links #2898

Making validateTLD to true and also adding a parameter of customTLDs

* Update ChatUserMessage.tsx

* Prettified Code!

---------

Co-authored-by: dev265545 <dev265545@users.noreply.github.com>
2023-04-03 18:00:21 -07:00

35 lines
1022 B
TypeScript

import { FC } from 'react';
import cn from 'classnames';
import { Interweave } from 'interweave';
import { UrlMatcher } from 'interweave-autolink';
import { ChatMessage } from '../../../interfaces/chat-message.model';
import styles from './ChatSystemMessage.module.scss';
import { ChatMessageHighlightMatcher } from '../ChatUserMessage/customMatcher';
export type ChatSystemMessageProps = {
message: ChatMessage;
highlightString: string;
};
export const ChatSystemMessage: FC<ChatSystemMessageProps> = ({
message: {
body,
user: { displayName },
},
highlightString,
}) => (
<div className={cn([styles.chatSystemMessage, 'chat-message_system'])}>
<div className={styles.user}>
<span className={styles.userName}>{displayName}</span>
</div>
<Interweave
className={styles.message}
content={body}
matchers={[
new UrlMatcher('url',{ customTLDs: ['online'] }),
new ChatMessageHighlightMatcher('highlight', { highlightString }),
]}
/>
</div>
);