4

The question How do i accept MathML? already explains how to handle output from Windows 7 and Windows 8 Math Input Panel using native Windows code.

Is it possible to do the same with any web browser using just JavaScript (that is, no silverlight or any other plugin allowed)? I understand that the MathML input is on the clipboard but it's declared as non-text (despite the fact that it really is application/mathml or more exactly UTF-16LE encoded XML with MathML markup with a BOM at the start of the data). My target is to get the MathML as UTF-8 encoded text and further embed that text via TinyMCE. The resulting MathML will be later rendered by MathJax but could be processed by the server, too. The missing part is to extract the correct data from the clipboard. As far as TinyMCE and JavaScript (as I'm using it) sees the clipboard, it's always empty when it really contains the formats described in the How do i accept MathML?

I'd prefer supporting MSIE 10 and latest versions of Firefox and Google Chrome. However, in short run I'd be okay supporting only a single browser running on Windows 8. I'd really really want to avoid any plugin dependency even for supporting a single browser running on Windows 8.

If somebody can show me the code to display MathML from Math Input Panel in an alert() using just JavaScript (jquery and TinyMCE dependencies are okay if those help), I can handle the rest.

Community
  • 1
  • 1
Mikko Rantalainen
  • 14,132
  • 10
  • 74
  • 112
  • As for the correct flovour choosen to paste from the clipboard it looks impossible to do this without a browser AddOn. Do you use CLCL to check the clipboard content and its flavours? – Thariama Apr 23 '13 at 07:42
  • I tried http://www.peterbuettner.de/develop/tools/clipview/ for inspecting the cliboard. It seems that the `MathML` is in fact encoded in `UTF-16LE` with a `BOM` instead of being plain `UTF-8`. – Mikko Rantalainen Apr 23 '13 at 07:53
  • that tool is good enough. +1 for your good question – Thariama Apr 23 '13 at 08:29

1 Answers1

1

Access to the clipboard is not possible using javascript on a webpage due to the fact that javascript cannot reach out of the browser sandbox. As for the correct flovour choosen to paste from the clipboard it looks impossible to do this without a browser AddOn.

Thariama
  • 50,002
  • 13
  • 138
  • 166
  • 1
    Once Clipboard API (http://dev.w3.org/2006/webapi/clipops/clipops.html#processing-model) is supported by at least one browser this should be doable as long as UA does not decide to not include MathML content to `DataTransferItemList`. Google Chrome might support it: http://strd6.com/2011/09/html5-javascript-pasting-image-data-in-chrome/ – Mikko Rantalainen Apr 23 '13 at 09:19
  • According to Mozilla bug, Clipboard API should be supported in Firefox 22. – Mikko Rantalainen May 16 '13 at 07:25
  • According to http://caniuse.com/#feat=clipboard Clipboard API could be used. Firefox requires changing browser settings at the client end so that really does not work. MSIE and Edge do not support required MIME types so the only possible browser with suitable features is Google Chrome. However, I haven't tested if the features work for this use case in real. – Mikko Rantalainen Mar 02 '16 at 15:48
  • yes, but this is not acceptable for many enterprise users. if it is not for you then go ahead – Thariama Mar 03 '16 at 12:44