Stacks-Editor icon indicating copy to clipboard operation
Stacks-Editor copied to clipboard

bug(md-editor) Pasting in code within a fenced code block, creates 2nd inner code block

Open KyleMit opened this issue 3 years ago • 1 comments

Describe the bug In the markdown editor, when pasting code into a pre-existing fenced code block, a second code block is created inside.

To Reproduce Steps to reproduce the behavior:

  1. Open md editor

  2. Create fenced code block ```

  3. Paste anything detected as code into block - ex: copy the text below:

    var x = 1
    

Expected behavior Only the single (existing) fenced region is used

Screenshots paste-code-into-code

This will also render incorrectly if saved without manually fixing:

image

Desktop

  • OS: Windows
  • Browser: Chrome
  • Version: v104

KyleMit avatar Aug 18 '22 18:08 KyleMit

Currently, this is working "by design". Unlike rich-text mode, we don't have any easy way to detect what type of "node" you're modifying. Because of this, you're going to see issue like the one you describe. Although I do agree that the current behavior is not ideal, this would take quite a bit of effort to resolve due to a number of factors. Because of this, I'm placing it in the backlog to revisit at a later date.

Notes to self

How would we handle the following edge cases?

indented code blocks (pretend the dots are spaces)
····paste here
unterminated code blocks (yes, this is legal: https://spec.commonmark.org/0.30/#example-126)
```
paste here

b-kelly avatar Aug 18 '22 18:08 b-kelly

potentially related to #230

yellis avatar Oct 27 '22 06:10 yellis

Relevant Meta.SE report: https://meta.stackexchange.com/q/383727/377214

gparyani avatar Nov 11 '22 20:11 gparyani

Fixed by https://github.com/StackExchange/Stacks-Editor/releases/tag/v0.8.3

giamir avatar Dec 12 '22 17:12 giamir