emoji: Allow the option of using emojione (now that we sanitize)

This commit is contained in:
JC Brand 2017-07-15 19:17:15 +02:00
parent 284e884766
commit 972c31be1d
4 changed files with 14 additions and 9 deletions

View File

@ -993,13 +993,13 @@ Notification will be shown in the following cases:
Requires the `src/converse-notification.js` plugin.
show_emojione
-------------
* Default: ``false``
use_emojione
------------
* Default: ``true``
Determines whether `Emojione <https://www.emojione.com/>`_ should be used to
render emojis. The default is not to do this, but to simply let the operating
system or browser render emoji (if it has support for them).
render emojis. If set to ``false``, then rendering support will fall back to
the operating system or browser (which might not support emoji).
show_only_online_users
----------------------

View File

@ -412,6 +412,8 @@
}, 300).then(function () {
$toolbar.children('li.toggle-smiley').click();
expect(view.toggleEmojiMenu).toHaveBeenCalled();
view.$el.find('textarea.chat-textarea').trigger($.Event('keypress', {keyCode: 13}));
test_utils.waitUntil(function () {
var $picker = view.$el.find('.toggle-smiley .emoji-picker-container');
return $picker.is(':visible');

View File

@ -92,6 +92,7 @@
{ __ } = _converse;
_converse.api.settings.update({
use_emojione: true,
chatview_avatar_height: 32,
chatview_avatar_width: 32,
show_toolbar: true,
@ -426,9 +427,7 @@
'extra_classes': this.getExtraMessageClasses(attrs)
})
));
if (_converse.visible_toolbar_buttons.emoji) {
text = utils.addEmoji(_converse, emojione, text);
}
text = utils.addEmoji(_converse, emojione, text);
const msg_content = $msg[0].querySelector('.chat-msg-content');
msg_content.innerHTML = xss.filterXSS(text, {'whiteList': {}});
utils.addHyperlinks(msg_content);

View File

@ -599,7 +599,11 @@
};
utils.addEmoji = function (_converse, emojione, text) {
return emojione.shortnameToUnicode(text);
if (_converse.use_emojione) {
return emojione.toImage(text);
} else {
return emojione.shortnameToUnicode(text);
}
}
utils.marshallEmojis = function (emojione) {