Is there a way to allow all html attributes for CKEditor5 or use a wildcard?

Viewed 747

I'm setting up ckeditor5, but it removes a lot of the html attributes. I want to know if there's a way to allow all attributes without specifying one by one, or maybe specify it with a wildcard.

(example)

editor.model.schema.extend('$block', { allowAttributes: 'on-*'}); //for onclick and other events

Here's the way I'm doing it so far, which is a bit tedious since I have to specify each attributes.

import Plugin from '@ckeditor/ckeditor5-core/src/plugin';

export default class Extension extends Plugin {
    init() {
        const editor = this.editor;

        let allowedAttributes = [
            'id',
            'class'
        ];

        editor.model.schema.extend('$root', { allowAttributes: allowedAttributes });
        editor.model.schema.extend('$block', { allowAttributes: allowedAttributes });
        editor.model.schema.extend('$text', { allowAttributes: allowedAttributes });

        for (var i = 0; i < allowedAttributes.length; i++) {
            editor.conversion.attributeToAttribute({ model: allowedAttributes[i], view: allowedAttributes[i] });
        }

    }
}
1 Answers
Related