singerdmx / flutter-quill

Rich text editor for Flutter
https://pub.dev/packages/flutter_quill
MIT License
2.6k stars 840 forks source link

onImageRemovedCallback not called when Image is Removed with a keystroke(backspace) #2113

Open Uche01 opened 3 months ago

Uche01 commented 3 months ago

Is there an existing issue for this?

The question

I am trying to delete an image from file system when an image is removed from the editor. Overriding the callback onImageRemovedCallback appears to work only when image is removed by clicking on the 'Remove' option on the image actions popup. However, when image is removed by clicking backspace key on the keyboard, the callback is not fired. How can I fix this?

Here is the call back code:

QuillEditorImageEmbedConfigurations imageEmbedConfigurations = QuillEditorImageEmbedConfigurations(  
    onImageRemovedCallback: (imageUrl) async {
      final file = File(imageUrl);
      if (await file.exists()) {
        await file.delete();
        print('File deleted successfully');
      } else {
        print('File does not exist');
      }
    },
  );
CatHood0 commented 3 months ago

You can create a custom Rule that extends from DeleteRule and verify if the content that will be removed is an image (by now is the solution that i can think)

CatHood0 commented 2 months ago

By now we don't have plan to add this by now. Probably in future releases this will be fixed (at this moment we need to take more attention to issues that are affecting to the perfomance and the stability of the package).

EchoEllet commented 2 months ago

There are similar issues related to this, will reopen it since I do plan on a solution when I have the time, should not make changes directly to flutter_quill for this fix.

at this moment we need to take more attention to issues that are affecting to the perfomance and the stability of the package

This is why a fix will take a while before introducing it.