Use UndoFX undo manager.