The `getSelection()` function throws an exception if `editor.parentNode` is a `ShadowRoot`.
angezid opened this issue · 2 comments
angezid commented
As it's turns out, this is a Firefox problem.
antonmedv commented
Well. We can fix it as well, maybe?
angezid commented
I ended up with JavaScript code:
function getSelection() {
const root = editor.getRootNode();
if(root.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
try { return root.getSelection(); } catch(e) { }
}
return window.getSelection();
}