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:
- Schema Update: Add
load_inline(boolean) tocss_editor.theme.*incss_editor.schema.yml. - Theme Settings Form: Expose a checkbox ("Load CSS directly from field (inline) instead of file") in
css_editor_form_system_theme_settings_alter(). - Attachment Logic: In
css_editor_page_attachments(), check ifload_inlineis 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.
- If enabled, inject the CSS into
- Service Handling: Update
CssEditorService::generateCssFile()to skip disk operations whenload_inlineis 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_generatorservice to bypass file generation when inline loading is enabled.
Issue fork css_editor-3637028
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
Comment #3
vladimirausComment #4
jannakha commentedpatch applies, css loaded not from file but directly from HTML doc as described.
RTBC