mdx-editor / editor

A rich text editor React component for markdown
https://mdxeditor.dev
MIT License
1.75k stars 139 forks source link

No way to get to next line when doing ```[language] shortcut for codeblocks #397

Open RobertBrunhage opened 5 months ago

RobertBrunhage commented 5 months ago

Describe the bug Testing in https://mdxeditor.dev/editor/demo go to the bottom of the page and write ```js followed by space. Now try to get to the next line to write in. (I would expect this to work with shift+enter or just clicking below it).

When using the code block button in the navbar it will add a newline below the codeblock to continue writing in.

Reproduction Testing in https://mdxeditor.dev/editor/demo go to the bottom of the page and write ```js followed by space

To Reproduce Steps to reproduce the behavior:

  1. https://mdxeditor.dev/editor/demo
  2. Click on the last editable part of the markdown editor
  3. write ```js followed by enter
  4. try to write after the codeblock

Expected behavior Should be able to continue after writing a codeblock

Desktop (please complete the following information):

petyosi commented 5 months ago

That's a legit problem. I have a code that might need some tweaking, as I believe that down arrow should be able to exit the code block, even if it means creating a new paragraph. Right now, you have to press twice if the block is empty.

@RobertBrunhage if you're interested, I'm happy to accept an improvement PR - this is the code block that does some special handling of the codemirror blocks. https://github.com/mdx-editor/editor/blob/a87df2f75e4297b09595c84eeb1cc62ec53063fa/src/plugins/sandpack/useCodeMirrorRef.ts#L28-L56