fix: Use textContent as fallback for htmlContent instead of content.value (#10901)

Some emails contain HTML content within the text part, but our content
parser currently strips HTML automatically, which needs a proper fix. In
the new UI, the fallback for HTML content was set to the parsed content,
which may omit HTML tags, leading to issues like missing inline
attachments.

This PR updates the fallback mechanism to use the text content instead
of the parsed content, ensuring HTML elements are preserved.

Fixes
https://linear.app/chatwoot/issue/CW-4046/text-content-is-not-respected-in-emails
This commit is contained in:
Pranav
2025-02-13 19:23:04 -08:00
committed by GitHub
parent f112e500e1
commit 94baba1d15

View File

@@ -29,8 +29,15 @@ const isOutgoing = computed(() => {
});
const isIncoming = computed(() => !isOutgoing.value);
const textToShow = computed(() => {
const text =
contentAttributes?.value?.email?.textContent?.full ?? content.value;
return text?.replace(/\n/g, '<br>');
});
// Use TextContent as the default to fullHTML
const fullHTML = computed(() => {
return contentAttributes?.value?.email?.htmlContent?.full ?? content.value;
return contentAttributes?.value?.email?.htmlContent?.full ?? textToShow.value;
});
const unquotedHTML = computed(() => {
@@ -40,12 +47,6 @@ const unquotedHTML = computed(() => {
const hasQuotedMessage = computed(() => {
return EmailQuoteExtractor.hasQuotes(fullHTML.value);
});
const textToShow = computed(() => {
const text =
contentAttributes?.value?.email?.textContent?.full ?? content.value;
return text?.replace(/\n/g, '<br>');
});
</script>
<template>