michelson / dante2

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

How can i custom request with graphql or fetch ? #137

Closed sessionboy closed 5 years ago

sessionboy commented 5 years ago

hi! Each update triggers a request, but I don't want that; I want the freedom to get the editor's content and submit the data using custom requests. But it doesn't seem to be right now.

astr0junk commented 5 years ago

@sessionboy if i correctly understand Dante code the problem is that Dante do not pass DraftJS (under the hood) onChange event which contains editableContent state of editor instanse=(

astr0junk commented 5 years ago

@sessionboy maybe this will helps

data_storage="{ interval: 1500, url: '/store', method: 'POST', save_handler: (editorContext, content) => { // make custom request }, }"

sessionboy commented 5 years ago

@sessionboy maybe this will helps

data_storage="{ interval: 1500, url: '/store', method: 'POST', save_handler: (editorContext, content) => { // make custom request }, }"

thank you, but that's going to keep sending requests, and I don't need to do that, and my backend API is graphql, It's not appropriate

michelson commented 5 years ago

Hi @sessionboy . if you keep the data_storage.url and data_storage.save_handler with a null value the automatic store will not be triggered and implement your own logic.

hint: check the emitSerializedOutput() function file to get the editor content to implement your GQ post

michelson commented 5 years ago

@sessionboy I've released the 0.5.0-rc7 version it supports a onChange callback that returns the entire instance of the editor, examples added in https://michelson.github.io/dante2/#/src-index (search for onChange callback)

thanks for report this. reopen this issue if needed