print("email@author.de")
[1] "email@author.de"
print("email@author.de")
[1] "email@author.de"
.button(
Inputshtml`📧 <i>Copy</i>`,
value: null, reduce:() => copyToClipboard('.cell-output code')}
{ )
= function(domRef) {
copyToClipboardB // get DOM Element which contains the output
// i.e. ".cell-output code" to the first output chunk
const dom = document.querySelector(domRef);
// get the clean inner string of the DOM Element (no HTML)
const innerText = dom.innerText;
// with RegEx, remove [nr] and "
const cleanString = innerText.replace(/\[\d+]\s/, '').replace(/"/g, "")
// write to clipboard
navigator.clipboard.writeText(cleanString);
console.log(cleanString) // TODO: remove in production
}
html
template literalhtml`
<button onclick="copyToClipboard('.cell-output code')">Copy</button>`