fixup! Extract method to convert html content to text content

Move the method in utils
This commit is contained in:
Théo Poizat
2025-12-11 11:17:41 +01:00
committed by Dat H. Pham
parent d369fcbf5f
commit 4d0880b8be
2 changed files with 15 additions and 15 deletions
+14
View File
@@ -196,4 +196,18 @@ class StringConvert {
.map((e) => NamedAddress(name: '', address: e))
.toList();
}
static String convertHtmlContentToTextContent(String htmlContent) {
String textContent = htmlContent.replaceAll(RegExp(r'<[^>]*>'), '');
textContent = textContent
.replaceAll('&nbsp;', ' ')
.replaceAll('&amp;', '&')
.replaceAll('&lt;', '<')
.replaceAll('&gt;', '>')
.replaceAll('&quot;', '"')
.replaceAll('&#39;', "'");
return textContent.trim();
}
}
@@ -867,25 +867,11 @@ class ComposerController extends BaseController
}
}
String convertHtmlContentToTextContent(String htmlContent) {
String textContent = htmlContent.replaceAll(RegExp(r'<[^>]*>'), '');
textContent = textContent
.replaceAll('&nbsp;', ' ')
.replaceAll('&amp;', '&')
.replaceAll('&lt;', '<')
.replaceAll('&gt;', '>')
.replaceAll('&quot;', '"')
.replaceAll('&#39;', "'");
return textContent.trim();
}
Future<String> getTextOnlyContentInEditor() async {
try {
final htmlContent = await getContentInEditor();
String textContent = convertHtmlContentToTextContent(htmlContent);
String textContent = StringConvert.convertHtmlContentToTextContent(htmlContent);
return textContent;
} catch (e) {