I have used MathType Editor in ReactJs using Javascript.
Here is the steps:
- Include in index.html
- render normal text area in the component
<textarea name="question" id="question" cols="100" rows="6"></textarea>
- use below code in componentDidMount function :
let ED = window.CKEDITOR;
let mathElements = [
'math',
'maction',
'maligngroup',
'malignmark',
'menclose',
'merror',
'mfenced',
'mfrac',
'mglyph',
'mi',
'mlabeledtr',
'mlongdiv',
'mmultiscripts',
'mn',
'mo',
'mover',
'mpadded',
'mphantom',
'mroot',
'mrow',
'ms',
'mscarries',
'mscarry',
'msgroup',
'msline',
'mspace',
'msqrt',
'msrow',
'mstack',
'mstyle',
'msub',
'msup',
'msubsup',
'mtable',
'mtd',
'mtext',
'mtr',
'munder',
'munderover',
'semantics',
'annotation',
'annotation-xml'
];
ED.plugins.addExternal( 'ckeditor_wiris', 'https://www.wiris.net/demo/plugins/ckeditor/', 'plugin.js' );
ED.replace( 'question', {
extraPlugins: 'ckeditor_wiris',
// For now, MathType is incompatible with CKEditor file upload plugins.
removePlugins: 'filetools,uploadimage,uploadwidget,uploadfile,filebrowser,easyimage',
height: 320,
// Update the ACF configuration with MathML syntax.
extraAllowedContent: mathElements.join( ' ' ) + '(*)[*]{*};img[data-mathml,data-custom-editor,role](Wirisformula)'
} );
If you want to check Ml tags in the react component. Need to load a script in the component:
const script = document.createElement("script");
script.src ='https://www.wiris.net/demo/plugins/app/WIRISplugins.js?viewer=image;
script.async = true;
document.body.appendChild(script);