-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Copy/pasting void elements is not working #4808
Comments
I have tested both versions provided and copy/paste does not work on either 0.61.3 nor 0.72.6. I would also suggest we tweak the wording of the issue a bit (of course if @evasteingrims would confirm that this is indeed the case, and not a failed reproduction on my end). Namely, copy/paste of the void element does work if you have the void element as part of an expanded selection (first thing to confirm). So for example, if you select the text around the void and paste everything works as expected. What does not work - when you only click the void and copy, it does not add anything to the clipboard (second thing to confirm). My view of the issue then is, given the above is correct - copy does not add the focused void element when the selection is collapsed (or rather, click + copy, as opposed to selecting a fragment). |
We are using version 0.61.3 in our project and copy pasting works as expected there. But yes you are correct, I can confirm both things suggested here |
I can confirm, and would like to +1 this issue
when selection is a range the inline element is properly copied as part of that larger selection
|
We haven't been able to upgrade Slate versions in long time because of this issue. Has anyone found a workaround? |
In general I think you need to be able to select the empty elements just before and after the void in order for copy-paste to retain the structure. That said, you can (and should) write your own paste handler to retain the void. There's a partial example in #4333 and discussion in various PRs around copy/paste (in particular #4489 ), but essentially |
…ableTarget. Fixes Copy/pasting void elements is not working ianstormtaylor#4808
* Create new function hasSelectableTarget and use it instead of hasEditableTarget. Fixes Copy/pasting void elements is not working #4808 * Add changeset * Revert a change that made editable void not editable and add cypress test for editing editable void * Extract methoods into easily overridable with help from @alex-vladut
Description
Copy/pasting a void element is not working. Copy/paste works for text but then then when I try to copy a void element and paste, the text is pasted instead of the element
Recording
Screen.Recording.2022-01-26.at.14.07.33.mov
Sandbox
It works in slate-react version 0.61.3 but not in version 0.72.6,
https://codesandbox.io/s/slate-reproductions-forked-bx8wd
Steps
To reproduce the behavior:
Expectation
The green box should be pasted
Environment
The text was updated successfully, but these errors were encountered: