Wysiwyg - defaultEditorConfig - Pimcore 5


#1

Pimcore version 5.4.2

Hi,
I want to set a Global configuration for all WYSIWYG Editors:
https://pimcore.com/docs/5.x/Development_Documentation/Documents/Editables/WYSIWYG.html#page_Global-Configuration

src/CKEditoreBundle/CKEditoreBundle.php

<?php

    namespace CKEditorBundle;

    use Pimcore\Extension\Bundle\AbstractPimcoreBundle;

    class CKEditorBundle extends AbstractPimcoreBundle
    {
        public function getJsPaths()
        {

            return [
                '/bundles/ckeditor/js/ckeditor.js'
            ];
        }
    }

src/CKEditoreBundle/Resources/public/js/ckeditore.js

pimcore.registerNS("pimcore.plugin.CKEditorBundle");

pimcore.plugin.CKEditorBundle = Class.create(pimcore.plugin.admin, {
    getClassName: function () {
        return "pimcore.plugin.CKEditorBundle";
    },

    initialize: function () {
        pimcore.plugin.broker.registerPlugin(this);
    },

    pimcoreReady: function (params, broker) {
        // Global configuration for all WYSIWYG Editors
        pimcore.document.tags.wysiwyg.defaultEditorConfig = pimcore.document.tags.wysiwyg.defaultEditorConfig || {
            allowedContent: true,
            toolbar: [
                { name: 'clipboard', items: [ 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
                { name: 'links', items: [ 'Link', 'Unlink' ] },
                { name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule', 'SpecialChar' ] },
                { name: 'document', items: [ 'Sourcedialog' ] },
                '/',
                { name: 'basicstyles', items: [ 'Bold', 'Italic', '-', 'RemoveFormat' ] },
                { name: 'colors', items : [ 'BGColor' ] },
                { name: 'paragraph', items: [ 'NumberedList', 'BulletedList', '-', 'Blockquote' ] },
                { name: 'styles', items: [ 'Format' ] }
            ]
        };
    }
});

var CKEditorBundlePlugin = new pimcore.plugin.CKEditorBundle();

I get the followig error in console:

TypeError: Cannot read property ‘wysiwyg’ of undefined
at klass.pimcoreReady (ckeditor.js?_dc=1535773685:14)
at …

That worked very well on Pimcore 4 and Pimcore 5.2.3.
How to solve this problem please!

Regards
M. Ali


#2

If I use

public function getEditmodeJsPaths()
{
return [
‘/bundles/ckeditor/js/ckeditor.js’
];
}

in src/CKEditoreBundle/CKEditoreBundle.php

I get I get the followig error in console:

class.js?_dc=7ca19c0443c4469fd535cd89d0819706ea90291c:58
Uncaught TypeError: Cannot convert undefined or null to object
at Function.keys ()
at Function.addMethods (class.js?_dc=7ca19c0443c4469fd535cd89d0819706ea90291c:58)
at Object.create (class.js?_dc=7ca19c0443c4469fd535cd89d0819706ea90291c:47)
at script-proxy?scripts=minified_javascript_core_e10f5593004b00b4955a8ae08391be74.js&_dc=7ca19c0443c4469fd535cd89d0819706ea90291c:11216
addMethods @ class.js?_dc=7ca19c0443c4469fd535cd89d0819706ea90291c:58
create @ class.js?_dc=7ca19c0443c4469fd535cd89d0819706ea90291c:47
(anonymous) @ script-proxy?scripts=minified_javascript_core_e10f5593004b00b4955a8ae08391be74.js&_dc=7ca19c0443c4469fd535cd89d0819706ea90291c:11216