hypothesis/annotator — pull request #61 by csillag (2014-04-25 07:17:08+00:00)
Title: Decouple text selection detection and range encoding

Here is one more step of decoupling independent functionality.

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
(as it always did), and then emits the `successfulSelection` event
with this data. (Which will then trigger the `Adder` button.)

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 time, the PR comes with full test coverage, for all involved plugins.
(TextSelector, LegacyRange, Adder.)