[w3c/editing] Disambiguate caret position at wrapped line boundaries (#189)

Hello,

There's a gap in the current `Range` and `Selection` APIs for wrapped lines, where the position at the end of the first line and the beginning of the second line cannot be differentiated.
For example, if you have the following content:
```
AAA
BBB
```
Then if you position the caret at the end of `AAA` and get the `Range`, it is identical to when you position the caret before `BBB`. Similarly, if you try to move the caret to the end of `AAA` by creating a new `Range`, most browsers position the caret to be on the next line.

I've also tried using `getBoundingClientRect` and `getClientRects` to disambiguate the two, which doesn't work. Even if it did, there would still be a need to be able to position things at the end of the line.

The primary use-case for this is to be able to improve upon the default behavior of `up/down/home/end` keys for moving the caret in complex documents. For e.g. if you have a `cE="false"` node at the end of a wrapped line, pressing `end` takes the caret to the beginning of the next line, which is not what is expected. You can see this in action in "Case 3: Line wrapping" in https://y2wm48yqm9.codesandbox.io/

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/editing/issues/189

Received on Wednesday, 30 January 2019 01:01:04 UTC