labellife-design-tool 2.4.5 → 2.4.6
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 +33 -9
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +33 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/canvas/workspace.js +33 -9
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +33 -9
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1238,6 +1238,18 @@ function computeCurvedCacheBounds(element) {
|
|
|
1238
1238
|
height: declaredHeight + maxSagitta * 2
|
|
1239
1239
|
};
|
|
1240
1240
|
}
|
|
1241
|
+
|
|
1242
|
+
// Sync a newly measured/computed height onto the element while keeping its
|
|
1243
|
+
// vertical center fixed — grows/shrinks equally above and below the original
|
|
1244
|
+
// position, instead of anchoring the top edge and only ever expanding downward.
|
|
1245
|
+
function syncHeightKeepingCenter(element, newHeight) {
|
|
1246
|
+
if (Math.abs(newHeight - element.height) <= 1) return;
|
|
1247
|
+
var deltaY = (newHeight - element.height) / 2;
|
|
1248
|
+
element.set({
|
|
1249
|
+
height: newHeight,
|
|
1250
|
+
y: element.y - deltaY
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1241
1253
|
var TextElementComponent = observer(function (_ref) {
|
|
1242
1254
|
var _element$backgroundOp;
|
|
1243
1255
|
var element = _ref.element;
|
|
@@ -1248,6 +1260,7 @@ var TextElementComponent = observer(function (_ref) {
|
|
|
1248
1260
|
groupChild = _ref.groupChild;
|
|
1249
1261
|
var groupRef = useRef(null);
|
|
1250
1262
|
var textRef = useRef(null);
|
|
1263
|
+
var textareaRef = useRef(null);
|
|
1251
1264
|
var _useState = useState(element.height || 50),
|
|
1252
1265
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1253
1266
|
textHeight = _useState2[0],
|
|
@@ -1276,9 +1289,7 @@ var TextElementComponent = observer(function (_ref) {
|
|
|
1276
1289
|
var h = node.height();
|
|
1277
1290
|
if (h > 0) {
|
|
1278
1291
|
setTextHeight(h);
|
|
1279
|
-
|
|
1280
|
-
height: h
|
|
1281
|
-
});
|
|
1292
|
+
syncHeightKeepingCenter(element, h);
|
|
1282
1293
|
}
|
|
1283
1294
|
// Re-cache if blur is active
|
|
1284
1295
|
if (element.blurEnabled && node) {
|
|
@@ -1303,9 +1314,7 @@ var TextElementComponent = observer(function (_ref) {
|
|
|
1303
1314
|
var h = node.height();
|
|
1304
1315
|
if (h > 0) {
|
|
1305
1316
|
setTextHeight(h);
|
|
1306
|
-
|
|
1307
|
-
height: h
|
|
1308
|
-
});
|
|
1317
|
+
syncHeightKeepingCenter(element, h);
|
|
1309
1318
|
}
|
|
1310
1319
|
});
|
|
1311
1320
|
return function () {
|
|
@@ -1321,11 +1330,24 @@ var TextElementComponent = observer(function (_ref) {
|
|
|
1321
1330
|
var lineHeightMultiplier = typeof element.lineHeight === 'number' ? element.lineHeight : parseFloat(element.lineHeight) || 1.2;
|
|
1322
1331
|
var h = lineCount * element.fontSize * lineHeightMultiplier;
|
|
1323
1332
|
setTextHeight(h);
|
|
1324
|
-
|
|
1325
|
-
height: h
|
|
1326
|
-
});
|
|
1333
|
+
syncHeightKeepingCenter(element, h);
|
|
1327
1334
|
}, [element.text, element.placeholder, element.fontSize, element.lineHeight, element.curveEnabled, element.curvePower]);
|
|
1328
1335
|
|
|
1336
|
+
// While the live-typing textarea overlay is open, keep it aligned with the
|
|
1337
|
+
// Konva text node as syncHeightKeepingCenter adjusts element.y/height during
|
|
1338
|
+
// auto-grow — otherwise the invisible textarea (and its caret) stays at its
|
|
1339
|
+
// original position while the visible Konva text re-centers around it.
|
|
1340
|
+
useEffect(function () {
|
|
1341
|
+
if (!element._editModeEnabled) return;
|
|
1342
|
+
var node = textRef.current;
|
|
1343
|
+
var textarea = textareaRef.current;
|
|
1344
|
+
if (!node || !textarea) return;
|
|
1345
|
+
var pos = node.absolutePosition();
|
|
1346
|
+
var scaleY = node.getAbsoluteScale().y;
|
|
1347
|
+
textarea.style.top = "".concat(pos.y, "px");
|
|
1348
|
+
textarea.style.height = "".concat(element.height * scaleY, "px");
|
|
1349
|
+
}, [element._editModeEnabled, element.y, element.height]);
|
|
1350
|
+
|
|
1329
1351
|
// Apply blur filter: cache the text node when blur is enabled
|
|
1330
1352
|
useEffect(function () {
|
|
1331
1353
|
var _node$getLayer3;
|
|
@@ -1445,6 +1467,7 @@ var TextElementComponent = observer(function (_ref) {
|
|
|
1445
1467
|
textarea.style.minHeight = '0';
|
|
1446
1468
|
textarea.style.minWidth = '0';
|
|
1447
1469
|
stageContainer.appendChild(textarea);
|
|
1470
|
+
textareaRef.current = textarea;
|
|
1448
1471
|
textarea.focus();
|
|
1449
1472
|
var caretPos = textarea.value.length;
|
|
1450
1473
|
textarea.setSelectionRange(caretPos, caretPos);
|
|
@@ -1462,6 +1485,7 @@ var TextElementComponent = observer(function (_ref) {
|
|
|
1462
1485
|
text: cancel ? originalText : textarea.value
|
|
1463
1486
|
});
|
|
1464
1487
|
element.toggleEditMode(false);
|
|
1488
|
+
if (textareaRef.current === textarea) textareaRef.current = null;
|
|
1465
1489
|
if (textarea.parentNode) {
|
|
1466
1490
|
textarea.parentNode.removeChild(textarea);
|
|
1467
1491
|
}
|