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.
package/dist/cjs/index.js CHANGED
@@ -11475,13 +11475,8 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11475
11475
  element.toggleEditMode(true);
11476
11476
  var textNode = textRef.current;
11477
11477
  if (!textNode) return;
11478
- var grp = groupRef.current;
11479
11478
  var stage = textNode.getStage();
11480
11479
  if (!stage) return;
11481
-
11482
- // Hide the group so the textarea appears as in-place editing
11483
- if (grp) grp.hide();
11484
- stage.batchDraw();
11485
11480
  var stageContainer = stage.container();
11486
11481
  var textPosition = textNode.absolutePosition();
11487
11482
  var absScale = textNode.getAbsoluteScale();
@@ -11490,11 +11485,17 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11490
11485
  var cssFontStyle = element.fontStyle === 'italic' ? 'italic' : 'normal';
11491
11486
  var cssFontWeight = String(element.fontWeight || 'normal');
11492
11487
  var originalText = element.text;
11488
+
11489
+ // The Group stays visible and mirrors the textarea's value live (via the
11490
+ // 'input' listener below), so what's on screen while typing is the real
11491
+ // Konva render — stroke, shadow, background, curve all included — not a
11492
+ // CSS approximation of it (CSS can't reproduce Canvas 2D's stroke/shadow
11493
+ // rendering faithfully; see e.g. -webkit-text-stroke looking bolder and
11494
+ // "welding" adjacent glyphs together vs. Canvas's per-glyph vector stroke).
11495
+ // The textarea itself is fully transparent — it only captures input and
11496
+ // shows a caret positioned over the real text.
11493
11497
  var textarea = document.createElement('textarea');
11494
11498
  textarea.value = originalText;
11495
- // Only show the dimmed placeholder hint when there's no real text yet
11496
- // (e.g. a freshly-added text element) — not when editing existing text.
11497
- textarea.placeholder = originalText ? '' : element.placeholder;
11498
11499
  textarea.style.position = 'absolute';
11499
11500
  textarea.style.top = "".concat(textPosition.y, "px");
11500
11501
  textarea.style.left = "".concat(textPosition.x, "px");
@@ -11505,7 +11506,8 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11505
11506
  textarea.style.fontStyle = cssFontStyle;
11506
11507
  textarea.style.fontWeight = cssFontWeight;
11507
11508
  textarea.style.textAlign = element.align;
11508
- textarea.style.color = element.fill;
11509
+ textarea.style.color = 'transparent';
11510
+ textarea.style.caretColor = element.stroke || element.fill || '#000000';
11509
11511
  textarea.style.border = '0';
11510
11512
  textarea.style.borderWidth = '0';
11511
11513
  textarea.style.padding = '0';
@@ -11527,33 +11529,27 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11527
11529
  textarea.style.wordBreak = 'break-word';
11528
11530
  textarea.style.minHeight = '0';
11529
11531
  textarea.style.minWidth = '0';
11530
-
11531
- // Placeholder inherits the element's text color at 40% opacity
11532
- var placeholderStyle = document.createElement('style');
11533
- placeholderStyle.textContent = "\n textarea:placeholder-shown { opacity: 1; }\n textarea::placeholder { color: ".concat(element.fill, "; opacity: 0.4; }\n ");
11534
- stageContainer.appendChild(placeholderStyle);
11535
11532
  stageContainer.appendChild(textarea);
11536
11533
  textarea.focus();
11537
11534
  var caretPos = textarea.value.length;
11538
11535
  textarea.setSelectionRange(caretPos, caretPos);
11536
+ textarea.addEventListener('input', function () {
11537
+ element.set({
11538
+ text: textarea.value
11539
+ });
11540
+ });
11539
11541
  var removed = false;
11540
11542
  var removeTextarea = function removeTextarea() {
11541
11543
  var cancel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
11542
11544
  if (removed) return;
11543
11545
  removed = true;
11544
- var newText = cancel ? originalText : textarea.value;
11545
11546
  element.set({
11546
- text: newText
11547
+ text: cancel ? originalText : textarea.value
11547
11548
  });
11548
11549
  element.toggleEditMode(false);
11549
- if (grp) grp.show();
11550
- stage.batchDraw();
11551
11550
  if (textarea.parentNode) {
11552
11551
  textarea.parentNode.removeChild(textarea);
11553
11552
  }
11554
- if (placeholderStyle.parentNode) {
11555
- placeholderStyle.parentNode.removeChild(placeholderStyle);
11556
- }
11557
11553
  };
11558
11554
  textarea.addEventListener('blur', function () {
11559
11555
  return removeTextarea(false);