Files
Trilium/src/ui/mathview.js
2019-10-03 19:11:09 +03:00

41 lines
654 B
JavaScript

import View from '@ckeditor/ckeditor5-ui/src/view';
import { renderEquation } from '../utils';
export default class MathView extends View {
constructor( engine, locale ) {
super( locale );
this.engine = engine;
this.set( 'value', '' );
this.set( 'display', false );
this.on( 'change', () => {
this.updateMath();
} );
this.setTemplate( {
tag: 'div',
attributes: {
class: [
'ck',
'ck-math-preview'
],
}
} );
}
updateMath() {
const el = this.element;
if ( el ) {
renderEquation( this.value, el, this.engine, this.display, true );
}
}
render() {
super.render();
this.updateMath();
}
}