[whatwg] [editing] Caret Position Access Methods

Ryosuke Niwa rniwa at webkit.org
Fri Jul 29 11:14:40 PDT 2011


On Fri, Jul 29, 2011 at 11:07 AM, Dan Gisolfi <gisolfi at us.ibm.com> wrote:
>
> My point herein and motivation for the suggestion is that this
> functionality (get/set caret) is available in the textarea element. Using
> a textarea element you can get/set caret position via
> get/setSelectionRange(). These two methods should be implemented for a
> contentEditable div or the likes. Within a contentEditable div, there is
> no way to [a] tell where the caret is in relation to the text, such as the
> index; [b] direct the caret to a specific position within the text.
>

So what you want is Range/Selection <-> TextIndex API?  I think that makes a
sense.  Ideally such an API provide an index of selection/range within the
textContent of the editing host.  WebKit already implements very similar
mechanism internally and use it extensively in editing, spell checking, and
IME code.

- Ryosuke



More information about the whatwg mailing list