{{ 'ckeditor/ckeditor.js' | mod_asset_url('wysiwyg') | script_tag }}
<script type="text/javascript">
    const editors = [];
    document.addEventListener("DOMContentLoaded", function () {
        document.querySelectorAll('.{{ class }}').forEach(function (element) {
            let required = false;
            CKEditor
                .create(element)
                .then(editor => {
                    if (element.hasAttribute('required')) {
                        element.removeAttribute('required');
                        required = true;
                    }
                    editors[element.name] = { editor, 'required': required };
                })
                .catch(error => { console.error(error) });
        });

        if (localStorage.getItem('theme') === 'dark') {
            setTimeout(() => {
                document.querySelectorAll('.ck-editor__main').forEach(function (element) {
                    element.style.color="#1d273b";
                });
            }, 1000);
        }
    });
</script>
