Thanks for your question. You have the right to intervene here and try for custody. You have good facts as the child's caretaker here to present and be considered here. No doubt that you will need a lawyer to file and represent you here in this matter.
But I think that you may well have a good claim to be given custody and even to adopt the child in this matter. The judge would be impressed by your care that was rendered herre and your involvement with the child. I wish you good luck here and sympathy for the situation.
Lawyer
25 years as a licensed attorney handling family law matters including divorce, child support, etc