huge upgrade to theme and pagefind search bar.
This commit is contained in:
12
themes/hugo-book.backup/assets/clipboard.js
Normal file
12
themes/hugo-book.backup/assets/clipboard.js
Normal file
@@ -0,0 +1,12 @@
|
||||
(function () {
|
||||
document.querySelectorAll("pre:has(code)").forEach(code => {
|
||||
code.addEventListener("click", code.focus);
|
||||
code.addEventListener("copy", function (event) {
|
||||
event.preventDefault();
|
||||
if (navigator.clipboard) {
|
||||
const content = window.getSelection().toString() || code.textContent;
|
||||
navigator.clipboard.writeText(content);
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user