In your main JavaScript file, import Editor.js and the custom Wiris plugin, and then initialize the editor:
javascript
// main.js
import EditorJS from '@editorjs/editorjs';
import WirisPlugin from './wirisPlugin';
const editor = new EditorJS({
holder: 'editorjs', // The ID of the element where you want to initialize the editor
tools: {
math: WirisPlugin,
},
});
// Save the content when needed
editor.save().then((outputData) => {
console.log('Data saved: ', outputData);
}).catch((error) => {
console.log('Saving failed: ', error);
});
Include the necessary CSS.
Make sure to include MathType's CSS file in your HTML:
Use the EditorWithWiris component in your Next.js application.
In your desired page or component, import and use the EditorWithWiris component:
javascript
// pages/index.js or other component
import EditorWithWiris from '../components/EditorWithWiris';
function MyApp() {
return (
<div>
<h1>Editor.js with Wiris</h1>
<EditorWithWiris />
</div>
);
}
export default MyApp;
Include the necessary CSS.
Add the following CSS import to your _app.js or _app.tsx file:
javascript
// pages/_app.js or pages/_app.tsx
import 'mathtype-html-integration-devkit/plugins/css/mathtype.min.css';
import '../styles/globals.css'; // Keep your existing global CSS import if you have one
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />;
}
export default MyApp;
Now you should have Wiris MathType integrated with Editor.js in your Next.js application.