Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 5f00bbb

Browse files
author
Luke Barnard
committed
Add comments
1 parent 844ca24 commit 5f00bbb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/RichText.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,24 +204,26 @@ export function textOffsetsToSelectionState({start, end}: SelectionRange,
204204
let selectionState = SelectionState.createEmpty();
205205
for (const block of contentBlocks) {
206206
const blockLength = block.getLength();
207+
// -1 indicating that the position start position has been found
207208
if (start !== -1) {
208209
if (start < blockLength + 1) {
209210
selectionState = selectionState.merge({
210211
anchorKey: block.getKey(),
211212
anchorOffset: start,
212213
});
213-
start = -1;
214+
start = -1; // selection state for the start calculated
214215
} else {
215216
start -= blockLength + 1; // +1 to account for newline between blocks
216217
}
217218
}
219+
// -1 indicating that the position end position has been found
218220
if (end !== -1) {
219221
if (end < blockLength + 1) {
220222
selectionState = selectionState.merge({
221223
focusKey: block.getKey(),
222224
focusOffset: end,
223225
});
224-
end = -1;
226+
end = -1; // selection state for the start calculated
225227
} else {
226228
end -= blockLength + 1; // +1 to account for newline between blocks
227229
}

0 commit comments

Comments
 (0)