Image file drag and drop populates the editor with garbage text


I am attempting to upload an image using the html 5 drag and drop functionality. When I drop the image on the CodeMirror editor the content for the image seems to be added to the editable area - like the contents of the file are being dumped.

The screenshot below illustrates this - so how do I prevent this from happening? I am creating a simple example app that used CodeMirror with the MeteorJS framework. I can listen for and intercept drop events inside my template, but I don’t want it doing this.


Are you using the latest version? That one should detect binary data and refuse to drop it.

I will check - I am using the version bundled with the MeteorJS package here -

Was the above a known issue with an older version of CodeMirror?

It looks like the version of CodeMirror in this package is almost a year out of date.

The binary data check was only added in the very last version of CodeMirror (released two weeks ago), so yes, if you’re using an old version you’ll see this problem.

Ok. I am forking the meteorjs package and adding the latest version of CodeMirror to it. Thanks for your help.