can paste images directly from clipboard

v1.18.x
Baris Soner Usakli 11 years ago
parent e671f0343e
commit 2d87ba534c

@ -94,8 +94,9 @@ define(['taskbar'], function(taskbar) {
var postContainer = $(composerTemplate[0]); var postContainer = $(composerTemplate[0]);
if(config.allowFileUploads || config.imgurClientIDSet) if(config.allowFileUploads || config.imgurClientIDSet) {
initializeFileReader(post_uuid); initializeFileReader(post_uuid);
}
var postData = composer.posts[post_uuid], var postData = composer.posts[post_uuid],
titleEl = postContainer.find('.title'), titleEl = postContainer.find('.title'),
@ -540,6 +541,14 @@ define(['taskbar'], function(taskbar) {
} }
return false; return false;
}); });
$(window).off('paste').on('paste', function(event) {
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
if(items && items.length) {
var blob = items[0].getAsFile();
loadFile(post_uuid, blob);
}
});
} }
} }
@ -552,7 +561,7 @@ define(['taskbar'], function(taskbar) {
var matches = this.result.match(regex); var matches = this.result.match(regex);
var fileData = { var fileData = {
name: file.name, name: file.name || '',
data: matches[1] data: matches[1]
}; };

Loading…
Cancel
Save