I want to filter a DOMRange in JavaScript so that it only contains span elements or #text but I can't find a way to do it.
code: window.getSelection().getRangeAt(0)
window.getSelection().getRangeAt(0)
Check nodeType and tagName
.filter(node => node.nodeType===Node.TEXTNODE || (node.nodeType===Node.ELEMENT_NODE && node.tagName==="SPAN"))