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/index.js
CHANGED
|
@@ -1973,7 +1973,7 @@ var Store = mobxStateTree.types.model('Store', {
|
|
|
1973
1973
|
_toCanvas: function _toCanvas() {
|
|
1974
1974
|
var _arguments = arguments;
|
|
1975
1975
|
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
1976
|
-
var _ref4, _ref4$pixelRatio, pixelRatio, pageId, _ref4$mimeType, mimeType, stage, page, layer, prevX, prevY, prevScaleX, prevScaleY, displayOnlyNodes, transformerNodes, rawCanvas, finalCanvas, ctx;
|
|
1976
|
+
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;
|
|
1977
1977
|
return _regenerator().w(function (_context) {
|
|
1978
1978
|
while (1) switch (_context.n) {
|
|
1979
1979
|
case 0:
|
|
@@ -2004,10 +2004,39 @@ var Store = mobxStateTree.types.model('Store', {
|
|
|
2004
2004
|
}
|
|
2005
2005
|
throw new Error('No layer found in stage for export.');
|
|
2006
2006
|
case 3:
|
|
2007
|
+
// Ensure all fonts used in text elements are fully loaded before rendering.
|
|
2008
|
+
// _autoLoadFonts fires them asynchronously after loadJSON; without this
|
|
2009
|
+
// await the export can run before they arrive, causing the fallback font to
|
|
2010
|
+
// be used which produces garbled / mis-sized text in the output image.
|
|
2011
|
+
fontFamilies = new Set();
|
|
2012
|
+
_collectFonts = function collectFonts(elements) {
|
|
2013
|
+
elements.forEach(function (el) {
|
|
2014
|
+
if (el.type === 'text' && el.fontFamily) fontFamilies.add(el.fontFamily);
|
|
2015
|
+
if (Array.isArray(el.children)) _collectFonts(el.children);
|
|
2016
|
+
});
|
|
2017
|
+
};
|
|
2018
|
+
_collectFonts(page.children || []);
|
|
2019
|
+
if (!(fontFamilies.size > 0)) {
|
|
2020
|
+
_context.n = 4;
|
|
2021
|
+
break;
|
|
2022
|
+
}
|
|
2023
|
+
_context.n = 4;
|
|
2024
|
+
return Promise.allSettled(_toConsumableArray(fontFamilies).flatMap(function (f) {
|
|
2025
|
+
return [document.fonts.load("16px \"".concat(f, "\"")), document.fonts.load("bold 16px \"".concat(f, "\""))];
|
|
2026
|
+
}));
|
|
2027
|
+
case 4:
|
|
2007
2028
|
prevX = layer.x();
|
|
2008
2029
|
prevY = layer.y();
|
|
2009
2030
|
prevScaleX = layer.scaleX();
|
|
2010
|
-
prevScaleY = layer.scaleY();
|
|
2031
|
+
prevScaleY = layer.scaleY(); // Temporarily resize the stage to the exact design dimensions.
|
|
2032
|
+
// The viewport (stage) is usually smaller than the design when the design is
|
|
2033
|
+
// taller/wider than the screen. layer.draw() renders to the stage canvas, so
|
|
2034
|
+
// without this resize any element below stageSize.height would be clipped in
|
|
2035
|
+
// the internal canvas and potentially bleed into the export.
|
|
2036
|
+
prevStageWidth = stage.width();
|
|
2037
|
+
prevStageHeight = stage.height();
|
|
2038
|
+
stage.width(self.width);
|
|
2039
|
+
stage.height(self.height);
|
|
2011
2040
|
layer.x(0);
|
|
2012
2041
|
layer.y(0);
|
|
2013
2042
|
layer.scaleX(1);
|
|
@@ -2039,17 +2068,19 @@ var Store = mobxStateTree.types.model('Store', {
|
|
|
2039
2068
|
return n.show();
|
|
2040
2069
|
});
|
|
2041
2070
|
|
|
2042
|
-
// Restore layer transform
|
|
2071
|
+
// Restore layer transform and stage dimensions
|
|
2043
2072
|
layer.x(prevX);
|
|
2044
2073
|
layer.y(prevY);
|
|
2045
2074
|
layer.scaleX(prevScaleX);
|
|
2046
2075
|
layer.scaleY(prevScaleY);
|
|
2076
|
+
stage.width(prevStageWidth);
|
|
2077
|
+
stage.height(prevStageHeight);
|
|
2047
2078
|
layer.draw();
|
|
2048
2079
|
|
|
2049
2080
|
// For JPEG, composite onto a white canvas to eliminate any remaining transparency
|
|
2050
2081
|
// (avoids black areas and reduces file size vs checkerboard patterns)
|
|
2051
2082
|
if (!(mimeType === 'image/jpeg')) {
|
|
2052
|
-
_context.n =
|
|
2083
|
+
_context.n = 5;
|
|
2053
2084
|
break;
|
|
2054
2085
|
}
|
|
2055
2086
|
finalCanvas = document.createElement('canvas');
|
|
@@ -2060,7 +2091,7 @@ var Store = mobxStateTree.types.model('Store', {
|
|
|
2060
2091
|
ctx.fillRect(0, 0, finalCanvas.width, finalCanvas.height);
|
|
2061
2092
|
ctx.drawImage(rawCanvas, 0, 0);
|
|
2062
2093
|
return _context.a(2, finalCanvas);
|
|
2063
|
-
case
|
|
2094
|
+
case 5:
|
|
2064
2095
|
return _context.a(2, rawCanvas);
|
|
2065
2096
|
}
|
|
2066
2097
|
}, _callee);
|
|
@@ -11290,7 +11321,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
11290
11321
|
case 'radio':
|
|
11291
11322
|
{
|
|
11292
11323
|
var otherSelected = value === '__custom__';
|
|
11293
|
-
return /*#__PURE__*/jsxRuntime.
|
|
11324
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
|
|
11294
11325
|
sx: {
|
|
11295
11326
|
mt: 1,
|
|
11296
11327
|
flex: 1,
|
|
@@ -11311,7 +11342,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
11311
11342
|
background: '#aaa'
|
|
11312
11343
|
}
|
|
11313
11344
|
},
|
|
11314
|
-
children:
|
|
11345
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(material.RadioGroup, {
|
|
11315
11346
|
value: value,
|
|
11316
11347
|
onChange: function onChange(e) {
|
|
11317
11348
|
return setValue(e.target.value);
|
|
@@ -11319,7 +11350,73 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
11319
11350
|
sx: {
|
|
11320
11351
|
gap: 1
|
|
11321
11352
|
},
|
|
11322
|
-
children: [
|
|
11353
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
|
|
11354
|
+
sx: {
|
|
11355
|
+
display: 'flex',
|
|
11356
|
+
flexDirection: 'column'
|
|
11357
|
+
},
|
|
11358
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(material.FormControlLabel, {
|
|
11359
|
+
value: "__custom__",
|
|
11360
|
+
control: /*#__PURE__*/jsxRuntime.jsx(material.Radio, {
|
|
11361
|
+
sx: {
|
|
11362
|
+
color: '#d0d5dd',
|
|
11363
|
+
'&.Mui-checked': {
|
|
11364
|
+
color: accentColor
|
|
11365
|
+
}
|
|
11366
|
+
}
|
|
11367
|
+
}),
|
|
11368
|
+
label: /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
|
|
11369
|
+
sx: {
|
|
11370
|
+
fontSize: 18
|
|
11371
|
+
},
|
|
11372
|
+
children: t('inputFieldsDialog.other', 'Other')
|
|
11373
|
+
}),
|
|
11374
|
+
sx: {
|
|
11375
|
+
m: 0,
|
|
11376
|
+
border: '1px solid',
|
|
11377
|
+
borderColor: otherSelected ? accentColor : '#d0d5dd',
|
|
11378
|
+
borderRadius: otherSelected ? '8px 8px 0 0' : '8px',
|
|
11379
|
+
borderBottom: otherSelected ? 'none' : undefined,
|
|
11380
|
+
px: 2,
|
|
11381
|
+
py: 0.75,
|
|
11382
|
+
transition: 'border-color 0.15s ease, border-radius 0.15s ease',
|
|
11383
|
+
backgroundColor: otherSelected ? 'rgba(13,131,205,0.04)' : 'transparent',
|
|
11384
|
+
'&:hover': {
|
|
11385
|
+
borderColor: accentColor,
|
|
11386
|
+
backgroundColor: 'rgba(13,131,205,0.03)'
|
|
11387
|
+
}
|
|
11388
|
+
}
|
|
11389
|
+
}), otherSelected && /*#__PURE__*/jsxRuntime.jsx(material.TextField, {
|
|
11390
|
+
autoFocus: true,
|
|
11391
|
+
fullWidth: true,
|
|
11392
|
+
value: customRadioValue,
|
|
11393
|
+
onChange: function onChange(e) {
|
|
11394
|
+
return setCustomRadioValue(e.target.value);
|
|
11395
|
+
},
|
|
11396
|
+
onKeyDown: function onKeyDown(e) {
|
|
11397
|
+
if (e.key === 'Enter' && customRadioValue.trim()) handleSubmit();
|
|
11398
|
+
},
|
|
11399
|
+
placeholder: t('inputFieldsDialog.otherPlaceholder', 'Type your answer…'),
|
|
11400
|
+
sx: {
|
|
11401
|
+
'& .MuiOutlinedInput-root': {
|
|
11402
|
+
borderRadius: '0 0 8px 8px',
|
|
11403
|
+
fontSize: 18,
|
|
11404
|
+
'& fieldset': {
|
|
11405
|
+
borderColor: accentColor,
|
|
11406
|
+
borderTopColor: 'transparent'
|
|
11407
|
+
},
|
|
11408
|
+
'&:hover fieldset': {
|
|
11409
|
+
borderColor: accentColor,
|
|
11410
|
+
borderTopColor: 'transparent'
|
|
11411
|
+
},
|
|
11412
|
+
'&.Mui-focused fieldset': {
|
|
11413
|
+
borderColor: accentColor,
|
|
11414
|
+
borderTopColor: 'transparent'
|
|
11415
|
+
}
|
|
11416
|
+
}
|
|
11417
|
+
}
|
|
11418
|
+
})]
|
|
11419
|
+
}), options.map(function (opt) {
|
|
11323
11420
|
return /*#__PURE__*/jsxRuntime.jsx(material.FormControlLabel, {
|
|
11324
11421
|
value: opt,
|
|
11325
11422
|
control: /*#__PURE__*/jsxRuntime.jsx(material.Radio, {
|
|
@@ -11351,68 +11448,8 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
11351
11448
|
}
|
|
11352
11449
|
}
|
|
11353
11450
|
}, opt);
|
|
11354
|
-
}), /*#__PURE__*/jsxRuntime.jsx(material.FormControlLabel, {
|
|
11355
|
-
value: "__custom__",
|
|
11356
|
-
control: /*#__PURE__*/jsxRuntime.jsx(material.Radio, {
|
|
11357
|
-
sx: {
|
|
11358
|
-
color: '#d0d5dd',
|
|
11359
|
-
'&.Mui-checked': {
|
|
11360
|
-
color: accentColor
|
|
11361
|
-
}
|
|
11362
|
-
}
|
|
11363
|
-
}),
|
|
11364
|
-
label: /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
|
|
11365
|
-
sx: {
|
|
11366
|
-
fontSize: 18
|
|
11367
|
-
},
|
|
11368
|
-
children: t('inputFieldsDialog.other', 'Other')
|
|
11369
|
-
}),
|
|
11370
|
-
sx: {
|
|
11371
|
-
m: 0,
|
|
11372
|
-
border: '1px solid',
|
|
11373
|
-
borderColor: otherSelected ? accentColor : '#d0d5dd',
|
|
11374
|
-
borderRadius: otherSelected ? '8px 8px 0 0' : '8px',
|
|
11375
|
-
borderBottom: otherSelected ? 'none' : undefined,
|
|
11376
|
-
px: 2,
|
|
11377
|
-
py: 0.75,
|
|
11378
|
-
transition: 'border-color 0.15s ease, border-radius 0.15s ease',
|
|
11379
|
-
backgroundColor: otherSelected ? 'rgba(13,131,205,0.04)' : 'transparent',
|
|
11380
|
-
'&:hover': {
|
|
11381
|
-
borderColor: accentColor,
|
|
11382
|
-
backgroundColor: 'rgba(13,131,205,0.03)'
|
|
11383
|
-
}
|
|
11384
|
-
}
|
|
11385
11451
|
})]
|
|
11386
|
-
})
|
|
11387
|
-
autoFocus: true,
|
|
11388
|
-
fullWidth: true,
|
|
11389
|
-
value: customRadioValue,
|
|
11390
|
-
onChange: function onChange(e) {
|
|
11391
|
-
return setCustomRadioValue(e.target.value);
|
|
11392
|
-
},
|
|
11393
|
-
onKeyDown: function onKeyDown(e) {
|
|
11394
|
-
if (e.key === 'Enter' && customRadioValue.trim()) handleSubmit();
|
|
11395
|
-
},
|
|
11396
|
-
placeholder: t('inputFieldsDialog.otherPlaceholder', 'Type your answer…'),
|
|
11397
|
-
sx: {
|
|
11398
|
-
'& .MuiOutlinedInput-root': {
|
|
11399
|
-
borderRadius: '0 0 8px 8px',
|
|
11400
|
-
fontSize: 18,
|
|
11401
|
-
'& fieldset': {
|
|
11402
|
-
borderColor: accentColor,
|
|
11403
|
-
borderTopColor: 'transparent'
|
|
11404
|
-
},
|
|
11405
|
-
'&:hover fieldset': {
|
|
11406
|
-
borderColor: accentColor,
|
|
11407
|
-
borderTopColor: 'transparent'
|
|
11408
|
-
},
|
|
11409
|
-
'&.Mui-focused fieldset': {
|
|
11410
|
-
borderColor: accentColor,
|
|
11411
|
-
borderTopColor: 'transparent'
|
|
11412
|
-
}
|
|
11413
|
-
}
|
|
11414
|
-
}
|
|
11415
|
-
})]
|
|
11452
|
+
})
|
|
11416
11453
|
});
|
|
11417
11454
|
}
|
|
11418
11455
|
case 'list':
|