diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d5c748c..0ac690be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# [5.3.0] +* Added search function. + # [5.2.11] * Remove default small color. diff --git a/lib/src/widgets/toolbar.dart b/lib/src/widgets/toolbar.dart index e08f47e4..b901f74f 100644 --- a/lib/src/widgets/toolbar.dart +++ b/lib/src/widgets/toolbar.dart @@ -111,7 +111,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { bool showVideoButton = true, bool showCameraButton = true, bool showDirection = false, - bool showSearchButton = false, + bool showSearchButton = true, OnImagePickCallback? onImagePickCallback, OnVideoPickCallback? onVideoPickCallback, MediaPickSettingSelector? mediaPickSettingSelector, diff --git a/lib/src/widgets/toolbar/search_button.dart b/lib/src/widgets/toolbar/search_button.dart index b69997c9..779cbec1 100644 --- a/lib/src/widgets/toolbar/search_button.dart +++ b/lib/src/widgets/toolbar/search_button.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; +import '../../models/documents/document.dart'; import '../../models/themes/quill_dialog_theme.dart'; import '../../models/themes/quill_icon_theme.dart'; import '../../translations/toolbar.i18n.dart'; @@ -126,7 +127,7 @@ class _SearchDialogState extends State<_SearchDialog> { setState(() { _index -= 1; }); - widget.controller.moveCursorToPosition(_offsets![_index]); + _moveToPosition(); }, child: Text( 'Prev'.i18n, @@ -141,7 +142,7 @@ class _SearchDialogState extends State<_SearchDialog> { setState(() { _index += 1; }); - widget.controller.moveCursorToPosition(_offsets![_index]); + _moveToPosition(); }, child: Text( 'Next'.i18n, @@ -157,7 +158,7 @@ class _SearchDialogState extends State<_SearchDialog> { debugPrint(_offsets.toString()); }); if (_offsets!.isNotEmpty) { - widget.controller.moveCursorToPosition(_offsets![0]); + _moveToPosition(); } }, child: Text( @@ -170,6 +171,14 @@ class _SearchDialogState extends State<_SearchDialog> { }); } + void _moveToPosition() { + widget.controller.updateSelection( + TextSelection( + baseOffset: _offsets![_index], + extentOffset: _offsets![_index] + _text.length), + ChangeSource.LOCAL); + } + void _textChanged(String value) { setState(() { _text = value; diff --git a/pubspec.yaml b/pubspec.yaml index 14fa2e6e..a0a80f38 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_quill description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us) -version: 5.2.11 +version: 5.3.0 #author: bulletjournal homepage: https://bulletjournal.us/home/index.html repository: https://github.com/singerdmx/flutter-quill