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

Pasted copy with carriage returns doesn't render the carriage returns #1681

Closed
adrianclay opened this issue Feb 28, 2018 · 8 comments · Fixed by #3472
Closed

Pasted copy with carriage returns doesn't render the carriage returns #1681

adrianclay opened this issue Feb 28, 2018 · 8 comments · Fixed by #3472

Comments

@adrianclay
Copy link

bug

What's the current behavior?

When pasting existing copy with solo carriage returns \r these aren't rendered by SlateJS

Given This has a different new line\r\r\r\rThis is the final line. in the clipboard when pasting into Slate no lines are rendered as shown below.

SlateJS vs Draft JS
feb-28-2018 14-12-16

What's the expected behavior?

That the carriage returns are correctly rendered as shown in Draft JS

@DamareYoh
Copy link
Contributor

DamareYoh commented Feb 28, 2018

Developers can write custom deserializer rules in their paste handlers that convert '\r' to newline at least as a work around.

@ianstormtaylor
Copy link
Owner

Could be solved here:

nodes: string.split('\n').map(line => {

I'm not sure what the most standard behavior is though. I know nothing about the differences between \n and \r enough to make the decision. If anyone has prior art to point to that would be great!

@thesunny
Copy link
Collaborator

thesunny commented Mar 1, 2018

In terms of OS, the enter representation is:

  • \r for Mac before OSX
  • \n for OSX Mac and Unix
  • \r\n for Windows

When doing a search replace, I search for \r\n first, then \r and \n. If you don't do the Windows style first, you end up with too many [ENTER]s.

@thesunny thesunny closed this as completed Mar 1, 2018
@ianstormtaylor
Copy link
Owner

@thesunny but shouldn't we fix this in the slate-plain-serializer then to properly handle the Windows-style breaks?

@thesunny thesunny reopened this Mar 3, 2018
@thesunny
Copy link
Collaborator

thesunny commented Mar 3, 2018

Oops, sorry, I actually hit the wrong button. I didn't mean to close this!

@zhujinxuan
Copy link
Contributor

My naive solution about this:
https://github.com/zhujinxuan/slate-better-soft-break

@ianstormtaylor
Copy link
Owner

I'm fairly sure this is still an issue for the basic plaintext pasting. If anyone wants to help solve this, I think it would involve changing the default logic to split on any of the line break combinations instead of just \n in the insert_data command of withReact.

thallada added a commit to thallada/slate that referenced this issue Jan 29, 2020
@thallada
Copy link
Contributor

It looks like this issue is also occurring with plain text with normal \n newlines in 0.57.1.

I opened a PR to fix both styles of newlines: #3472

thallada added a commit to thallada/slate that referenced this issue Feb 21, 2020
cameracker pushed a commit that referenced this issue Feb 21, 2020
pull bot pushed a commit to considerhq/slate that referenced this issue Feb 21, 2020
pzhine pushed a commit to databyss-org/slate that referenced this issue May 17, 2020
lukesmurray pushed a commit to lukesmurray/slate that referenced this issue Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants