Search code examples
javascriptjqueryhtmlzeroclipboardzclip

Copy and Paste formatted text using zclip plugin in Javascript


I am using zclip plugin for copying text to clipboard. It works fine for plain text.

But when I try to copy some formatted text say for eg:

I am having div with html as

<div id="formattedDiv">
  <b>Copied Text </b>
</div>

and when I apply zclip on some button to copy formmattedDiv text as

$("a#copyCustombtn").on('click', function (e) {
    e.preventDefault();
}).zclip({
    path: 'http://www.steamdev.com/zclip/js/ZeroClipboard.swf',
    copy: function () {
     return $("#formattedDiv").html()
    }
  }); 

It copies entire html as "<b>Copied Text </b>".

When I try to paste, it pastes exactly "<b>Copied Text </b>"

but not formatted text as "Copied Text "

Can anybody guide me, why this happening?


Solution

  • Currently zclip won't provide such a way to implement. Raised an issue on github please refer to link in which suggestion are welcomed.

    Hope it will be implemented soon :)