export function parseHTMLToDataURL ( html , opts ) { const { width , height } = opts ; return new Promise ( ( resolve , reject ) => { const _svg = `
    <svg xmlns="http://www.w3.org/2000/svg" width="${ width || '' }" height = "${ height || '' }">
      <foreignObject width="100%" height="100%">
        <div xmlns = "http://www.w3.org/1999/xhtml">
          ${ html }
        </div>
      </foreignObject>
    </svg>
    ` ; const blob = new Blob ( [ _svg ] , { type : 'image/svg+xml;charset=utf-8' } ) ; const reader = new FileReader ( ) ; reader . readAsDataURL ( blob ) ; reader . onload = function ( event ) { const base64 = event ?. target ?. result as string ; resolve ( base64 ) ; } ; reader . onerror = function ( err ) { reject ( err ) ; } ; } ) ; } export function parseSVGToDataURL ( svg ) { return new Promise ( ( resolve , reject ) => { const _svg = svg ; const blob = new Blob ( [ _svg ] , { type : 'image/svg+xml;charset=utf-8' } ) ; const reader = new FileReader ( ) ; reader . readAsDataURL ( blob ) ; reader . onload = function ( event ) { const base64 = event ?. target ?. result as string ; resolve ( base64 ) ; } ; reader . onerror = function ( err ) { reject ( err ) ; } ; } ) ; }