fix: use ownerDocument to create element #4661
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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 theownerDocument.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
insteadChecks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)yarn changeset add
.)