labellife-design-tool 2.4.2 → 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 +20 -20
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +20 -20
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/canvas/workspace.js +20 -20
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +20 -20
- 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,9 +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
|
-
textarea.value =
|
|
11493
|
-
textarea.placeholder = originalText;
|
|
11496
|
+
textarea.value = originalText;
|
|
11494
11497
|
textarea.style.position = 'absolute';
|
|
11495
11498
|
textarea.style.top = "".concat(textPosition.y, "px");
|
|
11496
11499
|
textarea.style.left = "".concat(textPosition.x, "px");
|
|
@@ -11501,7 +11504,8 @@ var TextElementComponent = observer(function (_ref) {
|
|
|
11501
11504
|
textarea.style.fontStyle = cssFontStyle;
|
|
11502
11505
|
textarea.style.fontWeight = cssFontWeight;
|
|
11503
11506
|
textarea.style.textAlign = element.align;
|
|
11504
|
-
textarea.style.color =
|
|
11507
|
+
textarea.style.color = 'transparent';
|
|
11508
|
+
textarea.style.caretColor = element.stroke || element.fill || '#000000';
|
|
11505
11509
|
textarea.style.border = '0';
|
|
11506
11510
|
textarea.style.borderWidth = '0';
|
|
11507
11511
|
textarea.style.padding = '0';
|
|
@@ -11523,31 +11527,27 @@ var TextElementComponent = observer(function (_ref) {
|
|
|
11523
11527
|
textarea.style.wordBreak = 'break-word';
|
|
11524
11528
|
textarea.style.minHeight = '0';
|
|
11525
11529
|
textarea.style.minWidth = '0';
|
|
11526
|
-
|
|
11527
|
-
// Placeholder inherits the element's text color at 40% opacity
|
|
11528
|
-
var placeholderStyle = document.createElement('style');
|
|
11529
|
-
placeholderStyle.textContent = "\n textarea:placeholder-shown { opacity: 1; }\n textarea::placeholder { color: ".concat(element.fill, "; opacity: 0.4; }\n ");
|
|
11530
|
-
stageContainer.appendChild(placeholderStyle);
|
|
11531
11530
|
stageContainer.appendChild(textarea);
|
|
11532
11531
|
textarea.focus();
|
|
11532
|
+
var caretPos = textarea.value.length;
|
|
11533
|
+
textarea.setSelectionRange(caretPos, caretPos);
|
|
11534
|
+
textarea.addEventListener('input', function () {
|
|
11535
|
+
element.set({
|
|
11536
|
+
text: textarea.value
|
|
11537
|
+
});
|
|
11538
|
+
});
|
|
11533
11539
|
var removed = false;
|
|
11534
11540
|
var removeTextarea = function removeTextarea() {
|
|
11535
11541
|
var cancel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
11536
11542
|
if (removed) return;
|
|
11537
11543
|
removed = true;
|
|
11538
|
-
var newText = !cancel && textarea.value.length > 0 ? textarea.value : originalText;
|
|
11539
11544
|
element.set({
|
|
11540
|
-
text:
|
|
11545
|
+
text: cancel ? originalText : textarea.value
|
|
11541
11546
|
});
|
|
11542
11547
|
element.toggleEditMode(false);
|
|
11543
|
-
if (grp) grp.show();
|
|
11544
|
-
stage.batchDraw();
|
|
11545
11548
|
if (textarea.parentNode) {
|
|
11546
11549
|
textarea.parentNode.removeChild(textarea);
|
|
11547
11550
|
}
|
|
11548
|
-
if (placeholderStyle.parentNode) {
|
|
11549
|
-
placeholderStyle.parentNode.removeChild(placeholderStyle);
|
|
11550
|
-
}
|
|
11551
11551
|
};
|
|
11552
11552
|
textarea.addEventListener('blur', function () {
|
|
11553
11553
|
return removeTextarea(false);
|