Add undo/redo handler for codemirror