fix next/prev when the ref refers to a whole text.
some js fixes to handle texts with depth of 1 in the text menu.
Cleanup