Commit 75e26efe authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

[FIX] Correction des dysfonctionnements en lien avec TinyMCE (tests probants avec la v6.3.0).

parent 7fc108b7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
CHANGELOG
=========

7.0.2
-----
- [FIX] Correction des dysfonctionnements en lien avec TinyMCE (tests probants avec la v6.3.0). 

7.0.1
-----
- Fix : Initialisation du service TemplateEngineManager pour VerificationController
+23 −41
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ use UnicaenRenderer\Provider\Privilege\DocumenttemplatePrivileges;
$canTemplate = $this->isAllowed(DocumenttemplatePrivileges::getResourceId(DocumenttemplatePrivileges::DOCUMENTTEMPLATE_INDEX));

// le moteur utilisé par le template n'est pas forcément compatible avec une édition WYSIWYG :
$htmlEditorEnabled = (int) ! $template->requiresTextEditing();
$htmlEditorEnabled = ! $template->requiresTextEditing();
?>


@@ -53,18 +53,17 @@ $htmlEditorEnabled = (int) ! $template->requiresTextEditing();
            window.location.reload();
        });

        <?php if ($htmlEditorEnabled): ?>
            // installation de tinyMCE si le moteur de template est compatible
        if (<?php echo $htmlEditorEnabled ?>) {
            tinymce.remove();
            tinymce.init({
                selector: '.description',
                menubar: false,
                plugins: 'lists template link code',
                plugins: 'lists link code',
                toolbar: 'newdocument undo redo | bold italic | bullist numlist | link | code',
                resize: true,
                language: 'fr_FR',
                entity_encoding: "raw",
                templates: macros,
                statusbar: true,
                browser_spellcheck: true,
                branding: false,
@@ -79,12 +78,11 @@ $htmlEditorEnabled = (int) ! $template->requiresTextEditing();
            tinymce.init({
                selector: '.sujet',
                menubar: false,
                toolbar: 'newdocument undo redo | template',
                toolbar: 'newdocument undo redo',
                resize: true,
                language: 'fr_FR',
                entity_encoding: "raw",
                plugins: 'lists template',
                templates: macros,
                plugins: 'lists link code',
                statusbar: true,
                browser_spellcheck: true,
                branding: false,
@@ -98,15 +96,14 @@ $htmlEditorEnabled = (int) ! $template->requiresTextEditing();
            tinymce.init({
                selector: '.corps',
                menubar: false,
                toolbar: 'newdocument undo redo | bold italic underline | numlist bullist table link | alignjustify alignleft alignright aligncenter | formatselect template | code',
                toolbar: 'newdocument undo redo | bold italic underline | numlist bullist table link | alignjustify alignleft alignright aligncenter | formatselect | code',
                block_formats: 'Normal=p;Titre 1=h1;Titre 2=h2;Titre 3=h3',
                resize: true,
                language: 'fr_FR',
                entity_encoding: "raw",
                plugins: 'lists template table link code',
                plugins: 'lists table link code',
                extended_valid_elements: "pagebreak ?php",
                custom_elements: "pagebreak ?php",
                templates: macros,
                statusbar: true,
                browser_spellcheck: true,
                branding: false,
@@ -117,28 +114,7 @@ $htmlEditorEnabled = (int) ! $template->requiresTextEditing();
                    });
                }
            });
            // tinymce.init({
            //     selector: '.css',
            //     menubar: false,
            //     toolbar: 'newdocument undo redo',
            //     resize: true,
            //     language: 'fr_FR',
            //     entity_encoding: "raw",
            //     plugins: 'paste',
            //     paste_as_text: true,//Forcer le coler sans style
            //     forced_root_block: "",//Pas de balise <p> autour
            //     templates: macros,
            //     statusbar: true,
            //     browser_spellcheck: true,
            //     branding: false,
            //     body_id: 'css',
            //     setup: function (editor) {
            //         editor.on("focusout", function () {
            //             $('textarea#css').val(tinymce.get('css').getContent());
            //         });
            //     }
            // });
        }
        <?php endif ?>
    });
</script>

@@ -146,7 +122,6 @@ $htmlEditorEnabled = (int) ! $template->requiresTextEditing();

<!---------------------------------------------------------------------------------------------------------->
<!---------------------------- Widgets permettant de rechercher/insérer une macro -------------------------->
<!----------------------------          ------------------------->
<!---------------------------------------------------------------------------------------------------------->
<!--                                         (Select2 est requis)                                         -->
<!---------------------------------------------------------------------------------------------------------->
@@ -157,7 +132,9 @@ $htmlEditorEnabled = (int) ! $template->requiresTextEditing();
<style>
    .macro-insert-widget {
        position: relative;
        top: 32px; left: -10px;
        top: 32px;
        left: -5px;
        margin-left: 15px;
    }
    .macro-select {
        width: 500px;
@@ -166,9 +143,9 @@ $htmlEditorEnabled = (int) ! $template->requiresTextEditing();

<div id="macro-insert-widget-content" style="display: none">
    <div class="macro-insert-widget float-end">
        <button class="macro-btn btn btn-outline-secondary" type="button"
        <button class="macro-btn btn" type="button"
                data-bs-title="Insertion d'une macro" data-bs-placement="top">
            <i class="fas fa-stamp"></i>
            <i class="fas fa-stamp" title="Insertion d'une macro..."></i>
        </button>
        <div style="display: none">
            <div class="macro-popover-content">
@@ -237,16 +214,21 @@ $htmlEditorEnabled = (int) ! $template->requiresTextEditing();

            // bouton déclenchant l'insertion de la macro sélectionnée dans le textarea
            const $macroInsertBtn = $popoverContent.find(".macro-insert-btn").on("click", function () {
                // debugger;
                const macro = $macroSelect2.select2('data')[0];
                if (!macro) {
                    return;
                }
                if (tinyMCE && ($ed = tinyMCE.get($textarea.prop('id')))) {
                    $ed.selection.setContent(macro.value);
                } else {
                    const caretPos = $textarea.prop('selectionStart');
                    if (caretPos === undefined) {
                        $textarea.val($textarea.val() + ' ' + macro.value);
                    } else {
                        $textarea.val($textarea.val().substring(0, caretPos) + macro.value + $textarea.val().substring(caretPos));
                    }
                }
            });

            // bouton de fermeture du popover