about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen <eugen@zeonfederated.com>2017-01-05 13:37:29 +0100
committerGitHub <noreply@github.com>2017-01-05 13:37:29 +0100
commitc3c9879b5e319a0192a172b34c7c2fd4f3d35da5 (patch)
treec405cc14ed2ec8339722ae7a4ed552871e713184
parentdf89cb5488f4d54c71048c6ee6b2c608a0a8ab50 (diff)
parent53b765f4b150d7671d697eed7333c948622045cf (diff)
Merge pull request #404 from mistydemeo/emoji
Display native emoji on browsers which support it
-rw-r--r--app/assets/javascripts/components/emoji.jsx11
-rw-r--r--package.json1
-rw-r--r--yarn.lock8
3 files changed, 17 insertions, 3 deletions
diff --git a/app/assets/javascripts/components/emoji.jsx b/app/assets/javascripts/components/emoji.jsx
index c93c07c74..990aea5be 100644
--- a/app/assets/javascripts/components/emoji.jsx
+++ b/app/assets/javascripts/components/emoji.jsx
@@ -1,9 +1,18 @@
 import emojione from 'emojione';
+import detectVersion from 'mojibaka';
 
 emojione.imageType    = 'png';
 emojione.sprites      = false;
 emojione.imagePathPNG = '/emoji/';
 
+let emoji_version = detectVersion();
+
 export default function emojify(text) {
-  return emojione.toImage(text);
+  // Browser too old to support native emoji
+  if (emoji_version < 9.0) {
+    return emojione.toImage(text);
+  // Convert short codes into native emoji
+  } else {
+    return emojione.shortnameToUnicode(text);
+  }
 };
diff --git a/package.json b/package.json
index 05663a729..13b0484ec 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
     "intl": "^1.2.5",
     "jsdom": "^9.6.0",
     "mocha": "^3.1.1",
+    "mojibaka": "^0.0.1",
     "node-sass": "^4.0.0",
     "react": "^15.3.2",
     "react-addons-perf": "^15.3.2",
diff --git a/yarn.lock b/yarn.lock
index f71a8ae10..b79c46898 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2368,7 +2368,7 @@ glob-parent@^2.0.0:
   dependencies:
     is-glob "^2.0.0"
 
-glob@7.0.5, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5:
+glob@7.0.5, glob@^7.0.0, glob@^7.0.3:
   version "7.0.5"
   resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.5.tgz#b4202a69099bbb4d292a7c1b95b6682b67ebdc95"
   dependencies:
@@ -2389,7 +2389,7 @@ glob@^5.0.15:
     once "^1.3.0"
     path-is-absolute "^1.0.0"
 
-glob@~7.1.1:
+glob@^7.0.5, glob@~7.1.1:
   version "7.1.1"
   resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
   dependencies:
@@ -3392,6 +3392,10 @@ module-deps@^4.0.2:
     through2 "^2.0.0"
     xtend "^4.0.0"
 
+mojibaka@^0.0.1:
+  version "0.0.1"
+  resolved "https://registry.yarnpkg.com/mojibaka/-/mojibaka-0.0.1.tgz#54b0690d9149bbdf97f13b909f2417c53b8d52e5"
+
 ms@0.7.1:
   version "0.7.1"
   resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098"