0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-09 11:32:39 +00:00

Move "printPage()" to helpers.js for reuse in multiple pages

This commit is contained in:
Trevor Buckner
2024-05-24 19:28:02 -04:00
parent e396211f92
commit ac3168e365
6 changed files with 27 additions and 56 deletions

View File

@@ -13,6 +13,7 @@ const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx');
const NotificationPopup = require('./notificationPopup/notificationPopup.jsx');
const Frame = require('react-frame-component').default;
const dedent = require('dedent-tabs').default;
const { printPage } = require('../../../shared/helpers.js');
const DOMPurify = require('dompurify');
const purifyConfig = { FORCE_BODY: true, SANITIZE_DOM: false };
@@ -169,17 +170,6 @@ const BrewRenderer = (props)=>{
}
};
const printPage = ()=>{
if (window.typeof !== 'undefined') {
window.frames['BrewRenderer'].contentWindow.print();
//Force DOM reflow; Print dialog causes a repaint, and @media print CSS somehow makes out-of-view pages disappear
let node = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0);
node.style.display='none';
node.offsetHeight; // accessing this is enough to trigger a reflow
node.style.display='';
}
};
const frameDidMount = ()=>{ //This triggers when iFrame finishes internal "componentDidMount"
setTimeout(()=>{ //We still see a flicker where the style isn't applied yet, so wait 100ms before showing iFrame
updateSize();