From aa39672e4eb5e7da2f546a4ea6e88a1195e744c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20Jourdane?= Date: Mon, 4 Mar 2019 18:10:46 +0100 Subject: [PATCH] [wip upload-image] After image upload, insert image markdown template with uploaded image url --- src/js/easymde.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/js/easymde.js b/src/js/easymde.js index c7d2b47..66d99b1 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -188,7 +188,11 @@ function createImageInput(editor) { imageInput.style.opacity = 0; imageInput.addEventListener('change', function(event) { for(var i=0; i= options.imageMaxSize) { var units = options.imageTexts.sizeUnits.split(','); alert(options.text.errorImageTooBig @@ -1186,9 +1207,9 @@ function uploadImage(file, options) { request.onload = function () { if(this.status === 200) { - console.log('image url: ' + window.location.origin + '/' + this.responseText); + onSuccess(window.location.origin + '/' + this.responseText); } else { - console.log('EasyMDE: Error ' + this.status + ' while importing image: ' + this.statusText.toString()); + onError(this.status, this.statusText.toString()); } }; } @@ -1430,6 +1451,8 @@ var toolbarBuiltInButtons = { var insertTexts = { link: ['[', '](#url#)'], image: ['![](', '#url#)'], + uploadedImage: ['![](#url#)', ''], + // uploadedImage: ['![](#url#)\n', ''], // TODO: New line insertion doesn't work here. table: ['', '\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n'], horizontalRule: ['', '\n\n-----\n\n'], };