Skip to content

fix(mdxish-editor): embed serialization missing data#1376

Draft
Jadenzzz wants to merge 8 commits intonextfrom
jayden/rm-15617-embed-serialization-missing-data
Draft

fix(mdxish-editor): embed serialization missing data#1376
Jadenzzz wants to merge 8 commits intonextfrom
jayden/rm-15617-embed-serialization-missing-data

Conversation

@Jadenzzz
Copy link
Contributor

@Jadenzzz Jadenzzz commented Mar 17, 2026

PR App Fix RM-XYZ

🧰 Changes

Missing Embed attributes

Added missing Embed attributes to serialization process

Multi line Embed serialization bug

Problem

Multi-line <Embed /> JSX content failed to deserialize in the MdxishEditor, throwing:
RangeError: Invalid content for node doc: <>

Root Cause

When JSX spans multiple lines like:

  <Embed                                                                                                   
    typeOfEmbed="youtube"                                                                                  
    url="https://example.com"                                                                              
  />                    

CommonMark doesn't recognize it as an HTML block (because <Embed is incomplete on line 1). Instead, it
wraps it in a paragraph > html structure, which downstream processors couldn't handle correctly.

Solution

Created a new AST-level plugin mdxish-self-closing-blocks.ts that:

  1. Detects paragraph nodes containing a single html child with a self-closing PascalCase component tag
  2. Converts the structure to a proper mdxJsxFlowElement node
  3. Only processes specific component tags (currently Embed) via a configurable allowlist
  4. Runs only when newEditorTypes: true to limit scope to the new editor

🧬 QA & Testing

attributes: parseAttributes(attrString),
children: [],
position: paragraph.position,
data: { raw: value },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's data raw value for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it because I thought we need to preserve the magic block format. Thanks for pointing this out!
Just removed it

Copy link
Contributor

@eaglethrost eaglethrost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flow looks good, requested some changes

Jadenzzz and others added 3 commits March 20, 2026 17:00
Co-authored-by: Dimas Putra Anugerah <63914983+eaglethrost@users.noreply.github.com>
@eaglethrost
Copy link
Contributor

Nice looks good, tested with the readme side PR and it seems to have fixed the serialization issue!

@eaglethrost eaglethrost dismissed their stale review March 20, 2026 12:31

Resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants