Skip to content

[Bug]: Copy to Clipboard includes Color Information #2039

@ScottKemp

Description

@ScottKemp

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

OK, this one is interesting, stay with me LOL.

Calling utils.CopyToClipboard adds unwanted color information to clipboard. When I use this call, like

utils.copyToClipboard("This is Clipboard Text" );

it puts it in the windows clipboard with multiple formats, one being html. Using the program here: https://www.nirsoft.net/utils/inside_clipboard.html will show you the exact contents of the current clipboard.

The download link is well hidden, trying to get you to click on crap, but it is here:

Image

This will show the clipboard formats of the current clipboard. This will show the above call will generate an html clipboard type that looks like:

Version:0.9
StartHTML:0000000180
EndHTML:0000001068
StartFragment:0000000216
EndFragment:0000001032
SourceURL:............
<html>
<body>
<!--StartFragment--><span style="color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, Arial, &quot;Segoe UI&quot;, &quot;PingFang SC&quot;, &quot;Microsoft Yahei&quot;, &quot;Hiragino Sans GB&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Color Emoji&quot;; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">This is Clipboard Text</span><!--EndFragment-->
</body>
</html>

The issue is, the html format includes color information. This is a problem IMHO. Why this color, why any color at all?

My use case is I let my users click on a cell in a table, and it copies that value to the clipboard, which they can then paste into a lowcoder rich edit control. The issue is when they paste it, the rich text sees the html format, and uses that (including the unwanted color), instead of just plain text. So now the rich text value has color information in it.

The user cannot see that the rich text is now polluted with unwanted color information. If they right click and paste as text, then it works. But 99% of people wont know to do that.

Image

Note that a Copy To Clipboard event exhibits the same behavior.

Expected Behavior

If I use utils.CopyToClipboard("Clipboard Text"), I wouldn't expect it to also include color information in the clipboard, because I didn't give it any.

If this causes a backward compatibility to fix this, maybe and extra, optional param "text_only" or something like that.

Steps to reproduce

See attached app. Click the copy button, the control-V into the rich text edit.

Note, that value of the rich text will contain color information.

Copy Paste Rich HTML.json

Environment

Low coder 2.7.4

Additional Information

No response

Metadata

Metadata

Assignees

Labels

Javascript FrontendPull requests that update Javascript code

Type

Projects

Status

👀 In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions