<?php use Fisharebest\Webtrees\Module\CkeditorModule; ?>
<?php use Fisharebest\Webtrees\Services\ModuleService; ?>
<?php use Fisharebest\Webtrees\View; ?>

<?php if (app()->make(ModuleService::class)->findByInterface(CkeditorModule::class)): ?>
    <?php View::push('javascript') ?>
    <script src="<?= e(CkeditorModule::CKEDITOR_PATH) ?>ckeditor.js"></script>
    <script src="<?= e(CkeditorModule::CKEDITOR_PATH) ?>adapters/jquery.js"></script>

    <script>
    var CKEDITOR_BASEPATH = <?= json_encode(CkeditorModule::CKEDITOR_PATH) ?>;

    // Enable for all browsers
    CKEDITOR.env.isCompatible = true;

    // Disable toolbars
    CKEDITOR.config.language = "<?= strtolower(WT_LOCALE) ?>";
    CKEDITOR.config.removePlugins = "forms,newpage,preview,print,save,templates,flash,iframe";
    CKEDITOR.config.extraAllowedContent = "area[shape,coords,href,target,alt,title];map[name];img[usemap];*[class,style]";

    // Activate the editor
    $("textarea.html-edit").ckeditor();
    </script>
    <?php View::endpush() ?>
<?php endif ?>
