Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function renderChatMessage(body, from, allowEmojiRender, lowResolution) {
const isOneLine = body.split("\n").length === 1;
const context = messageCanvas.getContext("2d");
const emoji = toEmojis(body);
const isEmoji =
allowEmojiRender &&
emoji.length === 1 &&
emoji[0].props &&
emoji[0].props.children.match &&
emoji[0].props.children.match(emojiRegex);
const el = document.createElement("div");
el.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
el.setAttribute("class", `${styles.presenceLog} ${styles.presenceLogSpawn}`);
// The element is added to the DOM in order to have layout compute the width & height,
// and then it is removed after being rendered.
document.body.appendChild(el);
const entryDom = (
render() {
const { message } = this.props;
const processedMessage = [];
// content is an array of text and emoji components
const content = toArray(this._getMessageText(), { className: 'smiley' });
content.forEach(i => {
if (typeof i === 'string') {
processedMessage.push({ i });
} else {
processedMessage.push(i);
}
});
return (
<div>
<div>
<div>
<div>
{ this.props.showDisplayName && this._renderDisplayName() }
<div></div></div></div></div></div>
const emojified = lines.map(line =>
toArray(line, {
protocol: '',
baseUrl: '//cdnjs.cloudflare.com/ajax/libs/emojione/2.2.7/assets/png/',
size: '',
ext: 'png',
}));
const parseEmojis = (value) => {
const emojisArray = toArray(value);
const newValue = emojisArray.reduce((previous, current) => {
if (typeof current === 'string') return previous + current;
return previous + current.props.children;
}, '');
return newValue !== value ? newValue : null;
};
const parseEmojis = value => {
const emojisArray = toArray(value);
const newValue = emojisArray.reduce((previous, current) => {
if (typeof current === "string") return previous + current;
return previous + current.props.children;
}, "");
return newValue;
};
function emojify(text) {
try {
return toArray(text).map(e => typeof e === 'string' ? e : e.props.children).join('');
} catch (e) {
return text;
}
}
}
const cleanedBody = (mono ? body.substring(1, body.length - 1) : body).trim();
return (
<div>
{from && (
<div>
{from}:
</div>
)}
<div>
{toEmojis(cleanedBody)}
</div>
</div>
);
};
const parseEmojis = value => {
const emojisArray = toArray(value);
const newValue = emojisArray.reduce((previous, current) => {
if (typeof current === "string") return previous + current;
return previous + current.props.children;
}, "");
return newValue;
};