Copiar al portapapeles funciona bien en PC con Windows en el navegador Google Chrome, pero no funciona con MacOS en el navegador Google Chrome dentro del editor Wyswig de herramientas de marketing por correo electrónico como Snovio.
Aquí está mi código:
let htmlBlock = `<a style="padding: 10px 0px; max-width: 360px;" href="https://commons.wikimedia.org/wiki/Category:Images#/media/File:Volkswagen_Beetle_7.jpg" alt="Car Image"> <img height="168" width="300" src="https://commons.wikimedia.org/wiki/Category:Images#/media/File:Volkswagen_Beetle_7.jpg" alt="Car Image" /></a>` copyToClipboard(htmlBlock); function copyToClipboard(element) { // Create container for the HTML // [1] let html = element var container = document.createElement('div') container.innerHTML = html // Hide element // [2] container.style.position = 'fixed' container.style.pointerEvents = 'none' container.style.opacity = 0 // Detect all style sheets of the page var activeSheets = Array.prototype.slice.call(document.styleSheets) .filter(function (sheet) { return !sheet.disabled }) // Mount the container to the DOM to make `contentWindow` available // [3] document.body.appendChild(container) // Copy to clipboard // [4] window.getSelection().removeAllRanges() var range = document.createRange() range.selectNode(container) window.getSelection().addRange(range) // [5.1] document.execCommand('copy') // [5.2] for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = true // [5.3] document.execCommand('copy') // [5.4] for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = false // Remove the container // [6] document.body.removeChild(container) }El mismo código también funciona con el editor de Gmail en MacOS.
¿Alguna idea de lo que me podría estar perdiendo o podría ser muy específico de la plataforma Snovio?