2011-02-18 70 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,這並不困難。