Files
Trilium/src/ui/mathview.js

37 lines
610 B
JavaScript
Raw Normal View History

2019-08-31 20:48:37 +03:00
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', '' );
2019-09-17 15:47:58 +03:00
this.set( 'display', false);
2019-08-31 20:48:37 +03:00
2019-09-17 15:47:58 +03:00
this.on( 'change', () => {
2019-08-31 20:48:37 +03:00
this.updateMath();
} );
this.setTemplate( {
tag: 'div',
attributes: {
class: [
'ck',
'ck-math-preview'
],
}
} );
}
updateMath() {
2019-09-17 15:47:58 +03:00
renderEquation( this.value, this.element, this.engine, this.display );
2019-08-31 20:48:37 +03:00
}
render() {
super.render();
this.updateMath();
}
}