Hi Daniel, let us check with some more technical colleagues and get back to you.
Detect if unsaved work is present
I'm using the Bee plugin email editor in the context of an Angular app. I would like to know if there is a way that I can query the editor API to see if the user has unsaved changes. Currently the editor offers an option to prompt the user when trying to close/leave the page if there are unsaved changes, however I want to extend this functionality to also show the same prompt if the user tries to go to another page within the angular app.
Is this possible?
Please sign in to leave a comment.
Hi Daniel, I checked with the dev team and they reported that there is no way to check if a user has unsaved work natively in the plugin because the plugin is "state less".
In BEE Pro, for example, we use a combination of local storage information and autosave to determine if a user has any unsaved work.
I wonder then how does the plugin prompt you when you have unsaved changes and try to close the page or navigate away? There is a configuration option to prompt a user if they are about to loose unsaved work when they try to close the browser or navigate to a different page. Is it possible to extend that functionality somehow, or as part of a future release, so that it can be accessed via the plugin's API?
Hi Daniel, the preventClose parameter may help you when your users click on the browsers back button or alike (something completely out of your control).
In BEE Pro, and in case the user uses your application nav to close editing, it's not the plugin but the BEE Pro application what check changes and trigger an alert with this workflow:
1. When the user decides to abandon editing, the app asks the plugin for the JSON (saveAsTemplate)
2. The application makes a diff between the given JSON and the starting JSON
3. The application triggers (or not) a confirm dialog
A limit to give a general approach within the preventClose parameter is that the plugin can trigger the dialog on Window events, like browsing away, but not with application events.
Hope this helps.
Thanks for the detailed explanation. Definitely something to consider for a future release if possible.
Are there any developments for this post? i'm interrested
@Souhir, you can still use the method outlined by Guillermo, but we now have an "onChange" callback that reports every change made by the user: