yabwe/medium-editor

Multiple   after typing space repeatedly

skarensmoll opened this issue · 2 comments

Description

When typing multiple times space at the end of any line it'll turn into  . (Sometimes it will even add a dot.)

Steps to reproduce

  1. Just have a long sentence and put the cursor at the end of it.
  2. Start typing multiple times space
  3. Inspect the element to see the multiple 

Expected behavior: I expect no   when entering multiple spaces consecutively.

Actual behavior: Non-breaking spaces occur and are hard to tell for an author, without inspecting the website.

Link to an example: It is reproducible on the demo page (https://yabwe.github.io/medium-editor/demo.html)

Versions

  • medium-editor: 5.23.3
  • browser: chrome
    Screen Shot 2020-05-25 at 9 53 42 PM

+1, I'd love a way to natively remove   when pasting.

I use some pretty agressive cleanTags and cleanAttrs options, which works really well, but if you're copying and pasting from external sources, it can end up looking like this:

0LiuySO

This can't be done after pasting (server-side), since you don't know if those are intentional or not, maybe the user really wanted a few   to manually indent text. So it needs to happen upon paste, and then they can add them back manually if desired.

If I come up with a solution I'll post it here, maybe a custom function, or maybe cleanTags can be updated in a future release to allow   to be passed as a tag to remove.

I figured out a simple function that does exaclty what I want, sharing incase it's useful for others

paste: { cleanReplacements: [ [new RegExp(/^(&nbsp;|<br>)+/), ''], ], },