Skip to content

New Features In One Point Three

Tim edited this page Jul 16, 2014 · 10 revisions

New features in Rangy 1.3

Documentation home

New features in Rangy 1.3

Rangy 1.3 is still in development. It is incomplete and the API may change.

New TextRange module

Demo page

Character and word-based Range and Selection manipulation, relative to the visible text on the page. This is a major new module with some powerful features:

  • moveStart(), moveEnd(), move() and expand() Range methods inspired by IE's TextRange object
  • Page text search, using a string or a regular expression
  • Character offset-based selection save and restore, immune to changes in innerHTML
  • Selection snap to words
  • Cross-browser innerText implementation
  • Selection and range trimming

New Highlighter module

Demo page

API to allow creation, removal, serialization and deserialization of highlights within a page. It uses the TextRange module's character-based features to keep track of highlight positions. This should be an improvement on the approach of the previous, unofficial Highlighter module, whose performance worsened exponentially as the number of highlights increased.

Additions and enhancements

  • Rangy's main entry functions are now much more permissive. For example, rangy.createRange() and rangy.getSelection() and all related methods now accept a Window, Document or iframe element
  • Added setStartAndEnd() convenience method to Range
  • Added new useExistingElements option to CSS class applier options object (issue 111)
  • Selection setSingleRange() now accepts an additional second parameter, direction
  • Every backwards Boolean API parameter replaced with string direction parameter
  • Added applyToRanges(), unapplyToRanges() and toggleRanges() to CSS class applier
  • Added removeEmptyElements option to CSS class applier. When true, empty elements generated by (or appearing to be generated by) the applier are removed when applying or unapplying to a range or selection
  • Module loading improved: module script include order no longer matters, so long as rangy-core.js comes first. Also, the console now provides more helpful warning messages when modules fail to load.

Issues fixed

Issue 75, issue 80, issue 92, issue 99, issue 101, issue 104, issue 107, issue 108, issue 111

Clone this wiki locally