  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 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 fully discrete level, and
preserve steady states. Under certain smoothness assumptions, 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, blue and steady states, numerical simulations further reveal that
our numerical schemes are capable of solving \emph{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, can accurately and
robustly compute the waiting time of free boundaries without any oscillation,
and can approximate blow-up singularity up to machine precision.
