hypothesis/annotator — pull request #62 by csillag (2014-04-25 07:34:27+00:00)
Title: Decouple text selection detection and range encoding (try 2)

Previously, the `TextSelector` plugin was responsible for detecting
the selection of text (using the mouse), filtering out various
unwanted elements from the selection, and then encoding the selection
in a serialized form.

This commit separates this last task (the encoding of the selection)
into a new plugin.

Now the `TextSelector` plugin emits a `rawTextSelection` event, which
carries the list of raw `NormalizedRange` objects.

Then the `LegacyRanges` plugin captures this event, takes the ranges,
serializes them, and creates the annotation skeleton out of them,
and then emits the `successfulSelection` event
with this data. (Which will then trigger the `Adder` plugin.)

My goal here is to make it possible to introduce alternate methods
for describing the target of the annotation.

(For example, using targets and selectors, as done in the Hypothes.is
fork.)

Since both `TextSelector` and `LegacyRange` are core plugins, they are
both automatically installed by default, so end users don't need
to care about this change.

* * *

This PR is an updated version of https://github.com/hypothesis/annotator/pull/61.