extensions: update docs and release package 0.5.0

pull/1421/head
Jonathan Salmon 2 years ago
parent 9fcd0a7e7a
commit 09f2778acb
  1. 2
      example/macos/Flutter/GeneratedPluginRegistrant.swift
  2. 4
      flutter_quill_extensions/CHANGELOG.md
  3. 33
      flutter_quill_extensions/lib/embeds/builders.dart
  4. 5
      flutter_quill_extensions/lib/embeds/embed_types.dart
  5. 34
      flutter_quill_extensions/lib/flutter_quill_extensions.dart
  6. 19
      flutter_quill_extensions/pubspec.yaml

@ -11,7 +11,6 @@ import gal
import pasteboard import pasteboard
import path_provider_foundation import path_provider_foundation
import url_launcher_macos import url_launcher_macos
import video_player_avfoundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
@ -20,5 +19,4 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin")) PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
} }

@ -1,3 +1,7 @@
## 0.5.0
- Migrated from `gallery_saver` to `gal` for saving images
- Added callbacks for greater control of editing images
## 0.4.1 ## 0.4.1
- Updated dependencies to support image_picker 1.0 - Updated dependencies to support image_picker 1.0

@ -20,13 +20,13 @@ import 'widgets/video_app.dart';
import 'widgets/youtube_video_app.dart'; import 'widgets/youtube_video_app.dart';
class ImageEmbedBuilder extends EmbedBuilder { class ImageEmbedBuilder extends EmbedBuilder {
ImageEmbedBuilder({ const ImageEmbedBuilder({
this.afterRemoveImageFromEditor, this.onImageRemovedCallback,
this.shouldRemoveImageFromEditor, this.shouldRemoveImageCallback,
}); });
final ImageEmbedBuilderAfterRemoveImageFromEditor? afterRemoveImageFromEditor;
final ImageEmbedBuilderShouldRemoveImageFromEditor? final ImageEmbedBuilderOnRemovedCallback? onImageRemovedCallback;
shouldRemoveImageFromEditor; final ImageEmbedBuilderWillRemoveCallback? shouldRemoveImageCallback;
@override @override
String get key => BlockEmbed.imageType; String get key => BlockEmbed.imageType;
@ -136,18 +136,12 @@ class ImageEmbedBuilder extends EmbedBuilder {
final imageFile = File(imageUrl); final imageFile = File(imageUrl);
final shouldRemoveImageEvent = shouldRemoveImageFromEditor; // Call the remove check callback if set
if (await shouldRemoveImageCallback?.call(imageFile) ==
var shouldRemoveImage = true; false) {
if (shouldRemoveImageEvent != null) {
shouldRemoveImage = await shouldRemoveImageEvent(
imageFile,
);
}
if (!shouldRemoveImage) {
return; return;
} }
final offset = getEmbedNode( final offset = getEmbedNode(
controller, controller,
controller.selection.start, controller.selection.start,
@ -158,10 +152,9 @@ class ImageEmbedBuilder extends EmbedBuilder {
'', '',
TextSelection.collapsed(offset: offset), TextSelection.collapsed(offset: offset),
); );
final afterRemoveImageEvent = afterRemoveImageFromEditor;
if (afterRemoveImageEvent != null) { // Call the post remove callback if set
await afterRemoveImageEvent(imageFile); await onImageRemovedCallback?.call(imageFile);
}
}, },
); );
return Padding( return Padding(

@ -45,11 +45,10 @@ class QuillFile {
final Uint8List bytes; final Uint8List bytes;
} }
typedef ImageEmbedBuilderAfterRemoveImageFromEditor = Future<void> Function( typedef ImageEmbedBuilderWillRemoveCallback = Future<bool> Function(
File imageFile, File imageFile,
); );
typedef ImageEmbedBuilderShouldRemoveImageFromEditor = Future<bool> Function( typedef ImageEmbedBuilderOnRemovedCallback = Future<void> Function(
File imageFile, File imageFile,
); );

@ -27,28 +27,26 @@ class FlutterQuillEmbeds {
/// ///
/// [onVideoInit] is called when a video is initialized. /// [onVideoInit] is called when a video is initialized.
/// ///
/// [afterRemoveImageFromEditor] is called when an image /// [onImageRemovedCallback] is called when an image
/// is removed from the editor. /// is removed from the editor. This can be used to
/// By default, [afterRemoveImageFromEditor] deletes the cached /// delete the image from storage, for example:
/// image if it still exists. ///
/// If you want to customize the behavior, pass your own function
/// that handles the removal.
///
/// Example of [afterRemoveImageFromEditor] customization:
/// ```dart /// ```dart
/// afterRemoveImageFromEditor: (imageFile) async { /// (imageFile) async {
/// // Your custom logic here /// final fileExists = await imageFile.exists();
/// // or leave it empty to do nothing /// if (fileExists) {
/// } /// await imageFile.delete();
/// }
/// },
/// ``` /// ```
/// ///
/// [shouldRemoveImageFromEditor] is called when the user /// [shouldRemoveImageCallback] is called when the user
/// attempts to remove an image /// attempts to remove an image
/// from the editor. It allows you to control whether the image /// from the editor. It allows you to control whether the image
/// should be removed /// should be removed
/// based on your custom logic. /// based on your custom logic.
/// ///
/// Example of [shouldRemoveImageFromEditor] customization: /// Example of [shouldRemoveImageCallback] customization:
/// ```dart /// ```dart
/// shouldRemoveImageFromEditor: (imageFile) async { /// shouldRemoveImageFromEditor: (imageFile) async {
/// // Show a confirmation dialog before removing the image /// // Show a confirmation dialog before removing the image
@ -67,13 +65,13 @@ class FlutterQuillEmbeds {
/// ``` /// ```
static List<EmbedBuilder> builders({ static List<EmbedBuilder> builders({
void Function(GlobalKey videoContainerKey)? onVideoInit, void Function(GlobalKey videoContainerKey)? onVideoInit,
ImageEmbedBuilderAfterRemoveImageFromEditor? afterRemoveImageFromEditor, ImageEmbedBuilderOnRemovedCallback? onImageRemovedCallback,
ImageEmbedBuilderShouldRemoveImageFromEditor? shouldRemoveImageFromEditor, ImageEmbedBuilderWillRemoveCallback? shouldRemoveImageCallback,
}) => }) =>
[ [
ImageEmbedBuilder( ImageEmbedBuilder(
afterRemoveImageFromEditor: afterRemoveImageFromEditor, onImageRemovedCallback: onImageRemovedCallback,
shouldRemoveImageFromEditor: shouldRemoveImageFromEditor, shouldRemoveImageCallback: shouldRemoveImageCallback,
), ),
VideoEmbedBuilder(onVideoInit: onVideoInit), VideoEmbedBuilder(onVideoInit: onVideoInit),
FormulaEmbedBuilder(), FormulaEmbedBuilder(),

@ -1,6 +1,6 @@
name: flutter_quill_extensions name: flutter_quill_extensions
description: Embed extensions for flutter_quill including image, video, formula and etc. description: Embed extensions for flutter_quill including image, video, formula and etc.
version: 0.4.1 version: 0.5.0
homepage: https://bulletjournal.us/home/index.html homepage: https://bulletjournal.us/home/index.html
repository: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_extensions repository: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_extensions
@ -14,19 +14,14 @@ dependencies:
flutter_quill: ^7.4.7 flutter_quill: ^7.4.7
gal: ^2.1.1
http: ^1.1.0 http: ^1.1.0
image_picker: ">=1.0.4" image_picker: ">=0.8.5 <2.0.0"
math_keyboard: ">=0.1.8 <0.3.0"
photo_view: ^0.14.0 photo_view: ^0.14.0
video_player: ^2.7.2 universal_html: ^2.2.1
youtube_player_flutter: ^8.1.2 video_player: ^2.7.0
# gallery_saver: ^2.1.1 youtube_player_flutter: ^8.1.1
math_keyboard: ">=0.2.1"
# string_validator: ^1.0.0
universal_html: ^2.2.4
# url_launcher: ^6.1.14
# dio: ^5.3.3
gal: ^2.1.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save