Copy formatted text to clipboard

1.2k views Asked by At

A simple html page has FORMATTED text - not fancy - line breaks, and italic.

I want to have a button that takes this formatted text, and copies it to the clipboard, formatted (it is planned to be pasted into some LibreOffice document later).

Couldn't find how to do it.

I tried ZeroClipboard, and a suggestion to parse the text, replacing "
"-s to "\r\n". That indeed does the trick for line breaks, but what about italic?... Any means to get this functionality?...

2

There are 2 answers

1
Skywalker On

When you create an italic tag the responsible for formatting the document and showing the text properly is the browser. If you want to copy the text you should get the text already parse and render by the browser or parse yourself the text like you did with break lines. For italics when you find a ... tag you must create the adequate text. That is, text in italics, but that depends on the language you are using, but i'm sure it can be done.

0
Ohad On

OK,

Turns out that ZeroClipboard had this functionality (of rendering the HTML text upon paste), but have disabled it.

However, the version that supports it can be found at: https://github.com/botcheddevil/ZeroClipboard

Note: You may find that in this version, creating the client, binding the flash to a component, and handling the events are rather different than the documentation of current version of ZeroClipboard (https://github.com/zeroclipboard/zeroclipboard/blob/master/docs/instructions.md