Ionaru / easy-markdown-editor

EasyMDE: A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://stackblitz.com/edit/easymde
MIT License
2.44k stars 318 forks source link

Unexpected text deletion when selecting content with backticks #408

Closed silverwind closed 2 years ago

silverwind commented 2 years ago

Describe the bug When backtick characters are present, the editor will unexpectedly delete text during selection.

To Reproduce Steps to reproduce the behavior:

Expected behavior Text should never be deleted during selection

Ionaru commented 2 years ago

Could not reproduce, can you give some more information like browser, OS and record a video of it?

silverwind commented 2 years ago

Firefox 98 on macOS 12. It appears to be a Firefox-only issue, can not reproduce in Chrome. Here's how it looks, I enter the character, then attempt to select via click and drag:

backtick

silverwind commented 2 years ago

Safari 15 also shows the bug.

Ionaru commented 2 years ago

Looks like it's a macOS issue then. Even on Firefox I could not reproduce it.

That underline under the character, what does it mean? It might mean that is has not actually 'typed' the character yet, because ` is usually used as a dead key (needs Space to be typed.)

I'm seeing the same behaviour here: https://medium.com/@scr34mz/make-your-mac-keyboard-work-on-medium-and-others-editors-without-dead-keys-issues-french-keyboard-4666b72fa2ae

So what I gather from that article is that the ` with the underline in your video isn't real input yet, but it does become real once you hit Space, then the selection should work as normal.

silverwind commented 2 years ago

Might be related to the combinator input behaviour of the backtick, but the deletion on selection is still unexpected and does not happen in a <textarea>. I use backticks a lot in markdown and often leave "unresolved" ones open while I try to edit other text and any kind of selection action in the document destroys test between start point of the selection and that "unresolved" backtick.

Here's another example with text before the backtick and selection starting on that text:

backtick2

Ionaru commented 2 years ago

Can you try the same on https://codemirror.net/ and https://codemirror.net/6/ for me?

This might help narrow it down.

silverwind commented 2 years ago

Happens in https://codemirror.net/mode/markdown/index.html too, so it seems it's a CodeMirror bug. Report there?

Ionaru commented 2 years ago

Yeah, please do.

I'm not sure if they'll fix the bug in v5 since v6 is around the corner (I hope 😅), but having the bug registered is a good thing anyway.

silverwind commented 2 years ago

Opened https://github.com/codemirror/CodeMirror/issues/6893

silverwind commented 2 years ago

CodeMirror 5.65.8 is released with this fixed.

Ionaru commented 2 years ago

Awesome! I'll made an update with that version included :)

silverwind commented 2 years ago

You don't actually have to because semver range ^5.60.4 matches the new version already :)