Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css CKEditor 4-内联编辑-自定义样式组合_Css_Ckeditor_Inline - Fatal编程技术网

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

Css CKEditor 4-内联编辑-自定义样式组合,css,ckeditor,inline,Css,Ckeditor,Inline,我正在以内联编辑模式运行多个CKE实例,,让最终用户编辑内容块,就像在最终html呈现中一样 因此,编辑的所有内容都继承了我编辑页面的全局CSS。 这太棒了 现在我想让样式组合显示,不是所有的运行样式,而是其中的一部分(颜色类和类似这样的基本内容) 我怎样才能做到这一点 i、 e.将所有现有css应用于任何被编辑的内容,并且在组合中只提供其中的一小部分 感谢您的帮助或出发点 找到解决方案后:一个完全工作的代码示例,具有多个内联编辑、自定义样式、通过ajax自动保存和其他调优功能(如果有帮助的话

我正在以内联编辑模式运行多个CKE实例,,让最终用户编辑内容块,就像在最终html呈现中一样

因此,编辑的所有内容都继承了我编辑页面的全局CSS。 这太棒了

现在我想让样式组合显示,不是所有的运行样式,而是其中的一部分(颜色类和类似这样的基本内容)

我怎样才能做到这一点

i、 e.将所有现有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()
更多信息和示例如下:

还可以使用样式表解析器插件,信息如下:

谢谢,这绝对是正确的选择。我无法让stylesheetparser工作(尽管我的样式中有tag.class表单,但仍然不能),并且它掩盖了这样一个事实:该方法可以有效地替换全局CSS中自动生成的样式。我发现它实现了您链接中的基本示例。@n4National我很高兴它帮助了您:)