A
A
alexandrnevajno12018-02-18 13:00:48
JavaScript
alexandrnevajno1, 2018-02-18 13:00:48

Ckeditor - how can I make sure that when a DOM element (p, for example. or ul) is created, a class is automatically added to it immediately?

How can I do it? I need this because I am using reset.css. Which is why I don't have lists or bold or anything like that. But I don't want to cancel the reset. I want to add a class for elements that have been written in ckeditor. I found this code on the internet:

CKEDITOR.on('instanceReady', function (ev) {
        var editor = ev.editor;
        editor.dataProcessor.htmlFilter.addRules({
            elements: {
                p: function (el) {
                    el.addClass('myClass');
                }
            }
        });
});

But it doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Karen Ananiev, 2018-02-19
@karena

You don't have to want it. The found solution has a number of significant drawbacks. One adequate solution to the problem would be to assign a class to the body of the editor's document. There is config.bodyClass for this. And for its child elements already reassign styles.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question