From fd975fea91c2c8bca71b5192878daef2054443e7 Mon Sep 17 00:00:00 2001 From: dab246 Date: Mon, 8 Aug 2022 13:17:22 +0700 Subject: [PATCH] TF-753 Migrate `enough_html_editor` library to `Linagora` --- .../presentation/composer_controller.dart | 3 -- .../composer/presentation/composer_view.dart | 1 + .../rich_text_mobile_tablet_controller.dart | 34 ++++++++++++++++--- pubspec.yaml | 4 +-- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lib/features/composer/presentation/composer_controller.dart b/lib/features/composer/presentation/composer_controller.dart index 3048710a5..1f8f06920 100644 --- a/lib/features/composer/presentation/composer_controller.dart +++ b/lib/features/composer/presentation/composer_controller.dart @@ -141,9 +141,6 @@ class ComposerController extends BaseController { return newContentHtml; } else { String contentHtml = await htmlEditorApi?.getText() ?? ''; - if(Platform.isAndroid) { - contentHtml = contentHtml.replaceAll('"', '"'); - } log('ComposerController::_getEmailBodyText():MOBILE: $contentHtml'); final newContentHtml = contentHtml.removeEditorStartTag(); if (changedEmail) { diff --git a/lib/features/composer/presentation/composer_view.dart b/lib/features/composer/presentation/composer_view.dart index da1d2ed28..3772c8a50 100644 --- a/lib/features/composer/presentation/composer_view.dart +++ b/lib/features/composer/presentation/composer_view.dart @@ -670,6 +670,7 @@ class ComposerView extends GetWidget child: HtmlEditor( key: const Key('composer_editor'), minHeight: 550, + addDefaultSelectionMenuItems: false, initialContent: initialContent, onCreated: (editorApi) { richTextMobileTabletController.htmlEditorApi = editorApi; diff --git a/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart b/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart index eb3b65934..ac07f5c32 100644 --- a/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart +++ b/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart @@ -148,15 +148,41 @@ class RichTextMobileTabletController extends BaseRichTextController { htmlEditorApi?.formatHeader(styleSelected.styleValue); } - void applyParagraphType(ParagraphType newParagraph) { + void applyParagraphType(ParagraphType newParagraph) async { selectedParagraph.value = newParagraph; - htmlEditorApi?.execCommand(newParagraph.commandAction); + switch(newParagraph) { + case ParagraphType.alignLeft: + await htmlEditorApi?.formatAlignLeft(); + break; + case ParagraphType.alignRight: + await htmlEditorApi?.formatAlignRight(); + break; + case ParagraphType.alignCenter: + await htmlEditorApi?.formatAlignCenter(); + break; + case ParagraphType.justify: + await htmlEditorApi?.formatAlignJustify(); + break; + case ParagraphType.indent: + await htmlEditorApi?.formatIndent(); + break; + case ParagraphType.outdent: + await htmlEditorApi?.formatOutent(); + break; + } menuParagraphController.hideMenu(); } - void applyOrderListType(OrderListType newOrderList) { + void applyOrderListType(OrderListType newOrderList) async { selectedOrderList.value = newOrderList; - htmlEditorApi?.execCommand(newOrderList.commandAction); + switch(newOrderList) { + case OrderListType.bulletedList: + await htmlEditorApi?.insertUnorderedList(); + break; + case OrderListType.numberedList: + await htmlEditorApi?.insertOrderedList(); + break; + } menuOrderListController.hideMenu(); } diff --git a/pubspec.yaml b/pubspec.yaml index 87be6c537..e289a3a03 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -124,8 +124,8 @@ dependencies: # enough_html_editor: Compose email for Mobile & Tablet enough_html_editor: git: - url: https://github.com/ManhNTX/enough_html_editor.git - ref: improvements_for_use_tmail + url: https://github.com/linagora/enough_html_editor.git + ref: email_supported # html_editor_enhanced: Compose email for Web Browser html_editor_enhanced: