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

Converting a code block with newlines to a paragraph creates a paragraph with newlines #841

Open
marijnh opened this issue Aug 22, 2018 · 3 comments

Comments

@marijnh
Copy link
Member

marijnh commented Aug 22, 2018

Which are visible, but then normalized back to spaces as soon as you type something and the paragraph is re-parsed.

Ideally, the newlines should be converted to hard breaks when the textblock type is changed, though it's going to be kind of tricky to find a reasonable place for that code (it's very schema-specific).

Via ProseMirror/prosemirror-markdown#26

@m-gallesio
Copy link

Please note this problem still exists and is not unique to code blocks:
prosemirror-markdown-newline-problem
This also happens when the editor is initialized with a text already containing newlines (e.g. fetched from remote).

@m-gallesio
Copy link

After some testing, a preliminary consumer-level solution can be preprocessing the data:

  • plain text to rich text: convert any newline to double newlines
  • rich text to plain text: convert double newlines to single newlines

Again, this is tentative but it fits our use case (we are not interested in preserving the difference between the various type of line breaks).

@m-gallesio
Copy link

@marijnh As a reminder, for prosemirror-markdown there already seems to be a fix available introduced at latest here: ProseMirror/prosemirror-markdown@20905b3 which makes it possible to override the default parser's behaviour when parsing soft breaks. In our use case it seems to work fine.

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