summaryrefslogtreecommitdiffstats
path: root/web/react/components
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2015-09-17 11:56:59 -0400
committerJoram Wilander <jwawilander@gmail.com>2015-09-17 11:56:59 -0400
commit7901126b638a173a2d9752473e799417444466a7 (patch)
tree3b9afcd4d4dc982899bd9506df759eb64cc75de3 /web/react/components
parentde64bd19d5a9811ee2539baa8fdb61c4ece57378 (diff)
parent99d0db136cfaa88cf654c77e30fd1867136db9d5 (diff)
downloadchat-7901126b638a173a2d9752473e799417444466a7.tar.gz
chat-7901126b638a173a2d9752473e799417444466a7.tar.bz2
chat-7901126b638a173a2d9752473e799417444466a7.zip
Merge pull request #701 from mattermost/PLT-40
PLT-40 adding experimental support for emojis
Diffstat (limited to 'web/react/components')
-rw-r--r--web/react/components/post_body.jsx28
1 files changed, 26 insertions, 2 deletions
diff --git a/web/react/components/post_body.jsx b/web/react/components/post_body.jsx
index df4ed3d57..3be615bb9 100644
--- a/web/react/components/post_body.jsx
+++ b/web/react/components/post_body.jsx
@@ -17,19 +17,42 @@ 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});
+ this.getAllChildNodes(React.findDOMNode(this)).forEach((current) => {
+ global.window.emojify.run(current);
+ });
}
+
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;
@@ -75,7 +98,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 +121,7 @@ export default class PostBody extends React.Component {
href='#'
onClick={this.props.retryPost}
>
- Retry
+ {'Retry'}
</a>
);
} else if (post.state === Constants.POST_LOADING) {
@@ -133,6 +156,7 @@ export default class PostBody extends React.Component {
{comment}
<p
key={`${post.id}_message`}
+ id={`${post.id}_message`}
className={postClass}
>
{loading}