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: add support for pasting plain text into editable void #5305

Merged

Conversation

alex-vladut
Copy link
Contributor

Description
This is a fix for the issue preventing pasting plain text into editable voids. At the moment one can paste other Slate elements into an editable void, but nothing happens when plain text (e.g. copying a URL from browser's search bar).

Issue
Fixes: #5294

Example

Before:
https://user-images.githubusercontent.com/3620639/219029517-0f7b11e3-78ae-4033-af74-61730103ae04.gif

After:

copy.and.paste.into.editable.voids.mov

Context

A change was introduced recently to support copying and pasting void elements, which seems to have changed the behaviour for the paste action as you can find it here https://github.com/ianstormtaylor/slate/pull/5121/files#diff-1d0c52ec4c5562d96965f789988bd4efd4a6d24b88527918987d06bcc43d15adL1576
It is not fully clear to me if that change was intentional or it was simply added to match the onCopy logic. I performed some testing according to the original PR's purpose and the copy-paste of void elements seems to still work as expected. Let me know if anyone has more insights and there is something that should be checked.

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 Feb 22, 2023

🦋 Changeset detected

Latest commit: cde6c52

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

@alex-vladut alex-vladut force-pushed the fix-paste-into-editable-void branch from 134e9d8 to cde6c52 Compare February 22, 2023 15:33
@dylans dylans merged commit 11adbf9 into ianstormtaylor:main Feb 22, 2023
@github-actions github-actions bot mentioned this pull request Feb 22, 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.

Can't paste into void elements
2 participants