There is 1 comment.
 
 
XWiki Platform / cid:jira-generated-image-avatar-e6d8165d-502f-407b-b4e4-5c7c08910575 XWIKI-22611 Open

Copy and pasting images using the browser's "Copy Image" option does not upload an attachment to the wiki but adds an external URL image

 
View issue   ยท   Add comment
 

1 comment

 
cid:jira-generated-image-avatar-3076bb05-4ff3-45ea-870e-57f3cdbe9349 Marius Dumitru Florea on 21/Nov/24 15:56
 

The issue reported on CKEditor side is https://github.com/ckeditor/ckeditor4/issues/3765 (wrongly closed as Won't Fix IMO).

if the html is an image tag and there's a file that was made available by whoever put it on the clipboard, then most probably the file is the content of that image, and thus the CKEditor should favor the fileupload.

While digging in the CKEditor code, I found this code https://github.com/ckeditor/ckeditor4/blob/master/plugins/clipboard/plugin.js#L280-L282

// Only dataTransfer objects containing only file should be considered
// to image pasting (#3585, #3625).
function isFileData( evt, dataTransfer ) {

The two referenced issues are:

Anca Luca as you can see, the fact that the DataTransfer has both an image and some HTML (with an image tag) doesn't mean the user intent was to paste the image. Even if the user has copied a table from an Excel document or some part of a PowerPoint presentation, the HTML put in the clipboard may have an image tag (e.g. an icon in one of the Excel table cells or presentation slides). Checking that the image tag present in the copied HTML points to the same image found in the clipboard (DataTransfer object) is not easy. The image source may be a URL in the HTML so we'd have to fetch that URL and compare with the image from the clipboard.

I'm wondering if it's not better to allow the user to choose the type of paste when we detect that the DataTransfer object has multiple types. WDYT?