Socket
Socket
Sign inDemoInstall

@react-pdf-viewer/print

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-pdf-viewer/print - npm Package Compare versions

Comparing version 2.6.1 to 2.7.0

47

lib/cjs/print.js

@@ -31,7 +31,2 @@ 'use strict';

var PrintIcon = function () {
return (React__namespace.createElement(core.Icon, { size: 16 },
React__namespace.createElement("path", { d: "M7.5,19.499h9 M7.5,16.499h9 M5.5,16.5h-3c-1.103-0.003-1.997-0.897-2-2v-6c0.003-1.103,0.897-1.997,2-2h19\n c1.103,0.003,1.997,0.897,2,2v6c-0.003,1.103-0.897,1.997-2,2h-3\n M5.5,4.5v-4h9.586c0.265,0,0.52,0.105,0.707,0.293l2.414,2.414\n C18.395,3.394,18.5,3.649,18.5,3.914V4.5\n M18.5,22.5c0,0.552-0.448,1-1,1h-11c-0.552,0-1-0.448-1-1v-9h13V22.5z\n M3.5,8.499\n c0.552,0,1,0.448,1,1s-0.448,1-1,1s-1-0.448-1-1S2.948,8.499,3.5,8.499z\n M14.5,0.499v4h4" })));
};
/*! *****************************************************************************

@@ -63,8 +58,12 @@ Copyright (c) Microsoft Corporation.

var PrintIcon = function () { return (React__namespace.createElement(core.Icon, { size: 16 },
React__namespace.createElement("path", { d: "M7.5,19.499h9 M7.5,16.499h9 M5.5,16.5h-3c-1.103-0.003-1.997-0.897-2-2v-6c0.003-1.103,0.897-1.997,2-2h19\n c1.103,0.003,1.997,0.897,2,2v6c-0.003,1.103-0.897,1.997-2,2h-3\n M5.5,4.5v-4h9.586c0.265,0,0.52,0.105,0.707,0.293l2.414,2.414\n C18.395,3.394,18.5,3.649,18.5,3.914V4.5\n M18.5,22.5c0,0.552-0.448,1-1,1h-11c-0.552,0-1-0.448-1-1v-9h13V22.5z\n M3.5,8.499\n c0.552,0,1,0.448,1,1s-0.448,1-1,1s-1-0.448-1-1S2.948,8.499,3.5,8.499z\n M14.5,0.499v4h4" }))); };
var TOOLTIP_OFFSET = { left: 0, top: 8 };
var PrintButton = function (_a) {
var onClick = _a.onClick;
var enableShortcuts = _a.enableShortcuts, onClick = _a.onClick;
var l10n = React__namespace.useContext(core.LocalizationContext);
var label = l10n && l10n.print ? l10n.print.print : 'Print';
return (React__namespace.createElement(core.Tooltip, { position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { onClick: onClick },
var ariaKeyShortcuts = enableShortcuts ? (core.isMac() ? 'Meta+p' : 'Ctrl+p') : '';
return (React__namespace.createElement(core.Tooltip, { ariaControlsSuffix: "print", position: core.Position.BottomCenter, target: React__namespace.createElement(core.MinimalButton, { ariaKeyShortcuts: ariaKeyShortcuts, ariaLabel: label, onClick: onClick },
React__namespace.createElement(PrintIcon, null)), content: function () { return label; }, offset: TOOLTIP_OFFSET }));

@@ -80,12 +79,11 @@ };

})(PrintStatus || (PrintStatus = {}));
var PrintStatus$1 = PrintStatus;
var Print = function (_a) {
var children = _a.children, store = _a.store;
var children = _a.children, enableShortcuts = _a.enableShortcuts, store = _a.store;
var print = function () {
store.update('printStatus', PrintStatus$1.Preparing);
store.update('printStatus', PrintStatus.Preparing);
};
var defaultChildern = function (props) { return React__namespace.createElement(PrintButton, { onClick: props.onClick }); };
var render = children || defaultChildern;
var render = children || PrintButton;
return render({
enableShortcuts: enableShortcuts,
onClick: print,

@@ -179,3 +177,3 @@ });

React__namespace.useEffect(function () {
if (printStatus === PrintStatus$1.Ready) {
if (printStatus === PrintStatus.Ready) {
document.documentElement.classList.add('rpv-print__html-printing');

@@ -186,3 +184,3 @@ document.body.classList.add('rpv-print__body-printing');

var handler = function () {
if (printStatus === PrintStatus$1.Ready) {
if (printStatus === PrintStatus.Ready) {
document.documentElement.classList.remove('rpv-print__html-printing');

@@ -213,7 +211,7 @@ document.body.classList.remove('rpv-print__body-printing');

var doc = _a.doc, pageHeight = _a.pageHeight, pageWidth = _a.pageWidth, rotation = _a.rotation, store = _a.store;
var _b = React__namespace.useState(PrintStatus$1.Inactive), printStatus = _b[0], setPrintStatus = _b[1];
var _b = React__namespace.useState(PrintStatus.Inactive), printStatus = _b[0], setPrintStatus = _b[1];
var _c = React__namespace.useState(0), numLoadedPagesForPrint = _c[0], setNumLoadedPagesForPrint = _c[1];
var cancelPrinting = function () {
setNumLoadedPagesForPrint(0);
setPrintStatus(PrintStatus$1.Inactive);
setPrintStatus(PrintStatus.Inactive);
};

@@ -225,3 +223,3 @@ var handlePrintStatus = function (status) { return setPrintStatus(status); };

setNumLoadedPagesForPrint(total);
total === doc.numPages && setPrintStatus(PrintStatus$1.Ready);
total === doc.numPages && setPrintStatus(PrintStatus.Ready);
}

@@ -236,4 +234,4 @@ };

return (React__namespace.createElement(React__namespace.Fragment, null,
printStatus === PrintStatus$1.Preparing && (React__namespace.createElement(PrintProgress, { numLoadedPages: numLoadedPagesForPrint, numPages: doc.numPages, onCancel: cancelPrinting })),
(printStatus === PrintStatus$1.Preparing || printStatus === PrintStatus$1.Ready) &&
printStatus === PrintStatus.Preparing && (React__namespace.createElement(PrintProgress, { numLoadedPages: numLoadedPagesForPrint, numPages: doc.numPages, onCancel: cancelPrinting })),
(printStatus === PrintStatus.Preparing || printStatus === PrintStatus.Ready) &&
numLoadedPagesForPrint <= doc.numPages && (React__namespace.createElement(PrintZone, { doc: doc, numLoadedPages: numLoadedPagesForPrint, pageHeight: pageHeight, pageWidth: pageWidth, printStatus: printStatus, rotation: rotation, onCancel: cancelPrinting, onLoad: onLoadPage }))));

@@ -249,3 +247,2 @@ };

var isMac = function () { return (typeof window !== 'undefined' ? /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform) : false); };
var ShortcutHandler = function (_a) {

@@ -257,3 +254,3 @@ var containerRef = _a.containerRef, store = _a.store;

}
var isCommandPressed = isMac() ? e.metaKey : e.ctrlKey;
var isCommandPressed = core.isMac() ? e.metaKey : e.ctrlKey;
if (!isCommandPressed) {

@@ -263,7 +260,7 @@ return;

var containerEle = containerRef.current;
if (!containerEle || !document.activeElement || !document.activeElement.contains(containerEle)) {
if (!containerEle || !document.activeElement || !containerEle.contains(document.activeElement)) {
return;
}
e.preventDefault();
store.update('printStatus', PrintStatus$1.Preparing);
store.update('printStatus', PrintStatus.Preparing);
};

@@ -287,6 +284,6 @@ React__namespace.useEffect(function () {

return core.createStore({
printStatus: PrintStatus$1.Inactive,
printStatus: PrintStatus.Inactive,
});
}, []);
var PrintDecorator = function (props) { return React__namespace.createElement(Print, __assign({}, props, { store: store })); };
var PrintDecorator = function (props) { return (React__namespace.createElement(Print, __assign({ enableShortcuts: printPluginProps.enableShortcuts }, props, { store: store }))); };
var PrintButtonDecorator = function () { return React__namespace.createElement(PrintDecorator, null, function (props) { return React__namespace.createElement(PrintButton, __assign({}, props)); }); };

@@ -293,0 +290,0 @@ var PrintMenuItemDecorator = function (props) { return (React__namespace.createElement(PrintDecorator, null, function (p) { return (React__namespace.createElement(PrintMenuItem, { onClick: function () {

@@ -1,1 +0,15 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@react-pdf-viewer/core"),n=require("react-dom");function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var a,o=r(e),i=function(){return o.createElement(t.Icon,{size:16},o.createElement("path",{d:"M7.5,19.499h9 M7.5,16.499h9 M5.5,16.5h-3c-1.103-0.003-1.997-0.897-2-2v-6c0.003-1.103,0.897-1.997,2-2h19\n c1.103,0.003,1.997,0.897,2,2v6c-0.003,1.103-0.897,1.997-2,2h-3\n M5.5,4.5v-4h9.586c0.265,0,0.52,0.105,0.707,0.293l2.414,2.414\n C18.395,3.394,18.5,3.649,18.5,3.914V4.5\n M18.5,22.5c0,0.552-0.448,1-1,1h-11c-0.552,0-1-0.448-1-1v-9h13V22.5z\n M3.5,8.499\n c0.552,0,1,0.448,1,1s-0.448,1-1,1s-1-0.448-1-1S2.948,8.499,3.5,8.499z\n M14.5,0.499v4h4"}))},c=function(){return(c=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},u={left:0,top:8},l=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext),a=r&&r.print?r.print.print:"Print";return o.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:o.createElement(t.MinimalButton,{onClick:n},o.createElement(i,null)),content:function(){return a},offset:u})};!function(e){e.Inactive="Inactive",e.Preparing="Preparing",e.Cancelled="Cancelled",e.Ready="Ready"}(a||(a={}));var s=a,p=function(e){var t=e.children,n=e.store;return(t||function(e){return o.createElement(l,{onClick:e.onClick})})({onClick:function(){n.update("printStatus",s.Preparing)}})},d=function(e){var n=e.numLoadedPages,r=e.numPages,a=e.onCancel,i=o.useContext(t.LocalizationContext),c=Math.floor(100*n/r);return o.createElement("div",{className:"rpv-print__progress"},o.createElement("div",{className:"rpv-print__progress-body"},o.createElement("div",{className:"rpv-print__progress-message"},i&&i.print?i.print.preparingDocument:"Preparing document ..."),o.createElement("div",{className:"rpv-print__progress-bar"},o.createElement(t.ProgressBar,{progress:c})),o.createElement(t.Button,{onClick:a},i&&i.print?i.print.cancel:"Cancel")))},m=function(e){var t=e.canvas,n=e.page,r=e.pageHeight,a=e.pageWidth,i=e.rotation,c=e.onLoad,u=o.useRef(),l=o.useState(""),s=l[0],p=l[1];return o.useEffect((function(){var e=u.current;e&&e.cancel();var o=150/72;t.height=Math.floor(r*o),t.width=Math.floor(a*o);var c=t.getContext("2d");c.save(),c.fillStyle="rgb(255, 255, 255)",c.fillRect(0,0,t.width,t.height),c.restore();var l=n.getViewport({rotation:i,scale:1});u.current=n.render({canvasContext:c,intent:"print",transform:[o,0,0,o,0,0],viewport:l}),u.current.promise.then((function(){"toBlob"in t?t.toBlob((function(e){p(URL.createObjectURL(e))})):p(t.toDataURL())}),(function(){}))}),[]),s&&o.createElement("div",{className:"rpv-print__page"},o.createElement("img",{src:s,onLoad:function(){return c()}}))},g=function(e){var t=e.canvas,n=e.doc,r=e.pageHeight,a=e.pageIndex,i=e.pageWidth,c=e.rotation,u=e.onLoad,l=o.useState({height:r,page:null,viewportRotation:0,width:i}),s=l[0],p=l[1],d=s.page,g=s.height,f=s.width,v=Math.abs(c)%180==0;o.useEffect((function(){n.getPage(a+1).then((function(e){var t=e.getViewport({scale:1});p({height:t.height,page:e,viewportRotation:t.rotation,width:t.width})}))}),[]);var h=(c+s.viewportRotation)%360;return d&&o.createElement(m,{canvas:t,page:d,pageHeight:v?g:f,pageWidth:v?f:g,rotation:h,onLoad:u})},f=function(e){var t=e.doc,r=e.numLoadedPages,a=e.pageHeight,i=e.pageWidth,c=e.printStatus,u=e.rotation,l=e.onCancel,p=e.onLoad,d=o.useMemo((function(){return document.createElement("canvas")}),[]),m=o.useMemo((function(){var e=document.createElement("div");return e.classList.add("rpv-print__zone"),document.body.appendChild(e),e}),[]);return o.useEffect((function(){c===s.Ready&&(document.documentElement.classList.add("rpv-print__html-printing"),document.body.classList.add("rpv-print__body-printing"),window.print());var e=function(){c===s.Ready&&(document.documentElement.classList.remove("rpv-print__html-printing"),document.body.classList.remove("rpv-print__body-printing"),m.parentElement&&m.parentElement.removeChild(m),d.height=0,d.width=0,document.removeEventListener("mousemove",e),l())};return document.addEventListener("mousemove",e),function(){return document.removeEventListener("mousemove",e)}}),[c]),n.createPortal(o.createElement(o.Fragment,null,Array(Math.min(r+1,t.numPages)).fill(0).map((function(e,n){return o.createElement(g,{key:n,canvas:d,doc:t,pageHeight:a,pageIndex:n,pageWidth:i,rotation:u,onLoad:p})})),o.createElement("style",{dangerouslySetInnerHTML:{__html:"@page { size: "+i+"pt "+a+"pt }"}})),m)},v=function(e){var t=e.doc,n=e.pageHeight,r=e.pageWidth,a=e.rotation,i=e.store,c=o.useState(s.Inactive),u=c[0],l=c[1],p=o.useState(0),m=p[0],g=p[1],v=function(){g(0),l(s.Inactive)},h=function(e){return l(e)};return o.useEffect((function(){return i.subscribe("printStatus",h),function(){i.unsubscribe("printStatus",h)}}),[]),o.createElement(o.Fragment,null,u===s.Preparing&&o.createElement(d,{numLoadedPages:m,numPages:t.numPages,onCancel:v}),(u===s.Preparing||u===s.Ready)&&m<=t.numPages&&o.createElement(f,{doc:t,numLoadedPages:m,pageHeight:n,pageWidth:r,printStatus:u,rotation:a,onCancel:v,onLoad:function(){var e=m+1;e<=t.numPages&&(g(e),e===t.numPages&&l(s.Ready))}}))},h=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext),a=r&&r.print?r.print.print:"Print";return o.createElement(t.MenuItem,{icon:o.createElement(i,null),onClick:n},a)},E=function(e){var t=e.containerRef,n=e.store,r=function(e){if(!e.shiftKey&&!e.altKey&&"p"===e.key&&("undefined"!=typeof window&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)?e.metaKey:e.ctrlKey)){var r=t.current;r&&document.activeElement&&document.activeElement.contains(r)&&(e.preventDefault(),n.update("printStatus",s.Preparing))}};return o.useEffect((function(){if(t.current)return document.addEventListener("keydown",r),function(){document.removeEventListener("keydown",r)}}),[t.current]),o.createElement(o.Fragment,null)};exports.PrintIcon=i,exports.printPlugin=function(e){var n=o.useMemo((function(){return Object.assign({},{enableShortcuts:!0},e)}),[]),r=o.useMemo((function(){return t.createStore({printStatus:s.Inactive})}),[]),a=function(e){return o.createElement(p,c({},e,{store:r}))};return{renderViewer:function(e){var t=e.slot,a={children:o.createElement(o.Fragment,null,n.enableShortcuts&&o.createElement(E,{containerRef:e.containerRef,store:r}),o.createElement(v,{doc:e.doc,pageHeight:e.pageHeight,pageWidth:e.pageWidth,rotation:e.rotation,store:r}),t.children)};return c(c({},t),a)},Print:a,PrintButton:function(){return o.createElement(a,null,(function(e){return o.createElement(l,c({},e))}))},PrintMenuItem:function(e){return o.createElement(a,null,(function(t){return o.createElement(h,{onClick:function(){t.onClick(),e.onClick()}})}))}}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@react-pdf-viewer/core"),n=require("react-dom");function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var a,o=r(e),i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},c=function(){return o.createElement(t.Icon,{size:16},o.createElement("path",{d:"M7.5,19.499h9 M7.5,16.499h9 M5.5,16.5h-3c-1.103-0.003-1.997-0.897-2-2v-6c0.003-1.103,0.897-1.997,2-2h19\n c1.103,0.003,1.997,0.897,2,2v6c-0.003,1.103-0.897,1.997-2,2h-3\n M5.5,4.5v-4h9.586c0.265,0,0.52,0.105,0.707,0.293l2.414,2.414\n C18.395,3.394,18.5,3.649,18.5,3.914V4.5\n M18.5,22.5c0,0.552-0.448,1-1,1h-11c-0.552,0-1-0.448-1-1v-9h13V22.5z\n M3.5,8.499\n c0.552,0,1,0.448,1,1s-0.448,1-1,1s-1-0.448-1-1S2.948,8.499,3.5,8.499z\n M14.5,0.499v4h4"}))},u={left:0,top:8},l=function(e){var n=e.enableShortcuts,r=e.onClick,a=o.useContext(t.LocalizationContext),i=a&&a.print?a.print.print:"Print",l=n?t.isMac()?"Meta+p":"Ctrl+p":"";return o.createElement(t.Tooltip,{ariaControlsSuffix:"print",position:t.Position.BottomCenter,target:o.createElement(t.MinimalButton,{ariaKeyShortcuts:l,ariaLabel:i,onClick:r},o.createElement(c,null)),content:function(){return i},offset:u})};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */!function(e){e.Inactive="Inactive",e.Preparing="Preparing",e.Cancelled="Cancelled",e.Ready="Ready"}(a||(a={}));var s=function(e){var t=e.children,n=e.enableShortcuts,r=e.store;return(t||l)({enableShortcuts:n,onClick:function(){r.update("printStatus",a.Preparing)}})},p=function(e){var n=e.numLoadedPages,r=e.numPages,a=e.onCancel,i=o.useContext(t.LocalizationContext),c=Math.floor(100*n/r);return o.createElement("div",{className:"rpv-print__progress"},o.createElement("div",{className:"rpv-print__progress-body"},o.createElement("div",{className:"rpv-print__progress-message"},i&&i.print?i.print.preparingDocument:"Preparing document ..."),o.createElement("div",{className:"rpv-print__progress-bar"},o.createElement(t.ProgressBar,{progress:c})),o.createElement(t.Button,{onClick:a},i&&i.print?i.print.cancel:"Cancel")))},d=function(e){var t=e.canvas,n=e.page,r=e.pageHeight,a=e.pageWidth,i=e.rotation,c=e.onLoad,u=o.useRef(),l=o.useState(""),s=l[0],p=l[1];return o.useEffect((function(){var e=u.current;e&&e.cancel();var o=150/72;t.height=Math.floor(r*o),t.width=Math.floor(a*o);var c=t.getContext("2d");c.save(),c.fillStyle="rgb(255, 255, 255)",c.fillRect(0,0,t.width,t.height),c.restore();var l=n.getViewport({rotation:i,scale:1});u.current=n.render({canvasContext:c,intent:"print",transform:[o,0,0,o,0,0],viewport:l}),u.current.promise.then((function(){"toBlob"in t?t.toBlob((function(e){p(URL.createObjectURL(e))})):p(t.toDataURL())}),(function(){}))}),[]),s&&o.createElement("div",{className:"rpv-print__page"},o.createElement("img",{src:s,onLoad:function(){return c()}}))},m=function(e){var t=e.canvas,n=e.doc,r=e.pageHeight,a=e.pageIndex,i=e.pageWidth,c=e.rotation,u=e.onLoad,l=o.useState({height:r,page:null,viewportRotation:0,width:i}),s=l[0],p=l[1],m=s.page,g=s.height,f=s.width,v=Math.abs(c)%180==0;o.useEffect((function(){n.getPage(a+1).then((function(e){var t=e.getViewport({scale:1});p({height:t.height,page:e,viewportRotation:t.rotation,width:t.width})}))}),[]);var h=(c+s.viewportRotation)%360;return m&&o.createElement(d,{canvas:t,page:m,pageHeight:v?g:f,pageWidth:v?f:g,rotation:h,onLoad:u})},g=function(e){var t=e.doc,r=e.numLoadedPages,i=e.pageHeight,c=e.pageWidth,u=e.printStatus,l=e.rotation,s=e.onCancel,p=e.onLoad,d=o.useMemo((function(){return document.createElement("canvas")}),[]),g=o.useMemo((function(){var e=document.createElement("div");return e.classList.add("rpv-print__zone"),document.body.appendChild(e),e}),[]);return o.useEffect((function(){u===a.Ready&&(document.documentElement.classList.add("rpv-print__html-printing"),document.body.classList.add("rpv-print__body-printing"),window.print());var e=function(){u===a.Ready&&(document.documentElement.classList.remove("rpv-print__html-printing"),document.body.classList.remove("rpv-print__body-printing"),g.parentElement&&g.parentElement.removeChild(g),d.height=0,d.width=0,document.removeEventListener("mousemove",e),s())};return document.addEventListener("mousemove",e),function(){return document.removeEventListener("mousemove",e)}}),[u]),n.createPortal(o.createElement(o.Fragment,null,Array(Math.min(r+1,t.numPages)).fill(0).map((function(e,n){return o.createElement(m,{key:n,canvas:d,doc:t,pageHeight:i,pageIndex:n,pageWidth:c,rotation:l,onLoad:p})})),o.createElement("style",{dangerouslySetInnerHTML:{__html:"@page { size: "+c+"pt "+i+"pt }"}})),g)},f=function(e){var t=e.doc,n=e.pageHeight,r=e.pageWidth,i=e.rotation,c=e.store,u=o.useState(a.Inactive),l=u[0],s=u[1],d=o.useState(0),m=d[0],f=d[1],v=function(){f(0),s(a.Inactive)},h=function(e){return s(e)};return o.useEffect((function(){return c.subscribe("printStatus",h),function(){c.unsubscribe("printStatus",h)}}),[]),o.createElement(o.Fragment,null,l===a.Preparing&&o.createElement(p,{numLoadedPages:m,numPages:t.numPages,onCancel:v}),(l===a.Preparing||l===a.Ready)&&m<=t.numPages&&o.createElement(g,{doc:t,numLoadedPages:m,pageHeight:n,pageWidth:r,printStatus:l,rotation:i,onCancel:v,onLoad:function(){var e=m+1;e<=t.numPages&&(f(e),e===t.numPages&&s(a.Ready))}}))},v=function(e){var n=e.onClick,r=o.useContext(t.LocalizationContext),a=r&&r.print?r.print.print:"Print";return o.createElement(t.MenuItem,{icon:o.createElement(c,null),onClick:n},a)},h=function(e){var n=e.containerRef,r=e.store,i=function(e){if(!e.shiftKey&&!e.altKey&&"p"===e.key&&(t.isMac()?e.metaKey:e.ctrlKey)){var o=n.current;o&&document.activeElement&&o.contains(document.activeElement)&&(e.preventDefault(),r.update("printStatus",a.Preparing))}};return o.useEffect((function(){if(n.current)return document.addEventListener("keydown",i),function(){document.removeEventListener("keydown",i)}}),[n.current]),o.createElement(o.Fragment,null)};exports.PrintIcon=c,exports.printPlugin=function(e){var n=o.useMemo((function(){return Object.assign({},{enableShortcuts:!0},e)}),[]),r=o.useMemo((function(){return t.createStore({printStatus:a.Inactive})}),[]),c=function(e){return o.createElement(s,i({enableShortcuts:n.enableShortcuts},e,{store:r}))};return{renderViewer:function(e){var t=e.slot,a={children:o.createElement(o.Fragment,null,n.enableShortcuts&&o.createElement(h,{containerRef:e.containerRef,store:r}),o.createElement(f,{doc:e.doc,pageHeight:e.pageHeight,pageWidth:e.pageWidth,rotation:e.rotation,store:r}),t.children)};return i(i({},t),a)},Print:c,PrintButton:function(){return o.createElement(c,null,(function(e){return o.createElement(l,i({},e))}))},PrintMenuItem:function(e){return o.createElement(c,null,(function(t){return o.createElement(v,{onClick:function(){t.onClick(),e.onClick()}})}))}}};

@@ -10,5 +10,7 @@ /**

import * as React from 'react';
import { Plugin } from '@react-pdf-viewer/core';
import type { Plugin } from '@react-pdf-viewer/core';
// Types
export interface RenderPrintProps {
enableShortcuts: boolean;
onClick: () => void;

@@ -25,2 +27,3 @@ }

// Plugin
export interface PrintPlugin extends Plugin {

@@ -38,2 +41,3 @@ Print: (props: PrintProps) => React.ReactElement;

// Components
export class PrintIcon extends React.Component {}
{
"name": "@react-pdf-viewer/print",
"version": "2.6.1",
"version": "2.7.0",
"description": "A React component to view a PDF document",

@@ -36,3 +36,3 @@ "license": "https://react-pdf-viewer.dev/license",

"dependencies": {
"@react-pdf-viewer/core": "2.6.1"
"@react-pdf-viewer/core": "2.7.0"
},

@@ -52,3 +52,3 @@ "peerDependencies": {

},
"gitHead": "500247f24514da033bf92266f6903decaffebb68"
"gitHead": "331789d286847ac1c8a272c9df82bdab63ba4406"
}

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