Internal copy paste is broken
See original GitHub issueVersion 0.19.16 was the last version where copy and pasting internally in the document worked as expected (keeping the formatting intact). The .fragment
document is now null
, and there is only a .html
part, thus it falls back to onPasteText
by the default core plugin. I suspect it has something to do with #716.
If you try copying and pasting the contents of http://slatejs.org/#/rich-text?_k=952y37, you see what I mean.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:19 (11 by maintainers)
Top Results From Across the Web
How to Fix Copy and Paste Not Working in Windows
A chkdsk scan can help resolve copy and paste issues. To do this: Open File Explorer and select “This PC.”
Read more >How to Fix It When Copy and Paste Isn't Working in Windows ...
Run the latest Windows Updates. An out-of-date Windows system can lead to unexpected problems like copy and paste not working. Installing the ...
Read more >Copy + Paste (Clipboard) Issues / Not Working? - TechNet
Open an elevated command prompt. To do this, click Start, click All Programs, click Accessories, right-click Command Prompt, and then click Run ...
Read more >Android Studio copy/paste doesn't work [37045930]
I ran into this problem today. I found a simple, yet, still annoying fix for it. Just hit ctrl+c without anything selected in...
Read more >How to Fix When Copy-Paste Isn't Working - Alphr
Copy-Paste Not Working in Windows 10 · Check if Windows Is Updated · Keyboard Troubleshooting · Check for Viruses · Close Open Applications...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There are a hosts of problems relating to copy/paste in Chrome and Safari and they stem from a single problem:
Doing
when the
div
has a single child node, on copy the content of the child node is copied instead of the entire child node (as it happens in Firefox), i.e. Webkit will copy the “inner HTML” while Firefox will copy the “outer HTML”. What this means in practice is that the fragment data, which resides on the outer HTML, will be lost to Webkit in a host of situations, and it has to fall back to the HTML content, which is a single, unstyled span.A secondary problem is that any trailing whitespace is also lost in the process, but this can be fixed with a
white-space: pre-wrap
on the temporary div that gets created to hold the copy data.I’m not sure if this behavior is intended (or what spec governs it), but I have not found a way yet to make the selection take the “outer html” in this situation.
Selection.selectAllChildren()
is different fromRange.selectNodeContents
in subtle ways but exhibits the same essential problems.There is of course the possibility of always ensuring we have at least two child nodes by inserting a dummy node, but it needs to have non-empty content (a zero width space perhaps), and pasting into external apps will introduce these unwelcome artifacts.
Alternatively, we can theoretically use
clipboardData.setData('text/plain')
andclipboardData.setData('text/html')
on the copy event and eschew the div thing entirely.I’m not sure if this is a separate issue or not but when copy/pasting paragraph with inlines from a “hanging selection”, the inlines don’t make it through: