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
3 changed files with 22 additions and 233 deletions

View File

@@ -5,6 +5,7 @@ import { Tooltip } from 'antd';
import { useRecoilValue } from 'recoil'; import { useRecoilValue } from 'recoil';
import dynamic from 'next/dynamic'; import dynamic from 'next/dynamic';
import { decodeHTML } from 'entities'; import { decodeHTML } from 'entities';
import linkifyHtml from 'linkify-html';
import styles from './ChatUserMessage.module.scss'; import styles from './ChatUserMessage.module.scss';
import { formatTimestamp } from './messageFmt'; import { formatTimestamp } from './messageFmt';
import { ChatMessage } from '../../../interfaces/chat-message.model'; import { ChatMessage } from '../../../interfaces/chat-message.model';
@@ -107,6 +108,8 @@ export const ChatUserMessage: FC<ChatUserMessageProps> = ({
})} })}
style={{ borderColor: color }} style={{ borderColor: color }}
> >
<div className={styles.background} style={{ color }} />
{!sameUserAsLast && ( {!sameUserAsLast && (
<UserTooltip user={user}> <UserTooltip user={user}>
<div className={styles.user} style={{ color }}> <div className={styles.user} style={{ color }}>
@@ -119,11 +122,10 @@ export const ChatUserMessage: FC<ChatUserMessageProps> = ({
<Highlight search={highlightString}> <Highlight search={highlightString}>
<div <div
className={styles.message} className={styles.message}
dangerouslySetInnerHTML={{ __html: formattedMessage }} dangerouslySetInnerHTML={{ __html: linkifyHtml(formattedMessage) }}
/> />
</Highlight> </Highlight>
</Tooltip> </Tooltip>
{showModeratorMenu && ( {showModeratorMenu && (
<div className={styles.modMenuWrapper}> <div className={styles.modMenuWrapper}>
<ChatModerationActionMenu <ChatModerationActionMenu
@@ -134,7 +136,6 @@ export const ChatUserMessage: FC<ChatUserMessageProps> = ({
/> />
</div> </div>
)} )}
<div className={styles.background} style={{ color }} />
</div> </div>
</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", "classnames": "2.3.2",
"date-fns": "2.29.3", "date-fns": "2.29.3",
"entities": "^4.4.0", "entities": "^4.4.0",
"linkify-html": "^4.1.0",
"linkifyjs": "^4.1.0",
"lodash": "4.17.21", "lodash": "4.17.21",
"next": "13.1.5", "next": "13.1.5",
"next-with-less": "2.0.5", "next-with-less": "2.0.5",