Improve the algorithm for recording undo items.

Undo items are no longer recorded per-keystroke, but when the user:
- creates a new line
- finishes a word
- switches typing direction e.g. starts deleting text after adding
  text, or starts adding text after deleting text.

This is more performant and also makes it faster for the user to navigate the undo
history, while still capturing a reasonable amount of the history.
Save the current state before undoing.

To return to if the user hits redo. (This was not necessary when we were recording undo
items on every keystroke, because then we would be guaranteed up-to-date before
undoing. But now, the user might press undo in the middle of a word.)
Record an undo item before running a transaction.

In addition to (previously) after running a transaction: now that we are no
longer recording undo items on every keystroke, we might not be guaranteed to be
up-to-date before undoing.
Run the formatters as part of the input transaction.

This not only consolidates 'content-changed' events and undo items, but enables
us to avoid recording undo items for typing-related DOM mutations (which changes
are recorded, if appropriate, by the typing history manager).

Applying the formatters no longer pops an undo item because one will no longer
be created after the input transaction and before the formatter transaction,
now that both transactions will run together.
Document the undo algorithm in the README.

Fixes https://github.com/guardian/scribe/issues/98.