Add copy and paste for images
Switch comparison operator to === Move to stricter parsing of clipboard items
This commit is contained in:
parent
1e498294e0
commit
76c165a10a
1 changed files with 15 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue