Strip whitespace characters from formatted reply preview bodies
This commit is contained in:
1 parent
b02b5937d7
commit
c18efc1bab
2 files changed
+16
-5
No files matched your search
@@ -101,13 +101,18 @@ export const Reply = as<'div', ReplyProps>(
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
if (format === 'org.matrix.custom.html' && formatted_body) {
|
||||
const strippedHtml = trimReplyFromFormattedBody(formatted_body);
|
||||
const strippedHtml = trimReplyFromFormattedBody(formatted_body)
|
||||
.replace(/<br\s*\/?>/gi, ' ')
|
||||
.replace(/<\/p>\s*<p[^>]*>/gi, ' ')
|
||||
.replace(/<\/?p[^>]*>/gi, '')
|
||||
.replace(/(?:\r\n|\r|\n)/g, ' ');
|
||||
const parserOpts = getReactCustomHtmlParser(mx, room.roomId, {
|
||||
linkifyOpts: LINKIFY_OPTS
|
||||
});
|
||||
bodyJSX = parse(strippedHtml, parserOpts) as JSX.Element;
|
||||
} else if (body) {
|
||||
bodyJSX = scaleSystemEmoji(trimReplyFromBody(body));
|
||||
const strippedBody = trimReplyFromBody(body).replace(/(?:\r\n|\r|\n)/g, ' ');
|
||||
bodyJSX = scaleSystemEmoji(strippedBody);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -188,15 +188,21 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
let replyBodyJSX: React.ReactNode = replyDraft ? trimReplyFromBody(replyDraft.body) : null;
|
||||
|
||||
if (replyFormat === 'org.matrix.custom.html' && replyFormattedBody) {
|
||||
const strippedHtml = trimReplyFromFormattedBody(replyFormattedBody);
|
||||
const strippedHtml = trimReplyFromFormattedBody(formatted_body)
|
||||
.replace(/<br\s*\/?>/gi, ' ')
|
||||
.replace(/<\/p>\s*<p[^>]*>/gi, ' ')
|
||||
.replace(/<\/?p[^>]*>/gi, '')
|
||||
.replace(/(?:\r\n|\r|\n)/g, ' ');
|
||||
const parserOpts = getReactCustomHtmlParser(mx, roomId, {
|
||||
linkifyOpts: LINKIFY_OPTS,
|
||||
});
|
||||
replyBodyJSX = parse(strippedHtml, parserOpts);
|
||||
} else if (replyBody) {
|
||||
replyBodyJSX = scaleSystemEmoji(trimReplyFromBody(replyBody));
|
||||
const strippedBody = trimReplyFromBody(replyBody).replace(/(?:\r\n|\r|\n)/g, ' ');
|
||||
replyBodyJSX = scaleSystemEmoji(trimReplyFromBody(strippedBody));
|
||||
} else if (replyDraft) {
|
||||
replyBodyJSX = scaleSystemEmoji(trimReplyFromBody(replyDraft.body));
|
||||
const strippedBody = trimReplyFromBody(replyDraft.body).replace(/(?:\r\n|\r|\n)/g, ' ');
|
||||
replyBodyJSX = scaleSystemEmoji(trimReplyFromBody(strippedBody));
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in new issue
Block a user