Perform colons conversion

This commit is contained in:
Pierre 2018-04-20 16:11:32 +02:00
parent 25525dcd94
commit b05a26d734

View File

@ -14,6 +14,11 @@ ComunicWeb.components.emoji.parser = {
*/ */
__twemojiBase: ComunicWeb.__config.assetsURL + "3rdparty/twemoji/2/", __twemojiBase: ComunicWeb.__config.assetsURL + "3rdparty/twemoji/2/",
/**
* EmojiConvertor instance
*/
__emojiConvertor: null,
/** /**
* Parse emojies * Parse emojies
* *
@ -26,6 +31,9 @@ ComunicWeb.components.emoji.parser = {
//Peform string parsing //Peform string parsing
infos.element.innerHTML = this.shorcutToHTMLcode(infos.element.innerHTML); infos.element.innerHTML = this.shorcutToHTMLcode(infos.element.innerHTML);
//Perform colon conversion
infos.element.innerHTML = this.colonConversion(infos.element.innerHTML);
//Perform Twitter parsing //Perform Twitter parsing
this.twitterEmojiesParsing(infos.element); this.twitterEmojiesParsing(infos.element);
@ -33,6 +41,25 @@ ComunicWeb.components.emoji.parser = {
return true; 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 * Perform Twitter emojies parsing
* *