Skip to content

Commit

Permalink
[extensions] Add the image source to to onImageClicked
Browse files Browse the repository at this point in the history
this lets devs know which image has been clicked
  • Loading branch information
brightknight08 committed Dec 29, 2023
1 parent 4f50924 commit 7c6d75f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ class QuillEditorImageEmbedBuilder extends EmbedBuilder {
QuillSharedExtensionsConfigurations.get(context: context)
.imageSaverService;
return GestureDetector(
onTap: configurations.onImageClicked ??
() => showDialog(
onTap: configurations.onImageClicked != null
? () => configurations.onImageClicked!(imageSource)
: () => showDialog(
context: context,
builder: (_) => FlutterQuillLocalizationsWidget(
child: ImageOptionsMenu(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:io' show File;

import 'package:flutter/foundation.dart' show VoidCallback;
import 'package:flutter_quill/extensions.dart';
import 'package:meta/meta.dart' show immutable;

Expand Down Expand Up @@ -103,8 +102,9 @@ class QuillEditorImageEmbedConfigurations {

/// What should happen when the image is pressed?
///
/// By default will show `ImageOptionsMenu` dialog
final VoidCallback? onImageClicked;
/// By default will show `ImageOptionsMenu` dialog. If you want to handle what happens
/// to the image when it's clicked, you can pass a callback to this property.
final void Function(String imageSource)? onImageClicked;

static ImageEmbedBuilderOnRemovedCallback get defaultOnImageRemovedCallback {
return (imageUrl) async {
Expand Down

0 comments on commit 7c6d75f

Please sign in to comment.