Closed Bug 357218 Opened 18 years ago Closed 18 years ago

Editor:Midas. We need a method to get TextNode at caret's position.

Categories

(Core :: DOM: Editor, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: mva.led, Unassigned)

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060921 Ubuntu/dapper-security Firefox/1.5.0.7
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060921 Ubuntu/dapper-security Firefox/1.5.0.7

We need a method that rapidly we us the TextNode where the caret is positioned. Something like textNodeAtCaret() would be nice.

Reproducible: Always
More on why we need this feature.

JITIR agents [1] could be built on top of this kind of functionality. A JITIR like Remembrance Agent would be a very nice feature for some CMS.

Currently, MSHTML "supports" what they call "Markup Services" and "Display Services", through interfaces IMarkupServices and IDisplayServices.

Although none of those interfaces are "scriptable" (they don't inherit from IDispatch), we have create an automation object we can put inside HTML to by-pass this restriction. Our object has only one method: elementAtCaret(doc) which receives an IHTMLDocument reference (the document with designMode set to On) and returns the element in which the caret is positioned.


I'm willing to work on this feature, though I have little experience with C programming, and none with the mozilla code base. I'm reading lots of docs on http://developer.mozilla.org/. Any ideas where I should start?

--
References

[1] http://www.research.ibm.com/journal/sj/393/part2/rhodes.pdf
There's actually a way to do this:

s = document.getSelection()
r = s.getRangeAt(0);
textNodeAtCaret = r.commonAncesorContainer;
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.