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
|
@@ -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,11 +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
1392
|
textarea.value = originalText;
|
|
1389
|
-
// Only show the dimmed placeholder hint when there's no real text yet
|
|
1390
|
-
// (e.g. a freshly-added text element) — not when editing existing text.
|
|
1391
|
-
textarea.placeholder = originalText ? '' : element.placeholder;
|
|
1392
1393
|
textarea.style.position = 'absolute';
|
|
1393
1394
|
textarea.style.top = "".concat(textPosition.y, "px");
|
|
1394
1395
|
textarea.style.left = "".concat(textPosition.x, "px");
|
|
@@ -1399,7 +1400,8 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1399
1400
|
textarea.style.fontStyle = cssFontStyle;
|
|
1400
1401
|
textarea.style.fontWeight = cssFontWeight;
|
|
1401
1402
|
textarea.style.textAlign = element.align;
|
|
1402
|
-
textarea.style.color =
|
|
1403
|
+
textarea.style.color = 'transparent';
|
|
1404
|
+
textarea.style.caretColor = element.stroke || element.fill || '#000000';
|
|
1403
1405
|
textarea.style.border = '0';
|
|
1404
1406
|
textarea.style.borderWidth = '0';
|
|
1405
1407
|
textarea.style.padding = '0';
|
|
@@ -1421,33 +1423,27 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
|
|
|
1421
1423
|
textarea.style.wordBreak = 'break-word';
|
|
1422
1424
|
textarea.style.minHeight = '0';
|
|
1423
1425
|
textarea.style.minWidth = '0';
|
|
1424
|
-
|
|
1425
|
-
// Placeholder inherits the element's text color at 40% opacity
|
|
1426
|
-
var placeholderStyle = document.createElement('style');
|
|
1427
|
-
placeholderStyle.textContent = "\n textarea:placeholder-shown { opacity: 1; }\n textarea::placeholder { color: ".concat(element.fill, "; opacity: 0.4; }\n ");
|
|
1428
|
-
stageContainer.appendChild(placeholderStyle);
|
|
1429
1426
|
stageContainer.appendChild(textarea);
|
|
1430
1427
|
textarea.focus();
|
|
1431
1428
|
var caretPos = textarea.value.length;
|
|
1432
1429
|
textarea.setSelectionRange(caretPos, caretPos);
|
|
1430
|
+
textarea.addEventListener('input', function () {
|
|
1431
|
+
element.set({
|
|
1432
|
+
text: textarea.value
|
|
1433
|
+
});
|
|
1434
|
+
});
|
|
1433
1435
|
var removed = false;
|
|
1434
1436
|
var removeTextarea = function removeTextarea() {
|
|
1435
1437
|
var cancel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1436
1438
|
if (removed) return;
|
|
1437
1439
|
removed = true;
|
|
1438
|
-
var newText = cancel ? originalText : textarea.value;
|
|
1439
1440
|
element.set({
|
|
1440
|
-
text:
|
|
1441
|
+
text: cancel ? originalText : textarea.value
|
|
1441
1442
|
});
|
|
1442
1443
|
element.toggleEditMode(false);
|
|
1443
|
-
if (grp) grp.show();
|
|
1444
|
-
stage.batchDraw();
|
|
1445
1444
|
if (textarea.parentNode) {
|
|
1446
1445
|
textarea.parentNode.removeChild(textarea);
|
|
1447
1446
|
}
|
|
1448
|
-
if (placeholderStyle.parentNode) {
|
|
1449
|
-
placeholderStyle.parentNode.removeChild(placeholderStyle);
|
|
1450
|
-
}
|
|
1451
1447
|
};
|
|
1452
1448
|
textarea.addEventListener('blur', function () {
|
|
1453
1449
|
return removeTextarea(false);
|