Skip to content

Build your personal knowledge base with Trilium Notes

Fix sync issues

Meinzzzz22941a9ce095
diff --git a/packages/ckeditor5-math/src/ui/mainformview.ts b/packages/ckeditor5-math/src/ui/mainformview.ts
index 1c2403e18f..d459354fb1 100644
--- a/packages/ckeditor5-math/src/ui/mainformview.ts
+++ b/packages/ckeditor5-math/src/ui/mainformview.ts
@@ -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 );
}
diff --git a/packages/ckeditor5-math/src/ui/mathinputview.ts b/packages/ckeditor5-math/src/ui/mathinputview.ts
index 945bebc794..ace20848cc 100644
--- a/packages/ckeditor5-math/src/ui/mathinputview.ts
+++ b/packages/ckeditor5-math/src/ui/mathinputview.ts
@@ -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 {
diff --git a/packages/ckeditor5-math/src/ui/mathview.ts b/packages/ckeditor5-math/src/ui/mathview.ts
index 87af15d08d..aa1027329e 100644
--- a/packages/ckeditor5-math/src/ui/mathview.ts
+++ b/packages/ckeditor5-math/src/ui/mathview.ts
@@ -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 {