Closed marduc812 closed 1 year ago
Thanks for contributing <3 This is a good addition to the clipboard.
I noticed that the main.min.js needs to recompile. I was testing it locally and it was working because it was loading the main.js file directly. I will send a new update.
@patrickhener So the reason that it didn't work was because I tried to access it from http instead of https. Apparently the clipboard method works only for dev or if the app is served over https. Instead something like that could be used. https://stackoverflow.com/a/71876238
For some reason I am not able to update the js. It looks like they are somehow cached on a weird way. I tried clearing my cache, accessing from a private window and restarting the server, but the old version is constantly served. Could you update the function in main.js and in the main.min.js? Sorry for the extra effort.
function copyToClipboard(id) {
const textSelected = document.getElementById('card-body-' + id).innerText;
const textArea = document.createElement("textarea");
textArea.value = textSelected;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand('copy');
} catch (err) {
console.error('Unable to copy to clipboard', err);
}
document.body.removeChild(textArea);
return false;
}
I will need to allocate some spare time, which is not now. I will look into it though.
Added a small button next to the delete clipboard option to copy the text to clipboard. In many occasions the text I had to copy was large and it is tiring to manually scroll across the whole view to select it.
The last return false on the copyToClipboard function is just to prevent the page from reloading, instead of passing the event and using preventDefault, since it is not needed.