Problem / Motivation

Currently, the module writes custom CSS to a static file on disk at public://css_editor/[theme].css and registers it via theme libraries. When multiple multisite instances use the same theme machine name (e.g., yourtheme), saving settings on one site overwrites yourtheme.css for all sites sharing that file mount. Consequently, each site inadvertently loads styles intended for another.

Proposed Resolution

Introduce a configuration toggle (load_inline) in the theme settings form to render the custom CSS directly from configuration into an inline <style> tag, bypassing filesystem writes entirely:

  1. Schema Update: Add load_inline (boolean) to css_editor.theme.* in css_editor.schema.yml.
  2. Theme Settings Form: Expose a checkbox ("Load CSS directly from field (inline) instead of file") in css_editor_form_system_theme_settings_alter().
  3. Attachment Logic: In css_editor_page_attachments(), check if load_inline is active:
    • If enabled, inject the CSS into #attached['html_head'] as an inline <style> tag with appropriate config cache tags (config:css_editor.theme.[theme]).
    • If disabled, retain the existing library/file-attachment behavior.
  4. Service Handling: Update CssEditorService::generateCssFile() to skip disk operations when load_inline is enabled, preventing cache rebuilds from regenerating shared files.

Remaining Tasks

  • Add config schema definition for load_inline.
  • Update form alter and submit handlers in css_editor.module.
  • Adjust css_editor.css_generator service to bypass file generation when inline loading is enabled.

Issue fork css_editor-3637028

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

vladimiraus created an issue. See original summary.

vladimiraus’s picture

Status: Active » Needs review
jannakha’s picture

Status: Needs review » Reviewed & tested by the community

patch applies, css loaded not from file but directly from HTML doc as described.

RTBC