mdx-editor / editor

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

[BUG] {"type":"code","name":"N/A"}. if bad/misspelled language in codeblock is provided in *source* mode #474

Open ajboni opened 1 month ago

ajboni commented 1 month ago

"@mdxeditor/editor": "^3.4.0",

Editor throws error Parsing of the following markdown structure failed: {"type":"code","name":"N/A"}. when adding a non-existing language code block in the source view OR after modifying source after creating a codeblock in editor view.

This seems to be related to https://github.com/mdx-editor/editor/issues/423

Steps to reproduce:

Option 1:

  1. Go to https://mdxeditor.dev/editor/demo
  2. write ```jss
  3. hit space.
  4. A default code block is created succesfully
  5. switch to source view
  6. edit in any place. add a space or something
  7. go back to editor view, notice the error message.

Option 2:

  1. Go to https://mdxeditor.dev/editor/demo
  2. go to source view
  3. write ```jss
  4. hit enter
  5. write ```
  6. Go back to view mode. Notice the error message

image

petyosi commented 1 month ago

Wondering what should the correct behavior be. An early error? Not creating a code block at all?

ajboni commented 1 month ago

IMO it should just allow a similar behavior as when we are doing in the editor: create a block with the "default" language or to a "no language / text" block.

The option 1 case might also be confusing for users as they are allowed to misspell the language in editor view, but it will break later if/when the modify the source