CKEditor 4 - 内联编辑 - 自定义样式组合

CKEditor 4 - inline editing - custom styles combo

我是 运行 多个 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
                    },
                });

            }
        }
    } );

});

尝试像这样将您自己的样式定义传递给 CKEDITOR

CKEDITOR.stylesSet.add()

更多信息和例子在这里: http://docs.ckeditor.com/#!/guide/dev_howtos_styles

还有一个 Stylesheet Parser Plugin 可以使用,信息在这里: http://ckeditor.com/addon/stylesheetparser