From 8a2283cf274b106c001f035209b457ee389013ab Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Mon, 29 Jul 2019 02:54:20 -0700 Subject: [PATCH] Bail out if there are no files to upload. Without this change, if you either: - Click and drag some text into the markdown editor, or - Copy paste some text into the markdown editor The status bar will get updated to say "Uploading image ...", and will never stop. --- src/js/easymde.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/js/easymde.js b/src/js/easymde.js index 976328a..c675335 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -1669,6 +1669,9 @@ function EasyMDE(options) { * @param [onError] {function} see EasyMDE.prototype.uploadImage */ EasyMDE.prototype.uploadImages = function (files, onSuccess, onError) { + if (files.length === 0) { + return; + } var names = []; for (var i = 0; i < files.length; i++) { names.push(files[i].name); @@ -1688,6 +1691,9 @@ EasyMDE.prototype.uploadImages = function (files, onSuccess, onError) { * @param {FileList} files The files to upload the the server. */ EasyMDE.prototype.uploadImagesUsingCustomFunction = function (imageUploadFunction, files) { + if (files.length === 0) { + return; + } var names = []; for (var i = 0; i < files.length; i++) { names.push(files[i].name);