Added possibility to paste an image from the clipboard

This commit is contained in:
thororm 2017-05-13 21:43:32 +02:00
parent 838ca3d38e
commit 24aea957b3
4 changed files with 23 additions and 5 deletions

View file

@ -2298,6 +2298,23 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
});
};
/**
* Attaches the clipboard attachment handler to the page.
* @returns {undefined}
*/
me.addClipboardEventHandler = function () {
document.addEventListener("paste",
function (event) {
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
for (var i in items) {
var item = items[i];
if (item.kind === 'file') {
me.readFileData(item.getAsFile());
}
}
}, false);
};
/**
* initiate
*
@ -2315,6 +2332,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
me.$fileInput = $('#file');
me.addDragDropHandler();
me.addClipboardEventHandler();
}
}