This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,10 @@ var sanitizeHtml = require('sanitize-html');
2121var highlight = require ( 'highlight.js' ) ;
2222var linkifyMatrix = require ( './linkify-matrix' ) ;
2323import escape from 'lodash/escape' ;
24- import { unicodeToImage } from 'emojione' ;
24+ import { unicodeToImage , unicodeRegexp } from 'emojione' ;
25+ import classNames from 'classnames' ;
26+
27+ const EMOJI_REGEX = new RegExp ( unicodeRegexp + "+" , "gi" ) ;
2528
2629var sanitizeHtmlParams = {
2730 allowedTags : [
@@ -211,7 +214,15 @@ module.exports = {
211214 finally {
212215 delete sanitizeHtmlParams . textFilter ;
213216 }
214- return < span className = "markdown-body" dangerouslySetInnerHTML = { { __html : safeBody } } /> ;
217+
218+ EMOJI_REGEX . lastIndex = 0 ;
219+ let match = EMOJI_REGEX . exec ( body ) ;
220+ let emojiBody = match && match [ 0 ] && match [ 0 ] . length === body . length ;
221+
222+ let className = classNames ( 'markdown-body' , {
223+ 'emoji-body' : emojiBody ,
224+ } ) ;
225+ return < span className = { className } dangerouslySetInnerHTML = { { __html : safeBody } } /> ;
215226 } ,
216227
217228 highlightDom : function ( element ) {
You can’t perform that action at this time.
0 commit comments