DEV: Apply code review.

This commit is contained in:
Bianca Nenciu 2018-12-04 14:07:13 +02:00 committed by Régis Hanol
parent 79d987e483
commit a8e8473ea5
2 changed files with 10 additions and 5 deletions

View File

@ -410,12 +410,17 @@ export default Ember.Component.extend({
},
onKeyUp(text, cp) {
// Regular expressions used to extract emoji name from text.
// The space version requires a ' ' (space) before the emoji name
// (i.e. ' :smile'), while the other one does not and is used
// when enable_inline_emoji_translation is true.
const noSpaceColonEmoji = /(:(?!:).?[\w-]*:?(?!:)(?:t\d?)?:?) ?$/gi;
const spaceColonEmoji = /(?:^|[^a-z])(:(?!:).?[\w-]*:?(?!:)(?:t\d?)?:?) ?$/gi;
const regex = self.siteSettings.enable_inline_emoji_translation
? /(:(?!:).?[\w-]*:?(?!:)(?:t\d?)?:?) ?$/gi
: /(?:^|[^a-z])(:(?!:).?[\w-]*:?(?!:)(?:t\d?)?:?) ?$/gi;
? noSpaceColonEmoji
: spaceColonEmoji;
const matches = regex.exec(text.substring(0, cp));
if (matches && matches[1]) {
return [matches[1]];
}

View File

@ -195,7 +195,7 @@ function applyEmoji(
for (i = 0; i < content.length - 1; i++) {
let offset = 0;
let emojiName = getEmojiName(content, i, state, inlineEmoji);
const emojiName = getEmojiName(content, i, state, inlineEmoji);
let token = null;
if (emojiName) {