Created
September 29, 2019 13:09
-
-
Save VladimirCores/8e3ea60ae8c37c008181b4265d6ae991 to your computer and use it in GitHub Desktop.
Remove breaks from text and copy to clipboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function copyToClipboard(text) { | |
| var dummy = document.createElement("textarea"); | |
| // to avoid breaking orgain page when copying more words | |
| // cant copy when adding below this code | |
| // dummy.style.display = 'none' | |
| document.body.appendChild(dummy); | |
| //Be careful if you use texarea. setAttribute('value', value), which works with "input" does not work with "textarea". – Eduard | |
| dummy.value = text; | |
| dummy.select(); | |
| document.execCommand("copy"); | |
| document.body.removeChild(dummy); | |
| } | |
| a = ` | |
| SOME_TEXT | |
| ` | |
| a = a.replace(/(\r\n|\n|\r)/gm," ") | |
| copyToClipboard(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment