diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2022-03-18 17:43:21 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2022-03-18 17:43:21 +0000 |
commit | d6c0759db4f3322d18f970e558920b20aed552af (patch) | |
tree | 3c38af7ec764c05b8bde3d31fd9745cc6e6ae29b /public | |
parent | 5c24c1d63778e4861379694ddc64a965389a9362 (diff) | |
download | redmine-d6c0759db4f3322d18f970e558920b20aed552af.tar.gz redmine-d6c0759db4f3322d18f970e558920b20aed552af.zip |
Use @clipboardData.files@ instead of @clipboardData.items@ to get the images from the clipboard (#36013).
git-svn-id: http://svn.redmine.org/redmine/trunk@21463 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public')
-rw-r--r-- | public/javascripts/attachments.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 9380d1274..3155362fc 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -275,11 +275,10 @@ function copyImageFromClipboard(e) { if (!clipboardData) { return; } if (clipboardData.types.some(function(t){ return /^text\/plain$/.test(t); })) { return; } - var items = clipboardData.items - for (var i = 0 ; i < items.length ; i++) { - var item = items[i]; - if (item.type.indexOf("image") != -1) { - var blob = item.getAsFile(); + var files = clipboardData.files + for (var i = 0 ; i < files.length ; i++) { + var file = files[i]; + if (file.type.indexOf("image") != -1) { var date = new Date(); var filename = 'clipboard-' + date.getFullYear() @@ -288,9 +287,8 @@ function copyImageFromClipboard(e) { + ('0'+date.getHours()).slice(-2) + ('0'+date.getMinutes()).slice(-2) + '-' + randomKey(5).toLocaleLowerCase() - + '.' + blob.name.split('.').pop(); - var file = new Blob([blob], {type: blob.type}); - file.name = filename; + + '.' + file.name.split('.').pop(); + var inputEl = $('input:file.filedrop').first() handleFileDropEvent.target = e.target; addFile(inputEl, file, true); |