From 4ae7fc8bc9a370c57834ef71534e7a13e28aa2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20Jourdane?= Date: Wed, 13 Mar 2019 18:48:36 +0100 Subject: [PATCH] Allow openBrowseFileWindow() external call with custom callback --- src/js/easymde.js | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/js/easymde.js b/src/js/easymde.js index ee5ad80..3ff39a0 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -708,9 +708,8 @@ function drawImage(editor) { * @param editor {EasyMDE} The EasyMDE object */ function drawUploadedImage(editor) { - // TODO: Draw the image template with a fake url, ie: '![](importing foo.png...)' - var imageInput = editor.gui.toolbar.getElementsByClassName('imageInput')[0]; - imageInput.dispatchEvent(new MouseEvent('click')); + // TODO: Draw the image template with a fake url? ie: '![](importing foo.png...)' + editor.openBrowseFileWindow(); } /** @@ -1612,20 +1611,17 @@ function EasyMDE(options) { * - drag&drop; * - copy-paste; * - the browse-file window (opened when the user clicks on the *upload-image* icon). - * @param {FileList} files The files to upload the the server. + * @param [onSuccess] {function} see EasyMDE.prototype.uploadImage + * @param [onError] {function} see EasyMDE.prototype.uploadImage */ -EasyMDE.prototype.uploadImages = function(files) { +EasyMDE.prototype.uploadImages = function(files, onSuccess, onError) { var names = []; - var self = this; for(var i=0; i