Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Shadow DOM] Enhance range validation to support ranges encapsulated by shadow roots #4721

Conversation

mdgbayly
Copy link

We're trying to get tinymce working in web components that utilize shadow DOM. Our initial usage of tinymce is for an inline editor with a simple toolbar.

My intent is to create a number of small PRs that progressively fix more issues required in order to make our use cases work, rather than one big blanket PR that makes all tinymce use cases support shadow DOM.

This PR fixes the range validation so that if the range is encapsulated by a shadow root the range still validates as being contained by the document. It finds the top level shadow hosts for the start and end of the selection and validates that they are contained by the document.

@metricjs
Copy link
Contributor

Hey @mdgbayly, thanks for this PR! Unfortunately we are not accepting PRs for support for ShadowDOM in TinyMCE's inline mode, as we can not currently support it due to browser limitations. In particular:

  • Safari doesn't provide a way to get the selection for the shadow root (likely means we can't support Safari).
  • Firefox doesn't implement the DocumentOrShadowRoot.getSelection() API, but it will return the shadow root selection for Window.getSelection().

We are keeping an eye on discussions regarding replacing this API with Selection.getComposedRange(), however no browsers implement this API at this time. If it is implemented, we will then investigate inline mode support for ShadowDOM again.

See WICG/webcomponents#79 and w3c/selection-api#98 for more about the Selection.getComposedRange() API.

@metricjs metricjs closed this Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants