labellife-design-tool 2.2.3 → 2.2.5

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.
@@ -1901,11 +1901,11 @@ var Store = mobxStateTree.types.model('Store', {
1901
1901
  _toCanvas: function _toCanvas() {
1902
1902
  var _arguments = arguments;
1903
1903
  return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1904
- var _ref4, _ref4$pixelRatio, pixelRatio, pageId, stage, page, layer, prevX, prevY, prevScaleX, prevScaleY, canvas;
1904
+ var _ref4, _ref4$pixelRatio, pixelRatio, pageId, _ref4$mimeType, mimeType, stage, page, layer, prevX, prevY, prevScaleX, prevScaleY, displayOnlyNodes, rawCanvas, finalCanvas, ctx;
1905
1905
  return _regenerator().w(function (_context) {
1906
1906
  while (1) switch (_context.n) {
1907
1907
  case 0:
1908
- _ref4 = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {}, _ref4$pixelRatio = _ref4.pixelRatio, pixelRatio = _ref4$pixelRatio === void 0 ? 1 : _ref4$pixelRatio, _ref4.ignoreBackground, pageId = _ref4.pageId, _ref4.mimeType, _ref4.includeBleed, _ref4._skipTimeout, _ref4.quickMode;
1908
+ _ref4 = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {}, _ref4$pixelRatio = _ref4.pixelRatio, pixelRatio = _ref4$pixelRatio === void 0 ? 1 : _ref4$pixelRatio, _ref4.ignoreBackground, pageId = _ref4.pageId, _ref4$mimeType = _ref4.mimeType, mimeType = _ref4$mimeType === void 0 ? 'image/png' : _ref4$mimeType, _ref4.includeBleed, _ref4._skipTimeout, _ref4.quickMode;
1909
1909
  stage = self._stageRef;
1910
1910
  if (stage) {
1911
1911
  _context.n = 1;
@@ -1940,20 +1940,47 @@ var Store = mobxStateTree.types.model('Store', {
1940
1940
  layer.y(0);
1941
1941
  layer.scaleX(1);
1942
1942
  layer.scaleY(1);
1943
+
1944
+ // Hide display-only nodes (shadow, checkerboard, overlay) — not wanted in export
1945
+ displayOnlyNodes = layer.find('.display-only');
1946
+ displayOnlyNodes.forEach(function (n) {
1947
+ return n.hide();
1948
+ });
1943
1949
  layer.draw();
1944
- canvas = layer.toCanvas({
1950
+ rawCanvas = layer.toCanvas({
1945
1951
  pixelRatio: pixelRatio,
1946
1952
  x: 0,
1947
1953
  y: 0,
1948
1954
  width: self.width,
1949
1955
  height: self.height
1950
- }); // Restore
1956
+ }); // Restore display-only nodes
1957
+ displayOnlyNodes.forEach(function (n) {
1958
+ return n.show();
1959
+ });
1960
+
1961
+ // Restore layer transform
1951
1962
  layer.x(prevX);
1952
1963
  layer.y(prevY);
1953
1964
  layer.scaleX(prevScaleX);
1954
1965
  layer.scaleY(prevScaleY);
1955
1966
  layer.draw();
1956
- return _context.a(2, canvas);
1967
+
1968
+ // For JPEG, composite onto a white canvas to eliminate any remaining transparency
1969
+ // (avoids black areas and reduces file size vs checkerboard patterns)
1970
+ if (!(mimeType === 'image/jpeg')) {
1971
+ _context.n = 4;
1972
+ break;
1973
+ }
1974
+ finalCanvas = document.createElement('canvas');
1975
+ finalCanvas.width = rawCanvas.width;
1976
+ finalCanvas.height = rawCanvas.height;
1977
+ ctx = finalCanvas.getContext('2d');
1978
+ ctx.fillStyle = '#ffffff';
1979
+ ctx.fillRect(0, 0, finalCanvas.width, finalCanvas.height);
1980
+ ctx.drawImage(rawCanvas, 0, 0);
1981
+ return _context.a(2, finalCanvas);
1982
+ case 4:
1983
+ return _context.a(2, rawCanvas);
1957
1984
  }
1958
1985
  }, _callee);
1959
1986
  }))();
@@ -1984,7 +2011,7 @@ var Store = mobxStateTree.types.model('Store', {
1984
2011
  return _regenerator().w(function (_context3) {
1985
2012
  while (1) switch (_context3.n) {
1986
2013
  case 0:
1987
- _ref6 = _arguments3.length > 0 && _arguments3[0] !== undefined ? _arguments3[0] : {}, _ref6$mimeType = _ref6.mimeType, mimeType = _ref6$mimeType === void 0 ? 'image/png' : _ref6$mimeType, _ref6$quality = _ref6.quality, quality = _ref6$quality === void 0 ? 1 : _ref6$quality, rest = _objectWithoutProperties(_ref6, _excluded2);
2014
+ _ref6 = _arguments3.length > 0 && _arguments3[0] !== undefined ? _arguments3[0] : {}, _ref6$mimeType = _ref6.mimeType, mimeType = _ref6$mimeType === void 0 ? 'image/png' : _ref6$mimeType, _ref6$quality = _ref6.quality, quality = _ref6$quality === void 0 ? 0.92 : _ref6$quality, rest = _objectWithoutProperties(_ref6, _excluded2);
1988
2015
  _context3.n = 1;
1989
2016
  return self._toCanvas(_objectSpread2({
1990
2017
  mimeType: mimeType