Forum

Thread tagged as: Problem

Redactor in blocks issue

Currently if you have a textarea in a block and its set to redactor as the editor, redactor will not be applied to any textareas after the first block on the page.

You can reproduce this by setting a content region to use a template with this code in:

<perch:blocks>
    <perch:block type="redactors" label="Redactor">
        <perch:repeater id="section" label="Section">
            <perch:content id="content" label="Text Content" type="textarea" editor="redactor" html="true" />
        </perch:repeater>
    </perch:block>
</perch:blocks>

The redactors will be created correctly on the the first item, however once you create another item, the subsequent textareas will just be the default html.

This can be fixed the following, in /core/editors/redactor/perch/config.js replace create_editors methods with:

var create_editors = function() {
    var config = {
            plugins: ['perchassets']
        };
    jQuery('textarea.redactor:not([data-init])').each(function(i,o){
        var self = $(o);
        if (self.parents('.spare').length) {
        }
        else {
            self.wrap('<div class="editor-wrap"></div>');
            if (typeof Perch.UserConfig.redactor != 'undefined') {
                config = Perch.UserConfig.redactor.get(self.attr('data-editor-config'), config, self);
                self.redactor(config);
            } else {
                self.redactor(config);
            }
            self.attr('data-init', true);
        }
    });
};

While my change may not be the cleanest, it gets the job done. Would it be possible to include this in the next update? As I don't want to lose it when the site gets updated.

Thanks, Luke

Luke Foster

Luke Foster 0 points

  • 4 years ago

Cool, Luke!

Thanks Luke! This is actually the same fix I just applied to the ckeditor config.js file, which runs the exact same line of code:

if (self.parents('.spare').length) {
}

I commented out the return false; that was in that if statement, and now its working fine...or atleast appears to be...