Selection + insertion loses data
Inserting (e.g., typing, pasting) over a selection should delete the selection and replace it with text. Instead, it deletes everything until the end of the document (or at least a big chunk). Data is lost.
Need to handle properly deletions + insertions during the same action.
Solution: Use a javascript diff?