Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-to-print

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-to-print - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

2

lib/index.js

@@ -1,2 +0,2 @@

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault(require("react")),reactDom=require("react-dom"),propTypes=_interopDefault(require("prop-types")),classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},possibleConstructorReturn=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},ReactToPrint=function(e){function t(){var e,r,n,o;classCallCheck(this,t);for(var a=arguments.length,c=Array(a),i=0;i<a;i++)c[i]=arguments[i];return r=n=possibleConstructorReturn(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(c))),n.handlePrint=function(){var e=n.props,t=e.content,r=e.copyStyles,o=t(),a=reactDom.findDOMNode(o).outerHTML,c=window.open("/","Print","status=no, toolbar=no, scrollbars=yes","false");if(!1!==r){document.head.querySelectorAll("link, style").forEach(function(e){return c.document.head.appendChild(e.cloneNode(!0))})}var i=document.createElement("style");i.appendChild(document.createTextNode("@page { size: auto; margin: 0mm; }")),c.document.head.appendChild(i),c.document.body.innerHTML=a,console.log(a),setTimeout(function(){c.print(),c.close()},2250)},o=r,possibleConstructorReturn(n,o)}return inherits(t,e),createClass(t,[{key:"render",value:function(){var e=this;return React.cloneElement(this.props.trigger(),{ref:function(t){return e.triggerRef=t},onClick:this.handlePrint})}}]),t}(React.Component);ReactToPrint.defaultProps={copyStyles:!0},module.exports=ReactToPrint;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault(require("react")),reactDom=require("react-dom"),propTypes=_interopDefault(require("prop-types")),classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},possibleConstructorReturn=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},toConsumableArray=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},ReactToPrint=function(e){function t(){classCallCheck(this,t);var e=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.handlePrint=function(){var t=e.props,r=t.content,n=t.copyStyles,o=window.open("","Print","status=no, toolbar=no, scrollbars=yes","false"),a=r(),i=reactDom.findDOMNode(a),c=[].concat(toConsumableArray(i.getElementsByTagName("img")));e.imageTotal=c.length,e.imageLoaded=0;var u=function(){e.imageLoaded++,e.imageLoaded===e.imageTotal&&setTimeout(function(){o.print(),o.close()},200)};if(c.forEach(function(e){e.setAttribute("src",e.src),e.onload=u,e.onerror=u}),!1!==n){document.head.querySelectorAll("link, style").forEach(function(e){return o.document.head.appendChild(e.cloneNode(!0))})}var l=document.createElement("style");l.appendChild(document.createTextNode("@page { size: auto; margin: 0mm; }")),o.document.head.appendChild(l),o.document.body.innerHTML=i.outerHTML},e.imageTotal=0,e.imageLoaded=0,e}return inherits(t,e),createClass(t,[{key:"render",value:function(){var e=this;return React.cloneElement(this.props.trigger(),{ref:function(t){return e.triggerRef=t},onClick:this.handlePrint})}}]),t}(React.Component);ReactToPrint.defaultProps={copyStyles:!0},module.exports=ReactToPrint;
//# sourceMappingURL=index.js.map
{
"name": "react-to-print",
"version": "1.0.5",
"version": "1.0.6",
"description": "Print React components in the browser",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc