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
|
@@ -394,6 +394,25 @@ if (typeof window !== 'undefined' && !window[INPUT_FIELDS_CONFIG_KEY]) {
|
|
|
394
394
|
window[INPUT_FIELDS_CONFIG_KEY] = {};
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
+
// Cover-fit SIZE (no cropping) for an image of natural size over a box of given size.
|
|
398
|
+
// The image is scaled to the smallest size that fully covers the box, preserving aspect
|
|
399
|
+
// ratio — one dimension matches the box, the other is larger and overflows the box
|
|
400
|
+
// (centered overflow on both sides).
|
|
401
|
+
function coverFitSize(boxWidth, boxHeight, naturalWidth, naturalHeight) {
|
|
402
|
+
var boxAspect = boxWidth / boxHeight;
|
|
403
|
+
var imgAspect = naturalWidth / naturalHeight;
|
|
404
|
+
if (imgAspect > boxAspect) {
|
|
405
|
+
return {
|
|
406
|
+
width: boxHeight * imgAspect,
|
|
407
|
+
height: boxHeight
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
width: boxWidth,
|
|
412
|
+
height: boxWidth / imgAspect
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
|
|
397
416
|
var SliderRow = function SliderRow(_ref) {
|
|
398
417
|
var label = _ref.label,
|
|
399
418
|
value = _ref.value,
|
|
@@ -1161,7 +1180,7 @@ var toolbarBtnSx = {
|
|
|
1161
1180
|
|
|
1162
1181
|
// Image-specific toolbar
|
|
1163
1182
|
var ImageToolbar = observer(function (_ref5) {
|
|
1164
|
-
var _store$
|
|
1183
|
+
var _store$_toolbarPanel6, _store$_toolbarPanel7;
|
|
1165
1184
|
var element = _ref5.element,
|
|
1166
1185
|
store = _ref5.store;
|
|
1167
1186
|
var _useState = useState(null),
|
|
@@ -1183,6 +1202,11 @@ var ImageToolbar = observer(function (_ref5) {
|
|
|
1183
1202
|
setFlipAnchor(null);
|
|
1184
1203
|
};
|
|
1185
1204
|
var handleCrop = function handleCrop() {
|
|
1205
|
+
var _store$_toolbarPanel3;
|
|
1206
|
+
if (((_store$_toolbarPanel3 = store._toolbarPanel) === null || _store$_toolbarPanel3 === void 0 ? void 0 : _store$_toolbarPanel3.type) === 'crop') {
|
|
1207
|
+
store.closeToolbarPanel();
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1186
1210
|
if (!element._naturalWidth || !element._naturalHeight) return;
|
|
1187
1211
|
element.enterCropMode();
|
|
1188
1212
|
if (element._cropModeEnabled) {
|
|
@@ -1190,17 +1214,37 @@ var ImageToolbar = observer(function (_ref5) {
|
|
|
1190
1214
|
}
|
|
1191
1215
|
};
|
|
1192
1216
|
var handleFitToPage = function handleFitToPage() {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1217
|
+
// Cover-fit: scale the photo (preserving aspect ratio, never stretched) to the
|
|
1218
|
+
// smallest size that fully covers the page, centered. No crop is applied — if the
|
|
1219
|
+
// aspect ratio doesn't match the page, the image simply overflows the page bounds
|
|
1220
|
+
// on two sides (same as manually resizing it to cover), rather than permanently
|
|
1221
|
+
// cropping away image data.
|
|
1222
|
+
var updates = {
|
|
1223
|
+
cropX: 0,
|
|
1224
|
+
cropY: 0,
|
|
1225
|
+
cropWidth: 1,
|
|
1226
|
+
cropHeight: 1
|
|
1227
|
+
};
|
|
1228
|
+
if (element._naturalWidth && element._naturalHeight) {
|
|
1229
|
+
var _coverFitSize = coverFitSize(store.width, store.height, element._naturalWidth, element._naturalHeight),
|
|
1230
|
+
width = _coverFitSize.width,
|
|
1231
|
+
height = _coverFitSize.height;
|
|
1232
|
+
updates.width = width;
|
|
1233
|
+
updates.height = height;
|
|
1234
|
+
updates.x = (store.width - width) / 2;
|
|
1235
|
+
updates.y = (store.height - height) / 2;
|
|
1236
|
+
} else {
|
|
1237
|
+
updates.x = 0;
|
|
1238
|
+
updates.y = 0;
|
|
1239
|
+
updates.width = store.width;
|
|
1240
|
+
updates.height = store.height;
|
|
1241
|
+
}
|
|
1242
|
+
element.set(updates);
|
|
1199
1243
|
store.history.addUndoState();
|
|
1200
1244
|
};
|
|
1201
1245
|
var handleEffects = function handleEffects() {
|
|
1202
|
-
var _store$
|
|
1203
|
-
if (((_store$
|
|
1246
|
+
var _store$_toolbarPanel4;
|
|
1247
|
+
if (((_store$_toolbarPanel4 = store._toolbarPanel) === null || _store$_toolbarPanel4 === void 0 ? void 0 : _store$_toolbarPanel4.type) === 'effects') {
|
|
1204
1248
|
store.closeToolbarPanel();
|
|
1205
1249
|
} else {
|
|
1206
1250
|
store.openToolbarPanel('effects');
|
|
@@ -1213,8 +1257,8 @@ var ImageToolbar = observer(function (_ref5) {
|
|
|
1213
1257
|
});
|
|
1214
1258
|
store.history.addUndoState();
|
|
1215
1259
|
} else {
|
|
1216
|
-
var _store$
|
|
1217
|
-
if (((_store$
|
|
1260
|
+
var _store$_toolbarPanel5;
|
|
1261
|
+
if (((_store$_toolbarPanel5 = store._toolbarPanel) === null || _store$_toolbarPanel5 === void 0 ? void 0 : _store$_toolbarPanel5.type) === 'mask') {
|
|
1218
1262
|
store.closeToolbarPanel();
|
|
1219
1263
|
} else {
|
|
1220
1264
|
store.openToolbarPanel('mask');
|
|
@@ -1292,7 +1336,7 @@ var ImageToolbar = observer(function (_ref5) {
|
|
|
1292
1336
|
})]
|
|
1293
1337
|
}), /*#__PURE__*/jsx(Button, {
|
|
1294
1338
|
size: "small",
|
|
1295
|
-
sx: _objectSpread2(_objectSpread2({}, toolbarBtnSx), ((_store$
|
|
1339
|
+
sx: _objectSpread2(_objectSpread2({}, toolbarBtnSx), ((_store$_toolbarPanel6 = store._toolbarPanel) === null || _store$_toolbarPanel6 === void 0 ? void 0 : _store$_toolbarPanel6.type) === 'effects' ? {
|
|
1296
1340
|
backgroundColor: '#e3f2fd',
|
|
1297
1341
|
color: '#0d83cd'
|
|
1298
1342
|
} : {}),
|
|
@@ -1312,7 +1356,7 @@ var ImageToolbar = observer(function (_ref5) {
|
|
|
1312
1356
|
size: "small",
|
|
1313
1357
|
sx: _objectSpread2(_objectSpread2(_objectSpread2({}, toolbarBtnSx), hasMask ? {
|
|
1314
1358
|
color: '#d32f2f'
|
|
1315
|
-
} : {}), ((_store$
|
|
1359
|
+
} : {}), ((_store$_toolbarPanel7 = store._toolbarPanel) === null || _store$_toolbarPanel7 === void 0 ? void 0 : _store$_toolbarPanel7.type) === 'mask' ? {
|
|
1316
1360
|
backgroundColor: '#e3f2fd',
|
|
1317
1361
|
color: '#0d83cd'
|
|
1318
1362
|
} : {}),
|