From 33683048d0f5909ed62e1a1a1ba8819d2b4d9887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20Jourdane?= Date: Mon, 4 Mar 2019 17:05:22 +0100 Subject: [PATCH] [wip upload-image] Add image icon to open the browse-file window --- src/js/easymde.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/js/easymde.js b/src/js/easymde.js index bf59082..7fdaeed 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -170,6 +170,30 @@ function createTooltip(title, action, shortcuts) { return tooltip; } +/** + * Create the input element (ie. ) used to open the + * browse-file window in order to allow the user to select an image to be + * imported to the server. Used among with the 'import-image' icon. + * @param editor {Object} the EasyMDE object + * @returns Node The created input DOM element. + */ +function createImageInput(editor) { + var imageInput = document.createElement('input'); + imageInput.className = 'imageInput'; + imageInput.type = 'file'; + imageInput.multiple = true; + imageInput.name = 'image'; + imageInput.accept = editor.options.imageAccept; + imageInput.style.display = 'none'; + imageInput.style.opacity = 0; + imageInput.addEventListener('change', function(event) { + for(var i=0; i