diff --git a/core/lib/utils/string_convert.dart b/core/lib/utils/string_convert.dart index c490c8755..018e27692 100644 --- a/core/lib/utils/string_convert.dart +++ b/core/lib/utils/string_convert.dart @@ -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(' ', ' ') + .replaceAll('&', '&') + .replaceAll('<', '<') + .replaceAll('>', '>') + .replaceAll('"', '"') + .replaceAll(''', "'"); + + return textContent.trim(); + } } \ No newline at end of file diff --git a/lib/features/composer/presentation/composer_controller.dart b/lib/features/composer/presentation/composer_controller.dart index c277162c3..f59ea43e9 100644 --- a/lib/features/composer/presentation/composer_controller.dart +++ b/lib/features/composer/presentation/composer_controller.dart @@ -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 getTextOnlyContentInEditor() async { try { final htmlContent = await getContentInEditor(); - String textContent = convertHtmlContentToTextContent(htmlContent); + String textContent = StringConvert.convertHtmlContentToTextContent(htmlContent); return textContent; } catch (e) {