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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Status: Needs review » Active

Thanks - but please provide a proper patch.

And yes, this needs to be a separate option.

dkruglyak’s picture

FileSize
2.43 KB

OK, 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?

dkruglyak’s picture

Status: Active » Reviewed & tested by the community

Marking this ready to be committed because the patch is trivial and has been tested.

sun’s picture

Status: Reviewed & tested by the community » Needs work

This 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".

dkruglyak’s picture

I 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.

sun’s picture

Sorry, 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.

dkruglyak’s picture

Of 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.

dkruglyak’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
2.96 KB

Updated to reflect the latest code. This has been extensively tested and is ready to go.

sun’s picture

Status: Reviewed & tested by the community » Needs work

This 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'.

dkruglyak’s picture

You are welcome to make these final changes yourself. The patch is tested and works. Thank you.

David Lesieur’s picture

Here's an updated patch that makes a small step forward but still needs work. It:

  • removes the thing about the spellchecker;
  • uses key 'theme_self' for the new option;
  • updates TinyMCE and CKEditor. Other editors still need to be taken care of;
  • uses options labelled "Use theme CSS", "Use theme and custom CSS", "Use custom CSS", "Use editor default CSS". Does not change the internal keys.
sun’s picture

Thanks, @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.

deggertsen’s picture

This is an older issue. Is this something that still needs to happen or is it outdated? Also is this feature request relevant for D7?

TwoD’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev

Yes, 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.

webservant316’s picture

Issue summary: View changes

struggling with this today and worked out a solution here https://www.drupal.org/node/2496649.