TF-287 Fix bug replies do not preserve line breaks

This commit is contained in:
dab246
2022-03-07 09:24:16 +07:00
committed by Dat H. Pham
parent bea546d960
commit 46b8f74298
2 changed files with 16 additions and 1 deletions
@@ -292,7 +292,7 @@ class ComposerController extends BaseController {
: '';
final trustAsHtml = arguments.emailContents
?.map((emailContent) => emailContent.content)
?.map((emailContent) => emailContent.asHtml)
.toList()
.join('<br>') ?? '';
+15
View File
@@ -12,4 +12,19 @@ class EmailContent with EquatableMixin {
@override
List<Object?> get props => [type, content];
}
extension EmailContentExtension on EmailContent {
String get asHtml {
if (type == EmailContentType.textPlain) {
return content
.replaceAll("'", r"\'")
.replaceAll('"', r'\"')
.replaceAll('\r', '')
.replaceAll('\r\n', '')
.replaceAll('\n', '<br/>')
.replaceAll('\n\n', '<br/>');
}
return content;
}
}