import React from 'react' ; import classNames from 'classnames' ; import { getSizeClass , emojiRegEx , replaceColons } from '../conversations/emoji' ; import { message2React } from './MessageMarkdown' ; export default function MessageBody ( props ) { const { text , disableJumbomoji , preview } = props ; const emojifiedText = trim ( text . replace ( /:[\w\d_\-+]*:/g , replaceColons ) ) ; if ( emojifiedText . length < 50 && ! disableJumbomoji && emojifiedText . replace ( emojiRegEx , '' ) === '' ) { const sizeClass = disableJumbomoji ? '' : getSizeClass ( emojifiedText ) ; return ( < span className = { classNames ( 'emoji-container' , sizeClass ) } > { emojifiedText } < /span>); } if ( preview ) return < > { emojifiedText } < />; return message2React ( emojifiedText ) ; } const trimRegex = /^[\s\uFEFF\xA0\n\t]+|[\s\uFEFF\xA0\n\t]+$/g ; /** removes linebreaks at start and end */ function trim ( str ) { return str . replace ( trimRegex , '' ) ; }