Here's the scenario: The user selects some text. I want to modify the selection to include the complete text inside the bounding AnchorNode and FocusNode, regardless of where the user starts and stops selecting.
<script>
document.onselectionchange =(e)=>{
let sel=document.getSelection();
// Here I want to expand the selection to include all the text in the selection. For example
// if "AA CC" is selected in the html below, I want to expand it to "AAAA BBBB CCCC"
}
</script>
<span id="container" contenteditable="true">
<span id="span1">AAAA </span><span id="span2">BBBB </span><span id="span3">CCCC </span><span id="span4">DDDD</span>
</span>
Is this possible? Any guidance would be appreciated.