Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Copying / cutting / pasting in IE11 does not preserve newlines correctly #1448

Open
gdehmlow opened this issue Oct 23, 2017 · 4 comments
Open

Comments

@gdehmlow
Copy link

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

draftbug

There are two bugs here:

  • Copying text from a DraftJS editor appears to duplicate newlines (see what happens when it's pasted into a textarea).
  • Then, when you try to paste the selection back into the DraftJS editor, it removes all of the newlines.

It should preserve the newlines exactly as they were copied.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?

Latest Draft.js, tested on Windows 7 IE11

@gdehmlow
Copy link
Author

gdehmlow commented Oct 23, 2017

I fixed the copy issue manually by checking to see if the browser is IE11, setting up copy / cut event listeners on the document, checking to ensure that some parent node of the copy / cut target was our draft editor, and manually placing the correct plaintext into the clipboard via window.clipboardData.setData('Text', selectedContentState.getPlainText());. If this doesn't sound too dumb, I could create a PR with this approach

@colinjeanne
Copy link
Contributor

Cut, copy, and paste are rather difficult and we found that Draft's support was lacking in several ways. In our fork we have a separate div next to the editor that accepts the paste event and then we steal the data after it has been pasted. The initial implementation (with bugs that later PRs fixed) is https://github.com/textioHQ/draft-js/pull/21/files. We have a third div that we use to support copy operations for IE as well...

@sakuma1
Copy link

sakuma1 commented Jul 28, 2019

@gdehmlow @colinjeanne were you'll able to get your fixes merged back into the main draft-js repo? If not are there any plans to do so?

@colinjeanne
Copy link
Contributor

Unlikely. That would require time that I don't have to invest here and a larger discussion with the Draft team because our changes affect copy/paste pretty significantly. It's not clear if those changes would be something that they'd want more generally.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants