labellife-design-tool 2.5.3 → 2.5.5

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/esm/index.js CHANGED
@@ -11581,35 +11581,46 @@ var TextElementComponent = observer(function (_ref) {
11581
11581
  setTextHeight = _useState2[1];
11582
11582
  var isCurved = element.curveEnabled && element.curvePower !== 0;
11583
11583
 
11584
- // Force Konva to recalculate text layout when fonts finish loading.
11584
+ // Konva.Text measures per-line widths only when a text attribute changes, and
11585
+ // uses those stored widths for align (center/right). If the text was laid out
11586
+ // with a fallback font, the real font's glyphs get painted against stale
11587
+ // widths and the text sits off-center. Re-measure once the font is usable.
11588
+ // Kept in a ref so the effects below always call the latest closure.
11589
+ var relayoutRef = useRef(null);
11590
+ relayoutRef.current = function () {
11591
+ var _node$getLayer2;
11592
+ var node = textRef.current;
11593
+ if (!node) return;
11594
+
11595
+ // CurvedText's sceneFunc re-measures glyphs via ctx.measureText on
11596
+ // every draw (no internal cached layout like Konva.Text has), so
11597
+ // there's no stale-layout workaround needed — just repaint.
11598
+ if (element.curveEnabled && element.curvePower !== 0) {
11599
+ var _node$getLayer;
11600
+ if (element.blurEnabled) node.cache(computeCurvedCacheBounds(element));
11601
+ (_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
11602
+ return;
11603
+ }
11604
+ var f = node.fontFamily();
11605
+ node.fontFamily('serif');
11606
+ node.fontFamily(f);
11607
+ var h = node.height();
11608
+ if (h > 0) {
11609
+ setTextHeight(h);
11610
+ syncHeightKeepingCenter(element, h);
11611
+ }
11612
+ // Re-cache if blur is active
11613
+ if (element.blurEnabled) {
11614
+ node.cache();
11615
+ }
11616
+ (_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
11617
+ };
11618
+
11619
+ // Any font finishing a load (covers fonts requested elsewhere, e.g. store.loadFont).
11585
11620
  useEffect(function () {
11586
11621
  var onFontLoaded = function onFontLoaded() {
11587
- var _node$getLayer2;
11588
- var node = textRef.current;
11589
- if (!node) return;
11590
-
11591
- // CurvedText's sceneFunc re-measures glyphs via ctx.measureText on
11592
- // every draw (no internal cached layout like Konva.Text has), so
11593
- // there's no stale-layout workaround needed — just repaint.
11594
- if (element.curveEnabled && element.curvePower !== 0) {
11595
- var _node$getLayer;
11596
- if (element.blurEnabled) node.cache(computeCurvedCacheBounds(element));
11597
- (_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
11598
- return;
11599
- }
11600
- var f = node.fontFamily();
11601
- node.fontFamily('serif');
11602
- node.fontFamily(f);
11603
- var h = node.height();
11604
- if (h > 0) {
11605
- setTextHeight(h);
11606
- syncHeightKeepingCenter(element, h);
11607
- }
11608
- // Re-cache if blur is active
11609
- if (element.blurEnabled && node) {
11610
- node.cache();
11611
- }
11612
- (_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
11622
+ var _relayoutRef$current;
11623
+ return (_relayoutRef$current = relayoutRef.current) === null || _relayoutRef$current === void 0 ? void 0 : _relayoutRef$current.call(relayoutRef);
11613
11624
  };
11614
11625
  document.fonts.addEventListener('loadingdone', onFontLoaded);
11615
11626
  return function () {
@@ -11617,6 +11628,24 @@ var TextElementComponent = observer(function (_ref) {
11617
11628
  };
11618
11629
  }, []);
11619
11630
 
11631
+ // This element's exact font face. Covers the cases the global event misses:
11632
+ // the font finished loading before this element mounted, or only a different
11633
+ // weight/style batch has fired so far.
11634
+ useEffect(function () {
11635
+ var _document$fonts;
11636
+ if (!element.fontFamily || !((_document$fonts = document.fonts) !== null && _document$fonts !== void 0 && _document$fonts.load)) return;
11637
+ var cancelled = false;
11638
+ var style = element.fontStyle === 'italic' ? 'italic ' : '';
11639
+ var weight = element.fontWeight && element.fontWeight !== 'normal' ? "".concat(element.fontWeight, " ") : '';
11640
+ document.fonts.load("".concat(style).concat(weight, "16px \"").concat(element.fontFamily, "\""), element.text || element.placeholder || '').then(function () {
11641
+ var _relayoutRef$current2;
11642
+ if (!cancelled) (_relayoutRef$current2 = relayoutRef.current) === null || _relayoutRef$current2 === void 0 || _relayoutRef$current2.call(relayoutRef);
11643
+ })["catch"](function () {});
11644
+ return function () {
11645
+ cancelled = true;
11646
+ };
11647
+ }, [element.fontFamily, element.fontWeight, element.fontStyle]);
11648
+
11620
11649
  // Sync Konva auto-sized height back to element model after text reflows
11621
11650
  // (straight text only — curved text's height is computed synchronously
11622
11651
  // below, since it doesn't width-wrap and doesn't need a measured node).
@@ -13542,7 +13571,8 @@ var PageBackground = observer(function (_ref3) {
13542
13571
  });
13543
13572
  });
13544
13573
 
13545
- // Semi-transparent overlay that dims everything outside the page boundary.
13574
+ // Semi-transparent dark overlay that dims everything outside the page boundary
13575
+ // (dark rather than light so pale images stay distinguishable when they overflow).
13546
13576
  // Draws a huge rectangle with a rectangular hole cut out for the page area.
13547
13577
  var PageOverlayFrame = observer(function (_ref4) {
13548
13578
  var store = _ref4.store;
@@ -13567,7 +13597,7 @@ var PageOverlayFrame = observer(function (_ref4) {
13567
13597
  ctx.closePath();
13568
13598
  ctx.fillStrokeShape(shape);
13569
13599
  },
13570
- fill: "rgba(240,240,240,0.5)",
13600
+ fill: "rgba(0,0,0,0.8)",
13571
13601
  listening: false,
13572
13602
  name: "display-only"
13573
13603
  });