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

Unable to load soft newlines with createValueFromString #29

Closed
nbrendler opened this issue Apr 7, 2016 · 3 comments
Closed

Unable to load soft newlines with createValueFromString #29

nbrendler opened this issue Apr 7, 2016 · 3 comments
Assignees

Comments

@nbrendler
Copy link

I'm having trouble figuring out how to load a soft newline. When I type in the editor:

Hi
there

It spits out the html <p>Hi<br/>\nthere</p>. In my case, I'm exporting this html and saving it in a database. When they come back to the editor, I call createValueFromString to repopulate the text but the newline is gone... we get <p>Hi<br/> there</p>, instead. The newline is now a space.

I tracked this down to the collapseWhitespace function in draft-js-import-element. I assume there's a good reason to strip out the whitespace so I'm not sure the best way to go about fixing this is.

You can easily repro the issue by appending this block to EditorDemo.js:

<div className="row">
  <RichTextEditor
     value={RichTextEditor.createValueFromString(value.toString(format), format)}
     placeholder="Tell a story"
   />
</div>

Then fire up the demo page, and type some text with a soft newline (Shift-Enter) in the top editor.

@sstur
Copy link
Owner

sstur commented Apr 9, 2016

Thanks for reporting this @nbrendler! Seems like a bug. I will look into it.

@sstur sstur self-assigned this Apr 9, 2016
@sstur
Copy link
Owner

sstur commented May 10, 2016

I believe this is fixed in sstur/draft-js-import-element@7c0311e. Let me know if the issue still happens on latest. Thanks.

@sstur sstur closed this as completed May 10, 2016
@nbrendler
Copy link
Author

@sstur works with latest... thanks!

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

No branches or pull requests

2 participants