According to the information you quoted. If you use money from a New York state 529 plan for nonqualified expenses, then they want you to repay them for the state tax break.
For example if you pull out $5,000 from the 529, then the state wants you to show that you had qualified expenses. But K-12 tuition doesn't meet the states definition. So they want your money back.
Their tax forms will tell you how they figure the tax on the contribution, and separately how they figure the tax on gains.
I don't think that a 529 plan allows you to only pull contributions from the plan. All withdraws will be spit between contributions and gains. The 1099-Q from the 529 plan will tell you the split between contributions and gains.