Skip to content

Commit

Permalink
Rework emoji formatting (fixes airdcpp-web/airdcpp-webclient#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
maksis committed Feb 20, 2017
1 parent d0faf89 commit 06345e8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -68,8 +68,9 @@
"react-addons-pure-render-mixin": "^15.0.0",
"react-autosuggest": "^8.0.0",
"react-dom": "^15.0.0",
"react-emoji": "^0.4.1",
"react-grid-layout": "^0.13.0",
"react-easy-emoji": "^1.0.4",
"react-emojione": "^2.0.0",
"react-grid-layout": "^0.14.0",
"react-linkify": "^0.2.0",
"react-notification-system": "^0.2.5",
"react-resizable-box": "^1.8.0",
Expand Down
25 changes: 21 additions & 4 deletions src/components/TextDecorator.jsx
Expand Up @@ -3,7 +3,14 @@
import React from 'react';

import { default as ReactLinkify, linkify } from 'react-linkify';
import ReactEmoji from 'react-emoji';

// Convert :D, :P etc. to unicode
// Increases the compressed bundle size by ~25 kilobytes so a simplified custom
// implementation could be considered that would only replace ascii emoticons
import { emojify as emojisToUnicode } from 'react-emojione';

import emoji from 'react-easy-emoji';

import History from 'utils/History';


Expand Down Expand Up @@ -47,12 +54,22 @@ const TextDecorator = ({ emojify = false, text }, { routerLocation }) => (
onClick: evt => onClickLink(evt, routerLocation),
}}
>
{ !emojify ? text : ReactEmoji.emojify(text, {
emojiType: 'twemoji'
})}
{ !emojify ? text : emoji(emojisToUnicode(text, { output: 'unicode' }), {
props: {
style: {
height: '20px',
width: '20px',
}
}
}) }
</ReactLinkify>
);

TextDecorator.propTypes = {
text: React.PropTypes.string.isRequired,
emojify: React.PropTypes.bool,
};

TextDecorator.contextTypes = {
routerLocation: React.PropTypes.object.isRequired,
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/messages/Message.jsx
Expand Up @@ -75,7 +75,7 @@ const ChatMessage = React.createClass({
/>
<MessageText
message={ message }
emojify={ message.from.flags.indexOf('bot') === -1 } // No emojis to bot messages as they are likely to contain false matches
emojify={ true }
/>
</div>
</div>
Expand Down

0 comments on commit 06345e8

Please sign in to comment.