`; }else{ iframe.removeAttribute('srcdoc');iframe.src=remoteUrl; } } /****************** TOOLTIP **********************/ const tip=document.getElementById('hoverTip'); window.addEventListener('message',e=>{ if(e.data.tag){const r=iframe.getBoundingClientRect();tip.style.left=(r.left+e.data.x)+'px';tip.style.top=(r.top+e.data.y+8)+'px';tip.textContent=`<${e.data.tag.toLowerCase()}>::\n`+e.data.code;tip.style.display='block';} }); document.getElementById('file-content').addEventListener('mouseleave',()=>tip.style.display='none'); /****************** AUTOGUARDADO & CRUD *********/ function saveEdits(){if(!currentFolder)return;localStorage.setItem('edit_'+currentFolder,JSON.stringify({html:htmlEditor.value,css:cssEditor.value,js:jsEditor.value}));render();} ['htmlEditor','cssEditor','jsEditor'].forEach(id=>document.getElementById(id).addEventListener('input',saveEdits)); function insertTag(t){const m={h1:'

Nuevo encabezado

',p:'

Nuevo párrafo futurista

'};htmlEditor.value+='\n'+(m[t]||'');saveEdits();} function copyEdits(){navigator.clipboard.writeText(JSON.stringify({html:htmlEditor.value,css:cssEditor.value,js:jsEditor.value}));} function pasteEdits(){navigator.clipboard.readText().then(txt=>{try{const d=JSON.parse(txt);htmlEditor.value=d.html||'';cssEditor.value=d.css||'';jsEditor.value=d.js||'';saveEdits();}catch{}});} function clearEdits(){if(!currentFolder)return;if(confirm('Eliminar edición local?')){localStorage.removeItem('edit_'+currentFolder);htmlEditor.value=cssEditor.value=jsEditor.value='';render();}} /* ---------- AUTOLOAD PRIMERA CARPETA --------- */ loadFolder(folders[0],listContainer.firstChild);