Using TinyMCE "theme CSS" option I found that some styles - such as colored backgrounds - do not really belong in editor window "as is". Since I could not find how to modify them with existing functionality I had to write a patch myself.
The idea is to change 'Use theme CSS' option behavior to append 'Define CSS' style right after the main theme. This allows any overriding to take place. Here is my updated code for tinymce.inc
if ($config['css_setting'] == 'theme') {
$files = wysiwyg_get_css();
if (isset($config['css_path'])) {
$files[] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
}
$init['content_css'] = implode(',', $files);
}
In my case, I have tested %b%t/tinystyle.css
file with single line body {background-color: white;}
line and everything worked fine.
This is ready to commit, unless someone wants to turn "Modified Theme CSS" into a separate option.
Comment | File | Size | Author |
---|---|---|---|
#11 | wysiwyg-theme-custom-css-436030-10.patch | 3.39 KB | David Lesieur |
#8 | wysiwyg.patch | 2.96 KB | dkruglyak |
#2 | wysiwyg.patch | 2.43 KB | dkruglyak |
Comments
Comment #1
sunThanks - but please provide a proper patch.
And yes, this needs to be a separate option.
Comment #2
dkruglyak CreditAttribution: dkruglyak commentedOK, I made the patch against HEAD / 6.x-2.x and it works fine for me.
On the other note, it is not clear from anywhere in the docs how 6.x-2.x is different from 6.x-1.x, what is the roadmap and which release to use. Could you explain?
I suppose the patch should be applied to all relevant branches?
Comment #3
dkruglyak CreditAttribution: dkruglyak commentedMarking this ready to be committed because the patch is trivial and has been tested.
Comment #4
sunThis patch only adapts tinymce.inc to the new configuration option.
Also, I wonder why the value is internally called "theme_mod" and not "theme_self", i.e. the result of the settings "theme" + "self".
Comment #5
dkruglyak CreditAttribution: dkruglyak commentedI am not sure what you want/need to do with editors other than tinymce.inc. I am not using other editors but you are welcome to adapt them too.
"theme_mod" means "theme modified". I do not really care how you call it, but I believe the patch is ready to commit.
Comment #6
sunSorry, but no, this is not RTBC. This is Wysiwyg API, not tinymce module.
To get this committed, the remaining todos in #4 need to be incorporated. Additionally, the option title "Use theme CSS" should stay as is, and the new option should probably be titled "Use theme and defined CSS".
That said, I also wonder whether we shouldn't modify wysiwyg_get_css() to take an optional argument (i.e. $config['css_path']), which is automatically expanded and added to the resulting and returned array of CSS files. Ultimately resulting in less code in editor implementations.
Comment #7
dkruglyak CreditAttribution: dkruglyak commentedOf course it is RTBC. No reason to hold up the fix to the most used editor because you want the same thing for 10 other editors nobody cares about. When someone actually needs this option for those, I am sure they will submit a patch.
If you want to add an extra option to Wysiwyg API fine, but let's not hold up this feature for no good reason.
Comment #8
dkruglyak CreditAttribution: dkruglyak commentedUpdated to reflect the latest code. This has been extensively tested and is ready to go.
Comment #9
sunThis is far from being "reviewed and tested by the community". I did not test this patch and you cannot set this status yourself.
1) Something about a spellchecker is contained in the patch.
2) Still uses the key 'theme_mod' instead of 'theme_self'. See #4.
3) Only updates tinymce.inc accordingly, but the configuration options are used for all editors. So this patch breaks existing functionality.
4) The option values should be "Theme CSS", "Theme and custom CSS", and "Custom CSS". The internal option keys we either need to keep, or implement a module update that renames them accordingly to 'theme', 'theme_custom', and 'custom'.
Comment #10
dkruglyak CreditAttribution: dkruglyak commentedYou are welcome to make these final changes yourself. The patch is tested and works. Thank you.
Comment #11
David Lesieur CreditAttribution: David Lesieur commentedHere's an updated patch that makes a small step forward but still needs work. It:
Comment #12
sunThanks, @David Lesieur!
This looks very close to me. On a second look, I think we should go with theme, theme_custom, and custom for the internal key names, and add a module update to change existing profiles. That "self" dates back to the original tinymce.module and really is a very odd and confusing name.
Comment #13
deggertsen CreditAttribution: deggertsen commentedThis is an older issue. Is this something that still needs to happen or is it outdated? Also is this feature request relevant for D7?
Comment #14
TwoDYes, this could still be useful, but it needs a reroll and expansions to work with the other editors, as well as the changes mentioned by sun.
Comment #15
webservant316 CreditAttribution: webservant316 commentedstruggling with this today and worked out a solution here https://www.drupal.org/node/2496649.