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

Blank line between paragraphs is not preserved when preserveNewlines: true enabled #144

Open
alibosworth opened this issue Oct 2, 2020 · 4 comments

Comments

@alibosworth
Copy link
Contributor

alibosworth commented Oct 2, 2020

This results in multiple paragraphs in draft being combined into a single paragraph with a BR inside.

Opened a PR that shows this failing test #143

@igor-sysoev
Copy link

Currently dealing with the same issue. Did you find any solution?

@alibosworth
Copy link
Contributor Author

@supasus our workaround was to remove preserveNewlines: true - perhaps that will work in your case?

@igor-sysoev
Copy link

@alibosworth Thanks, that did the trick. If anyone ever stumbles onto this: I was trying to differentiate between a soft newline break and a paragraph break. Doing this

     if(e.shiftKey) {
                    const newEditorState = RichUtils.insertSoftNewline(this.state.editorState);
                    if (newEditorState !== this.state.editorState) {
                        this.onChange(newEditorState);
                    }
                } else {
                    const editorState = this.state.editorState;
                    const currentContent = editorState.getCurrentContent();
                    const selection = editorState.getSelection();
                    const textWithEntity = Modifier.splitBlock(currentContent, selection);

                    this.setState({
                        editorState: EditorState.push(editorState, textWithEntity, "split-block")
                    });
                }

And setting the data-blocks margin was the solution.

@alibosworth
Copy link
Contributor Author

@supasus interesting, is this general enough that it would be a good improvement to the library? If so I'm sure @Rosey would appreciate a pull-request!

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