PreviousNext: CKEditor5 scoped styles with PostCSS

1 week 3 days ago

The Drupal 10 update is moving to CKEditor 5. What’s different? It’s no longer an iframe! So how do we scope any custom styles we want to include?

by rikki.bochow / 23 May 2023

First and foremost, if you haven’t read the Drupal docs about including custom styles, then please read that. It will give you the necessary context.

This article is specifically about a theme setup that already uses PostCSS (as opposed to Sass - this is much easier with Sass), has various component stylesheets, and includes some level of theme CSS to the CKEditor window to help improve the content editor experience.

Simply including the same styles used in CKEditor 4 to CKEditor 5 now bleed out into the admin theme, so we need to scope them to the .ck-content class.

Let's just say the theme's original ckeditor.css file looks something like this:

@import "./custom-properties.css"; @import "./base/base.css"; @import "./button/button.css"; @import "./layout/layout.css"; body { font-family: var(--font-family); padding: .5rem; }

We use a couple of PostCSS plugins already, notably postcss-import and postcss-preset-env but in order to wrap everything here in a certain class, including everything we’re importing…

We need a new plugin

I tested a few class prefixing plugins, but the only one that suited my requirements was postcss-prefixwrap. With it installed, here’s our basic postcss.config.js:

module.exports = { plugins: [ require("postcss-import"), ... other plugins require("postcss-prefixwrap")(".ck-content", { whitelist: ["docroot/themes/my_theme/src/ckeditor.css"], nested: "&", ignoredSelectors: [":root", /^\\.ck-(.+)$/], }), ], }

We place it last; we add the class to use as the prefix .ck-content and specify our options;

  • whitelist: our ckeditor.css, so this plugin only applies to that file.
  • nested: because we use ampersand for nested selectors
  • ignoredSelectors: include the :root where we have some global custom properties and any class that starts with .ck- because it’s already scoped.

The only change we need to make to our ckeditor.css file is to change our body styles to live on .ck-content instead. Otherwise, they’ll come out at .ck-content body and be ignored.

Now every selector in our generated ckeditor.css file (that we didn’t ignore) is prefixed with .ck-content; thus all the styles are scoped to CKEditor 5 and no longer bleed into the admin theme.

A note on CSS Custom Properties

If you (like me) prefer to preserve your custom properties, you may find the need to scope them as well, to avoid clashes with custom properties the admin theme might have.

For this, I added one more PostCSS plugin postcss-variables-prefixer;

module.exports = { plugins: [ require("postcss-import"), ... other plugins require("postcss-variables-prefixer")({ prefix: "pnx-", }), require("postcss-prefixwrap")(".ck-content", { whitelist: ["docroot/themes/my_theme/src/ckeditor.css"], nested: "&", ignoredSelectors: [":root", /^\\.ck-(.+)$/], }), ], }

This isn’t specific to the ckeditor.css file, but that’s ok with me; they can be unique everywhere.

Hopefully, this helps make the transition to CKEditor 5 a little smoother for your content editors when updating to Drupal 10.

Acquia Developer Portal Blog: Evaluating Drupal Community Modules

1 week 3 days ago

When looking to use a module from the Drupal community there are a number of factors to consider, beyond its functional use, that determine suitable quality and support for your organisation to use.

When you deploy a Drupal site into production, who is responsible for maintaining it? How long will that site live for? These types of questions shape the risk tolerances of the project. E.g. Lower Drupal competencies means you need greater community support and more stable modules.

All modules on are open source and fall under the GPLv2 open source license. They are free to download and use at your own risk. Each project has its own set of maintainers and a sub-community that uses the module, interacts through issues and contributes bug fixes and feature enhancements.

Acquia Developer Portal Blog: Drupal: cache tags for all, regardless your backend

1 week 3 days ago

This blog has been re-posted and edited with permission from Matt Glaman's blog.

Phil Karlton is quoted as having said, "There are only two hard things in Computer Science: cache invalidation and naming things." As someone who suffers horribly from the latter, I'm glad Drupal's caching APIs make the former a breeze. The long short of it is that caching of data improves performance by not having to perform the same operations multiple times after it has been done the first time until you need to re-run that operation again. It involves some storage (static variable in memory, memory backend storage, or the database.) Generally, you store the data with a given identifier for later retrieval, the actual data to be cached for later reuse, and possibly an expiration time for automatic invalidation.

Ryan Szrama: Deadline drawing near for Pitch-burgh entries

1 week 3 days ago
You have a little more than two days to submit a proposal for DrupalCon Pittsburgh's innovation grant contest dubbed "Pitch-burgh." The Drupal Association has raised $75,000+ to allocate to the most compelling proposals received by May 25th. There is no lower limit on proposal size. A $1,000 "quick fix" is just as valid as a $20,000 proposal. Additionally, entrants can be individuals or companies. The only criteria is that pitches contribute to Drupal's continued innovation, whether through code, design, documentation, or even contribution process improvements. Read more

Talking Drupal: Talking Drupal #400 - A chat with Dries

1 week 3 days ago

Today we are talking with Dries Buytaert.

For show notes visit:

  • Favorite improvement to Drupal in last 10 years
  • Biggest opportunities and challenges facing Drupal
  • Drupalcon Portland Driesnote Ambitious site builder
  • Spoilers for the next Driesnote
  • Static site generators
  • 50,000 projects
  • Impact of AI
  • People just entering the development market
  • Last thing you coded
    • For work
    • For fun
  • Digital Public Good
