pull/1566/head
Ellet 1 year ago
parent daa597f1b6
commit 026b58aa0d
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 4
      CHANGELOG.md
  2. 2
      example/lib/presentation/quill/quill_toolbar.dart
  3. 3
      flutter_quill_extensions/README.md
  4. 15
      flutter_quill_extensions/lib/embeds/image/editor/image_menu.dart
  5. 16
      flutter_quill_extensions/lib/utils/utils.dart
  6. 3
      flutter_quill_extensions/pubspec.yaml

@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file.
* Breaking Changes:
* Rename `QuillToolbar` to `QuillSimpleToolbar`
* Rename `QuillBaseToolbar` to `QuillToolbar`
* Replace `pasteboard` with `rich_cliboard`
* Fix a bug in the example when inserting an image from url
* Flutter Quill Extensions:
* Add support for copying the image to the system cliboard
## 9.0.0-dev-2
* An attemp to fix CI automated publishing

@ -66,7 +66,7 @@ class MyQuillToolbar extends StatelessWidget {
}
Future<void> onImageInsert(String image, QuillController controller) async {
if (isWeb()) {
if (isWeb() || isHttpBasedUrl(image)) {
controller.insertImageBlock(imageSource: image);
return;
}

@ -53,8 +53,7 @@ dependencies:
>
> 1. We are using the [`gal`](https://github.com/natsuk4ze/) plugin to save images.
> For this to work, you need to add the appropriate permissions
> to your `Info.plist` and `AndroidManifest.xml` files.
> For this to work, you need to add the appropriate configurations
> See <https://github.com/natsuk4ze/gal#-get-started> to add the needed lines.
>
> 2. We also use [`image_picker`](https://pub.dev/packages/image_picker) plugin for picking images so please make sure to follow the instructions

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart'
show ImageUrl, QuillController, StyleAttribute, getEmbedNode;
import 'package:flutter_quill/translations.dart';
import 'package:super_clipboard/super_clipboard.dart';
import '../../../models/config/editor/image/image.dart';
import '../../../models/config/shared_configurations.dart';
@ -88,15 +89,17 @@ class ImageOptionsMenu extends StatelessWidget {
final navigator = Navigator.of(context);
final imageNode =
getEmbedNode(controller, controller.selection.start).value;
final imageUrl = imageNode.value.data;
final image = imageNode.value.data;
controller.copiedImageUrl = ImageUrl(
imageUrl,
image,
getImageStyleString(controller),
);
// TODO: Implement the copy image
// await Clipboard.setData(
// ClipboardData(),
// );
final data = await convertImageToUint8List(image);
if (data != null) {
final item = DataWriterItem()..add(Formats.png(data));
await ClipboardWriter.instance.write([item]);
}
navigator.pop();
},
),

@ -1,6 +1,8 @@
import 'dart:io' show File;
import 'package:flutter/foundation.dart' show immutable;
import 'package:cross_file/cross_file.dart';
import 'package:flutter/foundation.dart' show Uint8List, immutable;
import 'package:http/http.dart' as http;
import '../embeds/widgets/image.dart';
import '../services/image_saver/s_image_saver.dart';
@ -48,6 +50,18 @@ class SaveImageResult {
final SaveImageResultMethod method;
}
Future<Uint8List?> convertImageToUint8List(String image) async {
if (isHttpBasedUrl(image)) {
final response = await http.get(Uri.parse(image));
if (response.statusCode == 200) {
return Uint8List.fromList(response.bodyBytes);
}
return null;
}
final file = XFile(image);
return await file.readAsBytes();
}
Future<SaveImageResult> saveImage({
required String imageUrl,
required ImageSaverService imageSaverService,

@ -41,9 +41,10 @@ dependencies:
# Plugins
video_player: ^2.8.1
youtube_player_flutter: ^8.1.2
url_launcher: ^6.2.1
super_clipboard: ^0.7.3
gal: ^2.1.3
image_picker: ^1.0.4
url_launcher: ^6.2.1
dev_dependencies:
flutter_test:

Loading…
Cancel
Save