2011-02-18 51 views
2

我已经看到无处不在,我无法弄清楚如何添加另一个选项到tinyMCE的下拉格式。我想复制和修改pre标签的格式,并给它一个.prettyprint的类,以便我可以快速添加代码片段到我的帖子。TinyMCE自定义格式的前

它应该是技术上可行的,但我应该如何以及应该修改哪个文件。或者,我可以添加一个应用此格式的按钮

回答

2

您可以在tinymce init函数中添加如下内容(style_fomats setting))以添加样式下拉列表中的新选项。请注意,要应用的类应该是提供使用the content_css configuration setting

style_formats: [{ 
     title: 'block styles' 
    }, { 
     title: 'Name_to_be_displayed', 
     block: 'p', 
     classes: 'class_to_be_applied', 
     exact: true 
    }, { 
     title: 'inline styles' 
    }, { 
     title: 'Red text', 
     inline: 'span', 
     classes: 'red', 
     exact: true 
    }, { 
     title: 'Pre formatting', 
     inline: 'pre', 
     classes: 'xyzpre', 
     exact: true 
    }], 

或者我可以添加 应用该格式

是一个按钮,您将需要write your own plugin,这并不困难。