Project

General

Profile

Actions

Defect #32469

closed

Text copied from some applications such as MS Office and LibreOffice is pasted as an image in addition to plain text

Added by Takenori TAKAKI about 5 years ago. Updated almost 5 years ago.

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

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

When copying text from an Office product (e.g. MS Office, LibreOffice) and pasting it on redmine,
The image is pasted after the text. as shown below.

In this case, Clipboard contains multiple data (text and image), so both are pasted(attached) from clipboard.

To solve this problem, I propose the following change.
(Does not execute JS function ’copyImageFromClipboard’, if Clipboard contains text data)

index b856ff415..4a33daf55 100644
--- a/public/javascripts/attachments.js
+++ b/public/javascripts/attachments.js
@@ -255,6 +255,7 @@ function copyImageFromClipboard(e) {
   if (!$(e.target).hasClass('wiki-edit')) { return; }
   var clipboardData = e.clipboardData || e.originalEvent.clipboardData
   if (!clipboardData) { return; }
+  if (clipboardData.types.some(t => /^text/.test(t))) { return; }

   var items = clipboardData.items
   for (var i = 0 ; i < items.length ; i++) {

Files

duplicate-pasting.png (81.9 KB) duplicate-pasting.png Takenori TAKAKI, 2019-11-13 16:07
duplicate-pasting.png (81.8 KB) duplicate-pasting.png Takenori TAKAKI, 2019-11-13 16:19

Related issues

Related to Redmine - Feature #3816: Allow pasting screenshots from clipboardClosedGo MAEDA2009-09-03

Actions
Related to Redmine - Defect #33639: Cannot paste image from clipboard when copying the image from web browsers or some appsClosedGo MAEDA

Actions
Actions

Also available in: Atom PDF