# Conflicts:

#	src/views/Conversations/Components/Messages.jsx
#	src/views/Conversations/Conversations.css
dev/chat
Lei OT 1 year ago
parent 7811c3ab9a
commit b9e69c56c9

@ -60,28 +60,34 @@ const Messages = ({ ...props }) => {
}; };
const RenderText = memo(function renderText({ str }) { const RenderText = memo(function renderText({ str }) {
const parts = str.split(/(https?:\/\/[^\s]+|\p{Emoji_Presentation})/gmu).filter((s) => s !== ''); const parts = str.split(/(https?:\/\/[^\s]+|\p{Emoji_Presentation})/gmu).filter(s => s !== '');
// const parts = str.split(/(https?:\/\/[^\s]+|\p{Emoji}\uFE0F?|\b\d+\b)/gu); const links = str.match(/https?:\/\/[\S]+/gi) || [];
const emojis = str.match(/\p{Emoji_Presentation}/gu) || [];
const extraClass = isEmpty(emojis) ? '' : 'text-xl leading-5 emoji-text';
const objArr = parts.reduce((prev, curr, index) => {
if (links.includes(curr)) {
prev.push({ type: 'link', key: curr });
} else if (emojis.includes(curr)) {
prev.push({ type: 'emoji', key: curr });
} else {
prev.push({type: 'text', key: curr});
}
return prev;
}, []);
return ( return (
<> <span className={extraClass}>
{(parts || []).map((part, index) => { {(objArr || []).map((part, index) => {
// if (/\p{Emoji}\uFE0F?/u.test(part)) { if (part.type === 'link') {
if (/\p{Emoji_Presentation}/u.test(part)) { return (
const code = [...part].map((e) => e.codePointAt(0).toString(16)).join(`-`); <a href={part.key} target='_blank' key={`${part.key}${index}`} rel='noreferrer' className='text-sm'>
return <Emoji key={`${part}${index}${code}`} unified={code} size={24} emojiStyle={'google'} />; {part.key}
} else if (/https?:\/\/[\S]+/gi.test(part)) { </a>
return ( );
<a href={part} target='_blank' key={`${part}${index}`} rel='noreferrer'> } else { // if (part.type === 'emoji')
{part} return part.key;
</a>
);
} else if (part.trim() !== '') {
return <span key={`${part}${index}`}>{part}</span>;
} else {
return <span key={`${part}${index}`}>{part}</span>;
} }
})} })}
</> </span>
); );
}); });
// eslint-disable-next-line react/display-name // eslint-disable-next-line react/display-name

@ -1,3 +1,38 @@
@font-face {
font-family: 'Noto Color Emoji';
src: url('/src/assets/noto-color-emoji.2.woff2') format('woff2');
font-weight: normal;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Noto Color Emoji';
src: url('/src/assets/noto-color-emoji.7.woff2') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Noto Color Emoji';
src: url('/src/assets/noto-color-emoji.8.woff2') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Noto Color Emoji';
src: url('/src/assets/noto-color-emoji.9.woff2') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Noto Color Emoji';
src: url('/src/assets/noto-color-emoji.10.woff2') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
.ant-card .ant-card-head{ .ant-card .ant-card-head{
padding: 0 .5em .5em .5em; padding: 0 .5em .5em .5em;
min-height: unset; min-height: unset;

Loading…
Cancel
Save