Estoy usando un HTML DIV en modo de contenido editable. Desde Javascript, dada una URL de imagen válida en una cadena, ¿cómo puedo convertir eso en algo que pueda empujar al portapapeles para que cuando pegue en el DIV de contenido editable con la pulsación de tecla CTRL+V, pegue la imagen en sí y no el cadena de texto sin formato?
async function writeClipImg(url) { try { const data = await fetch(url); const blob = await data.blob(); await navigator.clipboard.write([new ClipboardItem({ [blob.type]: blob })]); console.log('Fetched image copied.'); } catch (err) { console.error(err.name, err.message); } } //function from https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem let text; //get somehow the text of the div if (text.indexOf('://') != -1) { //check 'https://' (typic url substring) is there at the text //only the https care - you can write this for http://, file:///, data etc. let link = text.slice(text.indexOf('https://'), text.indexOf(' ', text.indexOf('https://'))) //its only get the first link writeClipImg(link) }