@mathstack/viz 0.0.1-beta.13 → 0.0.1-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ import { TemplatePortal } from '@angular/cdk/portal';
13
13
  import saveAs from 'file-saver';
14
14
  import unparse from 'papaparse';
15
15
  import polylabel from 'polylabel';
16
- import * as domToImage from 'html-to-image';
16
+ import * as domToImage from '@zumer/snapdom';
17
17
 
18
18
  class Marks {
19
19
  ngOnChanges(changes) {
@@ -8276,7 +8276,6 @@ var VicImage;
8276
8276
  })(VicImage || (VicImage = {}));
8277
8277
 
8278
8278
  const DEFAULT$8 = {
8279
- fontEmbedCSS: undefined,
8280
8279
  backgroundColor: '#fff',
8281
8280
  quality: 1,
8282
8281
  };
@@ -8306,43 +8305,15 @@ class VicImageDownloadService {
8306
8305
  constructor() {
8307
8306
  this.domToImage = domToImage;
8308
8307
  }
8309
- /**
8310
- * @param imageConfig
8311
- * @returns fontEmbedCSS -- scans stylesheets for font files and base64 encodes them,
8312
- * reuse this value in imageConfig for subsequent downloads to avoid
8313
- * re-encoding fonts (slight performance boost)
8314
- */
8315
8308
  async downloadImage(imageConfig) {
8316
- let dataUrl;
8317
- if (imageConfig.fontEmbedCSS === undefined) {
8318
- imageConfig.fontEmbedCSS = await domToImage.getFontEmbedCSS(imageConfig.containerNode);
8319
- }
8320
- const sizedImageConfig = {
8321
- ...imageConfig,
8322
- width: imageConfig.containerNode.scrollWidth,
8323
- height: imageConfig.containerNode.scrollHeight,
8324
- };
8325
- switch (imageConfig.imageType) {
8326
- case VicImage.jpeg:
8327
- dataUrl = await this.domToImage.toJpeg(imageConfig.containerNode, sizedImageConfig);
8328
- break;
8329
- case VicImage.png:
8330
- dataUrl = await this.domToImage.toPng(imageConfig.containerNode, sizedImageConfig);
8331
- break;
8332
- case VicImage.svg:
8333
- dataUrl = await this.domToImage.toSvg(imageConfig.containerNode, sizedImageConfig);
8334
- break;
8335
- default:
8336
- break;
8337
- }
8338
- this.createLinkAndClick(dataUrl, `${imageConfig.fileName}.${imageConfig.imageType}`);
8339
- return imageConfig.fontEmbedCSS;
8340
- }
8341
- createLinkAndClick(dataUrl, fileName) {
8342
- const link = document.createElement('a');
8343
- link.download = fileName;
8344
- link.href = dataUrl;
8345
- link.click();
8309
+ const result = await domToImage.snapdom(imageConfig.containerNode, {
8310
+ embedFonts: true,
8311
+ cache: 'full',
8312
+ });
8313
+ await result.download({
8314
+ format: imageConfig.imageType,
8315
+ filename: imageConfig.fileName,
8316
+ });
8346
8317
  }
8347
8318
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: VicImageDownloadService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
8348
8319
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: VicImageDownloadService, providedIn: 'root' }); }