mirror of
				https://github.com/owncast/owncast.git
				synced 2025-11-04 13:27:21 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			1023 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1023 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>
 | 
						|
);
 |