我正在运行多个CKE实例,在其内联编辑模式,让最终用户编辑内容块,就像在最终的html呈现中看起来一样。
所以编辑的所有内容都继承自我编辑页面的全局CSS。 它太棒了。
现在我想要显示样式组合,而不是所有正在运行的样式,而只是它们的一部分(颜色类和基本的东西)。
我怎样才能做到这一点?
即。保持所有现有的css应用于编辑的任何内容,并且只在组合中提供一些
感谢您的帮助或起点...
找到解决方案后:一个完整工作的代码示例,具有多个内联编辑,自定义样式,通过ajax自动保存和其他调整,如果它可以帮助
CKEDITOR.disableAutoInline = true;
CKEDITOR.stylesSet.add( 'my_styles', [
// Block-level styles
{ name: 'Blue Title', element: 'h2', attributes: { 'class': 'bleu' } },
{ name: 'Red Title' , element: 'h3', attributes: { 'class': 'rouge' } },
// Inline styles
{ name: 'CSS Style', element: 'span', attributes: { 'class': 'my_style' } },
{ name: 'Marker: Yellow', element: 'span', styles: { 'background-color': 'Yellow' } }
] );
$("div[contenteditable='true']" ).each(function( index ) {
var content_id = $(this).attr('id');
var ligneidx = $(this).attr('ligneidx');
var blocidx = $(this).attr('blocidx');
CKEDITOR.inline( content_id, {
stylesSet : 'my_styles',
toolbarGroups : [
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
{ name: 'forms', groups: [ 'forms' ] },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
{ name: 'links', groups: [ 'links' ] },
{ name: 'insert', groups: [ 'insert' ] },
'/',
{ name: 'styles', groups: [ 'styles' ] },
{ name: 'colors', groups: [ 'colors' ] },
{ name: 'tools', groups: [ 'tools' ] },
{ name: 'others', groups: [ 'others' ] },
{ name: 'about', groups: [ 'about' ] }
],
// Remove some buttons provided by the standard plugins, which are
// not needed in the Standard(s) toolbar.
removeButtons : 'Form,Checkbox,Radio,TextField,Textarea,Select,Button,HiddenField,ImageButton,Replace,Find,SelectAll,JustifyLeft,JustifyCenter,JustifyRight,JustifyBlock,Language,BidiRtl,BidiLtr,Flash,Smiley,PageBreak,Iframe,Font,FontSize,About,NumberedList,Blockquote,CreateDiv,Underline,Subscript,Superscript,Page2images, Newpage,Templates,Strike,Indent,Outdent',
//removePlugins: 'page2images,VideoDetector',
format_tags : 'p;h1;h3',
// Simplify the dialog windows.
removeDialogTabs : 'image:advanced;link:advanced',
extraPlugins : 'sourcedialog',
colorButton_enableMore : false,
colorButton_colors : '00819c,e32434,e9632d,9c1f4d,795127,ececf0,ececec,fafafa,dddddd,939393,25242c,fff,000',
filebrowserBrowseUrl : '/modele/classes/filemanager/dialog.php?type=2&editor=ckeditor&lang=fr_FR&fldr=',
filebrowserUploadUrl : '/modele/classes/filemanager/dialog.php?type=2&editor=ckeditor&lang=fr_FR&fldr=',
filebrowserImageBrowseUrl : '/modele/classes/filemanager/dialog.php?type=1&editor=ckeditor&lang=fr_FR&fldr=',
uiColor : "#a7f0ff",
defaultLanguage : 'fr',
on: {
blur: function( event ) {
var data = event.editor.getData();
var request = jQuery.ajax({
url: "/modele/admin/ajaxupdate_bloc.php",
type: "POST",
data: {
content : data,
ligneidx : ligneidx,
blocidx : blocidx
},
});
}
}
} );
});
答案 0 :(得分:1)
尝试将您自己的样式定义传递给CKEDITOR,就像这样
CKEDITOR.stylesSet.add()
此处提供更多信息和示例: http://docs.ckeditor.com/#!/guide/dev_howtos_styles
还有一个可以使用的样式表解析器插件,信息在这里: http://ckeditor.com/addon/stylesheetparser