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

Directly paste ClipboardEvents in Safari #5362

Merged
merged 2 commits into from
Mar 16, 2023

Conversation

jason0x43
Copy link
Contributor

Description
This PR changes updates the paste handling code to always use ClipboardEvents in Safari rather than preferring InputEvents as InputEvents won't include files or data items with custom mime types.

Issue
Fixes: #4998

Example
Log the types of the data property passed to ReactEditor.insertData when pasting and verify that with this PR they include application/x-slate-fragment, and without this PR they don't.

Ideally, if a document that has problems copying and pasting in Safari is available, such as one containing inline images, verify that content that normally has problems pastes properly with this PR.

Context
Pasting generates two events in Safari: a ClipboardEvent and an InputEvent. Currently, Slate generally ignores ClipboardEvents in Safari in favor of InputEvents, which flow through Slate's onDOMBeforeInputHandler. This is problematic because InputEvents generated by pasting in Safari are missing some key pieces of data: they won't include files or an application/x-slate-fragment data item. ClipboardEvents do have this data.

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 Mar 15, 2023

🦋 Changeset detected

Latest commit: ba02b2c

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.

Wow, such a simple fix.

Could you please add a changeset (patch change level) and then I'll land it. Thanks!

@jason0x43
Copy link
Contributor Author

Changeset added

@dylans dylans merged commit 4399935 into ianstormtaylor:main Mar 16, 2023
@github-actions github-actions bot mentioned this pull request Mar 16, 2023
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.

Safari paste handling and Clipboard API
2 participants