labellife-design-tool 2.5.4 → 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.
@@ -1271,35 +1271,46 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1271
1271
  setTextHeight = _useState2[1];
1272
1272
  var isCurved = element.curveEnabled && element.curvePower !== 0;
1273
1273
 
1274
- // Force Konva to recalculate text layout when fonts finish loading.
1274
+ // Konva.Text measures per-line widths only when a text attribute changes, and
1275
+ // uses those stored widths for align (center/right). If the text was laid out
1276
+ // with a fallback font, the real font's glyphs get painted against stale
1277
+ // widths and the text sits off-center. Re-measure once the font is usable.
1278
+ // Kept in a ref so the effects below always call the latest closure.
1279
+ var relayoutRef = React.useRef(null);
1280
+ relayoutRef.current = function () {
1281
+ var _node$getLayer2;
1282
+ var node = textRef.current;
1283
+ if (!node) return;
1284
+
1285
+ // CurvedText's sceneFunc re-measures glyphs via ctx.measureText on
1286
+ // every draw (no internal cached layout like Konva.Text has), so
1287
+ // there's no stale-layout workaround needed — just repaint.
1288
+ if (element.curveEnabled && element.curvePower !== 0) {
1289
+ var _node$getLayer;
1290
+ if (element.blurEnabled) node.cache(computeCurvedCacheBounds(element));
1291
+ (_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
1292
+ return;
1293
+ }
1294
+ var f = node.fontFamily();
1295
+ node.fontFamily('serif');
1296
+ node.fontFamily(f);
1297
+ var h = node.height();
1298
+ if (h > 0) {
1299
+ setTextHeight(h);
1300
+ syncHeightKeepingCenter(element, h);
1301
+ }
1302
+ // Re-cache if blur is active
1303
+ if (element.blurEnabled) {
1304
+ node.cache();
1305
+ }
1306
+ (_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
1307
+ };
1308
+
1309
+ // Any font finishing a load (covers fonts requested elsewhere, e.g. store.loadFont).
1275
1310
  React.useEffect(function () {
1276
1311
  var onFontLoaded = function onFontLoaded() {
1277
- var _node$getLayer2;
1278
- var node = textRef.current;
1279
- if (!node) return;
1280
-
1281
- // CurvedText's sceneFunc re-measures glyphs via ctx.measureText on
1282
- // every draw (no internal cached layout like Konva.Text has), so
1283
- // there's no stale-layout workaround needed — just repaint.
1284
- if (element.curveEnabled && element.curvePower !== 0) {
1285
- var _node$getLayer;
1286
- if (element.blurEnabled) node.cache(computeCurvedCacheBounds(element));
1287
- (_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
1288
- return;
1289
- }
1290
- var f = node.fontFamily();
1291
- node.fontFamily('serif');
1292
- node.fontFamily(f);
1293
- var h = node.height();
1294
- if (h > 0) {
1295
- setTextHeight(h);
1296
- syncHeightKeepingCenter(element, h);
1297
- }
1298
- // Re-cache if blur is active
1299
- if (element.blurEnabled && node) {
1300
- node.cache();
1301
- }
1302
- (_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
1312
+ var _relayoutRef$current;
1313
+ return (_relayoutRef$current = relayoutRef.current) === null || _relayoutRef$current === void 0 ? void 0 : _relayoutRef$current.call(relayoutRef);
1303
1314
  };
1304
1315
  document.fonts.addEventListener('loadingdone', onFontLoaded);
1305
1316
  return function () {
@@ -1307,6 +1318,24 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1307
1318
  };
1308
1319
  }, []);
1309
1320
 
1321
+ // This element's exact font face. Covers the cases the global event misses:
1322
+ // the font finished loading before this element mounted, or only a different
1323
+ // weight/style batch has fired so far.
1324
+ React.useEffect(function () {
1325
+ var _document$fonts;
1326
+ if (!element.fontFamily || !((_document$fonts = document.fonts) !== null && _document$fonts !== void 0 && _document$fonts.load)) return;
1327
+ var cancelled = false;
1328
+ var style = element.fontStyle === 'italic' ? 'italic ' : '';
1329
+ var weight = element.fontWeight && element.fontWeight !== 'normal' ? "".concat(element.fontWeight, " ") : '';
1330
+ document.fonts.load("".concat(style).concat(weight, "16px \"").concat(element.fontFamily, "\""), element.text || element.placeholder || '').then(function () {
1331
+ var _relayoutRef$current2;
1332
+ if (!cancelled) (_relayoutRef$current2 = relayoutRef.current) === null || _relayoutRef$current2 === void 0 || _relayoutRef$current2.call(relayoutRef);
1333
+ })["catch"](function () {});
1334
+ return function () {
1335
+ cancelled = true;
1336
+ };
1337
+ }, [element.fontFamily, element.fontWeight, element.fontStyle]);
1338
+
1310
1339
  // Sync Konva auto-sized height back to element model after text reflows
1311
1340
  // (straight text only — curved text's height is computed synchronously
1312
1341
  // below, since it doesn't width-wrap and doesn't need a measured node).
@@ -3232,7 +3261,8 @@ var PageBackground = mobxReactLite.observer(function (_ref3) {
3232
3261
  });
3233
3262
  });
3234
3263
 
3235
- // Semi-transparent overlay that dims everything outside the page boundary.
3264
+ // Semi-transparent dark overlay that dims everything outside the page boundary
3265
+ // (dark rather than light so pale images stay distinguishable when they overflow).
3236
3266
  // Draws a huge rectangle with a rectangular hole cut out for the page area.
3237
3267
  var PageOverlayFrame = mobxReactLite.observer(function (_ref4) {
3238
3268
  var store = _ref4.store;
@@ -3257,7 +3287,7 @@ var PageOverlayFrame = mobxReactLite.observer(function (_ref4) {
3257
3287
  ctx.closePath();
3258
3288
  ctx.fillStrokeShape(shape);
3259
3289
  },
3260
- fill: "rgba(240,240,240,0.5)",
3290
+ fill: "rgba(0,0,0,0.8)",
3261
3291
  listening: false,
3262
3292
  name: "display-only"
3263
3293
  });