Adding the undo when pasting a region.