Constrain the rectangle shape

I’m making an annotation tool for time series data. When a user click on the plot, a rectangular shape will be created.

How could the rectangle shapes be constrained that y0=0 and y1=1? And also, what would be the best way to add text at the middle of the rectangle?

You can try listening to relayout as in

add an arrow-less (showarrow: false) annotation.