Browse Source

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

JC Brand 8 năm trước cách đây
mục cha
commit
972c31be1d
4 tập tin đã thay đổi với 14 bổ sung9 xóa
  1. 5 5
      docs/source/configuration.rst
  2. 2 0
      spec/chatbox.js
  3. 2 3
      src/converse-chatview.js
  4. 5 1
      src/utils.js

+ 5 - 5
docs/source/configuration.rst

@@ -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
 ----------------------

+ 2 - 0
spec/chatbox.js

@@ -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');

+ 2 - 3
src/converse-chatview.js

@@ -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);

+ 5 - 1
src/utils.js

@@ -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) {