tweak how copying text works

trunk
vilmibm 2023-07-18 06:39:12 +00:00
parent ddb1ceb146
commit 46964b5c2b
1 changed files with 15 additions and 3 deletions

View File

@ -102,7 +102,7 @@
--> -->
<center> <center>
<p> <p>
<button id="copy">copy to clipboard</button> <button id="copy">copy text to clipboard</button>
</p> </p>
<p> <p>
<a id="aboutToggle" href="">ABOUT</a> <a id="aboutToggle" href="">ABOUT</a>
@ -135,6 +135,18 @@
let toCopy = ""; let toCopy = "";
document.querySelectorAll("#paper span").forEach(span => { document.querySelectorAll("#paper span").forEach(span => {
let guts = span.innerHTML; let guts = span.innerHTML;
if (!span.classList.contains("black")) {
toCopy += guts.trim()+" ";
}
if (guts.includes("\n") && toCopy[toCopy.length-1] != "\n") {
toCopy += "\n"
}
/*
// I think this method of converting to plaintext is interesting but
// it's not very practical--it's way too many characters to
// realistically put in a toot or alt text or similar. I may add a
// "copy wide text" button that re-introduces this behavior.
let out = ""; let out = "";
if (span.classList.contains("black")) { if (span.classList.contains("black")) {
for (let i = 0; i < guts.length; i++) { for (let i = 0; i < guts.length; i++) {
@ -147,8 +159,8 @@
} else { } else {
out = guts; out = guts;
} }
toCopy += out
toCopy += out; */
}); });
navigator.clipboard.writeText(toCopy).then(() => { navigator.clipboard.writeText(toCopy).then(() => {