(root: Node, at: Point)
| 42 | } |
| 43 | |
| 44 | const 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 | |
| 65 | const endPoint = (root: Node, at: Point): Point => { |
| 66 | const { path } = at |