2012-06-03 57 views

回答

20

下面的說明適用於版本煉油廠CMS的2.x.x和3.x.x。

但是,在版本3.x.x中,您將需要使用custom_visual_editor_boot_options而不是custom_wymeditor_boot_options。

使用此文件:https://github.com/refinery/refinerycms/blob/master/core/app/assets/javascripts/admin.js您可以在煉油廠指定WYMeditor的自定義選項。

首先,你需要重寫文件:

bundle exec rake refinery:override javascript=admin 

現在,打開應用程序/資產/ JavaScript的/ admin.js和編輯它是這樣的:

// Use this to customize the wymeditor boot process 
// Just mirror the options specified in boot_wym.js with the new options here. 
// This will completely override anything specified in boot_wym.js for that key. 
// e.g. skin: 'something_else' 
if (typeof(custom_wymeditor_boot_options) == "undefined") { 
    custom_wymeditor_boot_options = { 
    containersItems: [ 
     {'name': 'h1', 'title':'Heading_1', 'css':'wym_containers_h1'} 
     , {'name': 'h2', 'title':'Heading_2', 'css':'wym_containers_h2'} 
     , {'name': 'h3', 'title':'Heading_3', 'css':'wym_containers_h3'} 
     , {'name': 'h4', 'title':'Heading_4', 'css':'wym_containers_h4'} 
     , {'name': 'p', 'title':'Paragraph', 'css':'wym_containers_p'} 
    ] 
    }; 
} 

注意你正在做的是重寫boot_wym.js.erb,它只將h1,h2,h3和p指定爲容器標籤。請參閱:https://github.com/refinery/refinerycms/blob/2-0-stable/core/app/assets/javascripts/refinery/boot_wym.js.erb#L49-L54

您在custom_wymeditor_boot_options內指定的任何選項都會覆蓋boot_wym.js.erb中wymeditor_boot_options中的所有內容,因此請確保它是有效的Javascript,否則編輯器將根本無法加載。

希望有幫助;讓我知道你是否需要澄清任何事情。

菲爾

+11

只是一點點修正,用於覆蓋admin.js的命令是「捆綁高管耙煉油廠:覆蓋的javascript =管理員」瓦特/輸出的擴展名爲.js –

+2

另外請注意,在3.x中,它已經更名到'custom_visual_editor_boot_options' ...花了我一段時間,找出爲什麼它不工作。 https://github.com/parndt/refinerycms-wymeditor/blob/master/app/assets/javascripts/refinery/boot_wym.js.erb#L5 – natebeaty