Merge branch 'big-emojis-fix' into 'develop'

Big emojis: ignore mentions

See merge request soapbox-pub/soapbox-fe!592
merge-requests/593/head
Alex Gleason 2021-07-09 23:40:33 +00:00
commit 8b4d855758
4 zmienionych plików z 11 dodań i 4 usunięć

Wyświetl plik

@ -92,7 +92,7 @@ class StatusContent extends React.PureComponent {
setOnlyEmoji = () => {
if (this.node && this.state.onlyEmoji === undefined) {
this.setState({ onlyEmoji: onlyEmoji(this.node, BIG_EMOJI_LIMIT) });
this.setState({ onlyEmoji: onlyEmoji(this.node, BIG_EMOJI_LIMIT, true) });
}
}

Wyświetl plik

@ -124,7 +124,7 @@ class ChatMessageList extends ImmutablePureComponent {
link.setAttribute('target', '_blank');
});
if (onlyEmoji(c, BIG_EMOJI_LIMIT)) {
if (onlyEmoji(c, BIG_EMOJI_LIMIT, false)) {
c.classList.add('chat-message__bubble--onlyEmoji');
} else {
c.classList.remove('chat-message__bubble--onlyEmoji');

Wyświetl plik

@ -1,6 +1,13 @@
// Returns `true` if the node contains only emojis, up to a limit
export const onlyEmoji = (node, limit = 1) => {
export const onlyEmoji = (node, limit = 1, ignoreMentions = true) => {
if (!node) return false;
// Remove mentions before checking content
if (ignoreMentions) {
node = node.cloneNode(true);
node.querySelectorAll('a.mention').forEach(m => m.parentNode.removeChild(m));
}
if (node.textContent.replaceAll(' ', '') !== '') return false;
const emojis = Array.from(node.querySelectorAll('img.emojione'));
if (emojis.length === 0) return false;

Wyświetl plik

@ -68,12 +68,12 @@
}
&--big {
font-size: 32px !important;
line-height: normal !important;
img.emojione {
width: 36px;
height: 36px;
padding: 5px;
}
}
}