Add linking to user chat messages. Closes #2635

This commit is contained in:
Gabe Kangas 2023-01-27 12:54:43 -08:00
parent 4e138642f9
commit bbd3041d90
No known key found for this signature in database
GPG Key ID: 4345B2060657F330
3 changed files with 22 additions and 233 deletions

View File

@ -5,6 +5,7 @@ import { Tooltip } from 'antd';
import { useRecoilValue } from 'recoil';
import dynamic from 'next/dynamic';
import { decodeHTML } from 'entities';
import linkifyHtml from 'linkify-html';
import styles from './ChatUserMessage.module.scss';
import { formatTimestamp } from './messageFmt';
import { ChatMessage } from '../../../interfaces/chat-message.model';
@ -107,6 +108,8 @@ export const ChatUserMessage: FC<ChatUserMessageProps> = ({
})}
style={{ borderColor: color }}
>
<div className={styles.background} style={{ color }} />
{!sameUserAsLast && (
<UserTooltip user={user}>
<div className={styles.user} style={{ color }}>
@ -119,11 +122,10 @@ export const ChatUserMessage: FC<ChatUserMessageProps> = ({
<Highlight search={highlightString}>
<div
className={styles.message}
dangerouslySetInnerHTML={{ __html: formattedMessage }}
dangerouslySetInnerHTML={{ __html: linkifyHtml(formattedMessage) }}
/>
</Highlight>
</Tooltip>
{showModeratorMenu && (
<div className={styles.modMenuWrapper}>
<ChatModerationActionMenu
@ -134,7 +136,6 @@ export const ChatUserMessage: FC<ChatUserMessageProps> = ({
/>
</div>
)}
<div className={styles.background} style={{ color }} />
</div>
</div>
);

244
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,8 @@
"classnames": "2.3.2",
"date-fns": "2.29.3",
"entities": "^4.4.0",
"linkify-html": "^4.1.0",
"linkifyjs": "^4.1.0",
"lodash": "4.17.21",
"next": "13.1.5",
"next-with-less": "2.0.5",
@ -115,4 +117,4 @@
"style-loader": "3.3.1",
"typescript": "4.9.4"
}
}
}