2016-11-16 02:38:57 +09:00
|
|
|
import emojione from 'emojione';
|
2017-01-05 15:23:02 +09:00
|
|
|
import detectVersion from 'mojibaka';
|
2016-11-16 02:38:57 +09:00
|
|
|
|
|
|
|
emojione.imageType = 'png';
|
|
|
|
emojione.sprites = false;
|
|
|
|
emojione.imagePathPNG = '/emoji/';
|
|
|
|
|
2017-01-05 15:23:02 +09:00
|
|
|
let emoji_version = detectVersion();
|
|
|
|
|
2016-11-16 02:38:57 +09:00
|
|
|
export default function emojify(text) {
|
2017-01-05 15:23:02 +09:00
|
|
|
// Browser too old to support native emoji
|
2017-01-05 15:47:51 +09:00
|
|
|
if (emoji_version < 9.0) {
|
2017-01-05 15:23:02 +09:00
|
|
|
return emojione.toImage(text);
|
|
|
|
// Convert short codes into native emoji
|
|
|
|
} else {
|
|
|
|
return emojione.shortnameToUnicode(text);
|
|
|
|
}
|
2016-11-16 02:38:57 +09:00
|
|
|
};
|