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