function formatDoc(e,t=null){t?document.execCommand(e,!1,t):document.execCommand(e)}function addLink(){formatDoc("createLink",prompt("Insert url"))}const content=document.getElementById("content");content.addEventListener("mouseenter",(function(){content.querySelectorAll("a").forEach((e=>{e.addEventListener("mouseenter",(function(){content.setAttribute("contenteditable",!1),e.target="_blank"})),e.addEventListener("mouseleave",(function(){content.setAttribute("contenteditable",!0)}))}))}));const showCode=document.getElementById("show-code");let active=!1;showCode.addEventListener("click",(function(){showCode.dataset.active=!active,active=!active,active?(content.textContent=content.innerHTML,content.setAttribute("contenteditable",!1)):(content.innerHTML=content.textContent,content.setAttribute("contenteditable",!0))}));const filename=document.getElementById("filename");function fileHandle(e){if("new"===e)content.innerHTML="",filename.value="untitled";else if("txt"===e){const e=new Blob([content.innerText]),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=`${filename.value}.txt`,n.click()}else"pdf"===e&&html2pdf(content).save(filename.value)}