Prevent pasting images from word/excel/numbers which is normally text or html. Just past images if first item is really an image.
This commit is contained in:
parent
863e43e107
commit
33cbbed774
1 changed files with 23 additions and 24 deletions
|
@ -200,12 +200,12 @@
|
|||
}
|
||||
|
||||
var clipboardData = e.clipboardData || e.originalEvent.clipboardData
|
||||
if (clipboardData && clipboardData.items) {
|
||||
if (clipboardData && clipboardData.items && clipboardData.items[0]) {
|
||||
var imageInserted = false
|
||||
jQuery.each(clipboardData.items, function(index, item){
|
||||
console.log(index, item)
|
||||
if (item.kind == 'file' && item.type == 'image/png') {
|
||||
var item = clipboardData.items[0]
|
||||
if (item.kind == 'file' && (item.type == 'image/png' || item.type == 'image/jpeg')) {
|
||||
_this.log('paste image', item)
|
||||
console.log(item)
|
||||
|
||||
var imageFile = item.getAsFile()
|
||||
var reader = new FileReader()
|
||||
|
@ -229,7 +229,6 @@
|
|||
reader.readAsDataURL(imageFile)
|
||||
imageInserted = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (imageInserted) {
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue