CKEditorを使用するようにCMSを移行しています。私は現在、スタイルシートパーサーを利用しようとしています。エディタースタイルがすでに定義されているサイトがたくさんあります。定義は、単純なクラス宣言で作成されます.[class]
。デフォルトでは、セレクターは[element].[class]
宣言を検索します。
設定してみましたstylesheetParser_validSelectors
:
config.stylesheetParser_validSelectors = /\.\w+/;
...しかし、スタイルの選択は空です。
Firebugを使用していますが、コンソールにエラーは表示されません。
私の解決策
私はstylesSet
2つの理由で構成オプションを使用することになりました:
- スタイルの選択に表示される名前を制御できます
- デフォルトを設定できますが、オーバーライドは許可します
コード:
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;