| 63 | } |
| 64 | |
| 65 | const 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 | |
| 86 | const marks = (editor: SlateEditor): EditorMarks | null => { |
| 87 | const { selection } = editor |