Rangy 1.3 alpha released

302 views
Skip to first unread message

Tim Down

unread,
May 27, 2012, 8:27:47 PM5/27/12
to ra...@googlegroups.com
I'm pleased to announce the release of Rangy 1.3 alpha. The major feature is a new TextRange module which provides:

- character and word-based range and selection manipulation, regardless of element boundaries
- flexible text/regex search within visible page text
- character index-based selection/range save and restore which is not vulnerable to formatting changes (unlike Rangy's existing selection save/restore module)
- innerText implementation

I would be very keen to hear any feedback on the new functionality and API.

Tim

nico burns

unread,
May 27, 2012, 11:27:02 PM5/27/12
to ra...@googlegroups.com

This sounds great Tim! The new save and restore feature may be the thing that finally tips me over the edge to porting my WYSIWYG editor to rangy. I have one suggestion, the word based selection - it might be more natural to have it ignore inline element boundaries, but break at block level ones, perhaps as an option... I probably won't get the chance to use this for a while, but keep up the good work!

Nico

Tim Down

unread,
May 28, 2012, 7:14:39 AM5/28/12
to ra...@googlegroups.com
Thanks. Block level element boundaries add line breaks into the
visible text, so I think this already works as you hoped.

Tim

prashant2402

unread,
May 29, 2012, 8:47:32 AM5/29/12
to ra...@googlegroups.com
Hi Tim,

Thanks for your work.

Could you let me know if save/restore module still has an issue if different browser is used for restore than the one in which original selection was saved?

Prash

Jay Smith

unread,
May 29, 2012, 10:03:57 AM5/29/12
to ra...@googlegroups.com
Yay! Tim, you've crafted something out of rock here, excellent job.
347.gif

Jay Smith

unread,
May 29, 2012, 10:07:56 AM5/29/12
to ra...@googlegroups.com, Tim Down, nico....@gmail.com
Nico, Tim
any idea how to get the caret position, or the word preceding the carets position to be more percise?
I am building a javascript editor and I want to offer intellisense support for objects, showing a popup of properties, methods etc following the dot "."...

I may not be explaining myself correctly, I want to build a simple javascript intellisense editor,
any help?

Jay

Tim Down

unread,
Jun 6, 2012, 7:36:40 PM6/6/12
to ra...@googlegroups.com
Hi Prash,

It *should* be OK, I think. More testing needed, but that was part of
the intention of this module: everything is based on a normalized view
of the text on the page. No guarantees at this stage, possibly ever:
CSS and HTML are complicated and it's impossible (or at least
prohibitively difficult) to cover every possibility.

Tim

Tim Down

unread,
Jun 6, 2012, 7:46:06 PM6/6/12
to ra...@googlegroups.com
Jay,

If the caret is immediately after a dot, you could do

var sel = rangy.getSelection();
var range = sel.getRangeAt(0);
range.moveStart("word", -1);
sel.setSingleRange(range);

By the way, if you're writing a code editor, have you looked at
CodeMirror (http://codemirror.net/)? That's a truly excellent piece of
engineering.

Tim

Rui Min

unread,
Dec 4, 2013, 10:01:33 AM12/4/13
to ra...@googlegroups.com
Thanks! Will play with this new module. This is very helpful.
Reply all
Reply to author
Forward
0 new messages