@ -1,9 +1,35 @@ |
||||
import emojione from 'emojione'; |
||||
|
||||
emojione.imageType = 'png'; |
||||
emojione.sprites = false; |
||||
emojione.imagePathPNG = '/emoji/'; |
||||
const toImage = str => shortnameToImage(unicodeToImage(str)); |
||||
|
||||
const unicodeToImage = str => { |
||||
const mappedUnicode = emojione.mapUnicodeToShort(); |
||||
|
||||
return str.replace(emojione.regUnicode, unicodeChar => { |
||||
if (typeof unicodeChar === 'undefined' || unicodeChar === '' || !(unicodeChar in emojione.jsEscapeMap)) { |
||||
return unicodeChar; |
||||
} |
||||
|
||||
const unicode = emojione.jsEscapeMap[unicodeChar]; |
||||
const short = mappedUnicode[unicode]; |
||||
const filename = emojione.emojioneList[short].fname; |
||||
const alt = emojione.convert(unicode.toUpperCase()); |
||||
|
||||
return `<img draggable="false" class="emojione" alt="${alt}" src="/emoji/${filename}.svg" />`; |
||||
}); |
||||
}; |
||||
|
||||
const shortnameToImage = str => str.replace(emojione.regShortNames, shortname => { |
||||
if (typeof shortname === 'undefined' || shortname === '' || !(shortname in emojione.emojioneList)) { |
||||
return shortname; |
||||
} |
||||
|
||||
const unicode = emojione.emojioneList[shortname].unicode[emojione.emojioneList[shortname].unicode.length - 1]; |
||||
const alt = emojione.convert(unicode.toUpperCase()); |
||||
|
||||
return `<img draggable="false" class="emojione" alt="${alt}" src="/emoji/${unicode}.svg" />`; |
||||
}); |
||||
|
||||
export default function emojify(text) { |
||||
return emojione.toImage(text); |
||||
return toImage(text); |
||||
}; |
||||
|
After Width: | Height: | Size: 596 B |
After Width: | Height: | Size: 363 B |
After Width: | Height: | Size: 902 B |
After Width: | Height: | Size: 679 B |
After Width: | Height: | Size: 788 B |
After Width: | Height: | Size: 569 B |
After Width: | Height: | Size: 485 B |
After Width: | Height: | Size: 266 B |
After Width: | Height: | Size: 775 B |
After Width: | Height: | Size: 556 B |
After Width: | Height: | Size: 918 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 479 B |
After Width: | Height: | Size: 260 B |
After Width: | Height: | Size: 726 B |
After Width: | Height: | Size: 507 B |
After Width: | Height: | Size: 889 B |
After Width: | Height: | Size: 674 B |
After Width: | Height: | Size: 525 B |
After Width: | Height: | Size: 320 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 833 B |
After Width: | Height: | Size: 885 B |
After Width: | Height: | Size: 662 B |
After Width: | Height: | Size: 811 B |
After Width: | Height: | Size: 394 B |
After Width: | Height: | Size: 909 B |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 328 B |
After Width: | Height: | Size: 479 B |
After Width: | Height: | Size: 417 B |
After Width: | Height: | Size: 381 B |
After Width: | Height: | Size: 581 B |
After Width: | Height: | Size: 691 B |
After Width: | Height: | Size: 865 B |
After Width: | Height: | Size: 571 B |
After Width: | Height: | Size: 543 B |
After Width: | Height: | Size: 471 B |
After Width: | Height: | Size: 519 B |
After Width: | Height: | Size: 718 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 896 B |
After Width: | Height: | Size: 861 B |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 443 B |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 620 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 387 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 714 B |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 938 B |
After Width: | Height: | Size: 655 B |
After Width: | Height: | Size: 802 B |
After Width: | Height: | Size: 722 B |
After Width: | Height: | Size: 259 B |
After Width: | Height: | Size: 817 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 243 B |
After Width: | Height: | Size: 388 B |
After Width: | Height: | Size: 356 B |
After Width: | Height: | Size: 387 B |
After Width: | Height: | Size: 402 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 353 B |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 818 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 527 B |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 794 B |
After Width: | Height: | Size: 509 B |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 607 B |
After Width: | Height: | Size: 793 B |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 767 B |
After Width: | Height: | Size: 671 B |
After Width: | Height: | Size: 461 B |
After Width: | Height: | Size: 216 B |
After Width: | Height: | Size: 389 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 389 B |
After Width: | Height: | Size: 483 B |
After Width: | Height: | Size: 575 B |
After Width: | Height: | Size: 331 B |