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).

The somewhat-complicated interleaving of timeouts is necessary because the input
event fires before the DOM observer. So, the timeouts ensure the following
ordering:

- input event occurs
- DOM mutation is observed and formatters are scheduled
- input transaction runs, flushing the formatters

(And the formatters are not run independently after that because they've already
been flushed.)
Document the undo algorithm in the README.

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