Notes/src/ui/mathview.ts

81 lines
1.7 KiB
TypeScript
Raw Normal View History

2024-03-14 21:33:24 -03:00
import { View } from 'ckeditor5/src/ui';
import { renderEquation } from '../utils';
import type { Locale } from 'ckeditor5/src/utils';
import type { KatexOptions } from '../katex';
export default class MathView extends View {
public value: string;
public display: boolean;
public previewUid: string;
public previewClassName: Array<string>;
public katexRenderOptions: KatexOptions;
public engine:
| 'mathjax'
| 'katex'
| ( ( equation: string, element: HTMLElement, display: boolean ) => void );
public lazyLoad: undefined | ( () => Promise<void> );
constructor(
engine:
| 'mathjax'
| 'katex'
| ( (
equation: string,
element: HTMLElement,
display: boolean,
) => void ),
lazyLoad: undefined | ( () => Promise<void> ),
locale: Locale,
previewUid: string,
previewClassName: Array<string>,
katexRenderOptions: KatexOptions
) {
super( locale );
this.engine = engine;
this.lazyLoad = lazyLoad;
this.previewUid = previewUid;
this.katexRenderOptions = katexRenderOptions;
this.previewClassName = previewClassName;
this.set( 'value', '' );
this.value = '';
this.set( 'display', false );
this.display = false;
this.on( 'change', () => {
if ( this.isRendered ) {
this.updateMath();
}
} );
this.setTemplate( {
tag: 'div',
attributes: {
class: [ 'ck', 'ck-math-preview' ]
}
} );
}
public updateMath(): void {
if ( this.element ) {
void renderEquation(
this.value,
this.element,
this.engine,
this.lazyLoad,
this.display,
true,
this.previewUid,
this.previewClassName,
this.katexRenderOptions
);
}
}
chore: Add override for methods ERROR in ckeditor5-math/src/mathcommand.ts ./src/mathcommand.ts 5:8-13 [tsl] ERROR in ckeditor5-math/src/mathcommand.ts(5,9) TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Command'. @ ./src/autoformatmath.ts 6:0-40 24:31-42 @ ./src/index.ts 5:0-61 5:0-61 ERROR in ckeditor5-math/src/mathcommand.ts ./src/mathcommand.ts 6:8-15 [tsl] ERROR in ckeditor5-math/src/mathcommand.ts(6,9) TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Command'. @ ./src/autoformatmath.ts 6:0-40 24:31-42 @ ./src/index.ts 5:0-61 5:0-61 ERROR in ckeditor5-math/src/mathcommand.ts ./src/mathcommand.ts 48:8-15 [tsl] ERROR in ckeditor5-math/src/mathcommand.ts(48,9) TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Command'. @ ./src/autoformatmath.ts 6:0-40 24:31-42 @ ./src/index.ts 5:0-61 5:0-61 ERROR in ckeditor5-math/src/mathui.ts ./src/mathui.ts 41:8-15 [tsl] ERROR in ckeditor5-math/src/mathui.ts(41,9) TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Plugin'. @ ./src/autoformatmath.ts 7:0-30 33:50-56 @ ./src/index.ts 5:0-61 5:0-61 ERROR in ckeditor5-math/src/ui/mainformview.ts ./src/ui/mainformview.ts 40:8-14 [tsl] ERROR in ckeditor5-math/src/ui/mainformview.ts(40,9) TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'View<HTMLElement>'. @ ./src/mathui.ts 2:0-45 61:29-41 @ ./src/autoformatmath.ts 7:0-30 33:50-56 @ ./src/index.ts 5:0-61 5:0-61 ERROR in ckeditor5-math/src/ui/mainformview.ts ./src/ui/mainformview.ts 130:8-14 [tsl] ERROR in ckeditor5-math/src/ui/mainformview.ts(130,9) TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'View<HTMLElement>'. @ ./src/mathui.ts 2:0-45 61:29-41 @ ./src/autoformatmath.ts 7:0-30 33:50-56 @ ./src/index.ts 5:0-61 5:0-61 ERROR in ckeditor5-math/src/ui/mathview.ts ./src/ui/mathview.ts 76:8-14 [tsl] ERROR in ckeditor5-math/src/ui/mathview.ts(76,9) TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'View<HTMLElement>'. @ ./src/ui/mainformview.ts 5:0-34 48:32-40 @ ./src/mathui.ts 2:0-45 61:29-41 @ ./src/autoformatmath.ts 7:0-30 33:50-56 @ ./src/index.ts 5:0-61 5:0-61 7 errors have detailed information that is not shown. Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
2024-03-16 05:40:55 -05:00
public override render(): void {
2024-03-14 21:33:24 -03:00
super.render();
this.updateMath();
}
}