Merge pull request #277 from Juupaa/drag_and_drop_link

Drag and drop a file checks the extension to either create an image or link
pull/280/head
Jeroen Akkerman 3 years ago committed by GitHub
commit 67592df8bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -811,7 +811,17 @@ function afterImageUploaded(editor, url) {
var stat = getState(cm);
var options = editor.options;
var imageName = url.substr(url.lastIndexOf('/') + 1);
_replaceSelection(cm, stat.image, options.insertTexts.uploadedImage, url);
var ext = imageName.substring(imageName.lastIndexOf('.') + 1);
// Check if media is an image
if (['png', 'jpg', 'jpeg', 'gif', 'svg'].includes(ext)) {
_replaceSelection(cm, stat.image, options.insertTexts.uploadedImage, url);
} else {
var text_link = options.insertTexts.link;
text_link[0] = '[' + imageName;
_replaceSelection(cm, stat.link, text_link, url);
}
// show uploaded image filename for 1000ms
editor.updateStatusBar('upload-image', editor.options.imageTexts.sbOnUploaded.replace('#image_name#', imageName));
setTimeout(function () {

Loading…
Cancel
Save