TinyMCE删除youtube链接
问题描述:
我有一个symfony窗体,其中使用了tinyMCE的“contents”textarea。TinyMCE删除youtube链接
当我写:
<p class="centre">
<object width="640" height="385">
<param name="movie" value="http://www.youtube.com/v/qOP2V_np2c0&hl=en_US&fs=1&rel=0">
</param>
<param name="allowFullScreen" value="true">
</param>
<param name="allowscriptaccess" value="always">
</param>
<embed src="http://www.youtube.com/v/qOP2V_np2c0&hl=en_US&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385">
</embed>
</object>
</p>
将保存为:
<p class="centre">
<object width="640" height="385">
<param name="movie" value="http://www.youtube.com/v/qOP2V_np2c0&hl=en_US&fs=1&rel=0" />
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always" />
</object>
</p>
答
我不得不添加一些元素* extended_valid_elements *,以便它不会删除Flash内容。
tinyMCE.init({
mode : “textareas”,
editor_selector:“mceEditor”,
theme : “advanced”,
theme_advanced_buttons1 : “bold,italic,underline,strikethrough,|,forecolor,backcolor,|,link,unlink,image,code”,
theme_advanced_buttons2 : “”,theme_advanced_buttons3 : “”,theme_advanced_buttons4 : “”,
theme_advanced_resizing : true, tab_focus : “:prev,:next”,
extended_valid_elements : “object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode]“
});
回答http://syedgakbar.wordpress.com/2008/01/28/adding-flash-embed-support-in-tinymce-editor/
答
只需添加您的init
配置阵列的closed
键内param
标签:
tinyMCE.init({
...
closed: /^(br|hr|input|meta|img|link|param|area|param)$/,
...
});
发现你与萤火检查呢?因为它有时会自动纠正无效的html。通过使用“查看源代码”方法或wget,确保这是真正的HTML。 – greg0ire 2011-04-08 13:36:35
即使在保存之前,tinymce也会删除该html。所以这不是symfony的错,我的不好。 – Manu 2011-04-08 13:56:02