0

Use same message highlighting on system messages

This commit is contained in:
Gabe Kangas 2023-02-05 15:46:48 -08:00
parent c0a2729226
commit 57d8bdbdbe
No known key found for this signature in database
GPG Key ID: 4345B2060657F330
5 changed files with 16 additions and 248 deletions

View File

@ -30,9 +30,11 @@
}
mark {
padding-left: 0.35em;
padding-right: 0.35em;
background-color: var(--theme-color-palette-12);
padding-left: 0.3em;
padding-right: 0.3em;
color: var(--theme-color-palette-4);
border-radius: var(--theme-rounded-corners);
background-color: var(--color-owncast-palette-7);
}
}

View File

@ -1,9 +1,10 @@
/* eslint-disable react/no-danger */
import { Highlight } from 'react-highlighter-ts';
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;
@ -21,8 +22,13 @@ export const ChatSystemMessage: FC<ChatSystemMessageProps> = ({
<div className={styles.user}>
<span className={styles.userName}>{displayName}</span>
</div>
<Highlight search={highlightString}>
<div className={styles.message} dangerouslySetInnerHTML={{ __html: body }} />
</Highlight>
<Interweave
className={styles.message}
content={body}
matchers={[
new UrlMatcher('url', { validateTLD: false }),
new ChatMessageHighlightMatcher('highlight', { highlightString }),
]}
/>
</div>
);

View File

@ -1,4 +1,3 @@
/* eslint-disable react/no-danger */
import { FC, ReactNode } from 'react';
import cn from 'classnames';
import { Tooltip } from 'antd';

238
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,6 @@
"react-chartkick": "^0.5.3",
"react-crossfade-img": "1.0.0",
"react-dom": "18.2.0",
"react-highlighter-ts": "18.0.1",
"react-hotkeys-hook": "4.3.4",
"react-linkify": "1.0.0-alpha",
"react-markdown": "8.0.5",