mdx-editor / mdx-editor/editor

HTML P tags are not handled correctly

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

Nobody has claimed this yet.

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

Description

After pasting HTML as the default value, an error appears when trying to edit:

TypeError
Cannot read properties of null (reading 'append')

https://codesandbox.io/p/sandbox/mdx-editor-paste-html-ld5366?file=%2Fsrc%2FApp.tsx%3A20%2C21-20%2C29

something is with the parsing, because the <p> tag without attributes wraps the whole content or every tag <p> is wraped by other <p> without attributes

image

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 the linked CodeSandbox and its App.tsx reproduction, then inspect the HTML paste/parsing path used by the editor. Paste HTML containing p tags without attributes and verify that editing no longer throws the reported TypeError and that the paragraph structure is preserved correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.