November Happy Hour will be moved to Thursday December 5th.

TinyMCE wrapping <object> with <p>

Vote:
 

I'm using the standard TinyMCE "Insert/Edit embedded media" button to add a flash movie within an XHTML string property.

The inserted code is this:

<p>
<object width="703" height="340" data="/PageFiles/920/v1.swf" type="application/x-shockwave-flash">
<param name="data" value="/PageFiles/920/v1.swf" />
<param name="src" value="/PageFiles/920/v1.swf" />
</object>
</p>

    

The object is being wrapped in paragraph tags. When I edit the HTML to remove them, hit the "update" button (don't save or publish the page) then view the HTML again, they have been re-inserted.

I am guessing this is entirely due to TinyMCE as it's not being submitted into the EPiServer DB.

Is there a way to stop this happening?

#55030
Nov 16, 2011 11:15
Vote:
 

Try to edit the property in HTML mode again and replace the p with a div

<div>
<object width="703" height="340" data="/PageFiles/920/v1.swf" type="application/x-shockwave-flash">
<param name="data" value="/PageFiles/920/v1.swf" />
<param name="src" value="/PageFiles/920/v1.swf" />
</object>
</div>

The embedded code will then not be wrapped with <p>

More advanced solution can be found here: http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=43969 but I dont think removing p for all content is a good idea.

#55032
Edited, Nov 16, 2011 13:07
Vote:
 

Thanks for the suggestion. I can see that this is a workaround if I have an editor who is happy to edit HTML. Unfortunately this isn't often the case.

I agree with you that it is very unwise to remove p for all content!

I was hoping that there would be some configuration where I could say "don't wrap HTML element type: object".

Writing a bit of js to undo the addition of the <p> tag only around objects and add it to tinyMCE but that would potentially be overwritten in any future upgrade and I would prefer not to have to alter it.

#55038
Nov 16, 2011 13:48
Vote:
 

Hi Joel,

Try adding following class in your project and rebuild.

using EPiServer.Editor.TinyMCE;
...
[TinyMCEPluginNonVisual(AlwaysEnabled = true, EditorInitConfigurationOptions = "{force_p_newlinesEdit:false}")]
public class TinyMceDisablePtagForLineBreak
{
}

As pointed out http://www.tinymce.com/wiki.php/Configuration:force_br_newlines, <P> tag is better for line break than <br />.

You can customise TinyMCE even further to change new line rule for Media type only.

Jay

#55051
Edited, Nov 17, 2011 15:02
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.