In this work, we develop novel structure-preserving numerical schemes for a class of nonlinear Fokker--Planck equations with nonlocal interactions. Such equations can cover many cases of importance, such as porous medium equations with external potentials, optimal transport problems, and aggregation-diffusion models. Based on the energetic variational approach, a trajectory equation is first derived by using the balance between the maximal dissipation principle and the least action principle. By a convex splitting technique, we propose energy dissipating numerical schemes for the trajectory equation. Rigorous numerical analysis reveals that the nonlinear numerical schemes are uniquely solvable, naturally respect mass conservation and positivity at the fully discrete level, and preserve steady states in an admissible convex set, where the discrete Jacobian of flow maps is positive. Under certain assumptions on smoothness and a positive Jacobian, the numerical schemes are shown to be second order accurate in space and first order accurate in time. Extensive numerical simulations are performed to demonstrate several valuable features of the proposed schemes. In addition to the preservation of physical structures, such as positivity, mass conservation, discrete energy dissipation, and steady states, numerical simulations further reveal that our numerical schemes are capable of solving degenerate cases of the Fokker--Planck equations effectively and robustly. It is shown that the developed numerical schemes have convergence order even in degenerate cases with the presence of solutions having compact support and can accurately and robustly compute the waiting time of free boundaries without any oscillation. The limitation of numerical schemes due to a singular Jacobian of the flow map is also discussed.