Project

General

Profile

Feature #3816 » attach_clipboard_image.patch

Takenori TAKAKI, 2019-02-14 12:22

View differences:

public/javascripts/attachments.js
255 255
  $("input.deleted_attachment").change(function(){
256 256
    $(this).parents('.existing-attachment').toggleClass('deleted', $(this).is(":checked"));
257 257
  }).change();
258
  $(".wiki-edit").on('paste', function(e){
259
    var items = e.originalEvent.clipboardData.items;
260
    for (var i = 0 ; i < items.length ; i++) {
261
      var item = items[i];
262
      if (item.type.indexOf("image") != -1) {
263
        var blob = item.getAsFile();
264
        var urlObj = window.URL || window.webkitURL;
265
        var filename = 'paste-' + urlObj.createObjectURL(blob).split('/').pop() + '.' + blob.name.split('.').pop();
266
        var file = new File([blob], filename, {type: blob.type});
267
        var inputEl = $('input[name="attachments[dummy][file]"]');
268
        handleFileDropEvent.target = e.target;
269
        addFile(inputEl, file, true);
270
      }
271
    }
272
  });
258 273
});
(20-20/24)