title: Javascript textarea undo redo
body: <p>I'm making a small javascript editor (for a chrome extension) somewhat like the one on SO.</p>
  
  <p>There's a toolbar for manipulation of the text in the textarea. (e.g. surround the selected text with some template)</p>
  
  <p>I was wondering if there is a easy way to achieve this, currently when using the system undo/redo, it messes the text up (I think the system is only keeping track of deltas between edits).</p>