@mathstack/viz 2.3.0 → 2.3.2
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
|
|
16
|
+
import { snapdom } 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
|
};
|
|
@@ -8303,46 +8302,27 @@ class VicSvgImageConfig {
|
|
|
8303
8302
|
}
|
|
8304
8303
|
|
|
8305
8304
|
class VicImageDownloadService {
|
|
8306
|
-
constructor() {
|
|
8307
|
-
this.domToImage = domToImage;
|
|
8308
|
-
}
|
|
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
8305
|
async downloadImage(imageConfig) {
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8306
|
+
const options = {
|
|
8307
|
+
fast: true,
|
|
8308
|
+
filterMode: 'remove',
|
|
8309
|
+
filter: (domNode) => {
|
|
8310
|
+
if (getComputedStyle(domNode).display === 'none') {
|
|
8311
|
+
return false;
|
|
8312
|
+
}
|
|
8313
|
+
return imageConfig.filter ? imageConfig.filter(domNode) : true;
|
|
8314
|
+
},
|
|
8315
|
+
backgroundColor: imageConfig.backgroundColor,
|
|
8324
8316
|
};
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
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();
|
|
8317
|
+
if (!imageConfig.backgroundColor) {
|
|
8318
|
+
delete options.backgroundColor;
|
|
8319
|
+
}
|
|
8320
|
+
const result = await snapdom(imageConfig.containerNode, options);
|
|
8321
|
+
await result.download({
|
|
8322
|
+
format: imageConfig.imageType,
|
|
8323
|
+
filename: imageConfig.fileName,
|
|
8324
|
+
quality: imageConfig.quality,
|
|
8325
|
+
});
|
|
8346
8326
|
}
|
|
8347
8327
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: VicImageDownloadService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
8348
8328
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: VicImageDownloadService, providedIn: 'root' }); }
|