Undo/Redo—initial implementation

WYMeditor's undo is, in some cases, not accurate.
I'm really happy about this. Can you suggest some ways to make it easier to understand while keeping the concept of this `_do` function and DRY?