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