froala-editor
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.
7 lines (6 loc) • 2.85 kB
JavaScript
/*!
* froala_editor v5.0.1 (https://www.froala.com/wysiwyg-editor)
* License https://froala.com/wysiwyg-editor/terms/
* Copyright 2014-2026 Froala Labs
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("froala-editor")):"function"==typeof define&&define.amd?define(["froala-editor"],t):t(("undefined"!=typeof globalThis?globalThis:e||self).FroalaEditor)}(this,function(e){"use strict";Object.assign(e.DEFAULTS,{html2pdf:window.html2pdf}),e.PLUGINS.print=function(d){return{run:function(){var e=function(){setTimeout(function(){d.events.disableBlur(),window.frames["fr-print"].focus(),window.frames["fr-print"].print(),d.$win.get(0).focus(),d.events.disableBlur(),d.events.focus()},0)},t=((r=d.opts.useClasses)||d.$el.addClass("print"),d.html.get()),n=(r||d.$el.removeClass("print"),null);d.shared.print_iframe?n=d.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",d.events.on("shared.destroy",function(){n.remove()}),d.shared.print_iframe=n);try{document.body.removeChild(n)}catch(l){}document.body.appendChild(n);var o=function(){e(),n.removeEventListener("load",o)},i=(n.addEventListener("load",o),n.contentWindow),r=(i.document.open(),i.document.write("<!DOCTYPE html><html "+(d.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(r,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"==d.opts.direction?"right":"left")+"; direction: "+d.opts.direction+"; "+(d.opts.documentReady?" padding: 2cm; width: 17cm; margin: 0;":"")+'"><div class="fr-view">'),i.document.write(t),i.document.write("</div></body></html>"),i.document.close()},toPDF:function(){d.opts.html2pdf&&(d.$el.css("text-align","left"),d.$el.addClass("pdf-export"),d.opts.html2pdf().set({margin:[10,20],html2canvas:{useCORS:!0}}).from(d.el).save(),setTimeout(function(){d.$el.css("text-align",""),d.$el.removeClass("pdf-export")},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()}})});