Fix bug && New properties && Remove old one

pull/1483/head
Ellet 2 years ago
parent 3dad9e4490
commit ef64616117
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 5
      CHANGELOG.md
  2. 22
      lib/src/models/config/editor/configurations.dart
  3. 2
      lib/src/widgets/editor/editor.dart
  4. 29
      lib/src/widgets/raw_editor/raw_editor.dart
  5. 2
      pubspec.yaml

@ -1,6 +1,9 @@
## [8.0.1]
## [8.1.0]
- Fixes a word typo of `mirgration` to `migration` in readme & migration document.
- Updated migration guide
- Remove property `enableUnfocusOnTapOutside` in QuillEditor Configurations and add `isOnTapOutsideEnabled` instead
- Add a new callback which is called `onTapOutside` in the `QuillEditorConfigurations` which allow you to do something when tap outside of the edtior
- Fix a bug which cause the web platform to not unfocus the editor when tap outside of it (the default logic) to override this pleae pass a value to the callback ``onTapOutside``
## [8.0.0]
- If you have mirgrated recently, don't get scared from this update, it just add a documentation, mirgration guide and mark the version as more stable release, since we did break a lot of breaking changes (at least that what most developers says) we should have change the major version but when we were in the development of this new version, our time was very tight and now we are fixing the version number

@ -1,3 +1,4 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart' show Brightness, Uint8List, immutable;
import 'package:flutter/material.dart'
@ -57,7 +58,8 @@ class QuillEditorConfigurations extends Equatable {
this.customShortcuts,
this.customActions,
this.detectWordBoundary = true,
this.enableUnfocusOnTapOutside = true,
this.isOnTapOutsideEnabled = true,
this.onTapOutside,
this.customLinkPrefixes = const <String>[],
this.dialogTheme,
this.contentInsertionConfiguration,
@ -103,8 +105,17 @@ class QuillEditorConfigurations extends Equatable {
/// Defaults to `false`. Cannot be `null`.
final bool autoFocus;
/// Whether focus should be revoked on tap outside the editor.
final bool enableUnfocusOnTapOutside;
/// Whether the [onTapOutside] should be triggered or not
/// by Defaults to `true`
/// it have default implementation, check [onTapOuside] for more
final bool isOnTapOutsideEnabled;
/// This will run only when [isOnTapOutsideEnabled] is true
/// by default on desktop and web it will unfocus
/// on mobile it will only unFocus if the kind property of
/// event [PointerDownEvent] is [PointerDeviceKind.unknown]
/// you can override this to fit your needs
final Function(PointerDownEvent event, FocusNode focusNode)? onTapOutside;
/// Whether to show cursor.
///
@ -313,6 +324,7 @@ class QuillEditorConfigurations extends Equatable {
EdgeInsetsGeometry? padding,
bool? autoFocus,
bool? enableUnfocusOnTapOutside,
Function(PointerDownEvent event, FocusNode focusNode)? onTapOutside,
bool? showCursor,
bool? paintCursorAboveText,
bool? enableInteractiveSelection,
@ -353,8 +365,8 @@ class QuillEditorConfigurations extends Equatable {
scrollBottomInset: scrollBottomInset ?? this.scrollBottomInset,
padding: padding ?? this.padding,
autoFocus: autoFocus ?? this.autoFocus,
enableUnfocusOnTapOutside:
enableUnfocusOnTapOutside ?? this.enableUnfocusOnTapOutside,
isOnTapOutsideEnabled: enableUnfocusOnTapOutside ?? isOnTapOutsideEnabled,
onTapOutside: onTapOutside ?? this.onTapOutside,
showCursor: showCursor ?? this.showCursor,
paintCursorAboveText: paintCursorAboveText ?? this.paintCursorAboveText,
enableInteractiveSelection:

@ -293,7 +293,7 @@ class QuillEditorState extends State<QuillEditor>
customShortcuts: configurations.customShortcuts,
customActions: configurations.customActions,
customLinkPrefixes: configurations.customLinkPrefixes,
enableUnfocusOnTapOutside: configurations.enableUnfocusOnTapOutside,
enableUnfocusOnTapOutside: configurations.isOnTapOutsideEnabled,
dialogTheme: configurations.dialogTheme,
contentInsertionConfiguration:
configurations.contentInsertionConfiguration,

@ -424,6 +424,10 @@ class RawEditorState extends EditorState
}
void _defaultOnTapOutside(PointerDownEvent event) {
if (isWeb()) {
widget.focusNode.unfocus();
}
/// The focus dropping behavior is only present on desktop platforms
/// and mobile browsers.
switch (defaultTargetPlatform) {
@ -434,9 +438,9 @@ class RawEditorState extends EditorState
// in the web browser, but we do unfocus for all other kinds of events.
switch (event.kind) {
case ui.PointerDeviceKind.touch:
if (isWeb()) {
widget.focusNode.unfocus();
}
// if (isWeb()) {
// widget.focusNode.unfocus();
// }
break;
case ui.PointerDeviceKind.mouse:
case ui.PointerDeviceKind.stylus:
@ -446,7 +450,8 @@ class RawEditorState extends EditorState
break;
case ui.PointerDeviceKind.trackpad:
throw UnimplementedError(
'Unexpected pointer down event for trackpad');
'Unexpected pointer down event for trackpad',
);
}
break;
case TargetPlatform.linux:
@ -454,6 +459,11 @@ class RawEditorState extends EditorState
case TargetPlatform.windows:
widget.focusNode.unfocus();
break;
default:
throw UnsupportedError(
'The platform ${defaultTargetPlatform.name} is not supported in the'
' _defaultOnTapOutside',
);
}
}
@ -555,7 +565,16 @@ class RawEditorState extends EditorState
return TextFieldTapRegion(
enabled: widget.enableUnfocusOnTapOutside,
onTapOutside: _defaultOnTapOutside,
onTapOutside: (event) {
final onTapOutside =
context.requireQuillEditorConfigurations.onTapOutside;
if (onTapOutside != null) {
context.requireQuillEditorConfigurations.onTapOutside
?.call(event, widget.focusNode);
return;
}
_defaultOnTapOutside(event);
},
child: QuillStyles(
data: _styles!,
child: Shortcuts(

@ -1,6 +1,6 @@
name: flutter_quill
description: A rich text editor built for the modern Android, iOS, web and desktop platforms. It is the WYSIWYG editor and a Quill component for Flutter.
version: 8.0.1
version: 8.1.0
homepage: https://1o24bbs.com/c/bulletjournal/108
repository: https://github.com/singerdmx/flutter-quill
topics:

Loading…
Cancel
Save