Fix standalone emoji not rendering at jumbo 100px size.

Detect emoji-only messages more reliably (including mx-emoticon HTML), bypass folds Text sizing when jumbo, and force 100px emote dimensions via data-jumbo-emoji styles.
This commit is contained in:
2026-07-21 15:56:02 +10:00
parent 9f8e446146
commit b912a53548
5 changed files with 53 additions and 19 deletions

View File

@@ -24,3 +24,28 @@ export const EMOJI_PATTERN = `[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u
export const JUMBO_EMOJI_REG = new RegExp(
`^(((${EMOJI_PATTERN})|(:.+?:))(${VARIATION_SELECTOR_PATTERN}|\\s)*){1,10}$`
);
/** Zero-width / format chars that break naive emoji-only matching. */
const JUMBO_IGNORE_CHARS_REG = /[\u200B-\u200D\uFEFF\u00AD\u2060]/g;
const ONLY_MX_EMOTICON_HTML_REG =
/^(?:\s|<br\s*\/?>)*((?:<img\b[^>]*\bdata-mx-emoticon\b[^>]*\/?>)(?:\s|<br\s*\/?>)*){1,10}$/i;
/**
* True when a message is emoji/custom-emote only (Discord-style jumbo).
* Strips zero-width chars and also accepts HTML that is only mx-emoticon imgs.
*/
export const isJumboEmoji = (body: string, customBody?: string): boolean => {
const plain = body.replace(JUMBO_IGNORE_CHARS_REG, '').trim();
if (plain.length > 0 && JUMBO_EMOJI_REG.test(plain)) return true;
if (typeof customBody === 'string') {
const html = customBody
.replace(JUMBO_IGNORE_CHARS_REG, '')
.trim()
.replace(/(<br\s*\/?>\s*)+$/gi, '');
if (html.length > 0 && ONLY_MX_EMOTICON_HTML_REG.test(html)) return true;
}
return false;
};