FEATURE: Show autocomplete when enable_inline_emoji_translation is true.

FEATURE: Show autocomplete when enable_inline_emoji_translation is true.
From 79d987e4833158850e620aefa2bee9cd1357bab8 Mon Sep 17 00:00:00 2001
From: Bianca Nenciu <nenciu.bianca@gmail.com>
Date: Mon, 26 Nov 2018 16:27:45 +0200
Subject: [PATCH] FEATURE: Show autocomplete when
 enable_inline_emoji_translation is true.


diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6
index f48836b..2d93bb2 100644
--- a/app/assets/javascripts/discourse/components/d-editor.js.es6
+++ b/app/assets/javascripts/discourse/components/d-editor.js.es6
@@ -410,9 +410,11 @@ export default Ember.Component.extend({
       },
 
       onKeyUp(text, cp) {
-        const matches = /(?:^|[^a-z])(:(?!:).?[\w-]*:?(?!:)(?:t\d?)?:?) ?$/gi.exec(
-          text.substring(0, cp)
-        );
+        const regex = self.siteSettings.enable_inline_emoji_translation
+          ? /(:(?!:).?[\w-]*:?(?!:)(?:t\d?)?:?) ?$/gi
+          : /(?:^|[^a-z])(:(?!:).?[\w-]*:?(?!:)(?:t\d?)?:?) ?$/gi;
+
+        const matches = regex.exec(text.substring(0, cp));
 
         if (matches && matches[1]) {
           return [matches[1]];
diff --git a/test/javascripts/lib/pretty-text-test.js.es6 b/test/javascripts/lib/pretty-text-test.js.es6
index 76f54a0..32670c4 100644
--- a/test/javascripts/lib/pretty-text-test.js.es6
+++ b/test/javascripts/lib/pretty-text-test.js.es6
@@ -1364,7 +1364,7 @@ QUnit.test("emoji - enable_inline_emoji_translation", assert => {
   assert.cookedOptions(
     "test:smile:test",
     { siteSettings: { enable_inline_emoji_translation: true } },
-    `<p>test<img src="/images/emoji/twitter/smile.png?v=${v}" title=":smile:" class="emoji" alt=":smile:">test</p>`
+    `<p>test<img src="/images/emoji/emoji_one/smile.png?v=${v}" title=":smile:" class="emoji" alt=":smile:">test</p>`
   );
 });

GitHub