The first thing you need to do is protect yourself. Go see a mental health professional and explain your situation. They will not be able to diagnose the ex but can give a diagnoses or you which may show you have been in an abusive relationship with a possible BPD. This would only help your case. Next gather evidence of her behaviour. Old emails or texts that may show dysregulation on her behalf. Character references might be useful. Having exs show that you are not violent could help.
Don't antagonize the situation. NC is the key and only have contact through a lawyer. You don't want harassment added to the charges.
As for mood changes in pregnancy yes yes yes. It is more likely to be estrogen or progesterone that causes this. Both my exs went loopy on oral contraceptives so this is a valid link for me.
Yes, protect yourself. That is the priority. If you go down for the count, then you can't help anyone, either her or the child.
Sadly, you can't waste precious time and effort worrying about her or how to help her. Pregnancy or mood changes probably can't explain all her behaviors. Maybe some, but not all. Many new members upon arrival here expressed the hope that telling the other person that they have a Personality Dysfunction would be received well. Such hopes didn't work out, to the contrary, it intensified the obstructions and overreactions. With the acting-out PDs - such as Borderline, Narcissistic, Antisocial, Histrionic or Paranoid - there is typically so much Denial, Blaming, Blame-Shifting, Posturing, etc that you are unlikely to help her.
Repeat, you can't reason with her, there is too much emotional baggage perceived by her in anything you say or do, it is smart to stay in the background as much as possible. Certainly don't do anything that could be twisted into accusations of harassment, stalking or worse.
The fact is she's an adult and you can't control another adult. (Believe it or not but you trying to 'help' her could be twisted into claims you're trying to control her!) Yes, she is effectively trying to control and destroy you by making the worst of false allegations, but your focus needs to be on taking care of yourself.
Now that you know the extent of what she is capable of, the wise course is to Never Again be in close contact with her in non-public and indefensible scenarios. Many here, myself included, have recorded themselves during child exchanges and other close contact in order to have some 'insurance' that we weren't the ones behaving poorly.
Meanwhile, defend yourself. Don't admit to anything you didn't do. Beware of 'plea deals' where you admit some level of guilt. Such admissions prevent you from making appeals of bad court decisions and don't allow you to state you are innocent.
Have you read Splitting, an essential handbook for both you and your lawyer?
Splitting: Protecting Yourself While Divorcing Someone with Borderline or Narcissistic Personality Disorder by Bill Eddy & Randi Kreger
Very likely one legal strategy you can take is to ask the court to order Psych Evals on BOTH of you. In the USA there are respected tests such as MMPI-2 that assist the other professionals in the case to figure what's really happening. Court needs to know whether you are psychologically likely to have done the things she claimed and whether she is psychologically likely to have made false allegations as you have claimed. Anything less and the court won't be able to make an informed decision.