jodit / jodit-react

React wrapper for Jodit
MIT License
354 stars 118 forks source link

Error when upload image with ctrl+v #220

Open igorcenzi opened 1 year ago

igorcenzi commented 1 year ago

Hey there! I'm using jodit-react 1.3.32. When I use the upload button it works pretty well, the error occurs when I ctrl+v an image, the function defaultHandlerSuccess is being called but dispatch this error: image

I tried to find out what could cause this error and I console.log "this" to see what "this" were in each case. The first one is "this" when I uploaded using the button: image

The second one is when I used ctrl+v: image

The image is sent to the backend in both cases, the problem is "this" has no selection.insertImage and I dont know how to change.

That's my uploader options: uploader: { url: myURLHere, isSuccess: function (resp) { return resp; }, buildData: function (data) { const formData = new FormData(); formData.append('image', data.getAll('files[0]')[0]); formData.append( 'article_id', 'd75d3749-ae18-4523-90d7-4770c5420a75' ); return formData; }, defaultHandlerSuccess: function (data) { console.log(this) this.selection.insertImage(data.image); }, process: function (resp) { return { image: resp.image, }; }, error: function (e) { console.log(e); this.e.fire('errorMessage', [e.getMessage(), 'error', 4000]); }, },