Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Add support for HTML and RichText (RTF) clipboard sections #143

Closed
7 tasks
JamesMGreene opened this issue May 7, 2013 · 12 comments · Fixed by #396
Closed
7 tasks

Add support for HTML and RichText (RTF) clipboard sections #143

JamesMGreene opened this issue May 7, 2013 · 12 comments · Fixed by #396

Comments

@JamesMGreene
Copy link
Member

Tasks:

  • Add a setHtml method to the ZeroClipboard JS client instances
  • Add a setRichText method to the ZeroClipboard JS client instances
  • Add support for setHtml on the Flash side
  • Add support for setRichText on the Flash side
  • Disable support for HTML/RichText by default when running on Linux
  • Add an option for consumers to override and re-enable HTML/RichText support on Linux despite its known limitations

Optional Tasks:

  • Provide an htmlToRtf method in a demo or docs (not in the ZeroClipboard library itself)

Related:

@pkbarbiedoll
Copy link

James, can you clarify what the "known limitations" are for HTML/RichText support? In an earlier build of ZC, copy/pasting HTML/RichText is not a problem on my linux systems. If I am not experiencing issues with 1.0.7, should I expect the proposed build to work?

@JamesMGreene
Copy link
Member Author

@pkbarbiedoll:
Clarifications regarding ZeroClipboard <= 1.0.7:

  1. The older version of ZeroClipboard's Flash 10 implementation ("ZeroClipboard10.swf") never supported RichText, only plain text and HTML.
  2. When you copied HTML, the plain text clipboard was forced to receive HTML markup rather than a plain text equivalent.

As I understand it from Issue #78, Linux poses a unique problem in that it has several different clipboard buffers. The Flash 9 implementation (plain text only) puts the data into 1+ clipboard buffers (PRIMARY, SECONDARY, and CLIPBOARD) that seem to work across all Linux applications but the Flash 10 implementation (plain text, rich texts, HTML) puts the data into either just the SECONDARY or CLIPBOARD buffer (but not the PRIMARY buffer). This seems to result in the data being available to other graphical applications (i.e. that are managed by the desktop environment, e.g. X, GNOME, etc.) but not in textual system applications (e.g. Terminal). Given that the Terminal is a very important target (particularly for GitHub's ZeroClipboard use case), this was majorly unacceptable.

You can read more details on Issue #78, the Adobe bug I filed, and Wikipedia.

If you truly didn't have any issues pasting into the Terminal, then please please please let me know so we can look into your Linux system's configuration (e.g. did you have autocutsel running?).

@pkbarbiedoll
Copy link

@JamesMGreene - I am still running the old version of ZC (1.0.7) and can confirm that I am not able to paste copied HTML data into Terminal. This is not a problem as my users paste into a rich text entry form.

@JamesMGreene
Copy link
Member Author

@pkbarbiedoll: Thank you very much for confirming!

@JamesMGreene
Copy link
Member Author

@pkbarbiedoll: Though, just to clarify, nothing gets pasted into the Terminal, right? Not even the "plain text" (raw markup)?

@pkbarbiedoll
Copy link

@JamesMGreene: That is correct. Nothing is pasted in Terminal. Same rich content pastes as expected (retains markup) in a RTE.

@JamesMGreene
Copy link
Member Author

Thanks much, @pkbarbiedoll. :)

@jaindeepti
Copy link

Hi Everybody,
Can anybody provide me the ZeroClipboard latest files to be included wile implementation and all the help documents which has the steps for "How to use the utility to copy the HTML and paste the same format of html in a word document?". I am not able to use the utility. I am using the following piece of code:

 ZeroClipboard.setMoviePath('ZeroClipboard11.swf')
        //create client
        var clip = new ZeroClipboard.Client();

        clip.addEventListener('mousedown', function () {
             clip.setHTML($('#box-content').html());
//            clip.setData({
//                "text": "Hello",
//                "html": "<b>Hello</b>",
//                "richText": "{\\rtf1\\ansi\n{\\b Hello}}",
//                "MyAwesomeCustomFormat": "0xDEADBEEF"
//            });

//                      clip.setText($('#box-content').html());


        });

        clip.addEventListener('complete', function (client, htmlText) {
            alert('copied: ' + htmlText);
        });
        clip.glue('copy');

Thanks in advance!!

@JamesMGreene
Copy link
Member Author

@jaindeepti The EnhancedClipboard isn't implemented yet, thus why this issue is still open. It will be available in the v2.0.0 release when it's ready.

The code sample you provided appears to be using a very old version of ZeroClipboard. Please consider upgrading to the latest version.

@jaindeepti
Copy link

Thanks James!! I am trying to implement the newer version of code too but it is not working. Kindly help me in this. Following is the code snippet which I am using:
Files included:

<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="ZeroClipboard.js" type="text/javascript"></script>

HTML:

<button id="copy-button" data-clipboard-text="Copy Me!" title="Click to copy me.">Copy to Clipboard</button>

Code:

        var clip = new ZeroClipboard(document.getElementById("copy-button"), {
            moviePath: "ZeroClipboard11.swf"
        });
clip.on("load", function (client) {
            // alert( "movie is loaded" );

            clip.on("complete", function (clip, args) {
                // `this` is the element that was clicked
                this.style.display = "none";
                alert("Copied text to clipboard: " + args.text);
            });
        });

When I click on the copy button, nothing happens.Please let me know if anything is wrong. This I have implemented from the following URL:
https://github.com/zeroclipboard/zeroclipboard/blob/master/docs/instructions.md

Thanks in advance!!

@JamesMGreene
Copy link
Member Author

@jaindeepti: Please open a new issue instead of hijacking this high profile issue. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants