about summary refs log tree commit diff
path: root/app/assets/javascripts/components/emoji.jsx
blob: 82b82b7196ca631a1dcd1c8b37e2c11036a380ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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) {
  // Browser too old to support native emoji
  if (emoji_version < 6.1) {
    return emojione.toImage(text);
  // Convert short codes into native emoji
  } else {
    return emojione.shortnameToUnicode(text);
  }
};