Hello everyone,
I have been using drupal for quite a while, but am really new to the wysiwyg plugin.
Almost everything is working really fine, but my only issue is, that on of the themes I use has a dark background and white text. Editing this page with CKEditor, you can't see any text, as both background and text is white. So I am wondering, how I can change the background color (changing text color would be fine, too, but it's not really wysiwyg then anymore, is it?).
I've already spent hours on searching for answers here, but they all refer to using the actual CKEditor-module (which I am not, because I want to use the wysiwyg-image upload module).
I would really appreciate if there was someone there who knows how i can change the background color of the text field.
Thanks a lot in advance!
llkks
Comments
Tried the Wysiwyg issue queue?
This has been discussed a few times and you should be able to find the (now closed) issues by searching for at least "background" and selecting Any issue, not just open ones.
The problem you are encountering, and its solution, isn't specific to CKEditor but applies to all editors under Wysiwyg. Though exactly how to solve it depends slightly on which editor and theme is used.
If you've set the editor profile to use the stylesheets from the theme (default under "CSS" on the profile configuration), that's where the changes need to happen.
The thing is that the editor's can't know exactly which elements will wrap the contents you enter when they are finall rendered, so your stylesheets may target the wrong elements - or completely miss some - when used in the editing area (usually an iframe).
Editors usually wrap the contents with the minimum markup needed to make things work. This means the stylesheets should now expect to find the contents just below the body tag, and it's applied style determines what the background and "default" styling will look like.
So, to make the editing area use the same background, font etc as your rendered "content area" does, style the body tag to match the styling of the "content area" (ie, the element where the content will finally end up on the page).
Now you might be thinking "WTF, that will mess up my layout!". Yes, it would, had it not been for the fact that the developers of most editors have foreseen this. Editors often add a specific class or id to the body tag in the editing area iframe, which of course your pages won't have. That makes it possible to write CSS selectors that will only match elements in your contents - or part of the minimal wrapping markup used by the editor - when they are being edited. Nice, isn't it?
One slight problem though; not all editors set a class or id on their body tag, and what to do if I'm using multiple editors? Well, one option is to reverse the same solution: Add a class or id to your theme's body tag, target the body tag (without this class/id) with some CSS selectors and style it as if it was used in the editing area, then add more selectors targeting the body tag having the class/id and override the previous styles with what you're using now. Basically, style for the editor, override for the final look. Not ideal but it works. It would be worth checking out if the editor(s) support changing the class or id set on the body using some setting. If so, that setting can be set via hook_wysiwyg_editor_settings_alter() - and later via the profile settings when we have a custom profile GUI for each editor.
Another solution could be to create a new stylesheet just for the editors and load that one instead of the theme's stylesheets by changing the settings under "CSS" on the editor profiles. This will probably take a bit more time than the previous solution, and you'l get more files to maintain. It might be preferable if you'd have to override a lot of style rules in your main files to make things look nice though.
Firebug
Use Firebug in Firefox, and you can easily see the CSS used/not used. This happened once to me using FCKeditor where there was "no" background in the editor window because it used the body CSS, and I just added a class in my theme that was picked up.
Thank you two!
thank you very much TwoD, your answer was REALLY helpful. Helped me a lot to understand how I am supposed to design the Editor and how to change the background-color in particular.
And Firebug was a good hint as well. I usually use Opera and Dragonfly, but for some reason that didnt help me to find the iframe, which Firebug easily did.
So thanks again :)
Use Editor Default CSS
A quick solution that works well for most sites is to expand the CSS tab in the CKEditor profile of the Wysiwyg settings. You then change the Editor CSS setting from "Use Theme" to "Editor Default". This will make CKEditor use its own default styling, which will give you black text on a white background in the editor.
CSS to add for CKeditor under either method
(yup - i edited this)
for themes with a dark background and white text
.cke_show_borders {
background: white;
color: black;
}
for themes with a dark body background and a white background with black text
.cke_show_borders {
background: white;
}
hope that helps someone else
PS - in theory you shouldn't have to change your text color since the background on your page is white with the body color being the dark background.