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/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,9 +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
|
-
textarea.value =
|
|
11495
|
-
textarea.placeholder = originalText;
|
|
11498
|
+
textarea.value = originalText;
|
|
11496
11499
|
textarea.style.position = 'absolute';
|
|
11497
11500
|
textarea.style.top = "".concat(textPosition.y, "px");
|
|
11498
11501
|
textarea.style.left = "".concat(textPosition.x, "px");
|
|
@@ -11503,7 +11506,8 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11503
11506
|
textarea.style.fontStyle = cssFontStyle;
|
|
11504
11507
|
textarea.style.fontWeight = cssFontWeight;
|
|
11505
11508
|
textarea.style.textAlign = element.align;
|
|
11506
|
-
textarea.style.color =
|
|
11509
|
+
textarea.style.color = 'transparent';
|
|
11510
|
+
textarea.style.caretColor = element.stroke || element.fill || '#000000';
|
|
11507
11511
|
textarea.style.border = '0';
|
|
11508
11512
|
textarea.style.borderWidth = '0';
|
|
11509
11513
|
textarea.style.padding = '0';
|
|
@@ -11525,31 +11529,27 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
11525
11529
|
textarea.style.wordBreak = 'break-word';
|
|
11526
11530
|
textarea.style.minHeight = '0';
|
|
11527
11531
|
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
11532
|
stageContainer.appendChild(textarea);
|
|
11534
11533
|
textarea.focus();
|
|
11534
|
+
var caretPos = textarea.value.length;
|
|
11535
|
+
textarea.setSelectionRange(caretPos, caretPos);
|
|
11536
|
+
textarea.addEventListener('input', function () {
|
|
11537
|
+
element.set({
|
|
11538
|
+
text: textarea.value
|
|
11539
|
+
});
|
|
11540
|
+
});
|
|
11535
11541
|
var removed = false;
|
|
11536
11542
|
var removeTextarea = function removeTextarea() {
|
|
11537
11543
|
var cancel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
11538
11544
|
if (removed) return;
|
|
11539
11545
|
removed = true;
|
|
11540
|
-
var newText = !cancel && textarea.value.length > 0 ? textarea.value : originalText;
|
|
11541
11546
|
element.set({
|
|
11542
|
-
text:
|
|
11547
|
+
text: cancel ? originalText : textarea.value
|
|
11543
11548
|
});
|
|
11544
11549
|
element.toggleEditMode(false);
|
|
11545
|
-
if (grp) grp.show();
|
|
11546
|
-
stage.batchDraw();
|
|
11547
11550
|
if (textarea.parentNode) {
|
|
11548
11551
|
textarea.parentNode.removeChild(textarea);
|
|
11549
11552
|
}
|
|
11550
|
-
if (placeholderStyle.parentNode) {
|
|
11551
|
-
placeholderStyle.parentNode.removeChild(placeholderStyle);
|
|
11552
|
-
}
|
|
11553
11553
|
};
|
|
11554
11554
|
textarea.addEventListener('blur', function () {
|
|
11555
11555
|
return removeTextarea(false);
|