Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Don't allow inserting empty equations Keep the model free of invisible empty equation tags
Jules Bertholetba34f1f3c1bb
diff --git a/demo/app.js b/demo/app.jsindex 398ecb3fdb..82e10d89d0 100644--- a/demo/app.js+++ b/demo/app.js@@ -17,5 +17,6 @@ ClassicEditor.create(document.querySelector("#editor"), {CKEditorInspector.attach(editor)}).catch((error) => {+ console.error(error);console.error(error.stack);});diff --git a/src/ui/mainformview.js b/src/ui/mainformview.jsindex c6205c096b..d3230b6c26 100644--- a/src/ui/mainformview.js+++ b/src/ui/mainformview.js@@ -30,16 +30,16 @@ export default class MainFormView extends View {// Create key event & focus trackersthis._createKeyAndFocusTrackers();+ // Submit button+ this.saveButtonView = this._createButton( t( 'Save' ), checkIcon, 'ck-button-save', null );+ this.saveButtonView.type = 'submit';+// Equation inputthis.mathInputView = this._createMathInput();// Display buttonthis.displayButtonView = this._createDisplayButton();- // Submit button- this.saveButtonView = this._createButton( t( 'Save' ), checkIcon, 'ck-button-save', null );- this.saveButtonView.type = 'submit';-// Cancel buttonthis.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 inputView = mathInput.inputView;mathInput.infoText = t( 'Insert equation in TeX format.' );- inputView.on( 'input', () => {- if ( this.previewEnabled ) {- const equationInput = inputView.element.value.trim();++ const onInput = () => {+ if ( inputView.element != null ) {+ let equationInput = inputView.element.value.trim();// If input has delimitersif ( hasDelimiters( equationInput ) ) {@@ -171,17 +172,22 @@ export default class MainFormView extends View {// Remove delimiters from input fieldinputView.element.value = params.equation;+ equationInput = params.equation;+// update display button and previewthis.displayButtonView.isOn = params.display;- if ( this.previewEnabled ) {- // Update preview view- this.mathView.value = params.equation;- }- } else {+ }+ if ( this.previewEnabled ) {+ // Update preview viewthis.mathView.value = equationInput;}++ this.saveButtonView.isEnabled = !!equationInput;}- } );+ };++ inputView.on( 'render', onInput );+ inputView.on( 'input', onInput );return mathInput;}diff --git a/theme/mathform.css b/theme/mathform.cssindex d5046e2542..2717610585 100644--- a/theme/mathform.css+++ b/theme/mathform.css@@ -26,7 +26,7 @@}.ck-math-tex.ck-placeholder::before {- display: none !important;+ display: none !important;}.ck.ck-toolbar-container {