Project

General

Profile

Actions

Defect #33639

closed

Cannot paste image from clipboard when copying the image from web browsers or some apps

Added by Sergey Zapunidi almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Attachments
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Redmine 4.1.0 gained embedded feature to automatically upload and embed images from clipboard. This works fine unless both text format and image format is present in the clipboard. Unfortunately it's how browsers (Firefox, Chrome) populate clipboard buffer when you copy an image.
To reproduce the problem take Firefox or Chrome browser and right button click on the image and select Copy image. Then open an issue in Redmine, put cursor in the text area, and Paste from clipboard. nothing will happen, while uploading image is expected.
How to fix: go to a clipboard editor (I used CopyQ), you will see image/png and text/html formats. Delete the text/html part. Now redmine will accept image from clipboard.
Another indirect approach is to pasting image to gimp and recopying it again from there to clipboard (text part will drop on the way)

The problem lies within JS function copyImageFromClipboard(e).

function copyImageFromClipboard(e) {
  if (!$(e.target).hasClass('wiki-edit')) { return; }
  var clipboardData = e.clipboardData || e.originalEvent.clipboardData
  if (!clipboardData) { return; }
  if (clipboardData.types.some(function(t){ return /^text/.test(t); })) { return; }
...
}

The last cited line finds text part and returns from function. I am not that far familiar with redmine to suggest a patch, but other applications have no problem pasting images copyed from a browser. So there is a way to detect the nature of clipboard contents.


Related issues

Related to Redmine - Defect #32469: Text copied from some applications such as MS Office and LibreOffice is pasted as an image in addition to plain textClosedGo MAEDA

Actions
Actions

Also available in: Atom PDF