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
This commit is contained in:
@@ -867,10 +867,7 @@ class ComposerController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> 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<String> 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;
|
||||
|
||||
Reference in New Issue
Block a user