mirror of
https://github.com/zadam/trilium.git
synced 2026-01-14 18:44:25 +01:00
Fix sync issues
This commit is contained in:
parent
633a09d414
commit
22941a9ce0
@ -11,8 +11,8 @@ import {
|
||||
FocusTracker,
|
||||
KeystrokeHandler
|
||||
} from 'ckeditor5';
|
||||
import IconCheck from '@ckeditor/ckeditor5-icons/theme/icons/check.svg?raw';
|
||||
import IconCancel from '@ckeditor/ckeditor5-icons/theme/icons/cancel.svg?raw';
|
||||
import { IconCheck } from 'ckeditor5';
|
||||
import { IconCancel } from 'ckeditor5';
|
||||
import { extractDelimiters, hasDelimiters } from '../utils.js';
|
||||
import MathView, { type MathViewOptions } from './mathview.js';
|
||||
import MathInputView from './mathinputview.js';
|
||||
@ -35,7 +35,7 @@ export default class MainFormView extends View {
|
||||
locale: Locale,
|
||||
mathViewOptions: MathViewOptions,
|
||||
previewEnabled = false,
|
||||
popupClassName: string[] = []
|
||||
popupClassName: Array<string> = []
|
||||
) {
|
||||
super( locale );
|
||||
const t = locale.t;
|
||||
@ -49,7 +49,7 @@ export default class MainFormView extends View {
|
||||
|
||||
// Build children
|
||||
|
||||
const children: View[] = [
|
||||
const children: Array<View> = [
|
||||
this.mathInputView,
|
||||
this.displayButtonView
|
||||
];
|
||||
@ -116,7 +116,10 @@ export default class MainFormView extends View {
|
||||
|
||||
this.mathInputView.on( 'mathfieldReady', () => {
|
||||
const mathfieldView = this.mathInputView.mathFieldFocusableView;
|
||||
if ( mathfieldView.element && !this._focusables.has( mathfieldView ) ) {
|
||||
if ( mathfieldView.element ) {
|
||||
if ( this._focusables.has( mathfieldView ) ) {
|
||||
this._focusables.remove( mathfieldView );
|
||||
}
|
||||
this._focusables.add( mathfieldView, 0 );
|
||||
this.focusTracker.add( mathfieldView.element );
|
||||
}
|
||||
|
||||
@ -55,6 +55,7 @@ export default class MathInputView extends View {
|
||||
public mathfield: MathFieldElement | null = null;
|
||||
public readonly latexTextAreaView: LatexTextAreaView;
|
||||
public readonly mathFieldFocusableView: MathFieldFocusableView;
|
||||
private _isSyncing = false;
|
||||
|
||||
constructor( locale: Locale ) {
|
||||
super( locale );
|
||||
@ -185,6 +186,11 @@ export default class MathInputView extends View {
|
||||
this.mathfield = mf;
|
||||
this.mathFieldFocusableView.setElement( mf );
|
||||
this.fire( 'mathfieldReady' );
|
||||
|
||||
// Auto-focus the mathfield when it's ready
|
||||
setTimeout( () => {
|
||||
mf.focus();
|
||||
}, 0 );
|
||||
}
|
||||
|
||||
public focus(): void {
|
||||
|
||||
@ -55,20 +55,20 @@ export default class MathView extends View {
|
||||
}
|
||||
|
||||
public updateMath(): void {
|
||||
if (!this.element) {
|
||||
if ( !this.element ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle empty equations
|
||||
if (!this.value || !this.value.trim()) {
|
||||
if ( !this.value || !this.value.trim() ) {
|
||||
this.element.textContent = '';
|
||||
this.element.classList.remove('ck-math-render-error');
|
||||
this.element.classList.remove( 'ck-math-render-error' );
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear previous render
|
||||
this.element.textContent = '';
|
||||
this.element.classList.remove('ck-math-render-error');
|
||||
this.element.classList.remove( 'ck-math-render-error' );
|
||||
|
||||
renderEquation(
|
||||
this.value,
|
||||
@ -80,14 +80,14 @@ export default class MathView extends View {
|
||||
this.options.previewUid,
|
||||
this.options.previewClassName,
|
||||
this.options.katexRenderOptions
|
||||
).catch(error => {
|
||||
console.error('Math rendering failed:', error);
|
||||
).catch( error => {
|
||||
console.error( 'Math rendering failed:', error );
|
||||
|
||||
if (this.element) {
|
||||
if ( this.element ) {
|
||||
this.element.textContent = 'Error rendering equation';
|
||||
this.element.classList.add('ck-math-render-error');
|
||||
this.element.classList.add( 'ck-math-render-error' );
|
||||
}
|
||||
});
|
||||
} );
|
||||
}
|
||||
|
||||
public override render(): void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user