How to iterate through the multiple selected html elements.
const selection = window.getSelection();
const selectedElements = selection.getRangeAt(0).cloneContents().querySelectorAll("*");
This gives all the elements, but I want only selected elements.
querySelectorAll("*")retrieves all elements within the cloned range to filter this down to only the elements you want: