[whatwg] [editing] Caret Position Access Methods
gisolfi at us.ibm.com
Fri Jul 29 11:07:57 PDT 2011
Ian Hickson <ian at hixie.ch> wrote on 07/29/2011 12:47:08 PM:
> From: Ian Hickson <ian at hixie.ch>
> To: Dan Gisolfi/Somers/IBM at IBMUS
> Cc: whatwg at lists.whatwg.org, ayg at aryeh.name
> Date: 07/29/2011 12:47 PM
> Subject: Re: [whatwg] [editing] Caret Position Access Methods
> On Fri, 29 Jul 2011, Dan Gisolfi wrote:
> > Ian Hickson <ian at hixie.ch> wrote on 07/29/2011 12:28:15 PM:
> > > >
> > > > An example scenario for such a requirement (addition of such
> > > > methods) would be the following: When developing an cooperative
> > > > enabled rich-text-editor, whereby multiple simultaneous users can
> > > > co-author shared content, the editor must be able to allow each
> > > > participant to get/set caret/cursor position in order to reflect
> > > > multiple positions of each active author in a cooperative web
> > > > session.
> > >
> > > Surely all but the local one would not be real carets?
> > Not sure what you mean by "real caret"
> By "real caret" I mean a caret that supports all the complexity of the
> system caret: relationship to the system selection, being movable by the
> user, effect on execCommand() APIs, effect on local system focus, etc.
> > but the scenario implies that each co-authoring conference(session)
> > participant would have a corresponding cursor (caret) position
> > their associated reference point for edits.
> I don't think those are system carets. Why wouldn't using a <span>
> be sufficient for this?
> Ian Hickson U+1047E )\._.,--....,'``. fL
> http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
> Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
My example use case is pertinent to a collaboration environment. In such a
case the web developer would handle the remote vs. local caret issues
using our framework.
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.
My assumptions is that such a request would be within the scope of the
HTML Edit API spec. If I am mistaken, my apologies.
More information about the whatwg