mirror of
https://github.com/zadam/trilium.git
synced 2025-10-27 00:06:30 +01:00
41 lines
654 B
JavaScript
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();
|
|
}
|
|
}
|