2018-01-30 19:48:26 +00:00
|
|
|
import React from 'react';
|
2019-05-20 20:43:50 +00:00
|
|
|
import { Text } from 'react-native';
|
2018-01-30 19:48:26 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { emojify } from 'react-emojione';
|
2019-05-20 20:43:50 +00:00
|
|
|
|
2018-01-30 19:48:26 +00:00
|
|
|
import CustomEmoji from '../EmojiPicker/CustomEmoji';
|
|
|
|
|
2019-05-20 20:43:50 +00:00
|
|
|
const Emoji = React.memo(({
|
|
|
|
content, standardEmojiStyle, customEmojiStyle, baseUrl, getCustomEmoji
|
|
|
|
}) => {
|
|
|
|
const parsedContent = content.replace(/^:|:$/g, '');
|
|
|
|
const emoji = getCustomEmoji(parsedContent);
|
|
|
|
if (emoji) {
|
|
|
|
return <CustomEmoji key={content} baseUrl={baseUrl} style={customEmojiStyle} emoji={emoji} />;
|
2018-09-25 19:28:42 +00:00
|
|
|
}
|
2019-05-20 20:43:50 +00:00
|
|
|
return <Text style={standardEmojiStyle}>{ emojify(content, { output: 'unicode' }) }</Text>;
|
|
|
|
}, () => true);
|
2018-09-25 19:28:42 +00:00
|
|
|
|
2019-05-20 20:43:50 +00:00
|
|
|
Emoji.propTypes = {
|
|
|
|
content: PropTypes.string,
|
|
|
|
standardEmojiStyle: PropTypes.object,
|
|
|
|
customEmojiStyle: PropTypes.object,
|
|
|
|
baseUrl: PropTypes.string,
|
|
|
|
getCustomEmoji: PropTypes.func
|
|
|
|
};
|
|
|
|
Emoji.displayName = 'MessageEmoji';
|
|
|
|
|
|
|
|
export default Emoji;
|