enable upload via clipboard paste

This commit is contained in:
Lukas Schulze 2024-04-30 15:49:01 +02:00
parent eee497669e
commit 4946750beb

View file

@ -48,6 +48,10 @@ var app = {
$('.alert').slideUp(500); $('.alert').slideUp(500);
}); });
if ($('.dropzone').length > 0) {
app.initClipboardPasteToUpload();
}
new ClipboardJS('.btn-clipboard'); new ClipboardJS('.btn-clipboard');
new Plyr($('#player'), {ratio: '16:9'}); new Plyr($('#player'), {ratio: '16:9'});
@ -252,7 +256,20 @@ var app = {
$('#dropdown-tag-list > a[data-id="' + $tag.data('id') + '"]').remove(); $('#dropdown-tag-list > a[data-id="' + $tag.data('id') + '"]').remove();
} }
}); });
} },
initClipboardPasteToUpload: function() {
document.onpaste = function(event){
if (event.clipboardData || event.originalEvent.clipboardData) {
const items = (event.clipboardData || event.originalEvent.clipboardData).items;
items.forEach((item) => {
if (item.kind === 'file') {
// Add the file to the dropzone instance.
Dropzone.forElement('.dropzone').addFile(item.getAsFile());
}
});
}
}
},
}; };
app.init(); app.init();