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