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 {
|
String convertHtmlContentToTextContent(String htmlContent) {
|
||||||
try {
|
|
||||||
final htmlContent = await getContentInEditor();
|
|
||||||
|
|
||||||
String textContent = htmlContent.replaceAll(RegExp(r'<[^>]*>'), '');
|
String textContent = htmlContent.replaceAll(RegExp(r'<[^>]*>'), '');
|
||||||
|
|
||||||
textContent = textContent
|
textContent = textContent
|
||||||
@@ -882,6 +879,15 @@ class ComposerController extends BaseController
|
|||||||
.replaceAll(''', "'");
|
.replaceAll(''', "'");
|
||||||
|
|
||||||
return textContent.trim();
|
return textContent.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> getTextOnlyContentInEditor() async {
|
||||||
|
try {
|
||||||
|
final htmlContent = await getContentInEditor();
|
||||||
|
|
||||||
|
String textContent = convertHtmlContentToTextContent(htmlContent);
|
||||||
|
|
||||||
|
return textContent;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError('ComposerController::getTextOnlyContentInEditor:Exception = $e');
|
logError('ComposerController::getTextOnlyContentInEditor:Exception = $e');
|
||||||
return '';
|
return '';
|
||||||
@@ -918,8 +924,6 @@ class ComposerController extends BaseController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void showAIScribeMenuForSelectedText(BuildContext context, {Offset? buttonPosition}) {
|
void showAIScribeMenuForSelectedText(BuildContext context, {Offset? buttonPosition}) {
|
||||||
final selection = selectedText.value;
|
final selection = selectedText.value;
|
||||||
if (selection == null || selection.isEmpty) {
|
if (selection == null || selection.isEmpty) {
|
||||||
@@ -943,7 +947,7 @@ class ComposerController extends BaseController
|
|||||||
if (textSelectionData.coordinates != null) {
|
if (textSelectionData.coordinates != null) {
|
||||||
textSelectionCoordinates.value = Offset(
|
textSelectionCoordinates.value = Offset(
|
||||||
textSelectionData.coordinates!.x,
|
textSelectionData.coordinates!.x,
|
||||||
textSelectionData.coordinates!.y + 6,
|
textSelectionData.coordinates!.y,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
textSelectionCoordinates.value = null;
|
textSelectionCoordinates.value = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user