Improve text replace in Scribe
- Delete selection content before inserting - Insert correct HTML
This commit is contained in:
@@ -214,4 +214,10 @@ class StringConvert {
|
||||
|
||||
return textContent.trim();
|
||||
}
|
||||
|
||||
static String convertTextContentToHtmlContent(String textContent) {
|
||||
final htmlContent = textContent.replaceAll('\n', '<br>');
|
||||
|
||||
return '<div>$htmlContent</div>';
|
||||
}
|
||||
}
|
||||
+7
-2
@@ -29,10 +29,15 @@ extension HandleAiScribeInComposerExtension on ComposerController {
|
||||
}
|
||||
}
|
||||
|
||||
void insertTextInEditor(String text) {
|
||||
final htmlContent = text.replaceAll('\n', '<br>');
|
||||
void insertTextInEditor(String text) async {
|
||||
final htmlContent = StringConvert.convertTextContentToHtmlContent(text);
|
||||
|
||||
if (PlatformInfo.isWeb) {
|
||||
await richTextWebController?.editorController.evaluateJavascriptWeb(
|
||||
HtmlUtils.deleteSelectionContent.name,
|
||||
hasReturnValue: false,
|
||||
);
|
||||
|
||||
richTextWebController?.editorController.insertHtml(htmlContent);
|
||||
} else {
|
||||
richTextMobileTabletController?.htmlEditorApi?.insertHtml(htmlContent);
|
||||
|
||||
Reference in New Issue
Block a user