Re-introduce custom HTML formatting for long messages

- The issue that this was originally removed to fix was actually only related to jumbo emojis.
- Since I've kept the safety mechanisms for jumbo emojis, there should be no regression.
This commit is contained in:
Septicity committed 2026-04-05 06:05:45 -05:00
1 parent 0ae47b689d
commit 73c139f719
2 files changed
+10 -14

No files matched your search

@@ -0,0 +1,5 @@
---
default: minor
---
Re-introduced custom HTML formatting for long messages
@@ -97,15 +97,6 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
[customBody, body]
);
const safeCustomBody = useMemo(() => {
if (!customBody) return undefined;
if (customBody.length > 8000) {
const imageTags = customBody.match(/<img[^>]*>/g);
return imageTags ? imageTags.join(' ') : undefined;
}
return customBody;
}, [customBody]);
const isForwarded = useMemo(() => {
const forwardMeta = content['moe.sable.message.forward'];
return typeof forwardMeta === 'object';
@@ -122,7 +113,7 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
const isJumbo = useMemo(() => {
if (!trimmedBody || trimmedBody.length >= 500) return false;
if (
(unwrappedPerMessageProfileMessage ?? safeCustomBody)?.match(
(unwrappedPerMessageProfileMessage ?? customBody)?.match(
/^(<img[^>]*data-mx-emoticon[^>]*\/>){1,20}$/i
)
)
@@ -130,12 +121,12 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
if (!JUMBO_EMOJI_REG.test(trimmedBody)) return false;
if (trimmedBody.includes(':')) {
const hasImage = safeCustomBody && /<img[^>]*>/i.test(safeCustomBody);
const hasImage = customBody && /<img[^>]*>/i.test(customBody);
if (!hasImage) return false;
}
return true;
}, [unwrappedPerMessageProfileMessage, trimmedBody, safeCustomBody]);
}, [unwrappedPerMessageProfileMessage, trimmedBody, customBody]);
if (!body && !customBody) return <BrokenContent body={customBody ?? body} />;
@@ -175,13 +166,13 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
return (
<>
<MessageTextBody
preWrap={typeof safeCustomBody !== 'string'}
preWrap={typeof customBody !== 'string'}
jumboEmoji={isJumbo ? jumboEmojiSize : 'none'}
style={style}
>
{renderBody({
body: trimmedBody,
customBody: safeCustomBody,
customBody: typeof customBody === 'string' ? customBody : undefined,
})}
{edited && <MessageEditedContent />}
</MessageTextBody>