eg. enter image description here
//works for textnodes but breaks the moment it encounters listnodes
const rangeSelection = $createRangeSelection();
const firstChild = firstNode.getTopLevelElement().getFirstChild();
let lastChild = lastNode.getTopLevelElement().getLastChild();
const initialFocusOffSet = prevText.length || 0;
const initialAnchorOffSet = lastChild?.getTextContentSize();
rangeSelection.setTextNodeRange(
firstChild,
initialFocusOffSet,
lastChild,
initialAnchorOffSet
);
$setSelection(rangeSelection);
But I want to achieve this for other nodes as well, eg. lists, etc.
I've tried the createDOMRange in the following way, but it doesn't seem to work as expected. I get range as null for some reason.
//doesn't work!
const range = createDOMRange(
activeEditor,
firstNode,
initialFocusOffSet,
lastNode,
initialAnchorOffSet
);
applyDomRange(range);