Copy text to clipboard as HTML

#1

Support copying HTML to the clipboard.

Currently we have support for:

clipboard.copyText("Hello world");

Request is for:

clipboard.copyHTML("<b>Hello world</b>");

Use Case
Phil is a web developer instructor who is making documentation using Adobe XD. He is creating a plugin to export SVG to the web.

In his plugin he uses the clipboard API to copy the SVG to the clipboard but when he pastes it into other programs and web interfaces the code is mangled into less than and greater than encoding.

Example, &lt;svg instead of <svg.

He noticed that if he copies the code to the clipboard as HTML the formatting is preserved when pasting into other programs.

0 Likes

#2

you mentioned in your use case: “HTML formatting is preserved when pasting into other programs” Is this a feature request for preserving svg format?

0 Likes

#3

My case is specifically for HTML.

However, in some clipboard API’s I’ve seen there is a parameter you can set to define the mime type:

clipboard.write(value, "text/plain");
clipboard.write(value, "text/html");
clipboard.write(value, "text/svg");
clipboard.write(value, "image/png");
0 Likes