flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

Deleting added images or videos leads to "storage leaks"

Open abcxcba opened this issue 3 years ago • 21 comments

Deleting an image in the editor only removes the URL, there is no way to delete the corresponding file. Think about adding and deleting a 10M size image 100 times in the editor. If the image is just left there, it will take up 1G storage space, “storage leak? ”

abcxcba avatar Jul 19 '22 09:07 abcxcba

Please submit a PR to fix it.

singerdmx avatar Jul 21 '22 03:07 singerdmx

I think adding a remove callback function should solve the problem, but I don't know where to add it. There are a lot of flutter-quill files and they often import each other, which seems a bit messy (sorry to say that), and I know very little about flutter-quill at the moment, so I can't submit a PR.

abcxcba avatar Jul 21 '22 08:07 abcxcba

You are using keyboard to delete the image/video?

singerdmx avatar Jul 21 '22 08:07 singerdmx

image If you are using the button, it is easy to add callback

singerdmx avatar Jul 21 '22 08:07 singerdmx

If you are talking about using keyboard, it is more complicated since we need to update keyboard listener

singerdmx avatar Jul 21 '22 08:07 singerdmx

check out lib/src/widgets/keyboard_listener.dart

singerdmx avatar Jul 21 '22 08:07 singerdmx

Actually no need for all these. You can just track the changes and figure out if the user deletes video/image

image

singerdmx avatar Jul 21 '22 08:07 singerdmx

Yes, I am using the keyboard to delete. Thank you very much for your reply, your reply was very helpful to me. I'll look into it.

Also it would be perfect if it provided onImagePickCallback like QuillToolbar.basic provides onImagePickCallback? onImageRemoveCallback would be perfect and the video would be similar.

I'm sure others will encounter this problem as well. I found a previous discussion:#600

abcxcba avatar Jul 21 '22 09:07 abcxcba

I think we need more generalized system here. What about add some callback to the Embeddable itself?

DmitrySboychakov avatar Jul 21 '22 09:07 DmitrySboychakov

I think we need more generalized system here. What about add some callback to the Embeddable itself?

I do agree with you. I think all embedded content that is not directly included in the document needs a remove callback function, just like the dispos() function to clean up unused resources. This is a very essential feature.

abcxcba avatar Jul 21 '22 10:07 abcxcba

Yes, true. But you also want to listen to DELETE key, right?

singerdmx avatar Jul 21 '22 16:07 singerdmx

Yes, true. But you also want to listen to DELETE key, right?

Yes, the DELETE key, unlike other character keys, represents the delete function for all objects in a document, whether they are characters or pictures, videos, etc.

abcxcba avatar Jul 22 '22 06:07 abcxcba

There may be a better way or a central way to deal with this. Add a new delete rule to subscribe any event you are interested. image

singerdmx avatar Jul 22 '22 06:07 singerdmx

This can intercept all delete operation happened

singerdmx avatar Jul 22 '22 06:07 singerdmx

This can intercept all delete operation happened

Yes, this is the best way 👍

abcxcba avatar Jul 22 '22 06:07 abcxcba

The name can be something like: EmbedDeletionCallbackRule. Of course we need to determine if it is embed being deleted.

singerdmx avatar Jul 22 '22 06:07 singerdmx

Depending on how embed is considered, I think all objects displayed in the editor can be considered embed units, just that their characteristics are different.

Characters, images, videos, and so on, are all embeded units inside the editor, so that all the content inside the editor is conceptually unified.

String is the connection of characters, characters belong to connectable objects, images, and videos can not be connected, perhaps Emoji, like characters, belong to connectable units.

If so it can be named DeletionCallbackRule , in which all deletions are handled.

Of course, if you treat characters as general objects, pictures, videos, files, etc. as embedded objects, EmbedDeletionCallbackRule is more appropriate.

abcxcba avatar Jul 22 '22 07:07 abcxcba

In order to clarify Embed, I recorded a video and please check it out https://youtu.be/pI5p5j7cfHc

This should help you.

singerdmx avatar Jul 22 '22 08:07 singerdmx

OK

abcxcba avatar Jul 22 '22 08:07 abcxcba

@abcxcba are you working on a change for this or do you need help?

singerdmx avatar Jul 25 '22 05:07 singerdmx

@abcxcba are you working on a change for this or do you need help?

I recently needed to stop and work on other issues and wasn't sure how soon I could keep coming back to this.

abcxcba avatar Jul 26 '22 07:07 abcxcba

We have added a callback for onRemove in flutter_quill_extensions

This issue has been fixed, if you still facing this issue or any others, feel free to contact us on GitHub

EchoEllet avatar Oct 25 '23 21:10 EchoEllet