mdx-editor / editor

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

[BUG] Initial markdown immediately changed by trim() #598

Closed rkok closed 1 month ago

rkok commented 1 month ago

Fixed by PR: https://github.com/mdx-editor/editor/pull/597


Describe the bug When starting with markdown that can be trimmed, e.g. markdown containing newlines at the end, MDXEditor will trim it before showing the editor.

When MDXEditor is passed diffSourcePlugin({viewMode: 'source'}), this triggers an unwanted onChange event on startup.

Reproduction https://codesandbox.io/p/sandbox/mdx-editor-base-forked-gqzjfz?file=%2Fsrc%2FApp.tsx%3A33%2C28&workspaceId=1e986154-c9ba-40cd-8a6f-4c674cdf70c8

To Reproduce Initialize with markdown that contains trailing newlines.

Expected behavior The editor keeps the trailing newlines.

Actual behavior Trailing newlines are trimmed.

petyosi commented 1 month ago

This was fixed by your PR I believe. Thank you for the contribution.

itsanishjain commented 3 weeks ago

I am using the latest version of 3.15.0

but it's new lines are trimmed

https://github.com/user-attachments/assets/b91c04da-d75d-4b6e-9214-8829ef71e201