fix multiple emojis not being processed correctly

This commit is contained in:
Nicolas Constant 2019-06-01 01:25:58 -04:00
parent 72c83a436c
commit 877f142238
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 8 additions and 7 deletions

View File

@ -14,21 +14,22 @@ export class EmojiConverter {
if (emojis) {
emojis.forEach(emoji => {
text = text.replace(
`:${emoji.shortcode}:`,
`<img class="${className}" src="${emoji.url}" title=":${
emoji.shortcode
}:" alt=":${emoji.shortcode}:" />`
);
text = this.replaceAll(text, `:${emoji.shortcode}:`, `<img class="${className}" src="${emoji.url}" title=":${
emoji.shortcode }:" alt=":${emoji.shortcode}:" />`)
});
}
text = this.emojiOne.toImage(text, className);
return text;
}
private replaceAll(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace);
}
}
export enum EmojiTypeEnum {
small,
medium
}
}