( node: DOMElement, text: string, softWrap?: boolean[], )
| 363 | // Only first node is taken into account, because other text nodes can't have margin or padding, |
| 364 | // so their coordinates will be relative to the first node anyway |
| 365 | function applyPaddingToText( |
| 366 | node: DOMElement, |
| 367 | text: string, |
| 368 | softWrap?: boolean[], |
| 369 | ): string { |
| 370 | const yogaNode = node.childNodes[0]?.yogaNode |
| 371 | |
| 372 | if (yogaNode) { |
| 373 | const offsetX = yogaNode.getComputedLeft() |
| 374 | const offsetY = yogaNode.getComputedTop() |
| 375 | text = '\n'.repeat(offsetY) + indentString(text, offsetX) |
| 376 | if (softWrap && offsetY > 0) { |
| 377 | // Prepend `false` for each padding line so indices stay aligned |
| 378 | // with text.split('\n'). Mutate in place — caller owns the array. |
| 379 | softWrap.unshift(...Array<boolean>(offsetY).fill(false)) |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | return text |
| 384 | } |
| 385 | |
| 386 | // After nodes are laid out, render each to output object, which later gets rendered to terminal |
| 387 | function renderNodeToOutput( |
no test coverage detected