2022-09-07 10:00:28 +03:00
|
|
|
import { FC } from 'react';
|
2022-12-13 09:54:29 +03:00
|
|
|
import cn from 'classnames';
|
2023-02-06 02:46:48 +03:00
|
|
|
import { Interweave } from 'interweave';
|
|
|
|
import { UrlMatcher } from 'interweave-autolink';
|
2022-08-11 06:22:00 +03:00
|
|
|
import { ChatMessage } from '../../../interfaces/chat-message.model';
|
2022-09-07 10:00:28 +03:00
|
|
|
import styles from './ChatSystemMessage.module.scss';
|
2023-02-06 02:46:48 +03:00
|
|
|
import { ChatMessageHighlightMatcher } from '../ChatUserMessage/customMatcher';
|
2022-07-15 23:15:20 +03:00
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export type ChatSystemMessageProps = {
|
2022-08-11 06:22:00 +03:00
|
|
|
message: ChatMessage;
|
|
|
|
highlightString: string;
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|
2022-08-11 06:22:00 +03:00
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export const ChatSystemMessage: FC<ChatSystemMessageProps> = ({
|
|
|
|
message: {
|
|
|
|
body,
|
|
|
|
user: { displayName },
|
|
|
|
},
|
|
|
|
highlightString,
|
|
|
|
}) => (
|
2023-07-11 23:07:58 +03:00
|
|
|
<div className={styles.chatSystemMessagePadding}>
|
|
|
|
<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 }),
|
|
|
|
]}
|
|
|
|
/>
|
2022-08-11 06:22:00 +03:00
|
|
|
</div>
|
2022-09-07 10:00:28 +03:00
|
|
|
</div>
|
|
|
|
);
|