Files
claude-code-mirror/claude-code源码-中文注释/src/ink/measure-element.ts
2026-04-03 13:01:19 +08:00

24 lines
404 B
TypeScript

import type { DOMElement } from './dom.js'
type Output = {
/**
* 元素宽度。
*/
width: number
/**
* 元素高度。
*/
height: number
}
/**
* 测量特定 `<Box>` 元素的尺寸。
*/
const measureElement = (node: DOMElement): Output => ({
width: node.yogaNode?.getComputedWidth() ?? 0,
height: node.yogaNode?.getComputedHeight() ?? 0,
})
export default measureElement