Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove meiData entry after clearing cell #123

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/Editor/MeiTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,22 @@ export class MeiTools {
) {
const meiData = this.meiData.find((meiData) => meiData.row === row);
if (meiData) {
if (mei !== undefined) {
meiData.mei = mei;
}
if (isValid !== undefined) {
meiData.isValid = isValid;
}
if (errorMsg !== undefined) {
meiData.errorMsg = errorMsg;
// Update this.meiData if it exists
if (mei === '') {
// if the mei cell is empty, remove the row from meiData
this.meiData = this.meiData.filter((data) => data.row !== row);
return;
}
if (mei !== undefined) meiData.mei = mei;
if (isValid !== undefined) meiData.isValid = isValid;
if (errorMsg !== undefined) meiData.errorMsg = errorMsg;
} else {
// Add a new entry to this.meiData if it doesn't exist
this.meiData.push({
row,
mei: mei ?? meiData.mei,
isValid: isValid ?? meiData.isValid,
errorMsg: errorMsg ?? meiData.errorMsg,
mei: mei ?? '',
isValid: isValid ?? null,
errorMsg: errorMsg ?? null,
});
}
}
Expand Down