Add ability to specify a custom window context

This change allows monotype to be used with selections inside an iframe. See note on commit for usage.

I'm sure there's a cleaner way to structure the code, and I bet there's a way to auto-detect the window context from `r.root`.