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