( selectionRects: CursorRect[], isBackward: boolean, isCollapsed: boolean, )
| 2 | import { CaretPosition } from '../types' |
| 3 | |
| 4 | export function getCaretPosition( |
| 5 | selectionRects: CursorRect[], |
| 6 | isBackward: boolean, |
| 7 | isCollapsed: boolean, |
| 8 | ): CaretPosition | null { |
| 9 | const anchorRect = selectionRects[isBackward ? 0 : selectionRects.length - 1] |
| 10 | |
| 11 | if (!anchorRect) { |
| 12 | return null |
| 13 | } |
| 14 | |
| 15 | return { |
| 16 | height: anchorRect.height, |
| 17 | top: anchorRect.top, |
| 18 | left: anchorRect.left + (isBackward || isCollapsed ? 0 : anchorRect.width), |
| 19 | } |
| 20 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…