Home › Forums › General XMetaL Discussion › Track Changes For Elements, Attributes, etc. In addition to Content › Reply To: Track Changes For Elements, Attributes, etc. In addition to Content
Reply to: Track Changes For Elements, Attributes, etc. In addition to Content
July 8, 2014 at 10:17 pmHere's something you can try adding to your document-level customization's MCR file.
I've only done basic testing on this so there are bound to be edge cases that this does not catch.
Make sure you test it thoroughly and make changes as needed (and remove the alerts I've put in here to aid with understanding the logic).
[code=example]
var rng = ActiveDocument.Range;
if(ActiveDocument.TrackRevisions) { //override default behaviour when Revision Tracking is enabled
Application.Alert(“change tracking is on”);
if (rng.CanChange(elemChangeTo)) { //<--safety check in case the change is not allowed for some unforeseen reason
Application.Alert(“doing the special change”);
//the change is allowed, do the override
rng.SelectElement();
var elemStr = rng.Text;
rng.Delete();
rng.PasteString(elemStr);
}
else {
//the change is not allowed
Application.Alert(“Cannot change element to '” + elemChangeTo + “'.”);
}
}
else {
Application.Alert(“change tracking is off, doing default behaviour”);
//do the default behaviour when Revision Tracking is disabled
rng.ContainerName = elemChangeTo;
}
]]>