2017-09-23 15:47:32 +03:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-12-04 09:26:40 +02:00
|
|
|
import unicodeMapping from 'flavours/glitch/util/emoji/emoji_unicode_mapping_light';
|
2017-09-23 15:47:32 +03:00
|
|
|
|
|
|
|
const assetHost = process.env.CDN_HOST || '';
|
|
|
|
|
|
|
|
export default class AutosuggestEmoji extends React.PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
emoji: PropTypes.object.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { emoji } = this.props;
|
|
|
|
let url;
|
|
|
|
|
|
|
|
if (emoji.custom) {
|
|
|
|
url = emoji.imageUrl;
|
|
|
|
} else {
|
2017-09-30 06:11:44 +03:00
|
|
|
const mapping = unicodeMapping[emoji.native] || unicodeMapping[emoji.native.replace(/\uFE0F$/, '')];
|
|
|
|
|
|
|
|
if (!mapping) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-10-06 04:42:34 +03:00
|
|
|
url = `${assetHost}/emoji/${mapping.filename}.svg`;
|
2017-09-23 15:47:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='autosuggest-emoji'>
|
|
|
|
<img
|
|
|
|
className='emojione'
|
|
|
|
src={url}
|
|
|
|
alt={emoji.native || emoji.colons}
|
|
|
|
/>
|
|
|
|
|
|
|
|
{emoji.colons}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|