我正在過渡我的CMS以使用CKEditor。我目前正在嘗試使用Stylesheet Parser。我有大量的網站編輯風格已經定義。定義用簡單的類聲明進行:.[class]
。默認情況下,選擇器找到[element].[class]
聲明。CKEditor - 樣式表分析器 - 有效的選擇器
我試過設置爲stylesheetParser_validSelectors
:
config.stylesheetParser_validSelectors = /\.\w+/;
...但款式選擇是空的。
我正在使用Firebug,並且在控制檯中看不到任何錯誤。
我的解決方案
我結束了使用stylesSet
配置選項,原因有二:
- 它給我了,顯示了一個樣式選擇
- 我的名字控制可以設置默認值,但允許覆蓋
代碼:
if ((typeof EditorStyleSet === 'undefined')
|| (typeof EditorStyleSet !== 'object')
|| !(EditorStyleSet instanceof Array)) {
// Allow this variable to be set at the site level
EditorStyleSet = [
{name:'Title', element:'span', attributes:{'class':'title'}},
{name:'Subtitle', element:'span', attributes:{'class':'subTitle'}},
{name:'Header Text', element:'span', attributes:{'class':'headerText'}},
{name:'Red', element:'span', attributes:{'class':'red'}},
{name:'Small', element:'span', attributes:{'class':'small'}},
{name:'Hi-Lite', element:'span', attributes:{'class':'hi-lite'}}
];
}
config.stylesSet = EditorStyleSet;
我接受你的解決方案,但我最終沒有使用Stylesheet Parser。我會將我的解決方案添加到OP中。 – Sonny