Django-CKEditor5 Source Editing Feature Doesn't Work

I am using Django CKEditor5 in my admin panel. When I'm trying to insert a html code using "Source Edit" feature,

enter image description here

it doesn't apply any style and transforms automatically after clicking "Source" button again into this: enter image description here

I already tried the GeneralHtmlSupport from documentation: https://ckeditor.com/docs/ckeditor5/latest/features/html/general-html-support.html

My ckeditor config looks like this

       ClassicEditor.create(
        editorEl,
        config,
        {
            plugins: [GeneralHtmlSupport, SourceEditing, Undo, Alignment, Image, ImageResizeEditing, ImageResizeHandles],
            htmlSupport: {
                allow: [
                    {
                        name: /.*/,
                        attributes: true,
                        classes: true,
                        styles: true
                    }
                ]
            },
            image: {
                resizeUnit: "%",
                styles: {
                    options: [
                        { name: 'Resize', title: 'Resize', className: 'Resize' },
                    ]
                },
            },
            htmlSupport: true,
            allowedContent: true
        }
    ).then(editor => {
        const textarea = document.querySelector(`#${editorEl.id}`);

        editor.model.document.on('change:data', () => {
            textarea.value = editor.getData();
        });
        if (editor.plugins.has('WordCount')) {
            const wordCountPlugin = editor.plugins.get('WordCount');
            const wordCountWrapper = element.querySelector(`#${script_id}-word-count`);
            wordCountWrapper.innerHTML = '';
            wordCountWrapper.appendChild(wordCountPlugin.wordCountContainer);
        }
        editors[editorEl.id] = editor;
        if (callbacks[editorEl.id]) {
                callbacks[editorEl.id](editor);
            }
    }).catch(error => {
        console.error((error));
    });
    editorEl.setAttribute('data-processed', '1');
});
window.editors = editors;
Вернуться на верх