|
|
@ -5,6 +5,8 @@ const trie = new Trie(Object.keys(unicodeMapping));
|
|
|
|
|
|
|
|
|
|
|
|
const assetHost = process.env.CDN_HOST || '';
|
|
|
|
const assetHost = process.env.CDN_HOST || '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let allowAnimations = false;
|
|
|
|
|
|
|
|
|
|
|
|
const emojify = (str, customEmojis = {}) => {
|
|
|
|
const emojify = (str, customEmojis = {}) => {
|
|
|
|
let rtn = '';
|
|
|
|
let rtn = '';
|
|
|
|
for (;;) {
|
|
|
|
for (;;) {
|
|
|
@ -25,7 +27,8 @@ const emojify = (str, customEmojis = {}) => {
|
|
|
|
// now got a replacee as ':shortname:'
|
|
|
|
// now got a replacee as ':shortname:'
|
|
|
|
// if you want additional emoji handler, add statements below which set replacement and return true.
|
|
|
|
// if you want additional emoji handler, add statements below which set replacement and return true.
|
|
|
|
if (shortname in customEmojis) {
|
|
|
|
if (shortname in customEmojis) {
|
|
|
|
replacement = `<img draggable="false" class="emojione" alt="${shortname}" title="${shortname}" src="${customEmojis[shortname]}" />`;
|
|
|
|
const filename = allowAnimations ? customEmojis[shortname].url : customEmojis[shortname].static_url;
|
|
|
|
|
|
|
|
replacement = `<img draggable="false" class="emojione" alt="${shortname}" title="${shortname}" src="${filename}" />`;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -48,12 +51,14 @@ const emojify = (str, customEmojis = {}) => {
|
|
|
|
|
|
|
|
|
|
|
|
export default emojify;
|
|
|
|
export default emojify;
|
|
|
|
|
|
|
|
|
|
|
|
export const buildCustomEmojis = customEmojis => {
|
|
|
|
export const buildCustomEmojis = (customEmojis, overrideAllowAnimations = false) => {
|
|
|
|
const emojis = [];
|
|
|
|
const emojis = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allowAnimations = overrideAllowAnimations;
|
|
|
|
|
|
|
|
|
|
|
|
customEmojis.forEach(emoji => {
|
|
|
|
customEmojis.forEach(emoji => {
|
|
|
|
const shortcode = emoji.get('shortcode');
|
|
|
|
const shortcode = emoji.get('shortcode');
|
|
|
|
const url = emoji.get('static_url');
|
|
|
|
const url = allowAnimations ? emoji.get('url') : emoji.get('static_url');
|
|
|
|
const name = shortcode.replace(':', '');
|
|
|
|
const name = shortcode.replace(':', '');
|
|
|
|
|
|
|
|
|
|
|
|
emojis.push({
|
|
|
|
emojis.push({
|
|
|
|