mdx-editor / editor

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

[BUG] HTML tables get linebreaks added between rows #320

Open dave-db opened 7 months ago

dave-db commented 7 months ago

If you're unlucky enough to have an HTML table in your content, the editor adds line breaks to it between sections, which are then converted to implicit <p>s by the MDX renderer, which breaks table display.

Describe the bug Loading <table> content gets line breaks added in (visible in the diff viewer), which are then turned into ps when the MDX is rendered.

Reproduction https://codesandbox.io/p/sandbox/mdx-editor-base-forked-y5mryt

To Reproduce Steps to reproduce the behavior: View the sandbox, switch to Diff mode to see the extra line breaks

Expected behavior The <table> HTML should be left undisturbed

Desktop (please complete the following information): Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 22.6.0: Fri Sep 15 13:39:52 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_X86_64 Binaries: Node: 20.10.0 npm: 10.2.3 Relevant Packages: next: 14.0.4 eslint-config-next: 14.0.4 react: 18.2.0 react-dom: 18.2.0 typescript: 5.3.3

Chrome 119 mdx-editor: 2.3.4

petyosi commented 7 months ago

I do understand your unlucky reference here. To be fair, I'm quite ambitious with my roadmap, but I don't foresee making HTML tables work in the near future. If I do that, I might rename the component to HTMLEditor :).

dave-db commented 7 months ago

Completely understood. If there was a way to leave the table markup as-is (without being able to edit it outside source mode) that would be great, but no expectation of converting to markdown syntax or allowing proper table editing.