|
|
| (6 versions intermédiaires par le même utilisateur non affichées) |
| Ligne 1 : |
Ligne 1 : |
| <includeonly> | | <includeonly> |
| <div class="syntax-copy-wrapper"> | | <div class="syntax-copy-wrapper"> |
| <button type="button" class="copy-syntax-btn">📋 Copier la syntaxe</button>
| | <span class="copy-syntax-btn" role="button" tabindex="0">📋 Copier la syntaxe</span> |
| <pre class="syntax-to-copy">{{{1}}}</pre>
| |
| </div>
| |
| | |
| <script>
| |
| (function () {
| |
| if (window.__copySyntaxInit) return;
| |
| window.__copySyntaxInit = true;
| |
| | |
| document.addEventListener('click', function (e) {
| |
| if (!e.target.classList.contains('copy-syntax-btn')) return;
| |
| | |
| var wrapper = e.target.closest('.syntax-copy-wrapper');
| |
| if (!wrapper) return;
| |
| | |
| var pre = wrapper.querySelector('.syntax-to-copy');
| |
| if (!pre) return;
| |
| | |
| var text = pre.innerText;
| |
|
| |
|
| if (navigator.clipboard && navigator.clipboard.writeText) {
| |
| navigator.clipboard.writeText(text).then(function () {
| |
| var original = e.target.textContent;
| |
| e.target.textContent = '✔ Copié';
| |
| setTimeout(function () {
| |
| e.target.textContent = original;
| |
| }, 1500);
| |
| });
| |
| }
| |
| });
| |
| })();
| |
| </script>
| |
| </includeonly>
| |
|
| |
| <noinclude>
| |
| <div class="documentation">
| |
|
| |
| == Utilisation ==
| |
| Ce modèle ajoute un bouton permettant de copier **exactement** une syntaxe
| |
| (retours à la ligne, indentation, balises `<sup>`, etc.).
| |
|
| |
| ---
| |
|
| |
| == Syntaxe ==
| |
| <pre> | | <pre> |
| {{CopierSyntaxe| | | {{{1}}} |
| contenu à copier
| |
| }} | |
| </pre> | | </pre> |
|
| |
| ---
| |
|
| |
| == Exemple fonctionnel (test réel) ==
| |
| ⚠️ Ceci est **un appel réel du modèle**, pas du code affiché.
| |
|
| |
| {{CopierSyntaxe|
| |
| {{Infobox V3/Organisation
| |
| | Charte = organisation
| |
| | Theme = clair
| |
| | Titre = Ordre des Veilleurs
| |
|
| |
| | Fondation = 18/13/480<sup>XII</sup>
| |
| | Type = Ordre militaro-religieux
| |
| | Effectif = ~3 500 membres
| |
| }}
| |
| }}
| |
|
| |
| 👉 Clique sur le bouton puis colle ailleurs :
| |
| la mise en page est **strictement conservée**.
| |
|
| |
| ---
| |
|
| |
| == Notes techniques ==
| |
| * JS injecté localement (pas de `Common.js`)
| |
| * Protection anti double chargement
| |
| * Fonctionne avec plusieurs boutons par page
| |
|
| |
|
| </div> | | </div> |
| </noinclude> | | </includeonly> |