DEV: replaces huge generated emoji list by a simpler regex (#11053)

DEV: replaces huge generated emoji list by a simpler regex (#11053)

Note that this commit is also fixing various mistakes in emojis.

Some of them have been fixed manually in db.json/data.js/groups.json and will need to be fixed in emoji-db gem.

diff --git a/app/assets/javascripts/discourse/app/templates/components/emoji-group-sections.hbs b/app/assets/javascripts/discourse/app/templates/components/emoji-group-sections.hbs
index 581c54d..82ada7f 100644
--- a/app/assets/javascripts/discourse/app/templates/components/emoji-group-sections.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/emoji-group-sections.hbs
@@ -8,7 +8,7 @@
   <div class="section-group">
     {{replace-emoji ":grinning:" (hash lazy=true)}}
     {{replace-emoji ":smiley:" (hash lazy=true)}}
-    {{replace-emoji ":smile:" (hash lazy=true)}}
+    {{replace-emoji ":grinning_face_with_smiling_eyes:" (hash lazy=true)}}
     {{replace-emoji ":grin:" (hash lazy=true)}}
     {{replace-emoji ":laughing:" (hash lazy=true)}}
     {{replace-emoji ":sweat_smile:" (hash lazy=true)}}
@@ -78,6 +78,7 @@
     {{replace-emoji ":flushed:" (hash lazy=true)}}
     {{replace-emoji ":pleading_face:" (hash lazy=true)}}
     {{replace-emoji ":frowning:" (hash lazy=true)}}
+    {{replace-emoji ":frowning_face_with_open_mouth:" (hash lazy=true)}}
     {{replace-emoji ":anguished:" (hash lazy=true)}}
     {{replace-emoji ":fearful:" (hash lazy=true)}}
     {{replace-emoji ":cold_sweat:" (hash lazy=true)}}
diff --git a/app/assets/javascripts/pretty-text/addon/emoji.js b/app/assets/javascripts/pretty-text/addon/emoji.js
index 2237fe8..3ff60de 100644
--- a/app/assets/javascripts/pretty-text/addon/emoji.js
+++ b/app/assets/javascripts/pretty-text/addon/emoji.js
@@ -21,45 +21,12 @@ export function extendedEmojiList() {
 
 const emojiHash = {};
 
-export function buildReplacementsList(emojiReplacements) {
-  return Object.keys(emojiReplacements)
-    .sort()
-    .reverse()
-    .map((emoji) => {
-      return emoji
-        .split("")
-        .map((chr) => {
-          return "\\u" + chr.charCodeAt(0).toString(16).padStart(4, "0");
-        })
-        .join("");
-    })
-    .join("|");
-}
-
-let replacementListCache;
-const unicodeRegexpCache = {};
-
-function replacementList() {
-  if (replacementListCache === undefined) {
-    replacementListCache = buildReplacementsList(replacements);
-  }
+// https://github.com/mathiasbynens/emoji-regex/blob/main/text.js
+export const emojiReplacementRegex =

[... diff too long, it was truncated ...]

GitHub sha: 0eeedf30

This commit appears in #11053 which was approved by ZogStriP. It was merged by jjaffeux.