fix: plain text with valid HTML not rendering [CW-5577] (#12369)

Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
Shivam Mishra
2025-09-04 12:50:49 +05:30
committed by GitHub
parent ce1690eeb1
commit 0e481a690c
3 changed files with 11 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
<script setup> <script setup>
import { computed, useTemplateRef, ref, onMounted } from 'vue'; import { computed, useTemplateRef, ref, onMounted } from 'vue';
import { Letter } from 'vue-letter'; import { Letter } from 'vue-letter';
import { sanitizeTextForRender } from '@chatwoot/utils';
import { allowedCssProperties } from 'lettersanitizer'; import { allowedCssProperties } from 'lettersanitizer';
import Icon from 'next/icon/Icon.vue'; import Icon from 'next/icon/Icon.vue';
@@ -37,11 +38,13 @@ const { hasTranslations, translationContent } =
const originalEmailText = computed(() => { const originalEmailText = computed(() => {
const text = const text =
contentAttributes?.value?.email?.textContent?.full ?? content.value; contentAttributes?.value?.email?.textContent?.full ?? content.value;
return text?.replace(/\n/g, '<br>'); return sanitizeTextForRender(text);
}); });
const originalEmailHtml = computed( const originalEmailHtml = computed(
() => contentAttributes?.value?.email?.htmlContent?.full || '' () =>
contentAttributes?.value?.email?.htmlContent?.full ||
originalEmailText.value
); );
const messageContent = computed(() => { const messageContent = computed(() => {

View File

@@ -34,7 +34,7 @@
"@breezystack/lamejs": "^1.2.7", "@breezystack/lamejs": "^1.2.7",
"@chatwoot/ninja-keys": "1.2.3", "@chatwoot/ninja-keys": "1.2.3",
"@chatwoot/prosemirror-schema": "1.2.1", "@chatwoot/prosemirror-schema": "1.2.1",
"@chatwoot/utils": "^0.0.50", "@chatwoot/utils": "^0.0.51",
"@formkit/core": "^1.6.7", "@formkit/core": "^1.6.7",
"@formkit/vue": "^1.6.7", "@formkit/vue": "^1.6.7",
"@hcaptcha/vue3-hcaptcha": "^1.3.0", "@hcaptcha/vue3-hcaptcha": "^1.3.0",

10
pnpm-lock.yaml generated
View File

@@ -23,8 +23,8 @@ importers:
specifier: 1.2.1 specifier: 1.2.1
version: 1.2.1 version: 1.2.1
'@chatwoot/utils': '@chatwoot/utils':
specifier: ^0.0.50 specifier: ^0.0.51
version: 0.0.50 version: 0.0.51
'@formkit/core': '@formkit/core':
specifier: ^1.6.7 specifier: ^1.6.7
version: 1.6.7 version: 1.6.7
@@ -409,8 +409,8 @@ packages:
'@chatwoot/prosemirror-schema@1.2.1': '@chatwoot/prosemirror-schema@1.2.1':
resolution: {integrity: sha512-UbiEvG5tgi1d0lMbkaqxgTh7vHfywEYKLQo1sxqp4Q7aLZh4QFtbLzJ2zyBtu4Nhipe+guFfEJdic7i43MP/XQ==} resolution: {integrity: sha512-UbiEvG5tgi1d0lMbkaqxgTh7vHfywEYKLQo1sxqp4Q7aLZh4QFtbLzJ2zyBtu4Nhipe+guFfEJdic7i43MP/XQ==}
'@chatwoot/utils@0.0.50': '@chatwoot/utils@0.0.51':
resolution: {integrity: sha512-GGvB+ujt+8qnV6KKEM2IH9/JmbMpMMfrJ4C+SdPvd/WbhUEFvRof0D9fsU+444G8BUh2om7GM7mXOa3pEH+Vtw==} resolution: {integrity: sha512-WlEmWfOTzR7YZRUWzn5Wpm15/BRudpwqoNckph8TohyDbiim1CP4UZGa+qjajxTbNGLLhtKlm0Xl+X16+5Wceg==}
engines: {node: '>=10'} engines: {node: '>=10'}
'@codemirror/commands@6.7.0': '@codemirror/commands@6.7.0':
@@ -4771,7 +4771,7 @@ snapshots:
prosemirror-utils: 1.2.2(prosemirror-model@1.22.3)(prosemirror-state@1.4.3) prosemirror-utils: 1.2.2(prosemirror-model@1.22.3)(prosemirror-state@1.4.3)
prosemirror-view: 1.34.1 prosemirror-view: 1.34.1
'@chatwoot/utils@0.0.50': '@chatwoot/utils@0.0.51':
dependencies: dependencies:
date-fns: 2.30.0 date-fns: 2.30.0