Fix status bar.

pull/101/head
Jeroen van Oorschot 5 years ago
parent bbf3340581
commit c54168a656

@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Merge 2.7.0 with https://github.com/Ionaru/easy-markdown-editor/pull/71 @jeroenvo - Merge 2.7.0 with https://github.com/Ionaru/easy-markdown-editor/pull/71 @jeroenvo
- replace MouseEvent(click) with .click() for IE compat - replace MouseEvent(click) with .click() for IE compat
- Fix status bar update when dragging but not dropping - Fix status bar update when dragging but not dropping
- - Fix progressbar
## [2.7.0] - 2019-07-13 ## [2.7.0] - 2019-07-13
### Added ### Added

@ -1956,7 +1956,7 @@ EasyMDE.prototype.clearAutosavedValue = function () {
EasyMDE.prototype.openBrowseFileWindow = function(onSuccess, onError) { EasyMDE.prototype.openBrowseFileWindow = function(onSuccess, onError) {
var self = this; var self = this;
var imageInput = this.gui.toolbar.getElementsByClassName('imageInput')[0]; var imageInput = this.gui.toolbar.getElementsByClassName('imageInput')[0];
imageInput.click() //dispatchEvent(new MouseEvent('click')); // replaced with click() for IE11 compatibility. imageInput.click(); //dispatchEvent(new MouseEvent('click')); // replaced with click() for IE11 compatibility.
function onChange(event) { function onChange(event) {
self.uploadImages(event.target.files, onSuccess, onError); self.uploadImages(event.target.files, onSuccess, onError);
imageInput.removeEventListener('change', onChange); imageInput.removeEventListener('change', onChange);
@ -1996,16 +1996,15 @@ EasyMDE.prototype.uploadImage = function(file, onSuccess, onError) {
var formData = new FormData(); var formData = new FormData();
formData.append('image', file); formData.append('image', file);
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();
request.open('POST', this.options.imageUploadEndpoint); // TODO insert csrf token in post ajax request
request.send(formData); request.upload.onprogress = function (event) {
request.onprogress = function (event) {
if (event.lengthComputable) { if (event.lengthComputable) {
// FIXME: progress doesn't work well
var progress = '' + Math.round((event.loaded * 100) / event.total); var progress = '' + Math.round((event.loaded * 100) / event.total);
self.updateStatusBar('upload-image', self.options.imageTexts.sbProgress.replace('#file_name#', file.name).replace('#progress#', progress)); self.updateStatusBar('upload-image', self.options.imageTexts.sbProgress.replace('#file_name#', file.name).replace('#progress#', progress));
} }
}; };
request.open('POST', this.options.imageUploadEndpoint);
request.onload = function () { request.onload = function () {
try { try {
@ -2033,6 +2032,9 @@ EasyMDE.prototype.uploadImage = function(file, onSuccess, onError) {
+ event.target.status + ' (' + event.target.statusText + ')'); + event.target.status + ' (' + event.target.statusText + ')');
onError(self.options.errorMessages.importError); onError(self.options.errorMessages.importError);
}; };
request.send(formData);
}; };
EasyMDE.prototype.createSideBySide = function () { EasyMDE.prototype.createSideBySide = function () {

Loading…
Cancel
Save