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

Function startPoint

packages/models/src/interfaces/editor.ts:44–63  ·  view source on GitHub ↗
(root: Node, at: Point)

Source from the content-addressed store, hash-verified

42}
43
44const startPoint = (root: Node, at: Point): Point => {
45 const { path } = at
46 const p = path.slice()
47 let n = Node.get(root, p)
48 let offset = at.offset
49 while (n) {
50 if (Text.isText(n) || n.children.length === 0) {
51 break
52 } else {
53 const index = Math.min(offset, n.children.length - 1)
54 n = n.children[index]
55 p.push(index)
56 offset = 0
57 }
58 }
59 return {
60 path: p,
61 offset,
62 }
63}
64
65const endPoint = (root: Node, at: Point): Point => {
66 const { path } = at

Callers 1

editor.tsFile · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…