You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is going to be a little bit hard to explain, so if something is unclear, please tell me. There is a little conflict between the saving and stopping functions. The saving is not equipped for handling request fails.
So when I initially used editor.stop(true) when the user clicks on "save" but when the request failed, it would clear out the whole "storage" and if I the user were to try to click on "save" again, it would not do anything because now the editor thinks no changes have been made.
So I started using editor.save(true), on "save" and when the request was successful I used editor.stop(true).
The problem is if I use editor.stop(false), it will check the reverts, and give the user the "are you sure you want to revert" message. If I use editor.stop(true), it will trigger save again. which means my whole listener will be triggered again. This is because there is two events called "saved" in the "_EditorApp.prototype.save".
One of them triggers if there are no changes. So I suggest either giving it a different event name or allow the stop function to stop without checking for reverts. So maybe have a second parameter, like editor.stop(false, false); // no save, no revert
I think you're right they probably should have different event names here, perhaps one should be 'passive_saved' and the other just 'saved'.
I'm not sure if this helps but you can also cancel the saved process by listening for the 'save' event (instead of the saved event) and returning false if you don't wish to continue the process.
This is going to be a little bit hard to explain, so if something is unclear, please tell me. There is a little conflict between the saving and stopping functions. The saving is not equipped for handling request fails.
So when I initially used editor.stop(true) when the user clicks on "save" but when the request failed, it would clear out the whole "storage" and if I the user were to try to click on "save" again, it would not do anything because now the editor thinks no changes have been made.
So I started using editor.save(true), on "save" and when the request was successful I used editor.stop(true).
The problem is if I use editor.stop(false), it will check the reverts, and give the user the "are you sure you want to revert" message. If I use editor.stop(true), it will trigger save again. which means my whole listener will be triggered again. This is because there is two events called "saved" in the "_EditorApp.prototype.save".
One of them triggers if there are no changes. So I suggest either giving it a different event name or allow the stop function to stop without checking for reverts. So maybe have a second parameter, like editor.stop(false, false); // no save, no revert
Right now, my quick solution is that I renamed the duplicate event to no_save, and now I can do this:
My trigger
My save function
Cancelling editor when nothing to save
The text was updated successfully, but these errors were encountered: