From b05a26d734dbd7d2e8e05640fd9120c39cc06e86 Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 20 Apr 2018 16:11:32 +0200 Subject: [PATCH] Perform colons conversion --- assets/js/components/emoji/parser.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/assets/js/components/emoji/parser.js b/assets/js/components/emoji/parser.js index 5a7fdf1e..cd1e2a93 100644 --- a/assets/js/components/emoji/parser.js +++ b/assets/js/components/emoji/parser.js @@ -14,6 +14,11 @@ ComunicWeb.components.emoji.parser = { */ __twemojiBase: ComunicWeb.__config.assetsURL + "3rdparty/twemoji/2/", + /** + * EmojiConvertor instance + */ + __emojiConvertor: null, + /** * Parse emojies * @@ -26,6 +31,9 @@ ComunicWeb.components.emoji.parser = { //Peform string parsing infos.element.innerHTML = this.shorcutToHTMLcode(infos.element.innerHTML); + //Perform colon conversion + infos.element.innerHTML = this.colonConversion(infos.element.innerHTML); + //Perform Twitter parsing this.twitterEmojiesParsing(infos.element); @@ -33,6 +41,25 @@ ComunicWeb.components.emoji.parser = { return true; }, + /** + * Perform the conversion from colon code to Emoji code + * + * @param {string} string The string to convert + * @return {string} Converted string + */ + colonConversion: function(string){ + + //Check if the emoji convertor has to be created + if(this.__emojiConvertor == null){ + this.__emojiConvertor = new EmojiConvertor(); + this.__emojiConvertor.init_env(); // else auto-detection will trigger when we first convert + this.__emojiConvertor.replace_mode = 'unified'; + this.__emojiConvertor.allow_native = true; + } + + return this.__emojiConvertor.replace_colons(string); + }, + /** * Perform Twitter emojies parsing *