Как убрать лишний «мусор» при всталвке из word в CKeditor 5?

При вставке из Word добавляем много всяких мусорных совйтв стилей тегов, как это можно чистить при вставке в CKeditor 5?

const htmlSupport = [{

        name: /^(h1|h2|h3|h4|h5|h6|sub|u|section|blockquote|em|hr|strong|div|p|img|table|tr|td|thead|tbody|ul|ol|li|a|figure)$/,

        attributes: {
            border: true,
            width: true,
            href: true,
            align: true,
            colspan: true,
            rowspan: true,
            src: true
        },

        styles: {
            width: true,
            border: true,
            'font-size': true,
            'font-weight': true,
            'border-width': true
        }

    }];

    // CKEditor
    ClassicEditor.create($('#data')[0], {
        htmlSupport: { allow: htmlSupport },
        removePlugins: [ 'Link', 'SourceEditing' ],
        fontSize: { options: [ 8, 10, 12, 14, 18, 20, 24, 28, 36 ] },
    })
    .then(editor => {
        CKEditor = { field: 'data', data : editor };
    })
    .catch(error => {
        console.error(error);
    });


Вот такой способ не подходит, хотя я думаю всё то разрещено, по идее остальное должно всё удалятсья но так не происходит
  • Вопрос задан
  • 66 просмотров
Решения вопроса 1
neuotq
@neuotq
Прокрастинация
Для этого используйте фичу по вставке из офиса.
https://ckeditor.com/docs/ckeditor5/latest/feature...

Добавить в плагины:
//****
 // CKEditor
    ClassicEditor.create($('#data')[0], {
        htmlSupport: { allow: htmlSupport },
        removePlugins: [ 'Link', 'SourceEditing' ],
        plugins: [ PasteFromOffice],
        fontSize: { options: [ 8, 10, 12, 14, 18, 20, 24, 28, 36 ] },
    })
    .then(editor => {
        CKEditor = { field: 'data', data : editor };
    })
    .catch(error => {
        console.error(error);
    });
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы