mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 21:36:05 +01:00
43 lines
850 B
JavaScript
43 lines
850 B
JavaScript
import View from '@ckeditor/ckeditor5-ui/src/view';
|
|
|
|
import { renderEquation } from '../utils';
|
|
|
|
export default class MathView extends View {
|
|
constructor( engine, lazyLoad, locale, previewUid, previewClassName ) {
|
|
super( locale );
|
|
|
|
this.engine = engine;
|
|
this.lazyLoad = lazyLoad;
|
|
this.previewUid = previewUid;
|
|
this.previewClassName = previewClassName;
|
|
|
|
this.set( 'value', '' );
|
|
this.set( 'display', false );
|
|
|
|
this.on( 'change', () => {
|
|
if ( this.isRendered ) {
|
|
this.updateMath();
|
|
}
|
|
} );
|
|
|
|
this.setTemplate( {
|
|
tag: 'div',
|
|
attributes: {
|
|
class: [
|
|
'ck',
|
|
'ck-math-preview'
|
|
]
|
|
}
|
|
} );
|
|
}
|
|
|
|
updateMath() {
|
|
renderEquation( this.value, this.element, this.engine, this.lazyLoad, this.display, true, this.previewUid, this.previewClassName );
|
|
}
|
|
|
|
render() {
|
|
super.render();
|
|
this.updateMath();
|
|
}
|
|
}
|