How to remove inline styles from automatically added images after upload in CkEditor 5

22 views Asked by At

I'm using CkEditor 5 and I'm having problems removing the line styles automatically added after uploading any image. I am not using any framework in this application.

The code I'm developing:

let editor;

    ClassicEditor
        .create(document.querySelector('#news-editor'), {
            language: 'pt-br', 
            toolbar: [
                'heading', '|',
                'bold', 'italic',
                'blockQuote', '|',
                'numberedList', 'bulletedList', '|',
                'link', '|',
                'imageUpload', 'imageTextAlternative', '|',
                'mediaEmbed'
            ],
            ckfinder: {
                uploadUrl: '/adm/equipe/upload-image-ck/',
            },
            heading: {
                options: [
                    { model: 'paragraph', title: 'Parágrafo', class: 'ck-heading_paragraph' },
                    { model: 'heading1', view: 'h2', title: 'Título 1', class: 'ck-heading_heading2' },
                    { model: 'heading2', view: 'h3', title: 'Título 2', class: 'ck-heading_heading3' },
                    { model: 'heading3', view: 'h4', title: 'Título 3', class: 'ck-heading_heading4' },
                ]
            },
        })
        .then(newEditor => { 
            editor = newEditor;
        
        })
        .catch(error => {
            console.error(error);
        });

Return of the image after upload: <img style="aspect-ratio:800/445;" src="/media/news/2024/03/10/test.png" alt="test" width="800" height="445">

I tried some solutions on some forums but without success.

0

There are 0 answers