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: use ownerDocument to create element #4661

Merged
merged 2 commits into from Nov 20, 2021

Conversation

leoc4e
Copy link
Contributor

@leoc4e leoc4e commented Nov 16, 2021

Description
Fixed the issue that copying from editable inside iframe does not work
https://github.com/leoc4e/slate/blob/d06706c9e15bbbdd7cdd9a1bbb38c87d37c85ea1/packages/slate-react/src/utils/dom.ts#L66-L70

Issue
Fixes: #4660

Example
capture

Context
The issues is due to getPlainText is returning empty string in iframe.
https://github.com/leoc4e/slate/blob/272ad7ffddae8d1163e395a44dd59f66e2b0f1b0/packages/slate-react/src/plugin/with-react.ts#L191-L192

This is because isDomNode would check if the element is an instance of the ownerDocument.defaultValue.Node
(https://github.com/leoc4e/slate/blob/d06706c9e15bbbdd7cdd9a1bbb38c87d37c85ea1/packages/slate-react/src/utils/dom.ts#L66-L70)
While slate is using default document when creating the element.
This PR change to use the ownerDocument instead

Checks

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)
  • You've added a changeset if changing functionality. (Add one with yarn changeset add.)

@changeset-bot
Copy link

changeset-bot bot commented Nov 16, 2021

🦋 Changeset detected

Latest commit: 1154c55

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
slate-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@dylans dylans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a changeset and then I'll land this. Thanks for the contribution @leoc4e .

The instructions are pretty straightforward for changesets, but if you have any questions just let me know.

@dylans dylans merged commit 0f194a8 into ianstormtaylor:main Nov 20, 2021
@github-actions github-actions bot mentioned this pull request Nov 20, 2021
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.

Could not copy content out of editable in iframe
2 participants