-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Is your feature request related to a problem? Please describe.
Yes. While reading the Theatre.js documentation, copying code snippets requires manually selecting text. This is time-consuming, especially for multi-line code examples, and can lead to copying errors.
Solution Description
Add a small "Copy" button to the top-right corner of every <pre><code> block in the documentation.
When clicked, it should copy the entire code snippet to the clipboard with a confirmation (e.g., tooltip: “Copied!”).
Proposed Implementation (Example):
document.querySelectorAll("pre code").forEach((block) => {
const btn = document.createElement("button");
btn.className = "copy-btn";
btn.innerText = "Copy";
block.parentElement.style.position = "relative";
block.parentElement.appendChild(btn);
btn.addEventListener("click", async () => {
await navigator.clipboard.writeText(block.innerText);
btn.innerText = "Copied!";
setTimeout(() => (btn.innerText = "Copy"), 1500);
});
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels