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.
Transactions can now overwrite, rather than add to, the undo history.
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).
Document the undo algorithm in the README.

Fixes https://github.com/guardian/scribe/issues/98.
Check the cursor position when deciding whether to save an undo item.

This ensures that the cursor position will be saved prior to running a transaction.

Fixes https://github.com/guardian/scribe/issues/309.
Do not inject `br` elements into childless elements.

Such "invalid" child elements will be escaped by `innerHTML` when a history item is
restored. This will prevent the user from ever undoing past this point, because when the
user next goes to undo, Scribe will then determine that the editor's contents have
diverged from the previous history item and save the contents before undoing.
Don't unnecessarily record an undo item on every press of the delete key.