Skip to content

Commit

Permalink
fix: error handling for extracting image and mei data
Browse files Browse the repository at this point in the history
- Make header search case insensitive
- Add notification if column not found

Resolves: #106
  • Loading branch information
yinanazhou committed Jul 15, 2024
1 parent ca06fd8 commit f172380
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/Editor/CressTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,26 @@ export class CressTable {
const indices = this.columnTools.getIndices(body).map(String);

// Process images
let inputImgHeader = inputHeader.find((header) => header.includes('image'));
this.imageTools.storeImages(inputImgHeader, body);
let inputImgHeader = inputHeader.find(
(header) =>
header.toLowerCase().includes('image') ||
header.toLowerCase().includes('img'),
);
if (inputImgHeader) {
this.imageTools.storeImages(inputImgHeader, body);
} else {
Notification.queueNotification('Failed to extract image data', 'error');
}

// Process mei data
let inputMeiHeader = inputHeader.find((header) => header.includes('mei'));
this.meiTools.initMeiData(inputMeiHeader, body);
let inputMeiHeader = inputHeader.find((header) =>
header.toLowerCase().includes('mei'),
);
if (inputMeiHeader) {
this.meiTools.initMeiData(inputMeiHeader, body);
} else {
Notification.queueNotification('Failed to extract MEI data', 'error');
}

// Initialize table
this.table = new Handsontable(container, {
Expand Down

0 comments on commit f172380

Please sign in to comment.