cancel
Showing results for 
Search instead for 
Did you mean: 

invalid_elements

samuel_penn
Champ in-the-making
Champ in-the-making
Hi all,

Has anyone successfully used TinyMCE parameters such as "invalid_elements" or "valid_elements" in web form elements? I have an xforms widget set up with these parameters (Alfresco 3.1 Enterprise), and I'd expect it to strip out these tags, but it's not.


           <widget xforms-type="xf:textarea"
                   appearance="abstract"
                   javascript-class-name="alfresco.xforms.RichTextEditor">
             <param name="theme_advanced_buttons1">bold,italic</param>
             <param name="height">150</param>
             <param name="mode">exact</param>
             <param name="force_p_newlines">true</param>
             <param name="apply_source_formatting">true</param>
             <param name="verify_html">true</param>
             <param name="cleanup_on_startup">true</param>
             <param name="valid_elements">p</param>
             <param name="invalid_elements">em,strong,br</param>
             <param name="verify_html">true</param>
           </widget>

The problem is that we want some limited formatting in the field, but it appears users are able to add random tags in anyway (I'm guessing via cut and paste from other sources). I'm using the above config for testing btw, hence allowing the bold/italic buttons whilst also trying to strip out em and strong tags.

Thanks,
Sam.
4 REPLIES 4

stevea
Champ in-the-making
Champ in-the-making
I'm having the same issue. Did anyone ever figure this one out? No matter what I pass in the valid_elements parameter I get the defaults for tinyMCE.
I also get the table plugin, which I don't want and can't seem to get rid of. However it does pick up other plugins that I specify correctly.
Thanks,
Steve

stevea
Champ in-the-making
Champ in-the-making
Looked into this a little more and found that only the tinyMCE settings that Alfresco sets by default can be updated. I'm sure this is the product of some well-meaning, defensive coding.
Editing Alfresco\tomcat\webapps\alfresco\scripts\ajax\xforms.js and making the following change, allows any tinyMCE configuration param to passed AND persist.
From:
  
 for (var i in this._params)
    {
      if (i in tinyMCE.settings)
      {
        alfresco.log("setting tinyMCE.settings[" + i + "] = " + this._params[i]);
        tinyMCE.settings[i] = this._params[i];
      }
    }
To:
   
for (var i in this._params)
    {
        alfresco.log("setting tinyMCE.settings[" + i + "] = " + this._params[i]);
        tinyMCE.settings[i] = this._params[i];
    }

stevea
Champ in-the-making
Champ in-the-making
One more follow up on this.
If any of the values you are passing to TinyMCE in the xml config are false, like the following:
<param name="inline_styles">false</param>
Be aware that they WON'T WORK. Alfresco passes them to TinyMCE as the string false, which evaluate to boolean true. Ahhh!!!
The way to work around this is to hard code them in xforms.js in the _createTinyMCE method where all the other settings are happening. For the above sample you would add the line below.
 tinyMCE.settings.inline_styles = false;

samuel_penn
Champ in-the-making
Champ in-the-making
Thanks Steve.

I've actually given up on WCM forms for my current web project, and I'm writing the XML content by hand (but it's just me doing it, and I can use a text editor quicker and more flexibly than the web UI).

If I ever need to use the UI again though, this will undoubtedly come in useful.

Thanks,
Sam.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.