mirror of
https://github.com/zadam/trilium.git
synced 2026-01-14 18:44:25 +01:00
Fix sync bug
This commit is contained in:
parent
29f0881c5a
commit
633a09d414
@ -116,7 +116,7 @@ export default class MainFormView extends View {
|
||||
|
||||
this.mathInputView.on( 'mathfieldReady', () => {
|
||||
const mathfieldView = this.mathInputView.mathFieldFocusableView;
|
||||
if ( mathfieldView.element ) {
|
||||
if ( mathfieldView.element && !this._focusables.has( mathfieldView ) ) {
|
||||
this._focusables.add( mathfieldView, 0 );
|
||||
this.focusTracker.add( mathfieldView.element );
|
||||
}
|
||||
|
||||
@ -91,13 +91,24 @@ export default class MathInputView extends View {
|
||||
|
||||
textarea.addEventListener( 'input', () => {
|
||||
const val = textarea.value;
|
||||
if ( this.mathfield ) {
|
||||
this.mathfield.setValue( val, { silenceNotifications: true } );
|
||||
}
|
||||
this.value = val || null;
|
||||
if ( this.mathfield ) {
|
||||
if ( val === '' ) {
|
||||
this.mathfield.remove();
|
||||
this.mathfield = null;
|
||||
this._createMathField();
|
||||
} else {
|
||||
this.mathfield.setValue( val, { silenceNotifications: true } );
|
||||
}
|
||||
}
|
||||
this._isSyncing = false;
|
||||
} );
|
||||
|
||||
this.on( 'change:value', ( _e, _n, val ) => {
|
||||
if ( this._isSyncing ) {
|
||||
return;
|
||||
}
|
||||
this._isSyncing = true;
|
||||
const newVal = val ?? '';
|
||||
textarea.value = newVal;
|
||||
if ( this.mathfield && this.mathfield.value !== newVal ) {
|
||||
@ -167,6 +178,7 @@ export default class MathInputView extends View {
|
||||
const val = mf.value;
|
||||
this.latexTextAreaView.element.value = val;
|
||||
this.value = val || null;
|
||||
this._isSyncing = false;
|
||||
} );
|
||||
|
||||
container.appendChild( mf );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user