From 6dc58e2eb6448114b2e813e935eb6f9c03b350c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Mon, 8 Dec 2025 15:00:37 +0100 Subject: [PATCH] Extract method to convert html content to text content Editor exposes html content (so with html tags) and we do not want to send them to AI backend --- .../presentation/composer_controller.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/features/composer/presentation/composer_controller.dart b/lib/features/composer/presentation/composer_controller.dart index 984eca5ed..bd1a0f810 100644 --- a/lib/features/composer/presentation/composer_controller.dart +++ b/lib/features/composer/presentation/composer_controller.dart @@ -867,10 +867,7 @@ class ComposerController extends BaseController } } - Future getTextOnlyContentInEditor() async { - try { - final htmlContent = await getContentInEditor(); - + String convertHtmlContentToTextContent(String htmlContent) { String textContent = htmlContent.replaceAll(RegExp(r'<[^>]*>'), ''); textContent = textContent @@ -882,6 +879,15 @@ class ComposerController extends BaseController .replaceAll(''', "'"); return textContent.trim(); + } + + Future getTextOnlyContentInEditor() async { + try { + final htmlContent = await getContentInEditor(); + + String textContent = convertHtmlContentToTextContent(htmlContent); + + return textContent; } catch (e) { logError('ComposerController::getTextOnlyContentInEditor:Exception = $e'); return ''; @@ -918,8 +924,6 @@ class ComposerController extends BaseController ); } - - void showAIScribeMenuForSelectedText(BuildContext context, {Offset? buttonPosition}) { final selection = selectedText.value; if (selection == null || selection.isEmpty) { @@ -943,7 +947,7 @@ class ComposerController extends BaseController if (textSelectionData.coordinates != null) { textSelectionCoordinates.value = Offset( textSelectionData.coordinates!.x, - textSelectionData.coordinates!.y + 6, + textSelectionData.coordinates!.y, ); } else { textSelectionCoordinates.value = null;