* Resolves the on-canvas dimensions of a note block. * Notes are fixed-width and use a deterministic height, but fall back to any * stored measurement or data override when present.
(block: BlockState)
| 321 | * stored measurement or data override when present. |
| 322 | */ |
| 323 | function getNoteDimensions(block: BlockState): { width: number; height: number } { |
| 324 | const width = Math.max( |
| 325 | resolveNumeric(block.data?.width, 0), |
| 326 | block.layout?.measuredWidth ?? 0, |
| 327 | BLOCK_DIMENSIONS.FIXED_WIDTH |
| 328 | ) |
| 329 | |
| 330 | const defaultHeight = |
| 331 | BLOCK_DIMENSIONS.HEADER_HEIGHT + |
| 332 | BLOCK_DIMENSIONS.NOTE_CONTENT_PADDING + |
| 333 | BLOCK_DIMENSIONS.NOTE_BASE_CONTENT_HEIGHT |
| 334 | |
| 335 | const height = Math.max( |
| 336 | resolveNumeric(block.data?.height, 0), |
| 337 | block.layout?.measuredHeight ?? 0, |
| 338 | block.height ?? 0, |
| 339 | defaultHeight |
| 340 | ) |
| 341 | |
| 342 | return { width, height } |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * Checks if a block has a valid, finite position. |
no test coverage detected