From 6c509e425fc215802e420faa816283130a6fa837 Mon Sep 17 00:00:00 2001 From: Tom Lawton Date: Tue, 5 Dec 2023 15:42:55 +0000 Subject: [PATCH] Moving the empty text fix as some were getting through before --- src/gen-tables.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gen-tables.ts b/src/gen-tables.ts index ef44a9736..fd9a6d24d 100644 --- a/src/gen-tables.ts +++ b/src/gen-tables.ts @@ -469,12 +469,10 @@ export function getSlidesForTableRows (tableRows: TableCell[][] = [], tableProps // 3: set array of words that comprise this line const currLine: TableCell[] = srcCell._lines.shift() - // 4: create new line by adding all words from curr line (or add empty if there are no words to avoid "needs repair" issue triggered when cells have null content) - if (Array.isArray(tgtCell.text)) { - if (currLine) tgtCell.text = tgtCell.text.concat(currLine) - else if (tgtCell.text.length === 0) tgtCell.text = tgtCell.text.concat({ _type: SLIDE_OBJECT_TYPES.tablecell, text: '' }) - // IMPORTANT: ^^^ add empty if there are no words to avoid "needs repair" issue triggered when cells have null content - } + // 4: create new line by adding all words from curr line + if (Array.isArray(tgtCell.text) && currLine) { + tgtCell.text = tgtCell.text.concat(currLine); + } // 5: increase table height by the curr line height (if we're on the last column) if (currCellIdx === rowCellLines.length - 1) emuTabCurrH += emuLineMaxH @@ -487,6 +485,17 @@ export function getSlidesForTableRows (tableRows: TableCell[][] = [], tableProps if (brent === 0) isDone = true } + // Fill in any empty text cells that may still exist + // NOTE: This fixes the "needs repair" issue when a cell has no text + currTableRow.forEach(function (cell) { + if (Array.isArray(cell.text) && cell.text.length === 0) { + cell.text.push({ + _type: SLIDE_OBJECT_TYPES.tablecell, + text: "", + }); + } + }); + // F: Flush/capture row buffer before it resets at the top of this loop if (currTableRow.length > 0) newTableRowSlide.rows.push(currTableRow)