Resources Guests

Dries Buytaert -


Nic Laflin - @nicxvan John Picozzi - @johnpicozzi Stephen Cross - @stephencross Martin Anderson-Clutz - @mandclu

MOTW Correspondent

Martin Anderson-Clutz - @mandclu OpenAI Provides a suite of modules and an API foundation for OpenAI integration for generating text content, images, content analysis and more.

CTI Digital: Gain Competitive Advantage and Accelerate Your Drupal Build

1 week 3 days ago

When it comes to upgrading your website, the decision is never taken lightly. 

It's a process that demands considerable effort, time, and money.

Whether aiming to boost your CMS platform's performance or enhance the user experience, making sure you choose the upgrade that delivers the greatest value for your investment is crucial.

We understand this better than anyone else as one of Europe's most experienced Drupal development agencies. Our expertise in Drupal allows us to streamline the installation process, getting you started on your priority features quickly and cost-effectively.

But that's not all. We've developed something truly special: Drupal Accelerator. 

This innovative tool is designed to fast-track the installation of Drupal, providing you with a cost-effective package to create highly effective and efficient content and marketing websites. It harnesses the power of commonly used, ready-to-go features and functionalities, making it the perfect solution to fast-track the build and focus on your specific needs.

Salsa Digital: CivicTheme wins UX/Design Splash Award

1 week 4 days ago
CivicTheme takes home the award Salsa’s CivicTheme won the UX/Design Splash Award at DrupalSouth 2023.    Special thanks A special  thanks to all the people who’ve contributed to CivicTheme along the way, including:  Early designs: Adam Walton from Oliver Grace. Early contributors: Australian Government and the Civil Aviation Safety Authority   Early client adopters: The Australian Radiation Protection and Nuclear Safety Agency (ARPANSA), The Australian Energy Infrastructure Commissioner (AEIC), Australian Commission for Law Enforcement Integrity, Vision Australia, Bendigo Wayfinder, Access Hub and Digital Aotearoa Collective.

Salsa Digital: BenefitMe runner up for Non-profit Splash Award

1 week 4 days ago
BenefitMe takes home runner-up award BenefitMe was honoured as the runner up in the Non-profit Splash Award. This project brought Drupal and Rules as Code (RaC) together. The project team consisted of members from the Digital Aotearoa Collective and Salsa Digital.  Special thanks A special thanks to all the people who contributed to BenefitMe, including: The initial crew from the Digital Aotearoa Collective : Jo Allum, Pia Andrews, Jonah Duckles, Robert O’Brien, Arama Maitara, Hamish Fraser, Tom Barraclough, Ben Tairea, Brenda Wallace, Siobhan McCarthy, Regan Gilmour, and more.

The Drop Times: A Traveler's Mindset

1 week 4 days ago

Each day in our life comes packed with different challenges. These challenges can sometimes be exciting and bring about a happy ending. But most of the time, challenges get coupled with difficulties. Difficulties in turn can get us stressed and even burn us out. As individuals, it is very important to convince ourselves that there seldom comes a day without a hurdle to cross. When we have such a prior understanding, challenges will fail to shock us.

I would like to put it another way. Just think about the last travel experience you had and try to remember the challenges faced. While traveling, there isn't much time available to solve a problem. We never wait for others to act first, instead we promptly go forward and find an alternative solution. A traveler is ready to seek advice from knowledgeable people without any inhibitions. Such a mindset helps to overcome any challenges on the road or anywhere. Because we know we will be stuck very badly if we do not find a solution. 

Life itself, in essence, is a journey. Nothing can help us better than to have a traveler's mindset. Now, let us journey through the important picks from the past week.

The Drop Times interviewed Margery Tongway on the sidelines of DrupalSouth. Margery Tongway is a Senior Consultant at Annex. Click here to read the interview. Read TDT's report on DrupalSouth Wellington 2023, where the Drupal community celebrated expertise and honored achievements.

A blog post published on provides a detailed guide on hosting a Drupal 9 or 10 website using NixOS. In a blog titled "Disabling Twig Caching Made Simpler," Mike Herchel writes on how to disable Twig caching. Kanopi Studios has published an article explaining the benefits of a great website design. Srijan has published a new blog post on how to install Drupal 10 using Colima and DDEV on MacBook.

 An article published by StyleLib explains how Facdori theme is designed to provide a professional and modern look for industrial and manufacturing businesses. A new blog post published by Acquia discusses the capabilities and advantages of using Drupal content management system (CMS), for building e-commerce websites. A blog post published by Evolving Web explores Drupal 10 and its integration with Symfony 6.2 framework. the new PHP framework brings significant enhancements to the Drupal tech stack. 

Pantheon has introduced a new direct purchase path that allows web teams to access valuable WebOps features with ease. Follow this link to know more. See how developers can enhance the flexibility and extensibility of their Drupal-powered websites by integrating Symfony Components and Twig into Drupal Core. Selecting the right e-commerce platform can be challenging. Two popular options, Drupal Commerce and BigCommerce, stand out as top choices for businesses of all sizes. LN Webworks have published a blog post comparing both the options.

 Evolve Drupal is scheduled on 26 May 2023 in Montreal, Canada. This will be an in-person event. Click here to read more. The Drupal Bangalore User Group (D-BUG) will hold its monthly event on Saturday, 27 May, 2023. The event,  will be held at Valuebound's headquarters.


That is all for the week,
Your's truly,
Thomas Alias K, 
Sub-Editor, TheDropTimes