labellife-design-tool 2.4.3 → 2.4.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.
- package/dist/cjs/canvas/workspace.js +47 -26
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +163 -166
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/store.js +5 -0
- package/dist/cjs/model/store.js.map +1 -1
- package/dist/cjs/side-panel/index.js +67 -131
- package/dist/cjs/side-panel/index.js.map +1 -1
- package/dist/cjs/side-panel/side-panel.js +67 -131
- package/dist/cjs/side-panel/side-panel.js.map +1 -1
- package/dist/cjs/toolbar/toolbar.js +57 -13
- package/dist/cjs/toolbar/toolbar.js.map +1 -1
- package/dist/esm/canvas/workspace.js +47 -26
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +163 -166
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/store.js +5 -0
- package/dist/esm/model/store.js.map +1 -1
- package/dist/esm/side-panel/index.js +67 -131
- package/dist/esm/side-panel/index.js.map +1 -1
- package/dist/esm/side-panel/side-panel.js +67 -131
- package/dist/esm/side-panel/side-panel.js.map +1 -1
- package/dist/esm/toolbar/toolbar.js +57 -13
- package/dist/esm/toolbar/toolbar.js.map +1 -1
- package/package.json +1 -1
|
@@ -398,6 +398,25 @@ if (typeof window !== 'undefined' && !window[INPUT_FIELDS_CONFIG_KEY]) {
|
|
|
398
398
|
window[INPUT_FIELDS_CONFIG_KEY] = {};
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
+
// Cover-fit SIZE (no cropping) for an image of natural size over a box of given size.
|
|
402
|
+
// The image is scaled to the smallest size that fully covers the box, preserving aspect
|
|
403
|
+
// ratio — one dimension matches the box, the other is larger and overflows the box
|
|
404
|
+
// (centered overflow on both sides).
|
|
405
|
+
function coverFitSize(boxWidth, boxHeight, naturalWidth, naturalHeight) {
|
|
406
|
+
var boxAspect = boxWidth / boxHeight;
|
|
407
|
+
var imgAspect = naturalWidth / naturalHeight;
|
|
408
|
+
if (imgAspect > boxAspect) {
|
|
409
|
+
return {
|
|
410
|
+
width: boxHeight * imgAspect,
|
|
411
|
+
height: boxHeight
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
return {
|
|
415
|
+
width: boxWidth,
|
|
416
|
+
height: boxWidth / imgAspect
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
401
420
|
var SliderRow = function SliderRow(_ref) {
|
|
402
421
|
var label = _ref.label,
|
|
403
422
|
value = _ref.value,
|
|
@@ -1165,7 +1184,7 @@ var toolbarBtnSx = {
|
|
|
1165
1184
|
|
|
1166
1185
|
// Image-specific toolbar
|
|
1167
1186
|
var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
1168
|
-
var _store$
|
|
1187
|
+
var _store$_toolbarPanel6, _store$_toolbarPanel7;
|
|
1169
1188
|
var element = _ref5.element,
|
|
1170
1189
|
store = _ref5.store;
|
|
1171
1190
|
var _useState = React.useState(null),
|
|
@@ -1187,6 +1206,11 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
1187
1206
|
setFlipAnchor(null);
|
|
1188
1207
|
};
|
|
1189
1208
|
var handleCrop = function handleCrop() {
|
|
1209
|
+
var _store$_toolbarPanel3;
|
|
1210
|
+
if (((_store$_toolbarPanel3 = store._toolbarPanel) === null || _store$_toolbarPanel3 === void 0 ? void 0 : _store$_toolbarPanel3.type) === 'crop') {
|
|
1211
|
+
store.closeToolbarPanel();
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1190
1214
|
if (!element._naturalWidth || !element._naturalHeight) return;
|
|
1191
1215
|
element.enterCropMode();
|
|
1192
1216
|
if (element._cropModeEnabled) {
|
|
@@ -1194,17 +1218,37 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
1194
1218
|
}
|
|
1195
1219
|
};
|
|
1196
1220
|
var handleFitToPage = function handleFitToPage() {
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1221
|
+
// Cover-fit: scale the photo (preserving aspect ratio, never stretched) to the
|
|
1222
|
+
// smallest size that fully covers the page, centered. No crop is applied — if the
|
|
1223
|
+
// aspect ratio doesn't match the page, the image simply overflows the page bounds
|
|
1224
|
+
// on two sides (same as manually resizing it to cover), rather than permanently
|
|
1225
|
+
// cropping away image data.
|
|
1226
|
+
var updates = {
|
|
1227
|
+
cropX: 0,
|
|
1228
|
+
cropY: 0,
|
|
1229
|
+
cropWidth: 1,
|
|
1230
|
+
cropHeight: 1
|
|
1231
|
+
};
|
|
1232
|
+
if (element._naturalWidth && element._naturalHeight) {
|
|
1233
|
+
var _coverFitSize = coverFitSize(store.width, store.height, element._naturalWidth, element._naturalHeight),
|
|
1234
|
+
width = _coverFitSize.width,
|
|
1235
|
+
height = _coverFitSize.height;
|
|
1236
|
+
updates.width = width;
|
|
1237
|
+
updates.height = height;
|
|
1238
|
+
updates.x = (store.width - width) / 2;
|
|
1239
|
+
updates.y = (store.height - height) / 2;
|
|
1240
|
+
} else {
|
|
1241
|
+
updates.x = 0;
|
|
1242
|
+
updates.y = 0;
|
|
1243
|
+
updates.width = store.width;
|
|
1244
|
+
updates.height = store.height;
|
|
1245
|
+
}
|
|
1246
|
+
element.set(updates);
|
|
1203
1247
|
store.history.addUndoState();
|
|
1204
1248
|
};
|
|
1205
1249
|
var handleEffects = function handleEffects() {
|
|
1206
|
-
var _store$
|
|
1207
|
-
if (((_store$
|
|
1250
|
+
var _store$_toolbarPanel4;
|
|
1251
|
+
if (((_store$_toolbarPanel4 = store._toolbarPanel) === null || _store$_toolbarPanel4 === void 0 ? void 0 : _store$_toolbarPanel4.type) === 'effects') {
|
|
1208
1252
|
store.closeToolbarPanel();
|
|
1209
1253
|
} else {
|
|
1210
1254
|
store.openToolbarPanel('effects');
|
|
@@ -1217,8 +1261,8 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
1217
1261
|
});
|
|
1218
1262
|
store.history.addUndoState();
|
|
1219
1263
|
} else {
|
|
1220
|
-
var _store$
|
|
1221
|
-
if (((_store$
|
|
1264
|
+
var _store$_toolbarPanel5;
|
|
1265
|
+
if (((_store$_toolbarPanel5 = store._toolbarPanel) === null || _store$_toolbarPanel5 === void 0 ? void 0 : _store$_toolbarPanel5.type) === 'mask') {
|
|
1222
1266
|
store.closeToolbarPanel();
|
|
1223
1267
|
} else {
|
|
1224
1268
|
store.openToolbarPanel('mask');
|
|
@@ -1296,7 +1340,7 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
1296
1340
|
})]
|
|
1297
1341
|
}), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
1298
1342
|
size: "small",
|
|
1299
|
-
sx: _objectSpread2(_objectSpread2({}, toolbarBtnSx), ((_store$
|
|
1343
|
+
sx: _objectSpread2(_objectSpread2({}, toolbarBtnSx), ((_store$_toolbarPanel6 = store._toolbarPanel) === null || _store$_toolbarPanel6 === void 0 ? void 0 : _store$_toolbarPanel6.type) === 'effects' ? {
|
|
1300
1344
|
backgroundColor: '#e3f2fd',
|
|
1301
1345
|
color: '#0d83cd'
|
|
1302
1346
|
} : {}),
|
|
@@ -1316,7 +1360,7 @@ var ImageToolbar = mobxReactLite.observer(function (_ref5) {
|
|
|
1316
1360
|
size: "small",
|
|
1317
1361
|
sx: _objectSpread2(_objectSpread2(_objectSpread2({}, toolbarBtnSx), hasMask ? {
|
|
1318
1362
|
color: '#d32f2f'
|
|
1319
|
-
} : {}), ((_store$
|
|
1363
|
+
} : {}), ((_store$_toolbarPanel7 = store._toolbarPanel) === null || _store$_toolbarPanel7 === void 0 ? void 0 : _store$_toolbarPanel7.type) === 'mask' ? {
|
|
1320
1364
|
backgroundColor: '#e3f2fd',
|
|
1321
1365
|
color: '#0d83cd'
|
|
1322
1366
|
} : {}),
|