To implement image upload to the PageDown markdown editor, I have modified some code about the editor.
Markdown.Editor.js
var defaultsStrings = { imagedialog : "< input id='image' type='file' />" }
When select a picture and then click ok button to sent ajax request. It can return image path.
var okButton = doc.createElement("input");
okButton.type = "button";
okButton.onclick = function () {
var data = new FormData();
data.append('file', $( '#image' )[0].files[0] );
$.ajax({
url: 'uploadFile',
data: data,
processData: false,
contentType: false,
type: 'POST',
success: function ( data ) {
alert(path);
}
});
return close(false);};
How to preview the image in the editor preview area?