DEV: Export add emoji logic in textarea manipulation mixin (#14976)

DEV: Export add emoji logic in textarea manipulation mixin (#14976)

diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js
index 13f589f..1b0ce15 100644
--- a/app/assets/javascripts/discourse/app/components/d-editor.js
+++ b/app/assets/javascripts/discourse/app/components/d-editor.js
@@ -22,7 +22,6 @@ import deprecated from "discourse-common/lib/deprecated";
 import discourseDebounce from "discourse-common/lib/debounce";
 import { findRawTemplate } from "discourse-common/lib/raw-templates";
 import { getRegister } from "discourse-common/lib/get-owner";
-import { isEmpty } from "@ember/utils";
 import { isTesting } from "discourse-common/config/environment";
 import { linkSeenHashtags } from "discourse/lib/link-hashtags";
 import { linkSeenMentions } from "discourse/lib/link-mentions";
@@ -794,28 +793,6 @@ export default Component.extend(TextareaTextManipulation, {
       this.set("emojiPickerIsActive", !this.emojiPickerIsActive);
     },
 
-    emojiSelected(code) {
-      let selected = this._getSelected();
-      const captures = selected.pre.match(/\B:(\w*)$/);
-
-      if (isEmpty(captures)) {
-        if (selected.pre.match(/\S$/)) {
-          this._addText(selected, ` :${code}:`);
-        } else {
-          this._addText(selected, `:${code}:`);
-        }
-      } else {
-        let numOfRemovedChars = selected.pre.length - captures[1].length;
-        selected.pre = selected.pre.slice(
-          0,
-          selected.pre.length - captures[1].length
-        );
-        selected.start -= numOfRemovedChars;
-        selected.end -= numOfRemovedChars;
-        this._addText(selected, `${code}:`);
-      }
-    },
-
     toolbarButton(button) {
       if (this.disabled) {
         return;
diff --git a/app/assets/javascripts/discourse/app/mixins/textarea-text-manipulation.js b/app/assets/javascripts/discourse/app/mixins/textarea-text-manipulation.js
index b825394..0256352 100644
--- a/app/assets/javascripts/discourse/app/mixins/textarea-text-manipulation.js
+++ b/app/assets/javascripts/discourse/app/mixins/textarea-text-manipulation.js
@@ -1,6 +1,8 @@
 import { bind } from "discourse-common/utils/decorators";
 import Mixin from "@ember/object/mixin";
 import toMarkdown from "discourse/lib/to-markdown";
+import { action } from "@ember/object";
+import { isEmpty } from "@ember/utils";
 import { isTesting } from "discourse-common/config/environment";
 import {
   clipboardHelpers,
@@ -288,4 +290,27 @@ export default Mixin.create({
       e.preventDefault();
     }
   },
+
+  @action
+  emojiSelected(code) {
+    let selected = this._getSelected();
+    const captures = selected.pre.match(/\B:(\w*)$/);
+
+    if (isEmpty(captures)) {
+      if (selected.pre.match(/\S$/)) {
+        this._addText(selected, ` :${code}:`);
+      } else {
+        this._addText(selected, `:${code}:`);
+      }
+    } else {
+      let numOfRemovedChars = selected.pre.length - captures[1].length;
+      selected.pre = selected.pre.slice(
+        0,
+        selected.pre.length - captures[1].length
+      );
+      selected.start -= numOfRemovedChars;
+      selected.end -= numOfRemovedChars;
+      this._addText(selected, `${code}:`);
+    }
+  },
 });

GitHub sha: 1b752a5dec99e6fc34dcfe5c6ded053382acc9aa

This commit appears in #14976 which was approved by eviltrout. It was merged by markvanlan.