2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-07-12 04:24:28 -06:00

[wip upload-image] make onError optionnal

This commit is contained in:
Nathanaël Jourdane 2019-03-11 18:17:29 +01:00
parent 8eff45f7a0
commit 5fa549d3b3

View File

@ -1623,8 +1623,6 @@ EasyMDE.prototype.uploadImages = function(files) {
this.uploadImage(files[i], function onSuccess(imageUrl) {
afterImageUploaded(self, imageUrl);
}, function onFailure(error) {
self.options.errorCallback(error);
});
}
this.updateStatusBar('upload-image', self.options.imageTexts.sbOnDrop.replace('#images_names#', names.join(', ')));
@ -1910,10 +1908,13 @@ EasyMDE.prototype.clearAutosavedValue = function () {
* @param file {File} The image to upload, as a HTML5 File object (https://developer.mozilla.org/en-US/docs/Web/API/File)
* @param onSuccess {function} A callback function to execute after the image has been successfully uploaded, with one parameter:
* - url (string): The URL of the uploaded image.
* @param onError {function} A callback function to execute when the image upload fails, with one parameter:
* @param [onError] {function} A callback function to execute when the image upload fails, with one parameter:
* - error (string): the detailed error to display to the user (based on messages from options.errorMessages).
*/
EasyMDE.prototype.uploadImage = function(file, onSuccess, onError) {
var self = this;
onError = onError || self.options.errorCallback;
function fillErrorMessage(errorMessage) {
var units = self.options.imageTexts.sizeUnits.split(',');
return errorMessage
@ -1931,7 +1932,6 @@ EasyMDE.prototype.uploadImage = function(file, onSuccess, onError) {
var request = new XMLHttpRequest();
request.open('POST', this.options.imageUploadEndpoint);
request.send(formData);
var self = this;
request.onprogress = function (event) {
if (event.lengthComputable) {