editor icon indicating copy to clipboard operation
editor copied to clipboard

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

Open RobertBrunhage opened this issue 1 year ago • 1 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 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):

  • OS: MacOs
  • Chrome

RobertBrunhage avatar Mar 23 '24 12:03 RobertBrunhage

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

petyosi avatar Mar 24 '24 10:03 petyosi