w3c / input-events

Input Events
https://w3c.github.io/input-events/
Other
24 stars 16 forks source link

How to get the real insert point in a "beforeInput" event ? #61

Open sspi opened 7 years ago

sspi commented 7 years ago

Example :

ab<em>cd</em>

If you select bc from left to right (focus node is in <em/>) and type X, you will get : a<em>Xd</em>

If you select bc from right to left (focus node is before <em/>) and type X, you will get : aX<em>d</em>

But the 2 events (type=beforeInput, inputType=insertText) are identical : getTargetRanges() will not help.

The Selection.focusNode and Selection.focusOffset are missing in the InputEvent in order to know where the insertion will take place.

sspi commented 7 years ago

Note : this issue does not exist in Chrome Canary because the focus seems to always be moved to the range start point before the insertion. In this specification, do we consider the insert point must always be at the first StaticRange InputEvent.getgetTargetRanges()[0] start point ?

johanneswilm commented 7 years ago

This is a good point. We should take it up in the next telco.