@firestitch/froala
Version:
The next generation Javascript WYSIWYG HTML rich text editor made by devs for devs. High performance and modern design make it easy to use for developers and loved by users.
3 lines (2 loc) • 2.58 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("froala-editor")):"function"==typeof define&&define.amd?define(["froala-editor"],t):t(e.FroalaEditor)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,Object.assign(e.DEFAULTS,{html2pdf:window.html2pdf}),e.PLUGINS.print=function(r){return{run:function(){var t=function(){setTimeout(function(){r.events.disableBlur(),window.frames["fr-print"].focus(),window.frames["fr-print"].print(),r.$win.get(0).focus(),r.events.disableBlur(),r.events.focus()},0)},e=r.html.get(),n=null;r.shared.print_iframe?n=r.shared.print_iframe:((n=document.createElement("iframe")).name="fr-print",n.style.position="fixed",n.style.top="0",n.style.left="-9999px",n.style.height="100%",n.style.width="0",n.style.overflow="hidden",n.style["z-index"]="2147483647",n.style.tabIndex="-1",r.events.on("shared.destroy",function(){n.remove()}),r.shared.print_iframe=n);try{document.body.removeChild(n)}catch(e){}document.body.appendChild(n),n.addEventListener("load",function e(){t(),n.removeEventListener("load",e)});var i=n.contentWindow,o=(i.document.open(),i.document.write("<!DOCTYPE html><html "+(r.opts.documentReady?'style="margin: 0; padding: 0;"':"")+"><head><title>"+document.title+"</title>"),Array.prototype.forEach.call(document.querySelectorAll("style"),function(e){e=e.cloneNode(!0),i.document.write(e.outerHTML)}),document.querySelectorAll("link[rel=stylesheet]"));Array.prototype.forEach.call(o,function(e){var t=document.createElement("link");t.rel=e.rel,t.href=e.href,t.media="print",t.type="text/css",t.media="all",i.document.write(t.outerHTML)}),i.document.write('</head><body style="height:auto;text-align: '+("rtl"==r.opts.direction?"right":"left")+"; direction: "+r.opts.direction+"; "+(r.opts.documentReady?" padding: 2cm; width: 17cm; margin: 0;":"")+'"><div class="fr-view">'),i.document.write(e),i.document.write("</div></body></html>"),i.document.close()},toPDF:function(){r.opts.html2pdf&&(r.$el.css("text-align","left"),r.opts.html2pdf().set({margin:[10,20],html2canvas:{useCORS:!0}}).from(r.el).save(),setTimeout(function(){r.$el.css("text-align","")},100))}}},e.DefineIcon("print",{NAME:"print",SVG_KEY:"print"}),e.RegisterCommand("print",{title:"Print",undo:!1,focus:!1,plugin:"print",callback:function(){this.print.run()}}),e.DefineIcon("getPDF",{NAME:"file-pdf-o",FA5NAME:"file-pdf",SVG_KEY:"pdfExport"}),e.RegisterCommand("getPDF",{title:"Download PDF",type:"button",focus:!1,undo:!1,callback:function(){this.print.toPDF()}})});
//# sourceMappingURL=print.min.js.map