我正面临着TinyMCE的问题。当我在TinyMCE的HTML编辑器中输入样式标记时,它会在我单击更新时删除标记。
<style type="text/css">
.newclasss { color:#c9c9c9; }
</style>
我的有效要素如下:
<script type="text/javascript">
var valid_elms = "hr[class|width|size|noshade]";
valid_elms += "span[class|align|style],";
valid_elms += "font[face|size|color|style],";
valid_elms += "img[href|src|name|title|onclick|align|alt|title|";
valid_elms += "width|height|vspace|hspace],";
valid_elms += "iframe[id|class|width|size|noshade|src|height|";
valid_elms += "frameborder|border|marginwidth|marginheight|";
valid_elms += "target|scrolling|allowtransparency],style";
extended_valid_elements: valid_elms
</script>
有人可以帮忙吗?
由于样式标记不是有效的XHTML,因此TinyMCE禁止在标记之外添加它们。
你必须添加样式标签到valid children configuration
valid_children : "+body[style]"
编辑:此解决方案适用于版本3.4.2
"hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],img[href|src|name|title|onclick|align|alt|title|width|height|vspace|hspace],iframe[id|class|width|size|noshade|src|height|frameborder|border|marginwidth|marginheight|target|scrolling|allowtransparency],style[type]"
让我知道这对你有用
如果您将tinyMCE置于全页模式,则可以将样式放在<head>
中
<script type="text/javascript">
tinyMCE.init({
plugins : "fullpage",
});
</script>
它有点hacky但是我正在使用TinyMCE 4并且处于紧张状态,所以我在TinyMCE编辑器的<script>
视图中添加了一个Source Code标签并使用了jQuery to change the styles。
<script>$("#signup").css("font-weight", "bold");</script>
这假设TinyMCE已被设置为不禁止脚本标记,并且您的页面已经包含了jQuery,就像我一样,如果不是,您可以使用标准的javascript to change styles。
对我来说,我需要在TinyMCE 4.5.7
中做以下事情:
tinyMCE.schema.addValidChildren("body[style]")