import { useMemo } from 'react' import ReactMarkdown from 'react-markdown' import gfm from 'remark-gfm' import remarkBreaks from 'remark-breaks' import remarkMath from 'remark-math' import rehypeKatex from 'rehype-katex' import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' import { vscDarkPlus } from 'react-syntax-highlighter/dist/cjs/styles/prism' import 'katex/dist/katex.min.css' import { Emoji, emojiPlugin, isStringWithOnlyOneEmoji } from '../../../../Emoji' import type { MessageWithMember } from '../../../../../models/Message' export interface MessageContentProps { message: MessageWithMember } export const MessageText: React.FC = (props) => { const { message } = props const isMessageWithOnlyOneEmoji = useMemo(() => { return isStringWithOnlyOneEmoji(message.value) }, [message.value]) if (isMessageWithOnlyOneEmoji) { return (

) } return ( { return ( ) }, emoji: (props) => { return }, code: (properties) => { const { inline, className, children, ...props } = properties const match = /language-(\w+)/.exec(className ?? '') return !(inline as boolean) && match != null ? ( {String(children).replace(/\n$/, '')} ) : ( {children} ) } }} > {message.value} ) }