Daniel-KM / Omeka-S-module-BlockPlus

Module for Omeka S that adds some new blocks for the static pages and improve some of the existing ones.
Other
4 stars 3 forks source link

Issue with HTML Purifier #8

Open Falteri opened 1 year ago

Falteri commented 1 year ago

When you extend ckeditor in BlockPlus to add the text color tool, you get problems if HTML Purifier is active. In fact, color style are removed as soon as you save the formatted text in ckeditor. This happens only if HTML Purifier is active. This happen to me since I moved to the latest version of Omeka S (3.2.3). I found this issue with all the latest version of BlockPlus (3.3.15.1-3).

Daniel-KM commented 1 year ago

In Omeka S v3, it's hard to manage multiple version of ckeditor. So the simplest way to fix it is to update the ckeditor config. That's why i created three variants that can be selected in the main config. But indeed the color is not included by default. But how do you do to extend ckeditor currently?

Falteri commented 1 year ago

I'm sorry to reply so late, Daniel. I extended ckeditor customizing ckeditor_config.js in BlockPlus->asset->js. This is my current version:

CKEDITOR.editorConfig = function( config ) {
    // Define changes to default configuration here.
    // For complete reference see:
    // http://docs.ckeditor.com/#!/api/CKEDITOR.config

    // config.toolbar = [
        // {
            // name: 'advanced',
            // items: [
                // 'Sourcedialog', '-',
                // 'Link', 'Unlink', 'Anchor', '-',
                // 'Format', 'Styles', 'PasteFromWord',
            // ],
        // },
        // '/',
        // {
            // items: [
                    // 'Bold', 'Italic', 'Underline', 'Strike', 'RemoveFormat', '-',
                    // 'NumberedList', 'BulletedList', 'Indent', 'Outdent', 'Blockquote', '-',
                    // 'Footnotes', '-',
                    // 'Maximize',
                // ],
        // },
    // ];

    config.toolbar = [
        {
            name: 'document', 
            items: [ 'Sourcedialog'] 
        },
        { 
            name: 'clipboard', 
            items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] 
        },  
        '/',
        { 
            name: 'basicstyles', 
            items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'CopyFormatting', 'RemoveFormat' ] 
        },
        { 
            name: 'paragraph', 
            items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language' ] 
        },      
        { 
            name: 'links', 
            items: [ 'Link', 'Unlink', 'Anchor', 'Tooltip' ] 
        },      
        { 
            name: 'insert', 
            items: [ 'Image', 'HorizontalRule', 'SpecialChar', 'CreateDiv', 'Table', 'Footnotes' ] 
        },      
        '/',        
        { 
            name: 'styles', 
            items: [ 'Styles', 'Format'] 
        },      
        { 
            name: 'colors', 
            items: [ 'TextColor', 'BGColor'] 
        },      
        { 
            name: 'tools', 
            items: [ 'Maximize', 'ShowBlocks' ] 
        },      
        { 
            name: 'about', 
            items: [ 'About' ] 
        }   ``
    ];

    // Disable content filtering
    config.allowedContent = true;
    //config.extraPlugins = 'footnotes,sourcedialog';
    config.extraPlugins = 'footnotes,sourcedialog,showblocks,tooltip,dialog,div,table,tableresize,tableselection,tabletools,colorbutton,colordialog';

    // Add some css to support attributes to "section", "li" and "sup" for footnotes.
    config.extraAllowedContent = 'section(footnotes);header;li[id,data-footnote-id];a[href,id,rel];cite;sup[data-footnote-id]';
};