mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 19:52:28 +08:00
Don't allow inserting empty equations
Keep the model free of invisible empty equation tags
This commit is contained in:
parent
2ad6076d6c
commit
ba34f1f3c1
@ -17,5 +17,6 @@ ClassicEditor.create(document.querySelector("#editor"), {
|
|||||||
CKEditorInspector.attach(editor)
|
CKEditorInspector.attach(editor)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
console.error(error.stack);
|
console.error(error.stack);
|
||||||
});
|
});
|
||||||
|
@ -30,16 +30,16 @@ export default class MainFormView extends View {
|
|||||||
// Create key event & focus trackers
|
// Create key event & focus trackers
|
||||||
this._createKeyAndFocusTrackers();
|
this._createKeyAndFocusTrackers();
|
||||||
|
|
||||||
|
// Submit button
|
||||||
|
this.saveButtonView = this._createButton( t( 'Save' ), checkIcon, 'ck-button-save', null );
|
||||||
|
this.saveButtonView.type = 'submit';
|
||||||
|
|
||||||
// Equation input
|
// Equation input
|
||||||
this.mathInputView = this._createMathInput();
|
this.mathInputView = this._createMathInput();
|
||||||
|
|
||||||
// Display button
|
// Display button
|
||||||
this.displayButtonView = this._createDisplayButton();
|
this.displayButtonView = this._createDisplayButton();
|
||||||
|
|
||||||
// Submit button
|
|
||||||
this.saveButtonView = this._createButton( t( 'Save' ), checkIcon, 'ck-button-save', null );
|
|
||||||
this.saveButtonView.type = 'submit';
|
|
||||||
|
|
||||||
// Cancel button
|
// Cancel button
|
||||||
this.cancelButtonView = this._createButton( t( 'Cancel' ), cancelIcon, 'ck-button-cancel', 'cancel' );
|
this.cancelButtonView = this._createButton( t( 'Cancel' ), cancelIcon, 'ck-button-cancel', 'cancel' );
|
||||||
|
|
||||||
@ -159,9 +159,10 @@ export default class MainFormView extends View {
|
|||||||
const mathInput = new LabeledInputView( this.locale, InputTextView );
|
const mathInput = new LabeledInputView( this.locale, InputTextView );
|
||||||
const inputView = mathInput.inputView;
|
const inputView = mathInput.inputView;
|
||||||
mathInput.infoText = t( 'Insert equation in TeX format.' );
|
mathInput.infoText = t( 'Insert equation in TeX format.' );
|
||||||
inputView.on( 'input', () => {
|
|
||||||
if ( this.previewEnabled ) {
|
const onInput = () => {
|
||||||
const equationInput = inputView.element.value.trim();
|
if ( inputView.element != null ) {
|
||||||
|
let equationInput = inputView.element.value.trim();
|
||||||
|
|
||||||
// If input has delimiters
|
// If input has delimiters
|
||||||
if ( hasDelimiters( equationInput ) ) {
|
if ( hasDelimiters( equationInput ) ) {
|
||||||
@ -171,17 +172,22 @@ export default class MainFormView extends View {
|
|||||||
// Remove delimiters from input field
|
// Remove delimiters from input field
|
||||||
inputView.element.value = params.equation;
|
inputView.element.value = params.equation;
|
||||||
|
|
||||||
|
equationInput = params.equation;
|
||||||
|
|
||||||
// update display button and preview
|
// update display button and preview
|
||||||
this.displayButtonView.isOn = params.display;
|
this.displayButtonView.isOn = params.display;
|
||||||
if ( this.previewEnabled ) {
|
}
|
||||||
// Update preview view
|
if ( this.previewEnabled ) {
|
||||||
this.mathView.value = params.equation;
|
// Update preview view
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.mathView.value = equationInput;
|
this.mathView.value = equationInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.saveButtonView.isEnabled = !!equationInput;
|
||||||
}
|
}
|
||||||
} );
|
};
|
||||||
|
|
||||||
|
inputView.on( 'render', onInput );
|
||||||
|
inputView.on( 'input', onInput );
|
||||||
|
|
||||||
return mathInput;
|
return mathInput;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ck-math-tex.ck-placeholder::before {
|
.ck-math-tex.ck-placeholder::before {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ck.ck-toolbar-container {
|
.ck.ck-toolbar-container {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user