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();
|
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) {
|
void insertTextInEditor(String text) async {
|
||||||
final htmlContent = text.replaceAll('\n', '<br>');
|
final htmlContent = StringConvert.convertTextContentToHtmlContent(text);
|
||||||
|
|
||||||
if (PlatformInfo.isWeb) {
|
if (PlatformInfo.isWeb) {
|
||||||
|
await richTextWebController?.editorController.evaluateJavascriptWeb(
|
||||||
|
HtmlUtils.deleteSelectionContent.name,
|
||||||
|
hasReturnValue: false,
|
||||||
|
);
|
||||||
|
|
||||||
richTextWebController?.editorController.insertHtml(htmlContent);
|
richTextWebController?.editorController.insertHtml(htmlContent);
|
||||||
} else {
|
} else {
|
||||||
richTextMobileTabletController?.htmlEditorApi?.insertHtml(htmlContent);
|
richTextMobileTabletController?.htmlEditorApi?.insertHtml(htmlContent);
|
||||||
|
|||||||
Reference in New Issue
Block a user