import flatpickrLocales from "flatpickr/dist/l10n/fr";

var defaultFormConfig = {
    config: {},
};

defaultFormConfig.config['aa-ft-picker-date'] = {
    locale: flatpickrLocales.fr,
    dateFormat: 'd/m/Y',
};
defaultFormConfig.config['aa-ft-picker-time'] = {
    locale: flatpickrLocales.fr,
    enableTime: true,
    noCalendar: true,
    dateFormat: 'H:i',
    time_24hr: true,
};
defaultFormConfig.config['aa-ft-picker-datetime'] = {
    locale: flatpickrLocales.fr,
    enableTime: true,
    dateFormat: 'd/m/Y H:i',
    time_24hr: true,
};

defaultFormConfig.config['aa-ft-select-rich'] = {
    removeItemButton: true,
    loadingText: 'Chargement...',
    noResultsText: 'Aucun résultats',
    noChoicesText: 'Aucune valeurs',
    itemSelectText: '',
    allowHTML: true,
};

defaultFormConfig.config['aa-ft-rich-entity'] = defaultFormConfig.config['aa-ft-select-rich'];

defaultFormConfig.config['aa-ft-text-rich'] = {
    toolbar: {
        items: [
            'undo',
            'redo',
            '|',
            'heading',
            '|',
            'alignment',
            //'alignment:left', 'alignment:right', 'alignment:center', 'alignment:justify',
            '|',
            'bold',
            'italic',
            '|',
            'link',
            '|',
            'bulletedList',
            'numberedList',
            '|',
            // 'indent',
            // 'outdent',
            // '|',
            // 'imageUpload',
            'blockQuote',
            'insertTable',
            // 'mediaEmbed',
            '|',
            'fontColor',
            '|',
            'sourceEditing',
        ]
    },
    autosave: {
        waitingTime: 300,
        save(editor) {
            editor.updateSourceElement()
        }
    },
    link: {
        decorators: {
            targetBlank: {
                mode: 'manual',
                label: 'Ouvrir dans un nouvel onglet',
                attributes: {
                    target: '_blank'
                }
            },
            obfuscated: {
                mode: 'manual',
                label: 'Obfusquer le lien',
                attributes: {
                    class: 'obfuscated-link'
                }
            }
        }
    }
};


// This global config node permit to override default config for admin types
//
// Could now be done by directly replacing handler config via AAForm,
// may need refactor down the line, keeping both ways for now
global.AAFormConfig = defaultFormConfig;
