CKEditor 5 html filter - fundamental elements

Created on 17 November 2023, about 1 year ago
Updated 22 November 2023, about 1 year ago

Problem/Motivation

CkEditor 5 FundamentalCompatibilityConstraintValidator has FUNDAMENTAL_CKEDITOR5_PLUGINS constraint with ckeditor5_essentials and ckeditor5_paragraph, those plugins are about <br> and <p> elements. When any filter plugin which extends FilterHtml try to be added, it won't contain <p> and <br> in Allowed HTML tags filter settings by default, so it ends with CKEditor 5 needs at least the <p> and <br> tags to be allowed to be able to function. They are not allowed by the %filter_label filter.

For core's filter_html(Limit allowed HTML tags and correct faulty HTML) filter happens something unexpected as at the beginning textarea value does not have <br> and <p> element, but when add filter ajax call finishes, it appears there, so it might be ajax adding those missing elements there - I didn't investigate this behaviour.

Steps to reproduce

Option one:
1. Create a new text format.
2. Select CKEditor5 as Text editor.
3. Check "Limit allowed HTML tags and correct faulty HTML" filter.
4. Verify that <p> and <br> attributes are not there at the beginning and they appear after ajax call is finished. (when you uncheck and check filter again without page refresh, it appear immediately)

Option two:
- Use contrib module which extends FilterHtml eg. extended_html_filter.
- Try to add provided filter to text format.
- Save the form.
(You cannot do that without adding <p> and <br> manually, as ajax call does not autofill missing values in this case - ends with described form validation error)

Proposed resolution

I suppose we should add <p> and <br> to class FilterHtml extends FilterBase "allowed_html" = "<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id>" as it is expected to be there, but it's not.

🐛 Bug report
Status

Closed: works as designed

Version

10.1

Component
Filter 

Last updated 4 days ago

No maintainer
Created by

🇵🇱Poland ad0z

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ad0z
  • Status changed to Postponed: needs info about 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    When any filter plugin which extends FilterHtml try to be added

    What's the use case for this?

    it won't contain <p> and <br> in Allowed HTML tags filter settings by default

    If you're customizing it anyway, why not add those tags to the defaults? 🤔

    Related: Match the filter_html <> ckeditor5 integration in Drupal core Needs work — where I made a filter extending core's filter_html to add style attribute support work in the exact same way as CKEditor 5's built-in UI support for filter_html.

  • Status changed to Closed: works as designed about 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Aha, so this was indeed for extended_html_filter — just found your comments at 🐛 Missing and tags Closed: duplicate .

    What you're asking for here is changing filter_html, which is unlikely to happen any time soon. I suggest you test Match the filter_html <> ckeditor5 integration in Drupal core Needs work so that the maintainers of that module can merge that 😊

  • 🇵🇱Poland ad0z

    @Wim Leers This issue was more about why

    and
    is missing in filter_html "allowed_html", as it is expected to be there, but it's not and it is loaded somehow later and injected in settings form.. what can be quite confusing?

Production build 0.71.5 2024