fixup! Extract method to convert html content to text content
Move the method in utils
This commit is contained in:
@@ -196,4 +196,18 @@ class StringConvert {
|
|||||||
.map((e) => NamedAddress(name: '', address: e))
|
.map((e) => NamedAddress(name: '', address: e))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String convertHtmlContentToTextContent(String htmlContent) {
|
||||||
|
String textContent = htmlContent.replaceAll(RegExp(r'<[^>]*>'), '');
|
||||||
|
|
||||||
|
textContent = textContent
|
||||||
|
.replaceAll(' ', ' ')
|
||||||
|
.replaceAll('&', '&')
|
||||||
|
.replaceAll('<', '<')
|
||||||
|
.replaceAll('>', '>')
|
||||||
|
.replaceAll('"', '"')
|
||||||
|
.replaceAll(''', "'");
|
||||||
|
|
||||||
|
return textContent.trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -867,25 +867,11 @@ class ComposerController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String convertHtmlContentToTextContent(String htmlContent) {
|
|
||||||
String textContent = htmlContent.replaceAll(RegExp(r'<[^>]*>'), '');
|
|
||||||
|
|
||||||
textContent = textContent
|
|
||||||
.replaceAll(' ', ' ')
|
|
||||||
.replaceAll('&', '&')
|
|
||||||
.replaceAll('<', '<')
|
|
||||||
.replaceAll('>', '>')
|
|
||||||
.replaceAll('"', '"')
|
|
||||||
.replaceAll(''', "'");
|
|
||||||
|
|
||||||
return textContent.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String> getTextOnlyContentInEditor() async {
|
Future<String> getTextOnlyContentInEditor() async {
|
||||||
try {
|
try {
|
||||||
final htmlContent = await getContentInEditor();
|
final htmlContent = await getContentInEditor();
|
||||||
|
|
||||||
String textContent = convertHtmlContentToTextContent(htmlContent);
|
String textContent = StringConvert.convertHtmlContentToTextContent(htmlContent);
|
||||||
|
|
||||||
return textContent;
|
return textContent;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user