Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getTextFromEmoji = (content) => {
let contentToParse = content;
const allEmojis = getAllEmojisRev();
Twemoji.replace(content, (emoji) => {
const unicodeEmoji = allEmojis[emoji];
if (unicodeEmoji) {
const regex = new RegExp(emoji, 'g');
contentToParse = contentToParse.replace(regex, `:${unicodeEmoji}:`);
}
});
return contentToParse;
};
if (!this.props.onlyEmoji) {
html = html.replace(/\B&(\w+)(?=$|[^\w;])/g, (match, name) =>
ReactDOMServer.renderToStaticMarkup(<a name="" href="{heimURL('/room/'">&{name}</a>)
)
html = html.replace(chat.mentionRe, (match, name) => {
const color = 'hsl(' + hueHash.hue(name) + ', 50%, 42%)'
return ReactDOMServer.renderToStaticMarkup(<span style="{{color:">@{name}</span>)
})
}
html = html.replace(emoji.namesRe, (match, name) =>
ReactDOMServer.renderToStaticMarkup(<div title="{match}">{match}</div>)
)
html = twemoji.replace(html, (match, icon, variant) => {
if (variant === '\uFE0E') {
return match
}
const codePoint = emoji.lookupEmojiCharacter(icon)
if (!codePoint) {
return match
}
const emojiName = emoji.names[codePoint] && ':' + emoji.names[codePoint] + ':'
return ReactDOMServer.renderToStaticMarkup(<div title="{emojiName}">{icon}</div>)
})
if (!this.props.onlyEmoji) {
html = autolinker.link(html)
}
return (