summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-05-05 15:35:01 -0400
committerCorey Hulen <corey@hulen.com>2016-05-05 12:35:01 -0700
commited3162a59d522981cd6b63e578d31e0a96b5d2ff (patch)
tree3e70807996077605fa45677efced738f71923db6 /webapp
parent511be7714b1939892f687bbdb46f0598916adf23 (diff)
downloadchat-ed3162a59d522981cd6b63e578d31e0a96b5d2ff.tar.gz
chat-ed3162a59d522981cd6b63e578d31e0a96b5d2ff.tar.bz2
chat-ed3162a59d522981cd6b63e578d31e0a96b5d2ff.zip
Moved twemoji parsing so that it doesn't occur inside of code blocks (#2896)
Diffstat (limited to 'webapp')
-rw-r--r--webapp/components/post_body.jsx35
-rw-r--r--webapp/components/rhs_comment.jsx16
-rw-r--r--webapp/components/rhs_root_post.jsx16
-rw-r--r--webapp/utils/text_formatting.jsx9
4 files changed, 9 insertions, 67 deletions
diff --git a/webapp/components/post_body.jsx b/webapp/components/post_body.jsx
index a159dcbb1..6c4e97d8e 100644
--- a/webapp/components/post_body.jsx
+++ b/webapp/components/post_body.jsx
@@ -1,13 +1,11 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
-import ReactDOM from 'react-dom';
import FileAttachmentList from './file_attachment_list.jsx';
import UserStore from 'stores/user_store.jsx';
import * as Utils from 'utils/utils.jsx';
import Constants from 'utils/constants.jsx';
import * as TextFormatting from 'utils/text_formatting.jsx';
-import twemoji from 'twemoji';
import PostBodyAdditionalContent from './post_body_additional_content.jsx';
import {FormattedMessage} from 'react-intl';
@@ -17,39 +15,6 @@ import loadingGif from 'images/load.gif';
import React from 'react';
export default class PostBody extends React.Component {
- constructor(props) {
- super(props);
-
- this.parseEmojis = this.parseEmojis.bind(this);
- }
-
- 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(ReactDOM.findDOMNode(this), {
- className: 'emoticon',
- base: '',
- folder: Constants.EMOJI_PATH
- });
- }
-
- componentDidMount() {
- this.parseEmojis();
- }
-
shouldComponentUpdate(nextProps) {
if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) {
return true;
diff --git a/webapp/components/rhs_comment.jsx b/webapp/components/rhs_comment.jsx
index 452174045..f21ae24e7 100644
--- a/webapp/components/rhs_comment.jsx
+++ b/webapp/components/rhs_comment.jsx
@@ -23,15 +23,12 @@ import {FormattedMessage, FormattedDate} from 'react-intl';
import loadingGif from 'images/load.gif';
import React from 'react';
-import ReactDOM from 'react-dom';
-import twemoji from 'twemoji';
export default class RhsComment extends React.Component {
constructor(props) {
super(props);
this.retryComment = this.retryComment.bind(this);
- this.parseEmojis = this.parseEmojis.bind(this);
this.handlePermalink = this.handlePermalink.bind(this);
this.state = {};
@@ -66,20 +63,10 @@ export default class RhsComment extends React.Component {
PostStore.updatePendingPost(post);
this.forceUpdate();
}
- parseEmojis() {
- twemoji.parse(ReactDOM.findDOMNode(this), {
- className: 'emoticon',
- base: '',
- folder: Constants.EMOJI_PATH
- });
- }
handlePermalink(e) {
e.preventDefault();
GlobalActions.showGetPostLinkModal(this.props.post);
}
- componentDidMount() {
- this.parseEmojis();
- }
shouldComponentUpdate(nextProps) {
if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) {
return true;
@@ -87,9 +74,6 @@ export default class RhsComment extends React.Component {
return false;
}
- componentDidUpdate() {
- this.parseEmojis();
- }
createDropdown() {
var post = this.props.post;
diff --git a/webapp/components/rhs_root_post.jsx b/webapp/components/rhs_root_post.jsx
index d56306d28..c771674a6 100644
--- a/webapp/components/rhs_root_post.jsx
+++ b/webapp/components/rhs_root_post.jsx
@@ -1,14 +1,12 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
-import ReactDOM from 'react-dom';
import ChannelStore from 'stores/channel_store.jsx';
import UserProfile from './user_profile.jsx';
import UserStore from 'stores/user_store.jsx';
import * as TextFormatting from 'utils/text_formatting.jsx';
import * as Utils from 'utils/utils.jsx';
import FileAttachmentList from './file_attachment_list.jsx';
-import twemoji from 'twemoji';
import PostBodyAdditionalContent from './post_body_additional_content.jsx';
import * as GlobalActions from 'action_creators/global_actions.jsx';
@@ -22,25 +20,14 @@ export default class RhsRootPost extends React.Component {
constructor(props) {
super(props);
- this.parseEmojis = this.parseEmojis.bind(this);
this.handlePermalink = this.handlePermalink.bind(this);
this.state = {};
}
- parseEmojis() {
- twemoji.parse(ReactDOM.findDOMNode(this), {
- className: 'emoticon',
- base: '',
- folder: Constants.EMOJI_PATH
- });
- }
handlePermalink(e) {
e.preventDefault();
GlobalActions.showGetPostLinkModal(this.props.post);
}
- componentDidMount() {
- this.parseEmojis();
- }
shouldComponentUpdate(nextProps) {
if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) {
return true;
@@ -48,9 +35,6 @@ export default class RhsRootPost extends React.Component {
return false;
}
- componentDidUpdate() {
- this.parseEmojis();
- }
render() {
const post = this.props.post;
const user = this.props.user;
diff --git a/webapp/utils/text_formatting.jsx b/webapp/utils/text_formatting.jsx
index 88dc412ca..cb61ecc8d 100644
--- a/webapp/utils/text_formatting.jsx
+++ b/webapp/utils/text_formatting.jsx
@@ -7,6 +7,7 @@ import Constants from './constants.jsx';
import * as Emoticons from './emoticons.jsx';
import * as Markdown from './markdown.jsx';
import UserStore from 'stores/user_store.jsx';
+import twemoji from 'twemoji';
import * as Utils from './utils.jsx';
// Performs formatting of user posts including highlighting mentions and search terms and converting urls, hashtags, and
@@ -62,6 +63,14 @@ export function doFormatText(text, options) {
// reinsert tokens with formatted versions of the important words and phrases
output = replaceTokens(output, tokens);
+ if (!('emoticons' in options) || options.emoticon) {
+ output = twemoji.parse(output, {
+ className: 'emoticon',
+ base: '',
+ folder: Constants.EMOJI_PATH
+ });
+ }
+
return output;
}