mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 01:31:34 +00:00
Added image pasting from clipboard
This commit is contained in:
parent
0258c290ff
commit
6c2eb4e98e
@ -105,6 +105,7 @@ upload.prepareDropzone = function(){
|
||||
},
|
||||
init: function() {
|
||||
this.on('addedfile', function(file) {
|
||||
myDropzone = this;
|
||||
document.getElementById('uploads').style.display = 'block';
|
||||
});
|
||||
}
|
||||
@ -139,6 +140,22 @@ upload.prepareDropzone = function(){
|
||||
|
||||
}
|
||||
|
||||
//Handle image paste event
|
||||
window.addEventListener('paste', function(event) {
|
||||
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
||||
for (index in items) {
|
||||
var item = items[index];
|
||||
if (item.kind === 'file') {
|
||||
var blob = item.getAsFile();
|
||||
console.log(blob.type);
|
||||
var file = new File([blob], "pasted-image."+blob.type.match(/(?:[^\/]*\/)([^;]*)/)[1]);
|
||||
file.type = blob.type;
|
||||
console.log(file);
|
||||
myDropzone.addFile(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.onload = function () {
|
||||
upload.checkIfPublic();
|
||||
};
|
Loading…
Reference in New Issue
Block a user