visual-space / visual-editor

Rich text editor for Flutter based on Delta format (Quill fork)
MIT License
290 stars 46 forks source link

Embeds - Callback when an Embed is removed #44

Closed adrian-moisa closed 2 years ago

adrian-moisa commented 2 years ago

When authors delete content that uses custom embeds we need to cleanup any leftovers entries from the app database. We don't want to leave behind associated data from a custom embed. At the moment I believe that it would be nice to expose an additional callback on the EditorController such that developers can provide their own implementation of how to deal with the situation. Though one concern stands out. We don't want to invoke such a callback no sooner than the author has saved the document. I'm open to receive any ideas of how you'd like this implementation to work. At the moment priority is low for this feature. There are far bigger concerns to be dealt with.

kairan77 commented 2 years ago

I believe controller already has a listener which you can subscribe to listen to all events, if someone needs to maintain consistency realtime, he probably want to maintain it for other events as well.

Personally, I leave all rectifications on refs with the backend to when the editor is done and closing. This need to be done anyway. Also when an article is deleted or being deleted due to cascade outside of the editor, this also need to be done. For me they all go through the same code path. So i don't need to manage those refs during editing.

adrian-moisa commented 2 years ago

The former change notifier on the controller is not ideal for such a scenario. that one emits on every single change. It does not fit in the above stated usecase. Though you are correct in stating that such cleanups can be done as part of the code that deals with saving the doc on the server side. So I think this is a non issue. I'll close.