Updated undo plugin to handle command states when entering/leaving read-only mode.