Jump to content

[solved] TInyMCE table attribute width stripped off


Soma
 Share

Recommended Posts

Since I don't know when, I got problem with the TinyMCE setting table attribute to 100%. The attribute get's stripped off when saved. All other attributes work. Anyone have same issue or know how to fix it?

I'm sure it worked before. So maybe this has to do with the new TinyMCE version 3.4.7?

This is the valid_elements:
@[id|class],a[href|target|name|title],strong/b,em/i,br,img[src|id|class|width|height|alt],ul,ol,li,p[class],h2,h3,h4,blockquote,-p,-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],code,pre,sup

Doing this it works setting it always to 100%:
...-table[border=0|cellspacing|cellpadding|width=100%|frame|rules|height|align|summary|bgcolor|background|bordercolor]...

Solution:

add the "style" attribute to the valid elements, as TinyMCE converts the width="100%" to style="width:100%".

To allow it for all add it to @[id,class|style] or just the table elements.

Link to comment
Share on other sites

  • 7 months later...

This bug is annoying, I got now a page where someone tried to insert a table with attr 100%. After saving the table in TinyMCE is gone, but it throws an error and fails to load completely and editor stays in a state where when saving it won't really save new content. DANG!

Link to comment
Share on other sites

Ok it wasn't the table, it is a image inserted in TinyMCE which looks like this in html:

<p><img mce_advimageresize_id="Inputfield_body_mce_1" height="343" width="643" mce_src="/site/assets/files/3349/egg.jpg" src="/site/assets/files/3349/egg.jpg" /></p>

I think this was because the table failed it failed to strip of the TinyMCE temporary attributes. omg.

No not really, all image get inserted like this, nothing with table todo. Strange thing.

Link to comment
Share on other sites

  • 2 months later...

I have the same problem with some attributes, e.g. setting table width or align and text align.

I tried to modify the valid_elements, i even tried to use the full set which is provided on the TinyMCE website, but it's always stripped.

Any news about this problem? 

Link to comment
Share on other sites

I have the same problem with some attributes, e.g. setting table width or align and text align.

How are you doing this? With a style attribute or actual "width" and "align" attributes? If you are using non-style attributes, it could simply be a matter of them being deprecated in HTML5/XHTML? Double check that you are using a style attribute. I honestly don't know off-hand which ones are deprecated or if TinyMCE even cares, but using the style attribute, or better yet, a dedicated class name is probably the proper way to do this stuff. See if you can find a consistently repeatable condition that we can test. 

Link to comment
Share on other sites

  • 2 weeks later...

Again im am stuck somehow with this table width problem...

How should one use TinyMCE if it is not more supported to set the width of a table or table cell? The different cells have no different CSS classes and even if they had, the person who edits the website cannot set the width in the CSS style sheet.

It would be easy possible to use CSS classes e.g. for text align - but e.g. for font size or table width it is not possible.

Of course i prefer to give the client just a very few options, no font size etc. - but there are some costumers who already worked with WYSIWYG and they want to have the same possibilities...

I still cannot imagine that the newest TinyMCE versions do not support this anymore - in the editor it shows the preview for setting tect left, right, center and it sets the width of the table and table cells.

So it has to be stripped somehow through the InputField, or not? Even if i use all the valid elements which are provided in TinyMCE it will not work.

Any idea how this could be solved?

Link to comment
Share on other sites

Add the "style" attribute to the valid_elements table. Now you can set the width and it stays.

TinyMCE converts the width="100%" to a style="width:100%", and since PW default config has "style" not in valid elements it gets stripped.

Ryan, can could you add that "style" to the table elements or default @[id|class]?

--

BTW you can also define classes to use with the table and I also always use the excellent html templates feature of TinyMCE to create various prepared tables that has the right settings to just fill in.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...