Reputation: 501
I have installed three packages:
I'm able to setup simple ckeditor5 but don't know how to use MathType plugin in this editor.
Here is my sample code:
<CKEditor
data={input.value}
editor={ClassicEditor}
onChange={(event, editor) => {
return input.onChange(editor.getData());
}}
/>;
Can anyone explain how i can use this? Thanks.
Upvotes: 8
Views: 5417
Reputation: 9560
https://www.npmjs.com/package/ckeditor5-build-classic-mathtype, a package which customizes classic editor build, which adds mathtype plugin.
import CKEditor from '@ckeditor/ckeditor5-react'
import ClassicEditor from 'ckeditor5-build-classic-mathtype'
...
render() {
return (
<CKEditor
editor={ClassicEditor}
data="<p>Hello from CKEditor 5 with MathType!</p>"
onInit={editor => {
// You can store the "editor" and use when it is needed.
// console.log( 'Editor is ready to use!', editor );
}}
/>
)
}
Upvotes: 1
Reputation: 501
I have used MathType Editor in ReactJs using Javascript.
Here is the steps:
<textarea name="question" id="question" cols="100" rows="6"></textarea>
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);
Upvotes: 0
Reputation: 301
Here's a link you should see to understand how to add a plugin to ckeditor.
TL;DR: You should create a new build containing your plugin (in your case MathType plugin), the easiest way to do it is using their online builder, then you can use that build that you generated instead of @ckeditor/ckeditor5-build-classic
for example.
I have already done this work and published it to npm, you can install it with:
npm install ckeditor5-classic-with-mathtype
Here's an example of using it with react:
import CKEditor from '@ckeditor/ckeditor5-react';
import ClassicEditor from 'ckeditor5-classic-with-mathtype';
...
render() {
return (
<CKEditor
editor={ClassicEditor}
config={{
toolbar: {
items: [
'heading', 'MathType', 'ChemType',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'imageUpload',
'mediaEmbed',
'insertTable',
'blockQuote',
'undo',
'redo'
]
},
}}
data="<p>Hello from CKEditor 5 with MathType!</p>"
onInit={editor => {
// You can store the "editor" and use when it is needed.
// console.log( 'Editor is ready to use!', editor );
}}
/>
);
}
Upvotes: 10