michelson / dante2

A complete rewrite of dante editor in draft-js
https://michelson.github.io/dante2/
Other
910 stars 121 forks source link

dispatchChangesToSave should call xhr handlers #6

Closed bbaughn closed 7 years ago

bbaughn commented 7 years ago

It would be great if calling dispatchChangesToSave could result in the same xhr handlers (before_handler, success_handler) being called so it's possible to keep the user updated on the article's status just as it is with automatic saving.

michelson commented 7 years ago

I think it already does that

El 20 dic. 2016 5:40 PM, "bbaughn" notifications@github.com escribió:

It would be great if calling dispatchChangesToSave could result in the same xhr handlers (before_handler, success_handler) being called so it's possible to keep the user updated on the article's status just as it is with automatic saving.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/michelson/dante2/issues/6, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAuyEkTRuFRePLAeDGWAHvjk6r_XCgjks5rKD0jgaJpZM4LSRuA .

bbaughn commented 7 years ago

Ah, I'm not seeing that behavior. Typing in the editor results in those functions being called but calling dispatchChangesToSave does not seem to.

michelson commented 7 years ago

if you have no changes in your content the store will not take place,

when dispatchChangesToSave is called the store behavior will call checkforStore function which will exit if there are no changes.

look at the save_content.coffee file on line 38. maybe you could add a PR which separate that function in 2 functions one for the return logic and another for save in order to call the save without the condition.

I could add this feature in the next days if you can't, (complicated week)

michelson commented 7 years ago

We have detached the check for changes from the store function which hits the server, so now you can call save function directly. use version 0.3.2

bbaughn commented 7 years ago

Could you give a quick example of using "save"? window.main_editor.editor.save()? On the Dante editor object I see "save" as a SaveBehavior object, not as a function.

michelson commented 7 years ago

yup, the save on editor references to SaveBehavior so you must call the save function on it, it's confusing but it works. in the demo page you can execute this in console: editor.editor.save.save

by the way, Dante2 provides an automatic save when changes on text are detected, so use this feature only when you really need to force the storage.