Middle mouse button paste in gecko #31

wants to merge 3 commits into

3 participants


This is a naive/lazy implementation for gecko middle mouse paste.

Gecko prohibits access to clipboard data in paste events. There are two solutions for this: either Flash or making diff to the content before the paste event and after it.

Because of how the terminal works (i.e. it expects text only, not html) a more simple solution would be to detect selection in the page and save the text of the selection and then use it in the case of paste event. It will not cover the case where the user wants to paste text from the clipboard, but is still useful because it can store selections from other windows/tabs in the same page.

pstjvn added some commits Jun 5, 2012
@pstjvn pstjvn Adds support for copy/middle button paste for Gecko/Firefox eefa0e6
@pstjvn pstjvn Re-implemented using content editable changes to allow pasting from a…
…ny source.

Not as aesthetically pleasing (the pasted content appears for a moment there), but works correctly for pasting from any source.

Needs some testing on older hardware for the timeout in the timing of receiving DOMCharacterDataModified but works good on recent netbooks and recent PCs.

I see an issue with the second attempt: If I paste text with space in it the bash interpreter does not seem to like it.
For example I paste 'telnet' (which in code is
Terminal.prototype.send('whatever I pasted as text string');
). However when I press enter the bash interpreter thinks the whole string is one command (i.e. 'telnet\') and thus cannot interpret it. Any idea why this is happening? I see that exactly the same code path is executed with the webkit approach of handling clipboad data.


There are two solutions for this:

either Flash


making diff to the content before the paste event and after it

What you have looks interesting. I kind to want to fool around with it a bit first.

I see an issue with the second attempt

Hmm, I'll see if I can figure it out once I try it.


Bump, +1, etc.

It really helps me to be able to paste into tty.js. I would love to see something like this in the main project so I don't have to re-apply the patch every time I upgrade tty.js.

It is a little flaky, though. Sometimes it pastes twice, for no adequately explained reason.


I spent some time today trying to get this working again with current tty.js and current Firefox. The reason I was getting things pasted twice (2 months ago) was that the regular paste handler was running as well as the code from @pstjvn. It seems that Firefox 25.0.1 and Nightly now support right-click paste events for divs if they have contentEditable == true.

See this gist for a user.js file that patches up bindPaste() and adds a new mousedown listener: https://gist.github.com/risacher/7837761

This seems to work in Firefox, Chrome, and Safari - but I'm not sure I'm testing all the cases that are supposed to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment