mdx-editor / editor

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

[BUG] jsxPlugin does not handle mdxFlowExpression #395

Closed StanlieK closed 6 months ago

StanlieK commented 7 months ago

Pre-check

Describe the bug jsxPlugin introduces handling of the JSX which includes expressions as well. When I want to use an expression within MDX, it correctly works for inline expressions. E.g.:

This is inline {expression}

Internally, it is correctly "identified" as mdxTextExpression, therefore it is handled correctly. But once it stands alone in the line, mdast will identify this expression as mdxFlowExpression which is correct as well, but jsxPlugin does not have a visitor for such type of expression. So it results in the error.

Reproduction Example of the erroneous MDX:

This is an example of a line

{expression}

To Reproduce You can use the MDX content from above.

Expected behavior It should correctly consume mdxFlowExpression as it does with mdxTextExpression.

Additional context I will open PR to fix this behavior in a few moments...