diff --git a/src/Editor/CressTable.ts b/src/Editor/CressTable.ts index 6cace21..1687631 100644 --- a/src/Editor/CressTable.ts +++ b/src/Editor/CressTable.ts @@ -173,16 +173,18 @@ export class CressTable { changes?.forEach(([row, prop, oldValue, newValue]) => { if (prop === 'mei' && oldValue !== newValue) { // validate the new edited mei data and update the validation status - this.meiTools.setProcessStatus(newValue); this.meiTools.updateMeiData(row, newValue, undefined, undefined); this.table.render(); - this.validationTools - .meiValidator(newValue) - .then(([isValid, errorMsg]) => { - this.meiTools.updateMeiData(row, undefined, isValid, errorMsg); - this.table.render(); - this.meiTools.setResultStatus(); - }); + if (newValue !== '') { + this.meiTools.setProcessStatus(newValue); + this.validationTools + .meiValidator(newValue) + .then(([isValid, errorMsg]) => { + this.meiTools.updateMeiData(row, undefined, isValid, errorMsg); + this.table.render(); + this.meiTools.setResultStatus(); + }); + } } }); } diff --git a/src/Editor/MeiTools.ts b/src/Editor/MeiTools.ts index a471a9f..9d82610 100644 --- a/src/Editor/MeiTools.ts +++ b/src/Editor/MeiTools.ts @@ -41,6 +41,11 @@ export class MeiTools { ) { const meiData = this.meiData.find((meiData) => meiData.row === row); if (meiData) { + // if the mei cell is empty, remove the row from meiData + if (mei === '') { + this.meiData = this.meiData.filter((meiData) => meiData.row !== row); + return; + } if (mei !== undefined) { meiData.mei = mei; } @@ -52,10 +57,10 @@ export class MeiTools { } } else { this.meiData.push({ - row, - mei: mei ?? meiData.mei, - isValid: isValid ?? meiData.isValid, - errorMsg: errorMsg ?? meiData.errorMsg, + row: row, + mei: mei ?? '', + isValid: isValid ?? null, + errorMsg: errorMsg ?? null, }); } }