W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2011

[whatwg] [editing] Caret Position Access Methods

From: Ehsan Akhgari <ehsan@mozilla.com>
Date: Wed, 10 Aug 2011 19:39:53 -0400
Message-ID: <4E4316C9.5040607@mozilla.com>
On 11-07-29 2:14 PM, Ryosuke Niwa wrote:
> 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.

I think I may be missing something.  Aren't ranges exactly what you 
want?  It would be very nice to enable execCommand to work on any given 
range, but besides that, I don't see why we need to modify the selection 
spec at all...

Ehsan
Received on Wednesday, 10 August 2011 16:39:53 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:35 UTC