mdx-editor / editor

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

[BUG] Directives cause following content to not render #372

Closed ckpearson closed 6 months ago

ckpearson commented 6 months ago

Describe the bug When adding the directives plugin ANY directive encountered causes content following it to not render

Reproduction Minimal repro here: https://codesandbox.io/p/sandbox/mdx-editor-base-forked-3k4wff

To Reproduce Steps to reproduce the behavior:

  1. Have markdown with a directive in it followed by other content
  2. Add the directives plugin

Expected behavior I would expect the plugin to skip over directives it cannot handle and for the editor to then render any following content

Desktop (please complete the following information):

ckpearson commented 6 months ago

This may actually be down to the markdown receiving weird additional \ characters at newlines from a multiline literal string. I've since tested it by importing from a markdown file directly as a string and it behaves as expected.

Was able to diagnose this by using the source viewer mode.

petyosi commented 6 months ago

I would expect the plugin to skip over directives it cannot handle and for the editor to then render any following content

That's not how the directives plugin (and the Editor in general) works. It would silently destroy content if it skips unknown constructs. If you expect such content, you can create a catch-all directive descriptor that does some basic rendering but preserves the structure.

Up to your example, one possible problem I see is the indent in the multiline string. However, I doubt that this would work without the catch all descriptor.