From 3cb4a817f2a3c006c2c0f521a8fd61e862476b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20Jourdane?= Date: Tue, 5 Mar 2019 11:44:31 +0100 Subject: [PATCH] [wip upload-image] Allow image upload with drag&drop --- src/js/easymde.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/js/easymde.js b/src/js/easymde.js index cb25a6b..1399e59 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -1624,6 +1624,37 @@ function EasyMDE(options) { if (options.initialValue && (!this.options.autosave || this.options.autosave.foundSavedValue !== true)) { this.value(options.initialValue); } + + if (options.uploadImage) { + var self = this; + + this.codemirror.on('dragenter', function(cm, event) { + event.stopPropagation(); + event.preventDefault(); + }); + + this.codemirror.on('dragover', function(cm, event) { + event.stopPropagation(); + event.preventDefault(); + }); + + this.codemirror.on('drop', function(cm, event) { + event.stopPropagation(); + event.preventDefault(); + + var dt = event.dataTransfer; + var files = dt.files; + console.log(files); + + for(var i=0; i