Fossil SCM
Cherry-pick [6a54cf2939]: Trim leading and trailing white space from the text to be copied to clipboard (do this in Javascript, so no need to care about the extra white space when generating HTML elements).
Commit
698245db8d9f2837d41e1067fa23fa55e24744427024bbc6f126db2b1a1c5e0b
Parent
3aab0bfdc0175d6…
1 file changed
+1
-1
+1
-1
| --- src/copybtn.js | ||
| +++ src/copybtn.js | ||
| @@ -58,11 +58,11 @@ | ||
| 58 | 58 | this.style.transition = "opacity 400ms ease-in-out"; |
| 59 | 59 | this.style.opacity = 0; |
| 60 | 60 | var idTarget = this.getAttribute("data-copytarget"); |
| 61 | 61 | var elTarget = document.getElementById(idTarget); |
| 62 | 62 | if( elTarget ){ |
| 63 | - var text = elTarget.innerText; | |
| 63 | + var text = elTarget.innerText.replace(/^\s+|\s+$/g,''); | |
| 64 | 64 | var cchLength = parseInt(this.getAttribute("data-copylength")); |
| 65 | 65 | if( !isNaN(cchLength) && cchLength>0 ){ |
| 66 | 66 | text = text.slice(0,cchLength); // Assume single-byte chars. |
| 67 | 67 | } |
| 68 | 68 | copyTextToClipboard(text); |
| 69 | 69 |
| --- src/copybtn.js | |
| +++ src/copybtn.js | |
| @@ -58,11 +58,11 @@ | |
| 58 | this.style.transition = "opacity 400ms ease-in-out"; |
| 59 | this.style.opacity = 0; |
| 60 | var idTarget = this.getAttribute("data-copytarget"); |
| 61 | var elTarget = document.getElementById(idTarget); |
| 62 | if( elTarget ){ |
| 63 | var text = elTarget.innerText; |
| 64 | var cchLength = parseInt(this.getAttribute("data-copylength")); |
| 65 | if( !isNaN(cchLength) && cchLength>0 ){ |
| 66 | text = text.slice(0,cchLength); // Assume single-byte chars. |
| 67 | } |
| 68 | copyTextToClipboard(text); |
| 69 |
| --- src/copybtn.js | |
| +++ src/copybtn.js | |
| @@ -58,11 +58,11 @@ | |
| 58 | this.style.transition = "opacity 400ms ease-in-out"; |
| 59 | this.style.opacity = 0; |
| 60 | var idTarget = this.getAttribute("data-copytarget"); |
| 61 | var elTarget = document.getElementById(idTarget); |
| 62 | if( elTarget ){ |
| 63 | var text = elTarget.innerText.replace(/^\s+|\s+$/g,''); |
| 64 | var cchLength = parseInt(this.getAttribute("data-copylength")); |
| 65 | if( !isNaN(cchLength) && cchLength>0 ){ |
| 66 | text = text.slice(0,cchLength); // Assume single-byte chars. |
| 67 | } |
| 68 | copyTextToClipboard(text); |
| 69 |