mdx-editor / mdx-editor/editor

[BUG] Quote in Quote breaking in Source mode

Open
#622 0 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
You can't stack block quotes in RichText mode. It is possible for it to present them if you make them in Source mode first however so I am guessing it is the reading and conversion of the input in RichText mode that prevents it. Like If you use MarkdownShortcuts and adds a ">" at the start of a line followed by a space it starts a Block Quote but if you add it anywhere else it gets escaped.

Also, Source mode scrambles the input of ">" if you try to stack quotes. If you add this:

> This is a quote
>> A second quote

and changes to RichText it will show up correctly and if you save content externally with the onChange it will be correct, like this: > This is a quote\n>> A second quote. But if you go back to Source mode it will have converted it to > This is a quote> A second quote which, if applied by editing or saving, etc, will break it in RichText mode since it doesn't seems to know how to handle that.

I have seen other Markdown situations where > This is a quote> A second quote is valid but the RichText does not. Maybe something to do with Lexical, but I don't know.

Reproduction
Start from https://codesandbox.io/p/sandbox/mdx-editor-base-q8s7zr?file=/src/App.tsx to reproduce the problem so that I can observe the issue on my side and make sure that the fix reliably addresses it.

https://codesandbox.io/p/sandbox/mdx-editor-base-forked-cgdwkp

To Reproduce
Steps to reproduce the behavior:

  1. In Preview, go to Source mode and add
> This is a quote
>> A second quote
  1. Go to RichText mode and it should have a Quote in Quote.
  2. Go back to Source mode and it should have converted to > This is a quote> A second quote.
  3. If you edit anything in Source mode and goes back to RichText it should now show up like this

This is a quote> A second quote

Expected behavior
That either RichText mode can handle > This is a quote> A second quote, or that Source mode does not convert

> This is a quote
>> A second quote

into > This is a quote> A second quote

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Brave, Edge, Chrome

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 Source mode and RichText mode conversion flow, using the linked CodeSandbox reproduction and the MarkdownShortcuts behavior described in the report; the issue also points to Lexical as a possible subsystem. Confirm the nested quote input and determine whether switching modes preserves the line break and nested quote syntax without changing it to a single-line quote.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.