Download wp-calypso/desktop/app/app-handlers/printer/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 857 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/desktop/app/app-handlers/printer/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/desktop/app/app-handlers/printer/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/desktop/app/app-handlers/printer/index.js
857 Bytes
| const { BrowserWindow, ipcMain: ipc } = require( 'electron' ); | |
| const log = require( '../../lib/logger' )( 'desktop:printer' ); | |
| module.exports = function () { | |
| ipc.on( 'print', function ( event, title, contents ) { | |
| let printer = new BrowserWindow( { width: 350, height: 300, title: title } ); | |
| log.info( `Printing contents '${ title }'...` ); | |
| const file = 'data:text/html;charset=UTF-8,' + encodeURIComponent( contents ); | |
| printer.loadURL( file ); | |
| printer.webContents.on( 'dom-ready', function () { | |
| const options = { silent: false }; // ask the user for print settings | |
| setTimeout( function () { | |
| printer.webContents.print( options, ( success, error ) => { | |
| if ( ! success ) { | |
| log.error( 'Failed to print: ', error ); | |
| } | |
| } ); | |
| }, 500 ); | |
| } ); | |
| printer.on( 'closed', function () { | |
| printer = null; | |
| } ); | |
| } ); | |
| }; | |