1

We upgraded to FF 19.0 from 12.0 and the clipboard access is completely restricted and I am not able to get data from clipboard.

In earlier vesions of FF, the following used to work.

netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard); var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);

UseCase:

For input text fields, when multi-line text is pasted, I would like to replace with separator of my choice instead of default space char as separator.

E.g: test1\n test2\n test3

On pasting this text in input text field in FF, O/p seen: test1 test2 test3 O/p required: test1,test2,test3 (when separator is ',') test1;test;test3 (when separator is ';')

Requirement:

The pasted text should be modified even before it is pasted to the text field and the only way seems to be access to clipboard.

I tried the following links but did not help.

 https://support.mozilla.org/en-US/questions/948379

 http://stackoverflow.com/questions/14809226/cut-copy-and-paste-is-not-working-for-firefox-15-onwords

I have tried modifying the user pref to allow clip board which did not work.

user_pref("capability.policy.policynames", "allowclipboard");

user_pref("capability.policy.allowclipboard.sites", mydomain);

user_pref("capability.policy.allowclipboard.Clipboard.cutcopy", "allAccess");

I am not supposed to use flash objects to get access to clipboard (ZClip or ZeroClipboard).

Appreciate your responses. Thanks in advance.

teja
  • 11
  • 2
  • Looks like this feature was really removed. https://support.mozilla.org/en-US/questions/977068#answer-500083 – nh2 Feb 19 '14 at 02:17

1 Answers1

1

try this way: http://jsfiddle.net/kUEBs/3/, works on firefox 23

<div style="border:1px solid grey;height:50px;" id="paste_ff" type="text" contenteditable></div>

<script type="text/javascript">
var pasteCatcher = document.getElementById('paste_ff');
document.getElementById('paste_ff').addEventListener('DOMSubtreeModified',function(){  
    if(pasteCatcher.children.length == 1){
        var text = pasteCatcher.innerHTML; console.log(text);   
        //text2  = text.replace(/\n/g, "___"); console.log(text);
        text2  = text.replace("<br>","____");
        if(text2 != text){
            pasteCatcher.innerHTML = text2;
            }
        }
    },false);
</script>
ViliusL
  • 4,589
  • 26
  • 28
  • ViliusL: Thanks for the reply. But the http://jsfiddle.net/kUEBs/ is not working. Also, I am looking for a solution which uses HTML element. The
    is more flexible HTML element.
    – teja Aug 13 '13 at 15:37
  • oops, looks like jsfiddle had old code, try: http://jsfiddle.net/kUEBs/3/ Paste few lines and it will appear like line1_line2_line3 Also in this example div works like input text. – ViliusL Aug 13 '13 at 16:24
  • Really Sorry !! Your solution does not work. I copied few lines of text from excel and pasted it in the div it is showing up in multiple lines. – teja Aug 14 '13 at 11:18
  • paste it from notepad and it will work. BTW if you pasted from excel, it was not text, you pasted hidden html code. My example works with code, but it can be tweaked. Short description: when you paste into div, you get all multiline text that you can change, then you update div. – ViliusL Aug 14 '13 at 17:22
  • ! DOMSubtreeModified is deprecated. http://stackoverflow.com/questions/6659662/why-is-the-domsubtreemodified-event-deprecated-in-dom-level-3 . Moreover the idea here is to not modify the content once the content of div/input field is changed as this is resulting in flickering effect.. – teja Aug 17 '13 at 06:43