Avoid handling clipboard data item if it is not file type
This commit is contained in:
parent
bb9a5772bc
commit
7eb96eb3cb
|
@ -3110,19 +3110,15 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||||
*/
|
*/
|
||||||
function addClipboardEventHandler() {
|
function addClipboardEventHandler() {
|
||||||
$(document).on('paste', function (event) {
|
$(document).on('paste', function (event) {
|
||||||
if (TopNav.isAttachmentReadonly()) {
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
const items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
||||||
for (let i = 0; i < items.length; ++i) {
|
const lastItem = items[items.length - 1];
|
||||||
if (items[i].kind === 'file') {
|
if (lastItem.kind === 'file') {
|
||||||
//Clear the file input:
|
if (TopNav.isAttachmentReadonly()) {
|
||||||
$fileInput.wrap('<form>').closest('form').get(0).reset();
|
event.stopPropagation();
|
||||||
$fileInput.unwrap();
|
event.preventDefault();
|
||||||
|
return false;
|
||||||
readFileData(items[i].getAsFile());
|
} else {
|
||||||
|
readFileData(lastItem.getAsFile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue