Window.getSelection API support?

It doesn’t appear like Vaadin components support the [Window.getSelection API]
( Can anyone confirm? If so, is it on the roadmap or is it planned?

I would find it a valuable feature / addon. I’d like to retrieve what text the user has selected and/or be able to programmatically select text.

Hello. While we use getSelection in Rich Text Editor, you should be aware of the following limitations:

  1. When using Shadow DOM, window.getSelection().getRange() does not correctly report nodes from within shadow root in Safari. This is a [known limitation]
    (, which exists by design due to how Safari respects the nature of encapsulation.

  2. In Chrome this works because they also implement shadowRoot.getSelection() but that API is not standardized.

  3. Firefox does not seem to have such a restriction (unlike Safari).

As a workaround, we included the [polyfill]
( for Safari behavior into the code of Rich Text Editor. However it’s not tested enough, not 100% reliable and there might be edge cases related to how getRange is calculated in certain conditions.

Whoever starts working on the addon should take the above into account.

Ok. I actually wasn’t aware of Rich Text Editor’s use of getSelection. I was actually thinking about the more basic components, like Span, Div, or Label. Would the situation be less or equally challenging for these components because they’re less sophisticated than Rich Text Editor? What is the likelihood of implementing getSelection for one of these more basic components?