From 4069886cbda08459fa5145fb2771cd77f7e95277 Mon Sep 17 00:00:00 2001 From: Aviral Dasgupta Date: Tue, 5 Jul 2016 04:04:57 +0530 Subject: [PATCH] feat: large emoji support --- src/HtmlUtils.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index 629851f9e8..91bb063ee2 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -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: [ @@ -211,7 +214,15 @@ module.exports = { finally { delete sanitizeHtmlParams.textFilter; } - return ; + + 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 ; }, highlightDom: function(element) {