* Gets metrics for a regular (non-container) block. * Falls back to subblock-based height estimation when no measurement exists, * which prevents overlaps for newly added blocks that haven't been rendered.
(block: BlockState)
| 245 | * which prevents overlaps for newly added blocks that haven't been rendered. |
| 246 | */ |
| 247 | function getRegularBlockMetrics(block: BlockState): BlockMetrics { |
| 248 | const minWidth = BLOCK_DIMENSIONS.FIXED_WIDTH |
| 249 | const minHeight = BLOCK_DIMENSIONS.MIN_HEIGHT |
| 250 | const measuredH = block.layout?.measuredHeight ?? block.height |
| 251 | const measuredW = block.layout?.measuredWidth |
| 252 | const estimatedDimensions = estimateWorkflowBlockDimensions(block) |
| 253 | const estimatedHeight = estimatedDimensions.height |
| 254 | |
| 255 | const hasMeasurement = typeof measuredH === 'number' && measuredH > 0 |
| 256 | const height = hasMeasurement ? Math.max(measuredH, estimatedHeight, minHeight) : estimatedHeight |
| 257 | const width = Math.max(measuredW ?? estimatedDimensions.width, minWidth) |
| 258 | |
| 259 | return { |
| 260 | width, |
| 261 | height, |
| 262 | minWidth, |
| 263 | minHeight, |
| 264 | paddingTop: BLOCK_DIMENSIONS.HEADER_HEIGHT, |
| 265 | paddingBottom: BLOCK_DIMENSIONS.HEADER_HEIGHT, |
| 266 | paddingLeft: BLOCK_DIMENSIONS.HEADER_HEIGHT, |
| 267 | paddingRight: BLOCK_DIMENSIONS.HEADER_HEIGHT, |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | /** |
| 272 | * Gets the dimensions and metrics for a block |
no test coverage detected