Fix for 4948: changing tags

This fixes #4948 when you change from one tag to another. It works by implementing an "elementReplace" edit type.

To @njx