reactjs-tiptap-editor
Version:
A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React
16 lines (15 loc) • 1.59 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-CSvnpArE.cjs"),d=require("./RichTextEditor-DaQRHXru.cjs");function s(n){const t=document.createElement("iframe");t.setAttribute("style","position: absolute; width: 0; height: 0; top: 0; left: 0;"),document.body.appendChild(t),t.textContent=`
<!DOCTYPE html>
<html lang="en">
<head>
<title>Echo Editor</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body class="is-print">
<div class="tiptap ProseMirror" translate="no" aria-expanded="false">
${n}
</div>
</body>
</html>
`;const e=t.contentWindow,o=t.contentDocument||t.contentWindow&&t.contentWindow.document,i=document.createElement("link");i.rel="stylesheet",i.href="https://cdn.jsdelivr.net/npm/reactjs-tiptap-editor@latest/lib/style.css",o.head.appendChild(i),o&&(o.open(),o.write(n),o.close()),e&&t.addEventListener("load",function(){try{setTimeout(()=>{e.focus();try{e.document.execCommand("print",!1)||e.print()}catch{e.print()}e.close()},10)}catch(r){console.error(r)}setTimeout(()=>{document.body.removeChild(t)},100)})}function a(n){const t=n.getHTML();return t?(s(t),!0):!1}const l=c.Extension.create({name:"exportPdf",addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),button:({editor:t,t:e})=>({component:d.ActionButton,componentProps:{action:()=>{a(t)},icon:"ExportPdf",tooltip:e("editor.exportPdf.tooltip"),isActive:()=>!1,disabled:!1}})}}});exports.ExportPdf=l;