labellife-design-tool 2.3.5 → 2.3.7
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.
- package/dist/cjs/canvas/workspace.js +70 -64
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +106 -69
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/store.js +36 -5
- package/dist/cjs/model/store.js.map +1 -1
- package/dist/esm/canvas/workspace.js +70 -64
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +106 -69
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/store.js +36 -5
- package/dist/esm/model/store.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/model/store.js
CHANGED
|
@@ -1901,7 +1901,7 @@ 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, _ref4$mimeType, mimeType, stage, page, layer, prevX, prevY, prevScaleX, prevScaleY, displayOnlyNodes, transformerNodes, rawCanvas, finalCanvas, ctx;
|
|
1904
|
+
var _ref4, _ref4$pixelRatio, pixelRatio, pageId, _ref4$mimeType, mimeType, stage, page, layer, fontFamilies, _collectFonts, prevX, prevY, prevScaleX, prevScaleY, prevStageWidth, prevStageHeight, displayOnlyNodes, transformerNodes, rawCanvas, finalCanvas, ctx;
|
|
1905
1905
|
return _regenerator().w(function (_context) {
|
|
1906
1906
|
while (1) switch (_context.n) {
|
|
1907
1907
|
case 0:
|
|
@@ -1932,10 +1932,39 @@ var Store = mobxStateTree.types.model('Store', {
|
|
|
1932
1932
|
}
|
|
1933
1933
|
throw new Error('No layer found in stage for export.');
|
|
1934
1934
|
case 3:
|
|
1935
|
+
// Ensure all fonts used in text elements are fully loaded before rendering.
|
|
1936
|
+
// _autoLoadFonts fires them asynchronously after loadJSON; without this
|
|
1937
|
+
// await the export can run before they arrive, causing the fallback font to
|
|
1938
|
+
// be used which produces garbled / mis-sized text in the output image.
|
|
1939
|
+
fontFamilies = new Set();
|
|
1940
|
+
_collectFonts = function collectFonts(elements) {
|
|
1941
|
+
elements.forEach(function (el) {
|
|
1942
|
+
if (el.type === 'text' && el.fontFamily) fontFamilies.add(el.fontFamily);
|
|
1943
|
+
if (Array.isArray(el.children)) _collectFonts(el.children);
|
|
1944
|
+
});
|
|
1945
|
+
};
|
|
1946
|
+
_collectFonts(page.children || []);
|
|
1947
|
+
if (!(fontFamilies.size > 0)) {
|
|
1948
|
+
_context.n = 4;
|
|
1949
|
+
break;
|
|
1950
|
+
}
|
|
1951
|
+
_context.n = 4;
|
|
1952
|
+
return Promise.allSettled(_toConsumableArray(fontFamilies).flatMap(function (f) {
|
|
1953
|
+
return [document.fonts.load("16px \"".concat(f, "\"")), document.fonts.load("bold 16px \"".concat(f, "\""))];
|
|
1954
|
+
}));
|
|
1955
|
+
case 4:
|
|
1935
1956
|
prevX = layer.x();
|
|
1936
1957
|
prevY = layer.y();
|
|
1937
1958
|
prevScaleX = layer.scaleX();
|
|
1938
|
-
prevScaleY = layer.scaleY();
|
|
1959
|
+
prevScaleY = layer.scaleY(); // Temporarily resize the stage to the exact design dimensions.
|
|
1960
|
+
// The viewport (stage) is usually smaller than the design when the design is
|
|
1961
|
+
// taller/wider than the screen. layer.draw() renders to the stage canvas, so
|
|
1962
|
+
// without this resize any element below stageSize.height would be clipped in
|
|
1963
|
+
// the internal canvas and potentially bleed into the export.
|
|
1964
|
+
prevStageWidth = stage.width();
|
|
1965
|
+
prevStageHeight = stage.height();
|
|
1966
|
+
stage.width(self.width);
|
|
1967
|
+
stage.height(self.height);
|
|
1939
1968
|
layer.x(0);
|
|
1940
1969
|
layer.y(0);
|
|
1941
1970
|
layer.scaleX(1);
|
|
@@ -1967,17 +1996,19 @@ var Store = mobxStateTree.types.model('Store', {
|
|
|
1967
1996
|
return n.show();
|
|
1968
1997
|
});
|
|
1969
1998
|
|
|
1970
|
-
// Restore layer transform
|
|
1999
|
+
// Restore layer transform and stage dimensions
|
|
1971
2000
|
layer.x(prevX);
|
|
1972
2001
|
layer.y(prevY);
|
|
1973
2002
|
layer.scaleX(prevScaleX);
|
|
1974
2003
|
layer.scaleY(prevScaleY);
|
|
2004
|
+
stage.width(prevStageWidth);
|
|
2005
|
+
stage.height(prevStageHeight);
|
|
1975
2006
|
layer.draw();
|
|
1976
2007
|
|
|
1977
2008
|
// For JPEG, composite onto a white canvas to eliminate any remaining transparency
|
|
1978
2009
|
// (avoids black areas and reduces file size vs checkerboard patterns)
|
|
1979
2010
|
if (!(mimeType === 'image/jpeg')) {
|
|
1980
|
-
_context.n =
|
|
2011
|
+
_context.n = 5;
|
|
1981
2012
|
break;
|
|
1982
2013
|
}
|
|
1983
2014
|
finalCanvas = document.createElement('canvas');
|
|
@@ -1988,7 +2019,7 @@ var Store = mobxStateTree.types.model('Store', {
|
|
|
1988
2019
|
ctx.fillRect(0, 0, finalCanvas.width, finalCanvas.height);
|
|
1989
2020
|
ctx.drawImage(rawCanvas, 0, 0);
|
|
1990
2021
|
return _context.a(2, finalCanvas);
|
|
1991
|
-
case
|
|
2022
|
+
case 5:
|
|
1992
2023
|
return _context.a(2, rawCanvas);
|
|
1993
2024
|
}
|
|
1994
2025
|
}, _callee);
|