At some point it looks like core's CKEditor switched to using iframes by default. This means that when the add_css AJAX command runs, the additional CSS gets added to the root document's head, and not the CKEditor iframe's head, so the styles don't actually load in the editor.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid created an issue. See original summary.

Dave Reid’s picture

It doesn't seem possible to add CSS to the WYSIWYG dynamically from the plugin JS. It does look like this would be possible with CKEditor.editor.addContentsCss(), which is available as of v4.4+, but with D8 we're only using 4.11.4 as the latest version. :(

Dave Reid’s picture

Dave Reid’s picture

For now let's provide a simpler preview if the request is a normal GET request.

Dave Reid’s picture

Status: Active » Needs review
Dave Reid’s picture

Try to fix the test

  • Dave Reid committed fe55fa9 on 8.x-1.x
    Issue #3097116 by Dave Reid: Allow the embed preview route to return a...
Dave Reid’s picture

Status: Needs review » Needs work

Marking back to needs work for now.

Dave Reid’s picture

Title: Preview controller and AJAX method no longer work to add CSS to CKEditor iframes » Preview controller and AJAX method no longer work to add CSS or JS to CKEditor iframes

I wonder if this is worth revisiting to see if we could also solve this for JS assets as well with https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_scriptLoader.html