@configuratorware/configurator-frontendgui 1.31.12 → 1.31.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.
@@ -170,9 +170,10 @@ var showVectorizeImageQuality = function showVectorizeImageQuality(imageToAnalys
170
170
 
171
171
  if (imageToAnalyse) {
172
172
  var pixelsInTheImage = (0, _get["default"])(imageToAnalyse, 'original.width', 0) * (0, _get["default"])(imageToAnalyse, 'original.height', 0);
173
- var hasFormatSVG = (0, _get["default"])(imageToAnalyse, 'original.format', '').toLowerCase() === 'svg';
173
+ var vectorFormats = ['ai', 'pdf', 'svg', 'eps', 'ps', 'ept'];
174
+ var hasVectorFormat = vectorFormats.indexOf((0, _get["default"])(imageToAnalyse, 'original.format', '').toLowerCase()) > -1;
174
175
  var pixelsOfReference = minimumPixelAmount || (0, _configuration.getConf)('vectorizeImageQuality');
175
- return !hasFormatSVG && pixelsInTheImage < pixelsOfReference;
176
+ return !hasVectorFormat && pixelsInTheImage < pixelsOfReference;
176
177
  }
177
178
 
178
179
  return false;
@@ -450,6 +450,8 @@ var applySvgContentOperations = function applySvgContentOperations(preview, oper
450
450
 
451
451
  if (svgTags && svgTags[0]) {
452
452
  var svgTag = svgTags[0];
453
+ var percentageHeight = /height=["']\d+%["']/;
454
+ var percentageWidth = /width=["']\d+%["']/;
453
455
 
454
456
  if (svgTag.indexOf('viewBox=') === -1) {
455
457
  svgContent = svgContent.replace('<svg', "<svg viewBox=\"0 0 ".concat(preview.width, " ").concat(preview.height, "\""));
@@ -462,7 +464,18 @@ var applySvgContentOperations = function applySvgContentOperations(preview, oper
462
464
  if (svgTag.indexOf('width=') === -1) {
463
465
  svgContent = svgContent.replace('<svg', "<svg width=\"".concat(preview.width, "px\""));
464
466
  }
465
- }
467
+
468
+ if (percentageHeight.test(svgTag)) {
469
+ svgContent = svgContent.replace(percentageHeight, "height=\"".concat(preview.height, "px\""));
470
+ }
471
+
472
+ if (percentageWidth.test(svgTag)) {
473
+ svgContent = svgContent.replace(percentageWidth, "width=\"".concat(preview.width, "px\""));
474
+ }
475
+ } // remove doctype if present
476
+
477
+
478
+ svgContent = svgContent.replace(/<!DOCTYPE(?:(?!>)[\s\S])*>/gi, '');
466
479
 
467
480
  if (operations && operations.vectorize && operations.vectorizeColorsMap && Object.keys(operations.vectorizeColorsMap).length) {
468
481
  var colorRegex = new RegExp("(".concat(Object.keys(operations.vectorizeColorsMap).join('|'), ")"), 'ig');
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@configuratorware/configurator-frontendgui",
3
- "version": "1.31.12",
3
+ "version": "1.31.14",
4
4
  "license": "UNLICENSED",
5
5
  "private": false,
6
6
  "main": "./index.js",
7
7
  "dependencies": {
8
8
  "@babel/polyfill": "^7.12.1",
9
- "@configuratorware/scripts": "1.31.12",
9
+ "@configuratorware/scripts": "1.31.14",
10
10
  "@hot-loader/react-dom": "^17.0.1",
11
11
  "@material-ui/core": "^4.12.2",
12
12
  "@material-ui/icons": "^4.11.2",
@@ -39,8 +39,8 @@
39
39
  "react-router-dom": "^5.2.0",
40
40
  "react-swipeable": "^5.5.1",
41
41
  "react-zoom-pan-pinch": "^2.1.3",
42
- "redhotmagma-graphics-editor": "1.31.12",
43
- "redhotmagma-visualization": "1.31.12",
42
+ "redhotmagma-graphics-editor": "1.31.14",
43
+ "redhotmagma-visualization": "1.31.14",
44
44
  "redux": "^4.1.0",
45
45
  "redux-logger": "^3.0.6",
46
46
  "redux-persist": "^5.10.0",
@@ -119,10 +119,12 @@ export const showVectorizeImageQuality = (imageToAnalyse, minimumPixelAmount = n
119
119
  if (imageToAnalyse) {
120
120
  const pixelsInTheImage =
121
121
  get(imageToAnalyse, 'original.width', 0) * get(imageToAnalyse, 'original.height', 0);
122
- const hasFormatSVG = get(imageToAnalyse, 'original.format', '').toLowerCase() === 'svg';
122
+ const vectorFormats = ['ai', 'pdf', 'svg', 'eps', 'ps', 'ept'];
123
+ const hasVectorFormat =
124
+ vectorFormats.indexOf(get(imageToAnalyse, 'original.format', '').toLowerCase()) > -1;
123
125
  const pixelsOfReference = minimumPixelAmount || getConf('vectorizeImageQuality');
124
126
 
125
- return !hasFormatSVG && pixelsInTheImage < pixelsOfReference;
127
+ return !hasVectorFormat && pixelsInTheImage < pixelsOfReference;
126
128
  }
127
129
  return false;
128
130
  };
@@ -397,6 +397,8 @@ export const applySvgContentOperations = (preview, operations, svgContent) => {
397
397
 
398
398
  if (svgTags && svgTags[0]) {
399
399
  const svgTag = svgTags[0];
400
+ const percentageHeight = /height=["']\d+%["']/;
401
+ const percentageWidth = /width=["']\d+%["']/;
400
402
 
401
403
  if (svgTag.indexOf('viewBox=') === -1) {
402
404
  svgContent = svgContent.replace('<svg', `<svg viewBox="0 0 ${preview.width} ${preview.height}"`);
@@ -409,8 +411,19 @@ export const applySvgContentOperations = (preview, operations, svgContent) => {
409
411
  if (svgTag.indexOf('width=') === -1) {
410
412
  svgContent = svgContent.replace('<svg', `<svg width="${preview.width}px"`);
411
413
  }
414
+
415
+ if (percentageHeight.test(svgTag)) {
416
+ svgContent = svgContent.replace(percentageHeight, `height="${preview.height}px"`);
417
+ }
418
+
419
+ if (percentageWidth.test(svgTag)) {
420
+ svgContent = svgContent.replace(percentageWidth, `width="${preview.width}px"`);
421
+ }
412
422
  }
413
423
 
424
+ // remove doctype if present
425
+ svgContent = svgContent.replace(/<!DOCTYPE[^>]*>/gis, '');
426
+
414
427
  if (
415
428
  operations &&
416
429
  operations.vectorize &&