MCPcopy Create free account
hub / github.com/editablejs/editable / getCaretPosition

Function getCaretPosition

packages/plugins/yjs/src/utils/selection.ts:4–20  ·  view source on GitHub ↗
(
  selectionRects: CursorRect[],
  isBackward: boolean,
  isCollapsed: boolean,
)

Source from the content-addressed store, hash-verified

2import { CaretPosition } from '../types'
3
4export 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}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…