fix: add support for pasting plain text into editable void #5305
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
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
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)yarn changeset add
.)