toOffset

Converts a CursorPosition to a character offset (index) in the text.

Return

the character offset corresponding to the given position, or -1 if the position is out of bounds

Parameters

text

the text content to search in