Skip to content
Open
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
33 changes: 25 additions & 8 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,27 @@ export class Table {
}

getHeadHeight(columns: Column[]) {
return this.head.reduce(
(acc, row) => acc + row.getMaxCellHeight(columns),
0,
)
var rowSpan = 1
return this.head.reduce((acc, row) => {
if(rowSpan === 1){
rowSpan = row.getMaxRowSpan(columns)
return acc + row.getMaxCellHeight(columns)
}
rowSpan--
return acc
}, 0)
}

getFootHeight(columns: Column[]) {
return this.foot.reduce(
(acc, row) => acc + row.getMaxCellHeight(columns),
0,
)
var rowSpan = 1
return this.foot.reduce((acc, row) => {
if(rowSpan === 1){
rowSpan = row.getMaxRowSpan(columns)
return acc + row.getMaxCellHeight(columns)
}
rowSpan--
return acc
}, 0)
}

allRows() {
Expand Down Expand Up @@ -193,6 +203,13 @@ export class Row {
)
}

getMaxRowSpan(columns: Column[]) {
return columns.reduce(
(acc, column) => Math.max(acc, this.cells[column.index]?.rowSpan || 0),
0,
)
}

hasRowSpan(columns: Column[]) {
return (
columns.filter((column: Column) => {
Expand Down