mdx-editor / editor

A rich text editor React component for markdown
https://mdxeditor.dev
MIT License
2.08k stars 160 forks source link

[BUG] Extraneous newlines truncated on load #639

Closed rbbydotdev closed 3 days ago

rbbydotdev commented 6 days ago

Describe the bug Initializing the editor with a markdown document with extraneous newlines, will automatically truncate the newline, thereby making a diff for the document /changing the document

Reproduction The following will be truncated

# Heading

becomes

# Heading

To Reproduce Initialized the editor with the first example with extraneous newlines, either check the document with the diff plugin, or monitor the gurx signals

Expected behavior Expecting the newlines to remain.

Screenshots None

Desktop (please complete the following information):

RokasAnisas commented 4 days ago

Same issue. Input data:

Screenshot 2024-11-24 at 18 54 11

Result:

Screenshot 2024-11-24 at 18 54 16
petyosi commented 3 days ago

The trimming of the markdown is intentional, but I can see how this can cause problems. I might consider changing this in a future version or introducing a prop to control it.

@RokasAnisas this is not the same issue, markdown does this by design.

firminochangani commented 3 days ago

@petyosi What would be your recommended way to add multi-newlines?

Saved as:

Hello\n\n\nWorld

Rendered as:

Hello

World
woong97 commented 3 days ago

I faced same issue. How to fix?

firminochangani commented 2 days ago

I faced same issue. How to fix?

At this point I am considering moving over to a different component.

RokasAnisas commented 2 days ago

The trimming of the markdown is intentional, but I can see how this can cause problems. I might consider changing this in a future version or introducing a prop to control it.

@RokasAnisas this is not the same issue, markdown does this by design.

This is a bad representation of the problem with the screenshots that I've provided, it was just for illustration, the other users that have commented on this issue with are more accurate

Hello\n\n\nWorld

Regardless, getting the same result, line breaks are removed, even thought the same string opened as a markdown document does indeed display those line breaks