import html2canvas from "html2canvas" ; const SCREENSHOT_IMAGE_MIME_TYPE = "image/png" ; const SCREENSHOT_IMAGE_MIME_TYPE_EXTENSION = "png" ; param el param filenameBase param options return export const createScreenshot = async ( el , filenameBase , options ) : Promise < File > => { const canvas = await html2canvas ( el , { scale : options . scale , onclone : options . onClone , } ) ; const fileName = `${ filenameBase }.${ SCREENSHOT_IMAGE_MIME_TYPE_EXTENSION }` ; return new Promise ( ( resolve , reject ) => { canvas . toBlob ( ( blob ) => { if ( blob == null ) { reject ( new TypeError ( "Could not convert canvas to blob." ) ) ; } resolve ( new File ( [ blob ! ] , fileName , { type : blob ! . type , } ) ) ; } , SCREENSHOT_IMAGE_MIME_TYPE ) ; } ) ; } ;