Skip to content

Commit

Permalink
feat: large emoji support
Browse files Browse the repository at this point in the history
  • Loading branch information
aviraldg committed Jul 4, 2016
1 parent 48f2c4a commit 4069886
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/HtmlUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ var sanitizeHtml = require('sanitize-html');
var highlight = require('highlight.js');
var linkifyMatrix = require('./linkify-matrix');
import escape from 'lodash/escape';
import {unicodeToImage} from 'emojione';
import {unicodeToImage, unicodeRegexp} from 'emojione';
import classNames from 'classnames';

const EMOJI_REGEX = new RegExp(unicodeRegexp+"+", "gi");

var sanitizeHtmlParams = {
allowedTags: [
Expand Down Expand Up @@ -211,7 +214,15 @@ module.exports = {
finally {
delete sanitizeHtmlParams.textFilter;
}
return <span className="markdown-body" dangerouslySetInnerHTML={{ __html: safeBody }} />;

EMOJI_REGEX.lastIndex = 0;
let match = EMOJI_REGEX.exec(body);
let emojiBody = match && match[0] && match[0].length === body.length;

let className = classNames('markdown-body', {
'emoji-body': emojiBody,
});
return <span className={className} dangerouslySetInnerHTML={{ __html: safeBody }} />;
},

highlightDom: function(element) {
Expand Down

0 comments on commit 4069886

Please sign in to comment.