From 94baba1d15bfe51bb6bf3e93b11726b697ce1d93 Mon Sep 17 00:00:00 2001 From: Pranav Date: Thu, 13 Feb 2025 19:23:04 -0800 Subject: [PATCH] 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 --- .../message/bubbles/Email/Index.vue | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/javascript/dashboard/components-next/message/bubbles/Email/Index.vue b/app/javascript/dashboard/components-next/message/bubbles/Email/Index.vue index 5c83067f3..ea2f57f34 100644 --- a/app/javascript/dashboard/components-next/message/bubbles/Email/Index.vue +++ b/app/javascript/dashboard/components-next/message/bubbles/Email/Index.vue @@ -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, '
'); +}); + +// 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, '
'); -});