in richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/TableMeasurer.kt [28:52]
override fun measure(
rowMeasurables: List<List<Measurable>>,
constraints: Constraints,
): Measurements {
val columns = rowMeasurables[0].size
val cellConstraints = Constraints(maxWidth = maxCellWidthPx)
val rowPlaceables = rowMeasurables.map { row ->
row.map { measurable ->
measurable.measure(cellConstraints)
}
}
// Determine the width for each column
val columnWidths = (0 until columns).map { colIndex ->
val measuredMax = rowPlaceables.maxOfOrNull { it[colIndex].width } ?: 0
maxOf(measuredMax, MinCellWidth)
}
// Each row’s height is the maximum cell height in that row.
val rowHeights = rowPlaceables.map { row ->
row.maxOf { it.height }
}
return Measurements(rowPlaceables, columnWidths, rowHeights)
}