logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

autosuggest_emoji.js (903B)


  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import unicodeMapping from '../features/emoji/emoji_unicode_mapping_light';
  4. const assetHost = process.env.CDN_HOST || '';
  5. export default class AutosuggestEmoji extends React.PureComponent {
  6. static propTypes = {
  7. emoji: PropTypes.object.isRequired,
  8. };
  9. render () {
  10. const { emoji } = this.props;
  11. let url;
  12. if (emoji.custom) {
  13. url = emoji.imageUrl;
  14. } else {
  15. const mapping = unicodeMapping[emoji.native] || unicodeMapping[emoji.native.replace(/\uFE0F$/, '')];
  16. if (!mapping) {
  17. return null;
  18. }
  19. url = `${assetHost}/emoji/${mapping.filename}.svg`;
  20. }
  21. return (
  22. <div className='autosuggest-emoji'>
  23. <img
  24. className='emojione'
  25. src={url}
  26. alt={emoji.native || emoji.colons}
  27. />
  28. {emoji.colons}
  29. </div>
  30. );
  31. }
  32. }