- Issue created by @rahaf albawab
- 🇺🇸United States mark_fullmer Tucson
Thanks for filing this report! I may need some help understanding the intent here, as my first analysis suggests this works as designed.
The description above states that "In Drupal 11, using CKEditor 5, libraries attached via $result->setAttachments() in a filter plugin are not automatically rendered on the page unless they are explicitly declared in the text format’s configuration (filter.format.*.yml)."
Would it be more accurate to say that the library is not attached unless the text format filter is executed as part of the page's rendering process?
If not, can you point to a Drupal change record that spells this out, and/or an example in Drupal core or contrib where this is the case? I find it very plausible to expect that `$result->setAttachments()` won't execute on a page if the the filter format plugin isn't executed on the page, but I don't follow the logic that a Drupal library would need to be explicitly declared in a text format configuration in order to allow `$result->setAttachments()` to execute.
Regardless, I don't find the Steps to Reproduce above to be true. When I create a text format with
filter_responsive_tables_filter
enabled and create a page that renders an HTML table with a header, I see the Tablesaw library loaded and working as designed.Furthermore, the proposed code change doesn't seem like the expected logic. By adding a
hook_preprocess_page()
hook, as indicated in the comments, if the Responsive Tables Filter plugin is added to *any* text format, it will add the library to *every* page, regardless of whether that page renders any content using the text format. This almost seems like using a "back door" of a text format filter to add the Tablesaw library to the entire site, which is not the design of the module.If sites do want to add the Tablesaw library to every single page, that's up to the developer I guess, and they could simply do the following, or add
responsive_tables_filter/tablesaw-filter
as a dependency to the site theme's library.function mymodule_preprocess_page(&$variables): void { $variables['#attached']['library'][] = 'responsive_tables_filter/tablesaw-filter'; }