Hi, I have been trying to call the replaceRange transaction method on positions that should definitely be in range, but continue to get a
RangeError: Position X out of range.
When running this:
const from = range.range.start.index + 1; const to = range.range.end.index + 1; const expression = initialValue.expressions[range.code]; const node = getExpressionNode(expression); transaction.replaceRangeWith(from, to, node);
The ranges I am providing above are valid ranges in the
editorState.doc.textContent that I am calculating based on regex patterns.
That code throws the error above, and when console logging first the
end value and then also calculating the last position using
const lastPos = Selection.atEnd(editorState.doc)?.anchor; My end position is lower than the lastPost, i.e: end = 177, lastPos = 185.
Trying to figure out why it’s complaining about being out of range when everything leads me to believe it is in fact in range. Any help is appreciated, thanks in advance!