I need to create a selection in JavaScript in a content editable HTML with define the caret at start of selection. The goal is that to allow the user to continue the selection later with the shortcut Shift + ←.
The main problem is when I defined a new range, the "direction" of selection is lost.
var selection = window.getSelection();
var range = document.createRange();
range.setStart(selection.anchorNode, selection.anchorOffset);
range.setEnd(selection.focusNode, selection.focusOffset);
selection.removeAllRanges();
selection.addRange(range);