diff options
Diffstat (limited to 'web/react/components/post_body.jsx')
-rw-r--r-- | web/react/components/post_body.jsx | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/web/react/components/post_body.jsx b/web/react/components/post_body.jsx index d9b8f20ce..6e98e4aba 100644 --- a/web/react/components/post_body.jsx +++ b/web/react/components/post_body.jsx @@ -5,6 +5,7 @@ const FileAttachmentList = require('./file_attachment_list.jsx'); const UserStore = require('../stores/user_store.jsx'); const Utils = require('../utils/utils.jsx'); const Constants = require('../utils/constants.jsx'); +const TextFormatting = require('../utils/text_formatting.jsx'); const twemoji = require('twemoji'); export default class PostBody extends React.Component { @@ -16,24 +17,43 @@ export default class PostBody extends React.Component { const linkData = Utils.extractLinks(this.props.post.message); this.state = {links: linkData.links, message: linkData.text}; } + + getAllChildNodes(nodeIn) { + var textNodes = []; + + function getTextNodes(node) { + textNodes.push(node); + + for (var i = 0, len = node.childNodes.length; i < len; ++i) { + getTextNodes(node.childNodes[i]); + } + } + + getTextNodes(nodeIn); + return textNodes; + } + parseEmojis() { twemoji.parse(React.findDOMNode(this), {size: Constants.EMOJI_SIZE}); } + componentDidMount() { this.parseEmojis(); } + componentDidUpdate() { this.parseEmojis(); } + componentWillReceiveProps(nextProps) { const linkData = Utils.extractLinks(nextProps.post.message); this.setState({links: linkData.links, message: linkData.text}); } + render() { const post = this.props.post; const filenames = this.props.post.filenames; const parentPost = this.props.parentPost; - const inner = Utils.textToJsx(this.state.message); let comment = ''; let postClass = ''; @@ -75,7 +95,7 @@ export default class PostBody extends React.Component { comment = ( <p className='post-link'> <span> - Commented on {name}{apostrophe} message: + {'Commented on '}{name}{apostrophe}{' message:'} <a className='theme' onClick={this.props.handleCommentClick} @@ -98,7 +118,7 @@ export default class PostBody extends React.Component { href='#' onClick={this.props.retryPost} > - Retry + {'Retry'} </a> ); } else if (post.state === Constants.POST_LOADING) { @@ -121,7 +141,6 @@ export default class PostBody extends React.Component { fileAttachmentHolder = ( <FileAttachmentList filenames={filenames} - modalId={`view_image_modal_${post.id}`} channelId={post.channel_id} userId={post.user_id} /> @@ -131,12 +150,18 @@ export default class PostBody extends React.Component { return ( <div className='post-body'> {comment} - <p + <div key={`${post.id}_message`} + id={`${post.id}_message`} className={postClass} > - {loading}<span>{inner}</span> - </p> + {loading} + <span + ref='message_span' + onClick={TextFormatting.handleClick} + dangerouslySetInnerHTML={{__html: TextFormatting.formatText(this.state.message)}} + /> + </div> {fileAttachmentHolder} {embed} </div> |