From 5abe224e58a1ee0d7268aa3420db941c5c4c3458 Mon Sep 17 00:00:00 2001 From: Ellet Date: Sat, 11 Nov 2023 03:57:54 +0300 Subject: [PATCH] Update flutter_quill and flutter_quill_extensions --- CHANGELOG.md | 7 + doc/todo.md | 1 + .../android/app/src/main/AndroidManifest.xml | 6 + example/lib/pages/home_page.dart | 40 ++- example/pubspec.yaml | 5 +- example/web/index.html | 5 + flutter_quill_extensions/CHANGELOG.md | 4 + .../embeds/editor/image/image.dart | 41 ++- .../embeds/editor/image/image_menu.dart | 9 +- .../embeds/widgets/image_resizer.dart | 4 +- .../models/config/editor/image/image.dart | 18 +- flutter_quill_extensions/pubspec.yaml | 2 +- lib/flutter_quill.dart | 2 + .../models/config/editor/configurations.dart | 8 +- .../config/raw_editor/configurations.dart | 290 ++++++++++++++++++ lib/src/utils/extensions/build_context.dart | 2 +- lib/src/utils/string.dart | 4 +- lib/src/widgets/editor/editor.dart | 117 +++---- lib/src/widgets/raw_editor/raw_editor.dart | 250 +-------------- .../raw_editor/raw_editor_actions.dart | 18 +- .../widgets/raw_editor/raw_editor_state.dart | 178 +++++------ ...editor_state_selection_delegate_mixin.dart | 32 +- ..._editor_state_text_input_client_mixin.dart | 37 ++- lib/src/widgets/utils/provider.dart | 8 +- pubspec.yaml | 2 +- 25 files changed, 623 insertions(+), 467 deletions(-) create mode 100644 lib/src/models/config/raw_editor/configurations.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a9b7268..2d9c2f1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [8.4.2] +- **Breaking change**: The `QuillRawEditor` configurations has been moved to a seperated class, also the `readOnly` has been renamed to `isReadOnly`, if you are using the `QuillEditor` you don't have to change anything +- Allow the developer to use override the `TextInputAction` in both `QuillRawEditor` and `QuillEditor` +- You can use now the `QuillRawEditor` without `QuillEditorProvider` +- Bug fixes +- Add implementation of image cropping in the `example` + ## [8.4.1] - Add `copyWith` in `OptionalSize` class diff --git a/doc/todo.md b/doc/todo.md index 7b8aa9b8..d31c9c73 100644 --- a/doc/todo.md +++ b/doc/todo.md @@ -27,6 +27,7 @@ This is a todo list page that added recently and will be updated soon. 1. Improve the Raw Quill Editor, for more [info](https://github.com/singerdmx/flutter-quill/issues/1509) 2. Provide more support to all the platforms + 3. Extract the shared properties between `QuillRawEditorConfigurations` and `QuillEditorConfigurations` ### Bugs diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 1d6e0b64..6176738c 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -42,6 +42,12 @@ + + + { ); } + /// When inserting an image + OnImageInsertCallback get onImageInsert { + return (image, controller) async { + final croppedFile = await ImageCropper().cropImage( + sourcePath: image, + aspectRatioPresets: [ + CropAspectRatioPreset.square, + CropAspectRatioPreset.ratio3x2, + CropAspectRatioPreset.original, + CropAspectRatioPreset.ratio4x3, + CropAspectRatioPreset.ratio16x9 + ], + uiSettings: [ + AndroidUiSettings( + toolbarTitle: 'Cropper', + toolbarColor: Colors.deepOrange, + toolbarWidgetColor: Colors.white, + initAspectRatio: CropAspectRatioPreset.original, + lockAspectRatio: false), + IOSUiSettings( + title: 'Cropper', + ), + WebUiSettings( + context: context, + ), + ], + ); + final newImage = croppedFile?.path; + if (newImage == null) { + return; + } + controller.insertImageBlock(imageSource: newImage); + }; + } + QuillToolbar get quillToolbar { final customButtons = [ QuillToolbarCustomButtonOptions( @@ -486,8 +522,8 @@ class _HomePageState extends State { onImageInsertedCallback: (image) async { _onImagePickCallback(File(image)); }, + onImageInsertCallback: onImageInsert, ), - // webImagePickImpl: _webImagePickImpl, ), ), buttonOptions: QuillToolbarButtonOptions( @@ -496,7 +532,6 @@ class _HomePageState extends State { ), ), ), - // afterButtonPressed: _focusNode.requestFocus, ); } if (isDesktop(supportWeb: false)) { @@ -533,6 +568,7 @@ class _HomePageState extends State { ), imageButtonOptions: QuillToolbarImageButtonOptions( imageButtonConfigurations: QuillToolbarImageConfigurations( + onImageInsertCallback: onImageInsert, onImageInsertedCallback: (image) async { _onImagePickCallback(File(image)); }, diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 5ff55f23..ccdf1958 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -17,10 +17,11 @@ dependencies: path_provider: ^2.1.1 # filesystem_picker: ^4.0.0 file_picker: ^6.1.1 - flutter_quill: ^8.2.5 - flutter_quill_extensions: ^0.6.3 + flutter_quill: ^8.4.1 + flutter_quill_extensions: ^0.6.5 path: ^1.8.3 desktop_drop: ^0.4.4 + image_cropper: ^5.0.0 dependency_overrides: flutter_quill: diff --git a/example/web/index.html b/example/web/index.html index 45cf2ca3..1029dffd 100644 --- a/example/web/index.html +++ b/example/web/index.html @@ -32,6 +32,11 @@ example + + + + +