Fix keyboard pops up when resizing the image

pull/890/head
X Code 3 years ago
parent 401f317690
commit 680a5db531
  1. 4
      lib/src/widgets/controller.dart
  2. 6
      lib/src/widgets/embeds/default_embed_builder.dart
  3. 12
      lib/src/widgets/raw_editor.dart

@ -62,6 +62,10 @@ class QuillController extends ChangeNotifier {
bool ignoreFocusOnTextChange = false; bool ignoreFocusOnTextChange = false;
/// Skip requestKeyboard being called in
/// RawEditorState#_didChangeTextEditingValue
bool skipRequestKeyboard = false;
/// True when this [QuillController] instance has been disposed. /// True when this [QuillController] instance has been disposed.
/// ///
/// A safety mechanism to ensure that listeners don't crash when adding, /// A safety mechanism to ensure that listeners don't crash when adding,

@ -84,8 +84,10 @@ Widget defaultEmbedBuilder(
controller, controller.selection.start); controller, controller.selection.start);
final attr = replaceStyleString( final attr = replaceStyleString(
getImageStyleString(controller), w, h); getImageStyleString(controller), w, h);
controller.formatText( controller
res.item1, 1, StyleAttribute(attr)); ..skipRequestKeyboard = true
..formatText(
res.item1, 1, StyleAttribute(attr));
}, },
imageWidth: _widthHeight?.item1, imageWidth: _widthHeight?.item1,
imageHeight: _widthHeight?.item2, imageHeight: _widthHeight?.item2,

@ -708,7 +708,11 @@ class RawEditorState extends EditorState
if (kIsWeb) { if (kIsWeb) {
_onChangeTextEditingValue(ignoreFocus); _onChangeTextEditingValue(ignoreFocus);
if (!ignoreFocus) { if (!ignoreFocus) {
requestKeyboard(); if (controller.skipRequestKeyboard) {
controller.skipRequestKeyboard = false;
} else {
requestKeyboard();
}
} }
return; return;
} }
@ -716,7 +720,11 @@ class RawEditorState extends EditorState
if (ignoreFocus || _keyboardVisible) { if (ignoreFocus || _keyboardVisible) {
_onChangeTextEditingValue(ignoreFocus); _onChangeTextEditingValue(ignoreFocus);
} else { } else {
requestKeyboard(); if (controller.skipRequestKeyboard) {
controller.skipRequestKeyboard = false;
} else {
requestKeyboard();
}
if (mounted) { if (mounted) {
setState(() { setState(() {
// Use widget.controller.value in build() // Use widget.controller.value in build()

Loading…
Cancel
Save