custom emoji in picker

This commit is contained in:
Thomas 2020-05-03 15:16:32 +02:00
parent cc2fc34ec9
commit 493f1966d9

View file

@ -269,6 +269,11 @@ document = window.document || {};
emoji: "" emoji: ""
}, },
custom_emoji: {
icon: "yum",
title: "Custom emoji",
emoji: "",
},
smileys_people: { smileys_people: {
icon: "yum", icon: "yum",
title: "Smileys & People", title: "Smileys & People",
@ -968,7 +973,7 @@ document = window.document || {};
var mainBlock = div('category-block').attr({"data-tone": 0}).prependTo(emojisList); var mainBlock = div('category-block').attr({"data-tone": 0}).prependTo(emojisList);
$.each(options.filters, function(filter, params) { $.each(options.filters, function(filter, params) {
var skin = 0; let skin = 0;
if (filter === 'recent' && !self.recentEmojis) { if (filter === 'recent' && !self.recentEmojis) {
return; return;
} }
@ -981,13 +986,13 @@ document = window.document || {};
.wrapInner(shortnameTo(params.icon, self.emojiTemplateAlt)) .wrapInner(shortnameTo(params.icon, self.emojiTemplateAlt))
.appendTo(filters); .appendTo(filters);
} else if (options.tones) { } else if (options.tones) {
skin = 5; skin = 6;
} else { } else {
return; return;
} }
do { do {
var category, let category,
items = params.emoji.replace(/[\s,;]+/g, '|'); items = params.emoji.replace(/[\s,;]+/g, '|');
if (skin === 0) { if (skin === 0) {
@ -1001,6 +1006,23 @@ document = window.document || {};
"data-tone": skin "data-tone": skin
}).appendTo(emojisList); }).appendTo(emojisList);
} }
if( filter === "custom_emoji"){
let titleTab = params.title;
$.ajax({
url: "https://"+$('#data_api').attr('data-instance')+"/api/v1/custom_emojis",
context: document.body
}).done(function(customEmoji) {
for(var i = 0 ; i < customEmoji.length ; i++) {
var element = $('<i class="emojibtn" role="button" data-name=":'+customEmoji[i].shortcode+':" title="'+customEmoji[i].shortcode+'"><img class="emojioneemoji" src="'+customEmoji[i].url+'" data-src="'+customEmoji[i].url+'"/></i>)');
element.on('click', function () {
pasteHtmlAtCaret(shortnameTo($(this).attr('data-name'), self.emojiTemplate));
})
category.append(element);
}
$('<div class="emojionearea-category-title"/>').text(titleTab).prependTo(category);
});
}else {
if (skin > 0) { if (skin > 0) {
category.hide(); category.hide();
@ -1016,12 +1038,14 @@ document = window.document || {};
'<i class="emojibtn" role="button" data-name="{name}" title="{friendlyName}"><i class="emojione-{uni}"></i></i>' : '<i class="emojibtn" role="button" data-name="{name}" title="{friendlyName}"><i class="emojione-{uni}"></i></i>' :
'<i class="emojibtn" role="button" data-name="{name}" title="{friendlyName}"><img class="emojioneemoji lazy-emoji" data-src="{img}"/></i>', '<i class="emojibtn" role="button" data-name="{name}" title="{friendlyName}"><img class="emojioneemoji lazy-emoji" data-src="{img}"/></i>',
true).split('|').join(''); true).split('|').join('');
category.html(items); category.html(items);
$('<div class="emojionearea-category-title"/>').text(params.title).prependTo(category); $('<div class="emojionearea-category-title"/>').text(params.title).prependTo(category);
}
} while (--skin > 0); } while (--skin > 0);
}); });
options.filters = null; options.filters = null;
if (!self.sprite) { if (!self.sprite) {
self.lasyEmoji = emojisList.find(".lazy-emoji"); self.lasyEmoji = emojisList.find(".lazy-emoji");