In my previous post, I mentioned that Firefox doesn’t make the clipboard data in paste event handler.
Sure there is a workout, but it is a dirty hack which is done by
- Detect a ctrl-v / shift-ins event using a keypress event handler
- In that handler, save the current user selection, add a textarea element off-screen (say at left -1000px) to the document, turn designMode off and call focus() on the textarea, thus moving the caret and effectively redirecting the paste
- Set a very brief timer (say 1 millisecond) in the event handler to call another function that stores the textarea value, removes the textarea from the document, turns designMode back on, restores the user selection and pastes the text in.
So I dig deeper and found the bug report in Mozilla’s Bugzilla. So back to 11th December 2007, a user named Spam complained why Firefox doesn’t have clipboardData access when paste event happened. He also mentioned that Chrome/Safari and Internet Explorer already implemented and quite secure.
From there, the progress had been very very slow I must say. Just look at the chart below:
But I guess this bug is almost resolved, albeit taking 5+ years. Neil Deakin has the last words on that bug report page. He suggested that no more round of reviews are required as the patches has resulted similar behaviour to WebKit with minor differences. So yeah, we are going to have clipboardData object in Firefox.
But when? I don’t know. So far there are no indication whether this bug-fix will be included in Firefox’s next release. As for JSON Table Editor, the paste event handling only will be done on Google Chrome, Safari and Opera.