Using a span to wrap the nbsp element is problematic, because it requires allowing <span class> in the limit html filter's allowed tags.

These are not CKEditor ACRs, the class attribute is permissive and optional - <span class> will still allow spans without a class, which is what browsers tend to produce when copy and pasting from elsewhere.

My editors are pasting in text that may have many levels of nested spans, and if I want the nbsp plugin I have to allow that.

I wonder if it might be desirable to allow the wrapping element to be configured in plugin settings? It gets stripped out anyway by the nbsp filter. In my case I'd probably prefer it was something that the html filter already allows, like <em>.

Comments

John Pitcairn created an issue. See original summary.

wengerk’s picture

Hey !!

You're right ! I never think about it but it could be an issue to deal with only.

I think we could indeed add the possibility to change the tag, but we still have to use by default.
Also, we will need to change a little bit our documentation to reflect the changes (especually for limited HTML Ckeditor).

Would you help me on that ?

johnpitcairn’s picture

Yes I can put together a patch.

wengerk’s picture

The module has tests now ! Yay, so you can help us with confidence, we will ensure nothing will break easily :D

wengerk’s picture

Category: Task » Feature request
phily’s picture

Instead of allowing the wide range <span class> in the html filter's allowed tags, what about limiting it to <span class="nbsp"> so that specific class only is kept by filter.

artusamak’s picture

There are custom tags now for the media library (drupal-media), you could use the same approach to target your custom item.

wengerk’s picture

seems this issue will be fixed with https://www.drupal.org/project/nbsp/issues/3277174.

wengerk’s picture

Status: Active » Fixed

Fixed by the support of CKeditor 5.

Will works on CKeditor 4 for Drupal 9.3+ verison too.

More about it on https://www.drupal.org/project/nbsp/issues/3277174

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.