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. Requires the `src/converse-notification.js` plugin.
show_emojione use_emojione
------------- ------------
* Default: ``false`` * Default: ``true``
Determines whether `Emojione <https://www.emojione.com/>`_ should be used to 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 render emojis. If set to ``false``, then rendering support will fall back to
system or browser render emoji (if it has support for them). the operating system or browser (which might not support emoji).
show_only_online_users show_only_online_users
---------------------- ----------------------

View File

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

View File

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

View File

@ -599,8 +599,12 @@
}; };
utils.addEmoji = function (_converse, emojione, text) { utils.addEmoji = function (_converse, emojione, text) {
if (_converse.use_emojione) {
return emojione.toImage(text);
} else {
return emojione.shortnameToUnicode(text); return emojione.shortnameToUnicode(text);
} }
}
utils.marshallEmojis = function (emojione) { utils.marshallEmojis = function (emojione) {
/* Return a dict of emojis with the categories as keys and /* Return a dict of emojis with the categories as keys and