Add copy and paste for images

Switch comparison operator to ===

Move to stricter parsing of clipboard items
pull/749/head
beejaygee 8 years ago
parent 1e498294e0
commit 76c165a10a

@ -35,7 +35,8 @@
'click .choose-file': 'open', 'click .choose-file': 'open',
'drop': 'openDropped', 'drop': 'openDropped',
'dragover': 'showArea', 'dragover': 'showArea',
'dragleave': 'hideArea' 'dragleave': 'hideArea',
'paste': 'onPaste'
}, },
open: function(e) { open: function(e) {
@ -281,6 +282,19 @@
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
this.$el.removeClass('dropoff'); this.$el.removeClass('dropoff');
},
onPaste: function(e) {
var items = e.originalEvent.clipboardData.items;
var imgBlob = null;
for (var i = 0; i < items.length; i++) {
if (items[i].type.split('/')[0] === 'image') {
imgBlob = items[i].getAsFile();
}
}
if (imgBlob !== null) {
this.file = imgBlob;
this.previewImages();
}
} }
}); });
})(); })();

Loading…
Cancel
Save