2014-06-16 36 views
0

我有一个tinyMCE和ich watn来创建自己的样式格式,但它没有显示在我的tinymce中。有人知道什么是错的?我必须在哪里放置我的按钮“格式”,我可以选择特殊的格式吗?tinyMce:自己的格式不显示

tinyMCE.init({ 
    mode: "exact", 
    elements: "mytextarea", 
    theme: "advanced", 
    plugins: "table,paste,wordcount", 
    width: "480", 
    theme_advanced_toolbar_location: "top", 
    theme_advanced_toolbar_align: "left", 
    convert_newlines_to_brs: true, 
    invalid_elements : "p", 
    forced_root_block: false, 
    force_br_newlines: true, 
    force_p_newlines: false, 
    theme_advanced_statusbar_location: "bottom", 
    theme_advanced_buttons1: "forecolor,|,bold,|,pastetext,|,bullist", 
    theme_advanced_buttons3: "", 
    theme_advanced_buttons2: "", 
    style_formats: [ 
     {title: 'Bold text', inline: 'b'}, 
     {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}}, 
     {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}}, 
     {title: 'Example 1', inline: 'span', classes: 'example1'}, 
     {title: 'Example 2', inline: 'span', classes: 'example2'}, 
     {title: 'Table styles'}, 
     {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'} 
    ], 
    formats: { 
     alignleft: {selector: 'h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'left'}, 
     aligncenter: {selector: 'h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'center'}, 
     alignright: {selector: 'h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'right'}, 
     alignfull: {selector: 'h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'full'}, 
     bold: {inline: 'span', 'classes': 'bold'}, 
     italic: {inline: 'span', 'classes': 'italic'}, 
     underline: {inline: 'span', 'classes': 'underline', exact: true}, 
     strikethrough: {inline: 'del'}, 
     customformat: {inline: 'span', styles: {color: '#00ff00', fontSize: '20px'}, attributes: {title: 'My custom format'}} 
    } 
}); 
+0

您正在使用哪个tinyMCE版本? – opp

+0

我正在使用verision 3 – Zwen2012

+0

你能为此创建一个tinymce小提琴吗? – Thariama

回答

0

将TinyMCE类和更新你的CSS,不要忘记把重要

.mceLayout 
{ 
width:100%!important;position:relative; 

} 
.mceListBoxMenu {width:90px!important; height:110px!important;} 
+0

但是,我如何添加一个按钮“格式”,例如h1标签? – Zwen2012

0

如果你希望他们的编辑器外,所有你需要做的就是添加你的文字区域下方的一些按钮:

<button onclick="tinymce.activeEditor.formatter.apply('customformat');return false;">Apply custom format</button> 
<button onclick="tinymce.activeEditor.formatter.remove('customformat');return false;">Remove custom format</button> 

或者,您可以编写一个插件并将该函数集成到您的编辑器中。