editor icon indicating copy to clipboard operation
editor copied to clipboard

[BUG] Quote in Quote breaking in Source mode

Open tsuzumiC opened this issue 1 year ago • 0 comments

  • [x] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [x] 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

tsuzumiC avatar Oct 31 '24 18:10 tsuzumiC