mdx-editor / mdx-editor/editor

[BUG] missing import statements when adding a jsx element inside a nested editor

Open
#733 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
3.7k
Forks
307
Avg merge
14h 22m
Merged PRs (30d)
5

Description

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • I have read the documentation and cannot find an answer.

Describe the bug
When a jsx component is added from inside a nested lexical editor, the import statement is ignored. The issue comes from the NestedLexicalEditor which prevents adding import statements when calling exportLexicalTreeToMdast with addImportStatements=false. It makes sense to not import directly inside the nested editor, but the import statement on the primary root seems not to be added.

Reproduction
See PR #734 where this issue is mentioned. The user story story=jsx--import-statements-nested can be used to reproduce the issue by focusing the admonition content and then clicking inside the toolbar Zazz. The inserted component does not trigger an import statement. Is this enough or do you need an explicit repro? :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with NestedLexicalEditor and the exportLexicalTreeToMdast call described in the issue. Reproduce using story=jsx--import-statements-nested: focus the admonition content and click Zazz in the toolbar. Done means the inserted JSX component causes the primary root editor to include its import statement while nested export still avoids adding imports locally.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, react, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.