Define CSS not working ..

h3@drupal.org - July 7, 2005 - 13:52
Project:TinyMCE
Version:4.6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I installed TinyMCE and ti works great, till I tried to match the styles of the editor's content with the rest of the page. First of all, there is ambiguity between the "CSS" and "FORMATING" sections of the editor profiles's config panel. I assumed that the "FORMATING" was for the content of the editor and the other for the editor itself.

Another thing I don't dig .. "Editor CSS:" here you can choose between "use theme css", "define css" and "use tinyMCE default" .. and you have exactly the same select box in the "FORMATING" section .. BUT when you change any one of the two, the other changes for the same .. so I ask, why 2 select boxes if we can't select differents options ? Or why can't we choose a different CSS for the editor's skin and the editor's content ?

this one bugs me too :
"Enter path to CSS file (example: "/css/editor.css"). Select "define css" above."

and this path is relative to ?? I tried using "define css" and I tried alot of paths and never achieved to change the damn default css. if I put the css file in the root of the drupal installation .. "drupal/modules/tinyMCE.css"
the path to CSS file shouln'd be "/tinyMCE.css" ? I tried "TinyMCE.css" too with no results ..

I have another issue, but it's more a feature request so I'll post it with the right flag ;>

keep your good work

#1

tenrapid - October 28, 2005 - 16:05
Status:active» reviewed & tested by the community

I had the same problem with 'define css', so I dived into the code.

To make it work as intended one has to change these 3 lines of code

from:

419    else if ($settings['css_setting'] == 'self') {
420      $init['content_css'] = $edit['css_path'];
421    }

to:

419  }
420  else if ($settings['css_setting'] == 'self') {
421      $init['content_css'] = $settings['css_path'];

I don't know how to generate a patch file yet, so I attached the patched tinymce.module.

The path to your css file is relative to the drupal installation directory. So if your 'my.css' file is in the directory of 'mytheme' you have to enter:
themes/mytheme/my.css

AttachmentSize
tinymce.module 27.79 KB

#2

mrchristian - November 11, 2005 - 13:31

thanks for the the patched
but i copied it and it didn't worked, i also tried different paths, but nothing.
any idea what i'm doing wrong?

thanks for your help

#3

tenrapid - November 13, 2005 - 11:15

sorry, no idea what is going wrong.

but if you look at the page source of a page containing a tinymce textarea (right click -> "view page souce" eg. in mozilla) you should see a javascript function "tinyMCE.init" followed by a listing of several options. one of this option should be

content_css : "themes/*/*.css",

can you see this line and what does it say?

#4

m3avrck - November 30, 2005 - 23:28
Status:reviewed & tested by the community» fixed

This issue has already been fixed in CVS and for the 4.7 release. The logic is much more smarter and there is a very clear description of what the file is relative too. Thanks!

#5

Anonymous - December 14, 2005 - 23:40
Status:fixed» closed

#6

ddegner - February 11, 2006 - 22:25
Version:<none>» 4.6.x-1.x-dev

I wish this had been folded into the latest release for 4.6 . It would have saved me an afternoon of searching. Thanks for the patch though.

#7

ddegner - February 16, 2006 - 18:09
Status:closed» reviewed & tested by the community

Could this be patched to the 4.6.0 code, this is the second time I have had to search for an hour for the patch. It fixes a bug. Is there something I don't understand?

#8

solipsist - March 14, 2006 - 17:09

Yeah, this bugs me too. If you can't commit a fix, at least explain how to fix it.

Thanks.

#9

solipsist - March 14, 2006 - 17:35

I found the problem:

On line 414 in tinymce.module:

  if ($settings['css_setting'] == 'theme') {
    $css = drupal_get_path('theme', init_theme()) . '/style.css';
    if (file_exists($css)) {
      $init['content_css'] = $base_url .'/'. $css;
    }
    else if ($settings['css_setting'] == 'self') {
      $init['content_css'] = $edit['css_path'];
    }
  }

Replace with:

  if ($settings['css_setting'] == 'theme') {
    $css = drupal_get_path('theme', init_theme()) . '/style.css';
    if (file_exists($css)) {
      $init['content_css'] = $base_url .'/'. $css;
    }
  }
  else if ($settings['css_setting'] == 'self') {
      $init['content_css'] = $settings['css_path'];
   }

Causes: brace never closer for if ($settings['css_setting'] == 'theme') and incorrect variable reference ($edit instead of $settings which someone noted above).

If someone can create a patch file hopefully this can be committed.

#10

decibel.places - May 4, 2006 - 08:24

I too have been tweaking TinyMCE to create a code-free node editing interface for a code-phobic client (who has so far insisted on using only his beloved Safari browser, but is finally coming around to a Firefox/Mac compromise)

The code snippets above were very helpful. I added this bit, and it's been tested to work for a "defined" custom css:

from:

421      $init['content_css'] = $settings['css_path'];

to:

421      $init['content_css'] = $base_url .'/'. $settings['css_path'];

$base_url .'/'. (as in the theme setting) helped Drupal find the correct path...
or possibly it's unnecessary, but I didn't see the style list in the editor until I added this!

Keep on slogging!

#11

m3avrck - May 6, 2006 - 22:35
Status:reviewed & tested by the community» fixed

Thanks, I've taken these fixes and committed them on the 4.6 branch.

#12

Anonymous - May 20, 2006 - 22:46
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.