This commit is contained in:
+6
-3
@@ -274,6 +274,7 @@ function buildLessonArray(row: Row, ignoreAddress: string, themeColors: ThemeCol
|
|||||||
|
|
||||||
const colIndex = letterToNumber(cell.address.replace(/[0-9]/g, ""));
|
const colIndex = letterToNumber(cell.address.replace(/[0-9]/g, ""));
|
||||||
lessons[colIndex] = parseLessonCell(cell, themeColors, ignoreColors);
|
lessons[colIndex] = parseLessonCell(cell, themeColors, ignoreColors);
|
||||||
|
console.log(lessons[colIndex])
|
||||||
});
|
});
|
||||||
|
|
||||||
const normalized = Array.from(lessons, (x) => (x === undefined ? null : x));
|
const normalized = Array.from(lessons, (x) => (x === undefined ? null : x));
|
||||||
@@ -284,23 +285,25 @@ function buildLessonArray(row: Row, ignoreAddress: string, themeColors: ThemeCol
|
|||||||
|
|
||||||
function parseLessonCell(cell: Cell, themeColors: ThemeColors | null, ignoreColors: boolean): Lesson | null {
|
function parseLessonCell(cell: Cell, themeColors: ThemeColors | null, ignoreColors: boolean): Lesson | null {
|
||||||
try {
|
try {
|
||||||
const text = (cell.text || "").trim();
|
const text = cell.text.trim();
|
||||||
const cleanupRegex = /^úklid\s+(?:\d+\s+)?[A-Za-z]{2}$/;
|
const cleanupRegex = /^úklid\s+(?:\d+\s+)?[A-Za-z]{2}$/;
|
||||||
|
|
||||||
|
// I thought that doing just !text will be enough, but NO. Apparently if text is empty the text isn't null or empty. It's fucking "[object Object]". I have no idea who thought this would be a good idea but here we are. It worked before just because .argb was throwing error and settings the whole value to null in the catch block.
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (!text || cleanupRegex.test(text) || (!cell.fill?.fgColor && !ignoreColors)) return null;
|
if (!text || text === "[object Object]" || cleanupRegex.test(text) || (!cell.fill?.fgColor && !ignoreColors)) return null;
|
||||||
|
|
||||||
const backgroundColor = resolveCellColor(cell, themeColors);
|
const backgroundColor = resolveCellColor(cell, themeColors);
|
||||||
const foregroundColor = !backgroundColor ? undefined : (
|
const foregroundColor = !backgroundColor ? undefined : (
|
||||||
cell.font?.color?.argb === undefined ? "#FF000000" : `#${cell.font.color.argb}`
|
cell.font?.color?.argb === undefined ? "#FF000000" : `#${cell.font.color.argb}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
text,
|
text,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
foregroundColor,
|
foregroundColor,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
willBeSpecified: cell.fill.fgColor.argb === "FFFFFF00" ? true : undefined,
|
willBeSpecified: cell.fill.fgColor?.argb === "FFFFFF00" ? true : undefined,
|
||||||
};
|
};
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user