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

Function endPoint

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

Source from the content-addressed store, hash-verified

63}
64
65const endPoint = (root: Node, at: Point): Point => {
66 const { path } = at
67 const p = path.slice()
68 let n = Node.get(root, p)
69 let offset = at.offset
70 while (n) {
71 if (Text.isText(n) || n.children.length === 0) {
72 break
73 } else {
74 const index = Math.min(offset, n.children.length - 1)
75 n = n.children[index]
76 p.push(index)
77 offset = Element.isElement(n) ? n.children.length : n.text.length
78 }
79 }
80 return {
81 path: p,
82 offset,
83 }
84}
85
86const marks = (editor: SlateEditor): EditorMarks | null => {
87 const { selection } = editor

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…