kbin-kes icon indicating copy to clipboard operation
kbin-kes copied to clipboard

[MOD] Upload image from clipboard via Ctrl-V binding

Open look997 opened this issue 2 years ago • 3 comments

I want this function in script form.

look997 avatar Jul 14 '23 23:07 look997

If I understood correctly, you want to copy images to your clipboard from some other program, then paste in the comment submission area, and it will insert the image as a thumbnail post?

Cf.

document.onpaste = function(event){
  var items = (event.clipboardData || event.originalEvent.clipboardData).items;
  console.log(JSON.stringify(items)); // will give you the mime types
  for (index in items) {
    var item = items[index];
    if (item.kind === 'file') {
      var blob = item.getAsFile();
      var reader = new FileReader();
      reader.onload = function(event){
        console.log(event.target.result)}; // data url!
      reader.readAsDataURL(blob);
    }
  }
}

aclist avatar Jul 15 '23 22:07 aclist

@aclist Yes, this is exactly the point.

look997 avatar Jul 15 '23 23:07 look997

Understood. I think it is technically possible, but fairly complicated. We will investigate the feasibility.

aclist avatar Jul 15 '23 23:07 aclist