Fixes #2645 - Insertion of inline pictures does not work, if you copy an image in your Browser
This commit is contained in:
parent
a5d4cd80b2
commit
265d60a65f
1 changed files with 15 additions and 2 deletions
|
@ -284,8 +284,19 @@
|
||||||
|
|
||||||
if (clipboardData && clipboardData.items && clipboardData.items[0]) {
|
if (clipboardData && clipboardData.items && clipboardData.items[0]) {
|
||||||
var imageInserted = false
|
var imageInserted = false
|
||||||
var item = clipboardData.items[0]
|
var item
|
||||||
if (item.kind == 'file' && (item.type == 'image/png' || item.type == 'image/jpeg')) {
|
|
||||||
|
// look for image only if no HTML with textual content is available.
|
||||||
|
// E.g. Excel provides images of the spreadsheet along with HTML.
|
||||||
|
// While some browsers make images available in clipboard as HTML,
|
||||||
|
// sometimes wrapped in multiple nodes.
|
||||||
|
if($(clipboardData.getData('text/html')).text().trim().length == 0) {
|
||||||
|
item = jQuery.grep(clipboardData.items, function(item){
|
||||||
|
return item.kind == 'file' && (item.type == 'image/png' || item.type == 'image/jpeg')
|
||||||
|
})[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item) {
|
||||||
this.log('paste image', item)
|
this.log('paste image', item)
|
||||||
console.log(item)
|
console.log(item)
|
||||||
|
|
||||||
|
@ -326,6 +337,8 @@
|
||||||
|
|
||||||
reader.readAsDataURL(imageFile)
|
reader.readAsDataURL(imageFile)
|
||||||
imageInserted = true
|
imageInserted = true
|
||||||
|
} else {
|
||||||
|
item = clipboardData.items[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (imageInserted) {
|
if (imageInserted) {
|
||||||
|
|
Loading…
Reference in a new issue