diff options
author | Vitaly Takmazov | 2019-04-04 17:08:59 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:54 +0300 |
commit | 1a81bda3db066301b3fada3b3db0e1db5f0b2e9e (patch) | |
tree | abe5d31c148b5402c2557b4809824b9d6adfb3bf /vnext/src/components | |
parent | 3b160c73fc2f2b11ceb91e74881ec3bc94a4b3f6 (diff) |
isCode format fix
Diffstat (limited to 'vnext/src/components')
-rw-r--r-- | vnext/src/components/Message.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/vnext/src/components/Message.js b/vnext/src/components/Message.js index 1d9afe9a..6b0854a4 100644 --- a/vnext/src/components/Message.js +++ b/vnext/src/components/Message.js @@ -12,6 +12,7 @@ import { format } from '../utils/embed'; import './Message.css'; function Message({ data, visitor, children, ...rest }) { + const isCode = (data.tags || []).indexOf('code') >= 0; return ( <div className="msg-cont"> <header className="h"> @@ -28,7 +29,7 @@ function Message({ data, visitor, children, ...rest }) { <TagsList user={data.user} data={data.tags || []} /> </header> <div className="msg-txt"> - <p dangerouslySetInnerHTML={{ __html: format(data.body, data.mid, (data.tags || []).indexOf('code') >= 0) }}></p> + <MessageContainer isCode={isCode} data={{ __html: format(data.body, data.mid, isCode) }} /> </div> {data.photo && <p className="ir"><a href={`//i.juick.com/p/${data.mid}.${data.attach}`} data-fname={`${data.mid}.${data.attach}`}> @@ -86,6 +87,10 @@ function Message({ data, visitor, children, ...rest }) { export default React.memo(Message); +function MessageContainer({isCode, data}) { + return isCode ? (<pre dangerouslySetInnerHTML={data} />) : (<p dangerouslySetInnerHTML={data} />); +} + function Tags({ data, user, ...rest }) { return data.length > 0 && ( <div className="msg-tags"> |