labellife-design-tool 2.4.3 → 2.4.4

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.
@@ -1365,13 +1365,8 @@ var TextElementComponent = observer(function (_ref) {
1365
1365
  element.toggleEditMode(true);
1366
1366
  var textNode = textRef.current;
1367
1367
  if (!textNode) return;
1368
- var grp = groupRef.current;
1369
1368
  var stage = textNode.getStage();
1370
1369
  if (!stage) return;
1371
-
1372
- // Hide the group so the textarea appears as in-place editing
1373
- if (grp) grp.hide();
1374
- stage.batchDraw();
1375
1370
  var stageContainer = stage.container();
1376
1371
  var textPosition = textNode.absolutePosition();
1377
1372
  var absScale = textNode.getAbsoluteScale();
@@ -1380,11 +1375,17 @@ var TextElementComponent = observer(function (_ref) {
1380
1375
  var cssFontStyle = element.fontStyle === 'italic' ? 'italic' : 'normal';
1381
1376
  var cssFontWeight = String(element.fontWeight || 'normal');
1382
1377
  var originalText = element.text;
1378
+
1379
+ // The Group stays visible and mirrors the textarea's value live (via the
1380
+ // 'input' listener below), so what's on screen while typing is the real
1381
+ // Konva render — stroke, shadow, background, curve all included — not a
1382
+ // CSS approximation of it (CSS can't reproduce Canvas 2D's stroke/shadow
1383
+ // rendering faithfully; see e.g. -webkit-text-stroke looking bolder and
1384
+ // "welding" adjacent glyphs together vs. Canvas's per-glyph vector stroke).
1385
+ // The textarea itself is fully transparent — it only captures input and
1386
+ // shows a caret positioned over the real text.
1383
1387
  var textarea = document.createElement('textarea');
1384
1388
  textarea.value = originalText;
1385
- // Only show the dimmed placeholder hint when there's no real text yet
1386
- // (e.g. a freshly-added text element) — not when editing existing text.
1387
- textarea.placeholder = originalText ? '' : element.placeholder;
1388
1389
  textarea.style.position = 'absolute';
1389
1390
  textarea.style.top = "".concat(textPosition.y, "px");
1390
1391
  textarea.style.left = "".concat(textPosition.x, "px");
@@ -1395,7 +1396,8 @@ var TextElementComponent = observer(function (_ref) {
1395
1396
  textarea.style.fontStyle = cssFontStyle;
1396
1397
  textarea.style.fontWeight = cssFontWeight;
1397
1398
  textarea.style.textAlign = element.align;
1398
- textarea.style.color = element.fill;
1399
+ textarea.style.color = 'transparent';
1400
+ textarea.style.caretColor = element.stroke || element.fill || '#000000';
1399
1401
  textarea.style.border = '0';
1400
1402
  textarea.style.borderWidth = '0';
1401
1403
  textarea.style.padding = '0';
@@ -1417,33 +1419,27 @@ var TextElementComponent = observer(function (_ref) {
1417
1419
  textarea.style.wordBreak = 'break-word';
1418
1420
  textarea.style.minHeight = '0';
1419
1421
  textarea.style.minWidth = '0';
1420
-
1421
- // Placeholder inherits the element's text color at 40% opacity
1422
- var placeholderStyle = document.createElement('style');
1423
- placeholderStyle.textContent = "\n textarea:placeholder-shown { opacity: 1; }\n textarea::placeholder { color: ".concat(element.fill, "; opacity: 0.4; }\n ");
1424
- stageContainer.appendChild(placeholderStyle);
1425
1422
  stageContainer.appendChild(textarea);
1426
1423
  textarea.focus();
1427
1424
  var caretPos = textarea.value.length;
1428
1425
  textarea.setSelectionRange(caretPos, caretPos);
1426
+ textarea.addEventListener('input', function () {
1427
+ element.set({
1428
+ text: textarea.value
1429
+ });
1430
+ });
1429
1431
  var removed = false;
1430
1432
  var removeTextarea = function removeTextarea() {
1431
1433
  var cancel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1432
1434
  if (removed) return;
1433
1435
  removed = true;
1434
- var newText = cancel ? originalText : textarea.value;
1435
1436
  element.set({
1436
- text: newText
1437
+ text: cancel ? originalText : textarea.value
1437
1438
  });
1438
1439
  element.toggleEditMode(false);
1439
- if (grp) grp.show();
1440
- stage.batchDraw();
1441
1440
  if (textarea.parentNode) {
1442
1441
  textarea.parentNode.removeChild(textarea);
1443
1442
  }
1444
- if (placeholderStyle.parentNode) {
1445
- placeholderStyle.parentNode.removeChild(placeholderStyle);
1446
- }
1447
1443
  };
1448
1444
  textarea.addEventListener('blur', function () {
1449
1445
  return removeTextarea(false);