Skip to content

Commit

Permalink
Merge pull request #31 from paganotoni/feature-30
Browse files Browse the repository at this point in the history
feature: allowing a copy widget to the code elements
  • Loading branch information
paganotoni authored Jun 14, 2024
2 parents 1fe23e7 + 2cbeace commit 49770f5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions internal/assets/doco.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ document.addEventListener("DOMContentLoaded", () => {
// Add highligthing to the code blocks
hljs.highlightAll();

document.querySelectorAll("pre").forEach((el) => {
let bt = document.createElement("button");
bt.appendChild(document.createTextNode("content_copy"));
bt.classList.add(
"material-symbols-outlined",
"absolute",
"top-4",
"right-2",
"p-1.5",
"bg-gray-50",
"hover:bg-gray-100",
"rounded",
);

bt.addEventListener("click", () => {
navigator.clipboard.writeText(el.textContent);
});

el.appendChild(bt);
el.classList.add("relative");
});

// Adding the mobile menu toggle
let toggles = document.querySelectorAll(".toggle-mobile-nav");
toggles.forEach((toggle) => {
Expand Down

0 comments on commit 49770f5

Please sign in to comment.