[support] different TinyMCE problems

Metzler, David metzlerd at evergreen.edu
Mon Aug 20 16:01:23 UTC 2007


Not exactly.  It's implemented as a positive filter (which tags do you allow). 
 
This is usually the list I work from for basic content. 
  h1,h2,h3,h4,p,br,a,em,strong,ul,ol,li,blockquote,img
 
I ask authors to use the H1, h2 styles, which I then can control via CSS. Of course the font tag is the biggest enemy in word.... :). 
 
The way you set this is by implementing a custom mytheme_tinymce_theme function which then allows you to change anything about tinymce.  
 
See the README.TXT file section on Tweaking TinyMCE for more info but there's a sample function that I've included below straight from the README file :). 
 
TWEAKING THE TINYMCE THEME
********************************************************************
 
Developers have complete control over when and how tinymce is enabled
for each textarea inside Drupal by creating a custom Drupal theme
function. The following example assumes you're using a phptemplate based theme.
 
Put the following function in your themes template.php file:
 
/**
 * Customize a TinyMCE theme.
 *
 * @param init
 *   An array of settings TinyMCE should invoke a theme. You may override any
 *   of the TinyMCE settings. Details here:
 *
 *    http://tinymce.moxiecode.com/wrapper.php?url=tinymce/docs/using.htm
 *
 * @param textarea_name
 *   The name of the textarea TinyMCE wants to enable.
 *
 * @param theme_name
 *   The default tinymce theme name to be enabled for this textarea. The
 *   sitewide default is 'simple', but the user may also override this.
 *
 * @param is_running
 *   A boolean flag that identifies id TinyMCE is currently running for this
 *   request life cycle. It can be ignored.
 */
function theme_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
  switch ($textarea_name) {
    // Disable tinymce for these textareas
    case 'log': // book and page log
    case 'img_assist_pages':
    case 'caption': // signature
    case 'pages':
    case 'access_pages': //TinyMCE profile settings.
    case 'user_mail_welcome_body': // user config settings
    case 'user_mail_approval_body': // user config settings
    case 'user_mail_pass_body': // user config settings
    case 'synonyms': // taxonomy terms
    case 'description': // taxonomy terms
      unset($init);
      break;
 
    // Force the 'simple' theme for some of the smaller textareas.
    case 'signature':
    case 'site_mission':
    case 'site_footer':
    case 'site_offline_message':
    case 'page_help':
    case 'user_registration_help':
    case 'user_picture_guidelines':
      $init['theme'] = 'simple';
      foreach ($init as $k => $v) {
        if (strstr($k, 'theme_advanced_')) unset($init[$k]);
      }
      break;
  }
 
  /* Example, add some extra features when using the advanced theme.
  
  // If $init is available, we can extend it
  if (isset($init)) {
    switch ($theme_name) {
     case 'advanced':
       $init['extended_valid_elements'] = array('a[href|target|name|title|onclick]');
       break;
    }
  }
  
  */
 
  // Always return $init
  return $init;
}

 

________________________________

From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On Behalf Of sander-martijn
Sent: Monday, August 20, 2007 8:31 AM
To: support at drupal.org
Subject: Re: [support] different TinyMCE problems


Ok, well since word drops in all kinds of wierd html when pasting and it's such a common way for nonhtml people to work, do you (or someone else) already have a list of html to strip out for word specifically?  And where do you configure that?

on another note: TinyMCE has a paste from word button you can show, and I believe if you train users to use that icon instead of the normal paste it will paste in plain text instead of word's formatted text.  In your experience does that button work well?

Metzler, David wrote: 

	Didn't mean TinyMCE has tags, but rather that you can build filters into TinyMCE. So that the HTML that you're worried not having on your site is not only not displayed, but also not stored in the database. 
	 
	Let me try and rephrase....
	 
	"SO if you're doing a bunch of pasting from Word, it will still leave any weird word generated tags in the HTML that gets stored in Drupal, even if you have them filtered out by a drupal input filter.  This only bothers you when you turn off the editor, or if you have some other process trying to get at the data that doesn't properly use the filters. 
	 
	You can also configure TinyMCE to filter tags, but these filters can only be set by implementing a special function in your theme, and can't be set via a configuration page. If you filter the tags out with TinyMCE as well,  tags you don't want users entering won't be stored in the database either. 
	 
	Hope that makes more sense.  
	 
________________________________

	From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On Behalf Of Jean Gazis
	Sent: Friday, August 17, 2007 10:30 PM
	To: support at drupal.org
	Subject: Re: [support] different TinyMCE problems
	
	
	Well, I'm not pasting form Word (I hate Word) but I don't understand this: "SO if you're doing a bunch of pasting from Word, it will still leave the tags in the HTML that gets stored in Drupal.  This only bothers you when you turn off the editor, or if you have some other process trying to get at the data. TinyMCE tag filters can only be set by implementing a special function in your theme. "
	
	How do I know what the tiny MCE tags are? I just see some HTML tags. 
	
	Jean
	
	
	On 8/17/07, Metzler, David <metzlerd at evergreen.edu> wrote: 

		An important thing to note:  Changing the default filter does not change any content.  If you're changing the input formats from FilteredHTML to Full HTML, and you had previously created a node as "Filtered HTML" changing the default won't change the original nodes input format.  You must have administer filters privilege and change the input format on each node. If you instead edit the allowed tag list for the "Filtered HTML" input format, then you don't have to update each node.  Hope that makes sense.   
		 
		Correspondingly, unless you're using "Filter Defaults" or some other module that alters this.  Drupal out of the can does not support Content Type specific filters. The input formats are set on a per node basis. 
		 
		FYI:  I have configured TinyMCE to filter out html tags as well in some cases.  Input formats filter out HTML on display and not input.  SO if you're doing a bunch of pasting from Word, it will still leave the tags in the HTML that gets stored in Drupal.  This only bothers you when you turn off the editor, or if you have some other process trying to get at the data. TinyMCE tag filters can only be set by implementing a special function in your theme. There's no place to "configure" this in the DB. 
		
		Dave
		 
		 
________________________________

		From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On Behalf Of sander-martijn
		Sent: Thursday, August 16, 2007 2:17 PM 
		
		To: support at drupal.org 
		Subject: Re: [support] different TinyMCE problems
		

		I've always thought the opposite of TinyMCE (or any wysiwyg editor).  It's not necessarily to restrict your users from using html but more to remove the requirement of knowing html.  
		
		However I do think you can get what you want: I think that if you turn on full html globally but turn off the option for users to select, require TinyMCE (also can be done globally I believe) and don't include the html button in the TinyMCE editor, then TinyMCE will be able to write all the html it needs to (restricting html will restrict it from TinyMCE as well - this is because TinyMCE is merely a front-end mask to what's really happening) while the user will never be able to see or edit it. 
		
		Jean Gazis wrote: 

			If <ul> and <li> are enabled, shouldn't the bulleted list format button work? I don't see where to associate the input format with a content type. I don't want to give all users full HTML, that's the whole point of installing TinyMCE. If I turn off line breaks in my default format, won't it mess up my other content types? I think that was why I turned them on. And TinyMCE worked or works sometimes with the default input format as is. I feel like I am just being dense. 
			
			
			On 8/16/07, Metzler, David <metzlerd at evergreen.edu> wrote: 

				Yes as sara has indicated.  You can change the defaults at 
				 
				Administer -> Site Configuration -> Input Formats. 
				 
				If you "Configure" the default format. Then select the Configure tab, you'll be able to set which tags are allowed.  The default set is 
				<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
				 
				When you enable tinymce you might also consider turning off the "line break converter" on this screen as well. 
				 
				Dave

________________________________

				From: support-bounces at drupal.org [mailto: support-bounces at drupal.org <mailto:support-bounces at drupal.org> ] On Behalf Of Jean Gazis
				Sent: Thursday, August 16, 2007 12:48 PM
				To: support at drupal.org
				Subject: Re: [support] different TinyMCE problems
				
				
				I don't want the users to have to select input formats, I want them to be set for the content type or field type. Is that possible?
				
				
				On 8/16/07, Sarah Adams <mr.sanders at geekjock.ca> wrote: 

					> I installed it, set up roles etc. It seemed to work fine with the first
					> custom content type. A few days later, it does not. In between I
					> installed Views and Viewfield, and created a new content type.
					>
					> What I'm getting is, instead of formatted text, e.g. bulleted list, it
					> just puts <br> or <div> between the items and removes the line breaks,
					> like this:
					>
					> "vegetable<br /> fruit<br /> vegetable<br /> fruit<br /> fruit<br /> 
					> vegetable<br /> veggie<br /> fruit <br /> veg"
					>
					> I'm sure this is some stupid thing I could figure out somehow, but I
					> can't figure out where to start.
					
					You probably have the content set to use filtered html instead of full 
					html. You can update this on a content item basis by clicking on input
					formats just below the TinyMCE editor, or site-wide by going to admin >
					site config > input formats.
					
					HTH!
					
					--
					sarah adams 
					web developer & programmer
					portfolio: http://sarah.designshift.com
					blog: http://hardedge.ca
					--
					[ Drupal support list | http://lists.drupal.org/ ]
					




				-- 
				Jean Gazis
				www.jeangazis.com
				www.boxofrain.us
				
				"Believe those who are seeking the truth; doubt those who find it." - André Gide 

				--
				[ Drupal support list | http://lists.drupal.org/ ]
				




			-- 
			Jean Gazis
			www.jeangazis.com
			www.boxofrain.us
			
			"Believe those who are seeking the truth; doubt those who find it." - André Gide 


		-- 
		
________________________________


		sander-martijn <mailto:sander at sander-martijn.com> 
		interface developer | architect
		sander at sander-martijn.com
		www.sander-martijn.com 

________________________________


		--
		[ Drupal support list | http://lists.drupal.org/ ]
		




	-- 
	Jean Gazis
	www.jeangazis.com
	www.boxofrain.us
	
	"Believe those who are seeking the truth; doubt those who find it." - André Gide 


-- 

________________________________


sander-martijn <mailto:sander at sander-martijn.com> 
interface developer | architect
sander at sander-martijn.com
www.sander-martijn.com 

________________________________

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20070820/419dcc52/attachment-0001.htm 


More information about the support mailing list