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

Fix: support iframes and portals #28

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sielay
Copy link

@sielay sielay commented Aug 23, 2023

The problem I faced is that I render editable elements in an iframe (forced by CSS I'm dependent on, long story). I use React.Portal and because the code is defined in the main window and the elements are in different the library gets confused and ends up with Uncaught DOMException: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index. on any commit.

The fix is to allow to pass reference object to the window from the iframe.

It will use window of the element and fallback to global window otherwise. This had to be applied to all window and document references. It was tested in the iframe, selection control and updates works. Range doesn't throw anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants