After adding support for external stylesheets the next step is to add support for Drupal root paths, in the same way that Library definitions can have a Drupal root url for CSS/JS assets.

Stylesheets that aren't external and use a '/' as the first character can be safely assumed to be Drupal root relative (this what LibraryDiscoveryParser does).

So the supported set of stylesheets paths would look like this:

ckeditor_stylesheets
  - //www.external.com/stylesheet.css
  - /libraries/your-library/stylesheet.css
  - css/stylesheet.css

The use case for this is to include CSS assets from outside the theme directory (i.e. the libraries directory).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jptaranto created an issue. See original summary.

jptaranto’s picture

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dpi’s picture

Version: 8.9.x-dev » 9.1.x-dev
dpi’s picture

Fixing D9 compat.

larowlan’s picture

Issue tags: +Needs change record

Can we get a change notice here?

jibran’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs change record

The code changes look good and comes with test also created change record https://www.drupal.org/node/3161831 so RTBC.

nod_’s picture

+++ b/core/modules/ckeditor/ckeditor.module
@@ -89,9 +89,15 @@ function _ckeditor_theme_css($theme = NULL) {
+        elseif ($url[0] === '/' && $url[1] !== '/') {

We just need $url[0] === '/' here, the double slash is checked by the condition above.

jibran’s picture

FileSize
553 bytes
3.05 KB

Nice catch! addressed #8.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 610682e and pushed to 9.1.x. Thanks!

  • alexpott committed 610682e on 9.1.x
    Issue #3099662 by jibran, dpi, jptaranto, larowlan, nod_: Allow...
saschaeggi’s picture

Awesome news, I've created a follow-up to bring the same functionality to quickedit_stylesheets => #3162637: Allow quickedit_stylesheets to refer to a Drupal root URL

Wim Leers’s picture

I'm sorry that I didn't see this until now — until after commit. 🙈

This makes total sense, thanks for doing this!

Status: Fixed » Closed (fixed)

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