the goal is to copy a div containing text and an image to create the body of an email to be pasted on the email client. I can do this with the execCommand (copy) command but being deprecated I would like to arrive at a solution using the Clipboard API. With Clipboard I can copy the text via the write function passing the html element by id but this eliminates any formatting of the text and images.
application that create template for email body
var toCopy = document.getElementById("riepilogonegozio")
var r = document.createRange();
r.selectNode(toCopy);
console.log(r)
window.getSelection().removeAllRanges();
window.getSelection().addRange(r);
console.log(r)
document.execCommand('copy');
window.getSelection().removeAllRanges();