Fixes 4898: undo of tag merge

This fixes #4898: undo deletion of a paragraph closing tag that causes tags to merge. This should fix a general problem with undo, which is that undo can sometimes result in tag IDs being reused. This forces reused tag IDs to be replaced with new ones.

To @njx