iink SDK Web

Answered

JIIX Missing In detail.exports

Hi,

I'm not able to get the JIIX from my editor. My export only provides the x-latex and mathML values. I'm using similar configs to https://github.com/MyScript/MyScriptJS/blob/master/examples/v4/import_math_jiix.html.


 useEffect(() => {
    let editor = editorRef.current;
    editor.addEventListener('exported'evt => {
        try{
            const exports = evt.detail.exports;
            console.log(exports)
            if (!exportsreturn;
            document.querySelector('.error-msg').style.display = "none"
            if (exports['application/x-latex']) {
              updater({type: ACTIONS.STAGING_LATEX,latex:exports['application/x-latex']});
            }
            if (exports['application/vnd.myscript.jiix']) {
              updater({type: ACTIONS.STAGING_INK,ink:JSON.stringify(exports)});
            }
          }
        catch{
          console.log({exports})
        }
      });
  
    editor = iink.register(editorRef.current, {
      recognitionParams: {
        type: 'MATH',
        protocol: 'WEBSOCKET',
        apiVersion: 'V4',
        server: {
            scheme: 'https',
            host: 'webdemoapi.myscript.com',
            applicationKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            hmacKey: 'XXXXXXXXXXXXXXXXXXXXXXX'
        },
        v4: {
            math: {
                mimeTypes: ['application/x-latex''application/vnd.myscript.jiix'],
            },
            export: {
              jiix: {
                strokes: true,
              }
            }
        }
      }
    });
    
    window.addEventListener('resize', () => { 
      editor.resize() 
    });

    return () => {
      window.removeEventListener('resize', () => { editor.resize() });
      editor.close();
    }
  },[]);

Best Answer

I figured it out. Thanks for the guidance. They issue was that the follow parameter was deprecated. v4 needed to be iink.


        v4: {
          math: {
            mimeTypes: ['application/x-latex''application/vnd.myscript.jiix''application/mathofficeXML']
          },
          export: {
            jiix: {
              strokes: true
            }
          }
        }

Dear Winston,


thank you for contacting us and your question.


First, just a quick remark, regarding MyScriptJS, which is deprecated ; instead, you shall use the iinkJS (switching to the latter should not be a major issue) ; you can refer to the following samples.

-https://github.com/MyScript/iinkJS/tree/master/examples/v4

-https://github.com/MyScript/iinkjs/blob/master/examples/non-version-specific/on_demand_exports.html


To answer your question, the recognition result are sent asynchronously by the server: you can refer to the following topic, which explain how you shall proceed: https://developer-support.myscript.com/support/discussions/topics/16000029004


Let us know if you have further questions.


Best regards,


Olivier

My code is using iinkJS. The config in your example (https://github.com/MyScript/iinkJS/blob/master/examples/v4/import_math_jiix.html) is the same. I am using ReactJS with Hooks. Is that an issue? I'm getting an export. It just doesn't have the jiix data.

Dear Winston,


currently, I am not sure to understand the issue you are facing ; indeed, you are pointing to our "import" code sample, while you want to export in JIIX. Did you refer to our corresponding "export on-demand" code sample: https://myscript.github.io/MyScriptJS/examples/non-version-specific/on_demand_exports.html

Or you can give it a quick try: https://myscript.github.io/MyScriptJS/examples/non-version-specific/on_demand_exports.html


I am using ReactJS with Hooks. Is that an issue?

>>We do not have much experience of ReactJS, but at present we have not heard of such issue


It just doesn't have the jiix data.

>>Can you please try the export on-demand and let us know if this helps.


Best regards,


Olivier

I tried the on-demand. It gave me the same output. Everything works except for the missing JIIX export. Below is the console log so you can see what I'm seeing.

image

 

The only way to get the JIIX output was to switch my type to "TEXT". I found out that it didn't matter what I set in the v4 JSON. I can remove "v4" and nothing changes. I need it to work with the "MATH" type though.

Dear Winston,


Thank you for your update.


If you want to get the JIIX output with math, here is how you can proceed.


Get the math example: https://myscript.github.io/iinkJS/examples/v4/websocket_math_iink.html


In this example, modify the line 70 method editorElement.addEventListener by following one:


 editorElement.addEventListener('exported', (evt) => {

const exports = evt.detail.exports;
if (exports && exports['application/vnd.myscript.jiix']) {
convertElement.disabled = false;
resultElement.innerText = exports['application/vnd.myscript.jiix'];
}

});



Best regards,


Gwenaëlle

Answer

I figured it out. Thanks for the guidance. They issue was that the follow parameter was deprecated. v4 needed to be iink.


        v4: {
          math: {
            mimeTypes: ['application/x-latex''application/vnd.myscript.jiix''application/mathofficeXML']
          },
          export: {
            jiix: {
              strokes: true
            }
          }
        }