Add/Remove image on GOJS diagram with undo-redo functionality

I really cannot read your code. Please format and properly indent your code by surrounding each section with lines consisting of triple backquotes.

Instead of removing and then re-adding a node, why not modify it by calling Model.setDataProperty?