Is there any way we can have access to a hook that executes when a custom module block is deleted?
Example: I was creating a module that uploads a file in editor.js ( similar to image module ). when my block gets removed from the editor I need a hook so that I can remove the file from the server.
If you're worried about storage space, I'd suggest that you create a backend job that periodically checks for files that are not in use and then deletes those, rather than relying on "delete" requests from the frontend. It's common enough to have users not move the already created blocks and instead re-upload the same picture multiple times, which could then result in problems, especially if you use the actual filename when you store the files, rather than auto-generating new ones. Also, network issues could result in "dead" files on the server, which would require a job to delete anyway.
That said, I'm not against this feature request. Just wanted to give my thoughts on the approach.
@lindelius I am sorry but this is my use case when a user removes the block I need to delete the file
You can use removed hook https://editorjs.io/tools-api#lifecycle-hooks
If you're worried about storage space, I'd suggest that you create a backend job that periodically checks for files that are not in use and then deletes those, rather than relying on "delete" requests from the frontend. It's common enough to have users not move the already created blocks and instead re-upload the same picture multiple times, which could then result in problems, especially if you use the actual filename when you store the files, rather than auto-generating new ones. Also, network issues could result in "dead" files on the server, which would require a job to delete anyway.
That said, I'm not against this feature request. Just wanted to give my thoughts on the approach.
i think it will affect on server performance
Most helpful comment
You can use
removedhook https://editorjs.io/tools-api#lifecycle-hooks