add `Document.positionToIndex` with test