TF-3399 Fix can not click on body of composer in Samsung A3

This commit is contained in:
dab246
2025-01-09 16:08:53 +07:00
committed by Dat H. Pham
parent 2212bae095
commit 248b6b6ac4
6 changed files with 75 additions and 112 deletions
@@ -199,6 +199,7 @@ class ComposerController extends BaseController
SignatureStatus _identityContentOnOpenPolicy = SignatureStatus.editedAvailable;
int? _savedEmailDraftHash;
bool _restoringSignatureButton = false;
GlobalKey? responsiveContainerKey;
@visibleForTesting
bool get restoringSignatureButton => _restoringSignatureButton;
@@ -230,6 +231,7 @@ class ComposerController extends BaseController
super.onInit();
if (PlatformInfo.isWeb) {
richTextWebController = getBinding<RichTextWebController>();
responsiveContainerKey = GlobalKey();
} else {
richTextMobileTabletController = getBinding<RichTextMobileTabletController>();
}
@@ -269,6 +271,7 @@ class ComposerController extends BaseController
_beforeReconnectManager.removeListener(onBeforeReconnect);
if (PlatformInfo.isWeb) {
richTextWebController = null;
responsiveContainerKey = null;
} else {
richTextMobileTabletController = null;
}
@@ -392,12 +395,6 @@ class ComposerController extends BaseController
}
});
});
if (richTextWebController != null) {
ever(richTextWebController!.formattingOptionsState, (_) {
richTextWebController!.editorController.setFocus();
});
}
}
void _triggerBrowserEventListener() {
@@ -525,6 +522,7 @@ class ComposerController extends BaseController
KeyEventResult _subjectEmailInputOnKeyListener(FocusNode node, KeyEvent event) {
if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.tab) {
subjectEmailInputFocusNode?.unfocus();
richTextWebController?.editorController.setFocus();
return KeyEventResult.handled;
}
@@ -1486,6 +1484,9 @@ class ComposerController extends BaseController
}
void displayScreenTypeComposerAction(ScreenDisplayMode displayMode) async {
if (screenDisplayMode.value == ScreenDisplayMode.minimize) {
_isEmailBodyLoaded = false;
}
if (richTextWebController != null && screenDisplayMode.value != ScreenDisplayMode.minimize) {
final textCurrent = await richTextWebController!.editorController.getText();
richTextWebController!.editorController.setText(textCurrent);
@@ -1955,7 +1956,6 @@ class ComposerController extends BaseController
return false;
}
void handleInitHtmlEditorWeb(String initContent) async {
if (_isEmailBodyLoaded) return;
log('ComposerController::handleInitHtmlEditorWeb:');
@@ -1980,9 +1980,7 @@ class ComposerController extends BaseController
richTextWebController?.closeAllMenuPopup();
}
void handleOnMouseDownHtmlEditorWeb(BuildContext context) {
Navigator.maybePop(context);
FocusScope.of(context).unfocus();
void handleOnMouseDownHtmlEditorWeb() {
_collapseAllRecipient();
_autoCreateEmailTag();
}
@@ -186,6 +186,7 @@ class ComposerView extends GetWidget<ComposerController> {
child: Padding(
padding: ComposerStyle.mobileEditorPadding,
child: Obx(() => WebEditorView(
key: controller.responsiveContainerKey,
editorController: controller.richTextWebController!.editorController,
arguments: controller.composerArguments.value,
contentViewState: controller.emailContentsViewState.value,
@@ -196,7 +197,6 @@ class ComposerView extends GetWidget<ComposerController> {
onMouseDown: controller.handleOnMouseDownHtmlEditorWeb,
onEditorSettings: controller.richTextWebController!.onEditorSettingsChange,
onEditorTextSizeChanged: controller.richTextWebController!.onEditorTextSizeChanged,
width: constraints.maxWidth,
height: constraints.maxHeight,
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
onPasteImageSuccessAction: (listFileUpload) => controller.handleOnPasteImageSuccessAction(
@@ -448,6 +448,7 @@ class ComposerView extends GetWidget<ComposerController> {
padding: ComposerStyle.desktopEditorPadding,
child: Obx(() {
return WebEditorView(
key: controller.responsiveContainerKey,
editorController: controller.richTextWebController!.editorController,
arguments: controller.composerArguments.value,
contentViewState: controller.emailContentsViewState.value,
@@ -458,7 +459,6 @@ class ComposerView extends GetWidget<ComposerController> {
onMouseDown: controller.handleOnMouseDownHtmlEditorWeb,
onEditorSettings: controller.richTextWebController?.onEditorSettingsChange,
onEditorTextSizeChanged: controller.richTextWebController?.onEditorTextSizeChanged,
width: constraints.maxWidth,
height: constraints.maxHeight,
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
onPasteImageSuccessAction: (listFileUpload) => controller.handleOnPasteImageSuccessAction(
@@ -728,6 +728,7 @@ class ComposerView extends GetWidget<ComposerController> {
child: Padding(
padding: ComposerStyle.tabletEditorPadding,
child: Obx(() => WebEditorView(
key: controller.responsiveContainerKey,
editorController: controller.richTextWebController!.editorController,
arguments: controller.composerArguments.value,
contentViewState: controller.emailContentsViewState.value,
@@ -738,7 +739,6 @@ class ComposerView extends GetWidget<ComposerController> {
onMouseDown: controller.handleOnMouseDownHtmlEditorWeb,
onEditorSettings: controller.richTextWebController!.onEditorSettingsChange,
onEditorTextSizeChanged: controller.richTextWebController!.onEditorTextSizeChanged,
width: constraints.maxWidth,
height: constraints.maxHeight,
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
onPasteImageSuccessAction: (listFileUpload) => controller.handleOnPasteImageSuccessAction(
@@ -296,6 +296,11 @@ class RichTextWebController extends BaseRichTextController {
: FormattingOptionsState.enabled;
formattingOptionsState.value = newState;
if (isFormattingOptionsEnabled) {
FocusManager.instance.primaryFocus?.unfocus();
editorController.setFocus();
}
}
bool get isFormattingOptionsEnabled => formattingOptionsState.value == FormattingOptionsState.enabled;
@@ -29,7 +29,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
final OnMouseDownEditorAction? onMouseDown;
final OnEditorSettingsChange? onEditorSettings;
final OnEditorTextSizeChanged? onEditorTextSizeChanged;
final double? width;
final double? height;
final OnDragEnterListener? onDragEnter;
final OnPasteImageSuccessAction? onPasteImageSuccessAction;
@@ -49,7 +48,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
this.onMouseDown,
this.onEditorSettings,
this.onEditorTextSizeChanged,
this.width,
this.height,
this.onDragEnter,
this.onPasteImageSuccessAction,
@@ -78,7 +76,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
@@ -106,7 +103,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
@@ -134,7 +130,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
@@ -171,7 +166,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
@@ -203,7 +197,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
@@ -225,7 +218,6 @@ class WebEditorView extends StatelessWidget with EditorViewMixin {
onMouseDown: onMouseDown,
onEditorSettings: onEditorSettings,
onEditorTextSizeChanged: onEditorTextSizeChanged,
width: width,
height: height,
onDragEnter: onDragEnter,
onPasteImageSuccessAction: onPasteImageSuccessAction,
@@ -9,7 +9,7 @@ import 'package:universal_html/html.dart' hide VoidCallback;
typedef OnChangeContentEditorAction = Function(String? text);
typedef OnInitialContentEditorAction = Function(String text);
typedef OnMouseDownEditorAction = Function(BuildContext context);
typedef OnMouseDownEditorAction = Function();
typedef OnEditorSettingsChange = Function(EditorSettings settings);
typedef OnEditorTextSizeChanged = Function(int? size);
typedef OnDragEnterListener = Function(List<dynamic>? types);
@@ -32,7 +32,6 @@ class WebEditorWidget extends StatefulWidget {
final OnMouseDownEditorAction? onMouseDown;
final OnEditorSettingsChange? onEditorSettings;
final OnEditorTextSizeChanged? onEditorTextSizeChanged;
final double? width;
final double? height;
final OnDragEnterListener? onDragEnter;
final OnPasteImageSuccessAction? onPasteImageSuccessAction;
@@ -51,7 +50,6 @@ class WebEditorWidget extends StatefulWidget {
this.onMouseDown,
this.onEditorSettings,
this.onEditorTextSizeChanged,
this.width,
this.height,
this.onDragEnter,
this.onPasteImageSuccessAction,
@@ -65,14 +63,9 @@ class WebEditorWidget extends StatefulWidget {
class _WebEditorState extends State<WebEditorWidget> {
static const double _offsetHeight = 50;
static const double _offsetWidth = 90;
static const double _defaultHtmlEditorHeight = 550;
late HtmlEditorController _editorController;
double? dropZoneWidth;
double? dropZoneHeight;
final ValueNotifier<double> _htmlEditorHeight = ValueNotifier(_defaultHtmlEditorHeight);
bool _dropListenerRegistered = false;
Function(Event)? _dropListener;
@@ -80,16 +73,6 @@ class _WebEditorState extends State<WebEditorWidget> {
void initState() {
super.initState();
_editorController = widget.editorController;
log('_WebEditorState::initState:height: ${widget.height} | width: ${widget.width}');
if (widget.height != null) {
dropZoneHeight = widget.height! - _offsetHeight;
_htmlEditorHeight.value = widget.height ?? _defaultHtmlEditorHeight;
}
if (widget.width != null) {
dropZoneWidth = widget.width! - _offsetWidth;
}
log('_WebEditorState::initState:dropZoneWidth: $dropZoneWidth | dropZoneHeight: $dropZoneHeight');
_dropListener = (event) {
if (event is MessageEvent) {
if (jsonDecode(event.data)['name'] == HtmlUtils.registerDropListener.name) {
@@ -108,18 +91,11 @@ class _WebEditorState extends State<WebEditorWidget> {
if (oldWidget.direction != widget.direction) {
_editorController.updateBodyDirection(widget.direction.name);
}
log('_EmailEditorState::didUpdateWidget():Old: ${oldWidget.height} | current: ${widget.height}');
if (oldWidget.height != widget.height) {
_htmlEditorHeight.value = widget.height ?? _defaultHtmlEditorHeight;
}
super.didUpdateWidget(oldWidget);
}
@override
void dispose() {
_htmlEditorHeight.dispose();
_editorController.evaluateJavascriptWeb(
HtmlUtils.unregisterDropListener.name);
if (_dropListener != null) {
@@ -131,72 +107,64 @@ class _WebEditorState extends State<WebEditorWidget> {
@override
Widget build(BuildContext context) {
return ValueListenableBuilder(
valueListenable: _htmlEditorHeight,
builder: (context, height, _) {
return HtmlEditor(
key: Key('web_editor_$height'),
controller: _editorController,
htmlEditorOptions: HtmlEditorOptions(
shouldEnsureVisible: true,
hint: '',
darkMode: false,
initialText: widget.content,
customBodyCssStyle: HtmlUtils.customCssStyleHtmlEditor(direction: widget.direction),
spellCheck: true,
disableDragAndDrop: true,
webInitialScripts: UnmodifiableListView([
WebScript(
name: HtmlUtils.lineHeight100Percent.name,
script: HtmlUtils.lineHeight100Percent.script,
),
WebScript(
name: HtmlUtils.registerDropListener.name,
script: HtmlUtils.registerDropListener.script,
),
WebScript(
name: HtmlUtils.unregisterDropListener.name,
script: HtmlUtils.unregisterDropListener.script,
)
])
return HtmlEditor(
controller: _editorController,
htmlEditorOptions: HtmlEditorOptions(
shouldEnsureVisible: true,
hint: '',
darkMode: false,
initialText: widget.content,
customBodyCssStyle: HtmlUtils.customCssStyleHtmlEditor(direction: widget.direction),
spellCheck: true,
disableDragAndDrop: true,
webInitialScripts: UnmodifiableListView([
WebScript(
name: HtmlUtils.lineHeight100Percent.name,
script: HtmlUtils.lineHeight100Percent.script,
),
htmlToolbarOptions: const HtmlToolbarOptions(
toolbarType: ToolbarType.hide,
defaultToolbarButtons: [],
WebScript(
name: HtmlUtils.registerDropListener.name,
script: HtmlUtils.registerDropListener.script,
),
otherOptions: OtherOptions(
height: height,
// dropZoneWidth: dropZoneWidth,
// dropZoneHeight: dropZoneHeight,
),
callbacks: Callbacks(
onBeforeCommand: widget.onChangeContent,
onChangeContent: widget.onChangeContent,
onInit: () {
widget.onInitial?.call(widget.content);
if (!_dropListenerRegistered) {
_editorController.evaluateJavascriptWeb(
HtmlUtils.registerDropListener.name);
_dropListenerRegistered = true;
}
},
onFocus: widget.onFocus,
onBlur: widget.onUnFocus,
onMouseDown: () => widget.onMouseDown?.call(context),
onChangeSelection: widget.onEditorSettings,
onChangeCodeview: widget.onChangeContent,
onTextFontSizeChanged: widget.onEditorTextSizeChanged,
onPaste: () => _editorController.evaluateJavascriptWeb(
HtmlUtils.lineHeight100Percent.name
),
onDragEnter: widget.onDragEnter,
onDragLeave: (_) {},
onImageUpload: widget.onPasteImageSuccessAction,
onImageUploadError: widget.onPasteImageFailureAction,
onInitialTextLoadComplete: widget.onInitialContentLoadComplete,
),
);
}
WebScript(
name: HtmlUtils.unregisterDropListener.name,
script: HtmlUtils.unregisterDropListener.script,
)
])
),
htmlToolbarOptions: const HtmlToolbarOptions(
toolbarType: ToolbarType.hide,
defaultToolbarButtons: [],
),
otherOptions: OtherOptions(
height: widget.height ?? _defaultHtmlEditorHeight,
),
callbacks: Callbacks(
onBeforeCommand: widget.onChangeContent,
onChangeContent: widget.onChangeContent,
onInit: () {
widget.onInitial?.call(widget.content);
if (!_dropListenerRegistered) {
_editorController.evaluateJavascriptWeb(
HtmlUtils.registerDropListener.name);
_dropListenerRegistered = true;
}
},
onFocus: widget.onFocus,
onUnFocus: widget.onUnFocus,
onMouseDown:widget.onMouseDown,
onChangeSelection: widget.onEditorSettings,
onChangeCodeview: widget.onChangeContent,
onTextFontSizeChanged: widget.onEditorTextSizeChanged,
onPaste: () => _editorController.evaluateJavascriptWeb(
HtmlUtils.lineHeight100Percent.name
),
onDragEnter: widget.onDragEnter,
onDragLeave: (_) {},
onImageUpload: widget.onPasteImageSuccessAction,
onImageUploadError: widget.onPasteImageFailureAction,
onInitialTextLoadComplete: widget.onInitialContentLoadComplete,
),
);
}
}
+2 -2
View File
@@ -1171,10 +1171,10 @@ packages:
description:
path: "."
ref: main
resolved-ref: "3274d7fe8c711e7466890b6a3948e9708877ca4a"
resolved-ref: "2572e5cea909c64b00f98cb49b07423dbab36b37"
url: "https://github.com/linagora/html-editor-enhanced.git"
source: git
version: "3.1.1"
version: "3.1.3"
http:
dependency: transitive
description: