diff --git a/src/webpage/markdown.ts b/src/webpage/markdown.ts index 39a6986..9c31885 100644 --- a/src/webpage/markdown.ts +++ b/src/webpage/markdown.ts @@ -374,6 +374,15 @@ class MarkDown { pre.textContent = build; span.appendChild(pre); if (count === 3) highlight(pre, lang, keep ? 3 + lang.length : 0, keep ? 3 : 0); + if (!keep && !stdsize && lang && count === 3) { + const button = document.createElement("button"); + button.textContent = I18n.copyCode(); + button.classList.add("copyCode"); + pre.append(button); + button.onclick = () => { + navigator.clipboard.writeText(build); + }; + } } i--; continue; diff --git a/src/webpage/style.css b/src/webpage/style.css index b239c50..4adb8a8 100644 --- a/src/webpage/style.css +++ b/src/webpage/style.css @@ -731,6 +731,9 @@ audio::-webkit-media-controls-panel { background: #00000050; } } +.copyCode { + margin-top: 12px; +} button, input::file-selector-button, select { diff --git a/translations/en.json b/translations/en.json index 27acb92..d839e34 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1035,6 +1035,7 @@ "manage": "Manage security keys" }, "webhook": "WEBHOOK", + "copyCode":"Copy code", "webhooks": { "EnterWebhookName": "Enter webhook name", "areYouSureDelete": "Are you sure you want to delete $1?",