@pixldocs/canvas-renderer 0.5.463 → 0.5.465

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.
@@ -17234,7 +17234,7 @@ const PageCanvas = forwardRef(
17234
17234
  visibilityUpdateInProgressRef.current = false;
17235
17235
  }
17236
17236
  doSyncRef.current = () => {
17237
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
17237
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
17238
17238
  const shouldSkipUpdates2 = syncLockedRef.current || editLockRef.current;
17239
17239
  const state = useEditorStore.getState();
17240
17240
  const elementsToSync = elements;
@@ -17467,6 +17467,17 @@ const PageCanvas = forwardRef(
17467
17467
  const fadeKeyChanged = newFadeKey !== oldFadeKey || newFadeKey !== innerOldKey || cropFadeRendererMissing;
17468
17468
  const needsReload = sourceUrlChanged || colorMapChanged || fadeKeyChanged && !isCropGroup2;
17469
17469
  const needsCropGroupFadeUpdate = isCropGroup2 && fadeKeyChanged;
17470
+ let cropFrameSizeChanged = false;
17471
+ if (isCropGroup2) {
17472
+ const liveCt = existingObj.__cropData;
17473
+ const liveW = Number(liveCt == null ? void 0 : liveCt.frameW) || 0;
17474
+ const liveH = Number(liveCt == null ? void 0 : liveCt.frameH) || 0;
17475
+ const schemaW = (Number(element.width) || 0) * (Number(element.scaleX) || 1);
17476
+ const schemaH = (Number(element.height) || 0) * (Number(element.scaleY) || 1);
17477
+ if (schemaW > 0 && schemaH > 0 && (Math.abs(schemaW - liveW) > 0.5 || Math.abs(schemaH - liveH) > 0.5)) {
17478
+ cropFrameSizeChanged = true;
17479
+ }
17480
+ }
17470
17481
  const hadUrlBefore = storedImageUrl && String(storedImageUrl).trim() !== "";
17471
17482
  if (!hasUrl && hadUrlBefore) {
17472
17483
  const resolvedSizeImg = (pageChildren == null ? void 0 : pageChildren.length) ? getNodeBounds(element, pageChildren) : { width: typeof element.width === "number" ? element.width : 200, height: typeof element.height === "number" ? element.height : 50 };
@@ -17503,7 +17514,7 @@ const PageCanvas = forwardRef(
17503
17514
  const clipShapeForReplace = element.clipShape ?? ((_g = element.style) == null ? void 0 : _g.imageFrameShape) ?? (isPreviewMode ? "rectangle" : "none");
17504
17515
  const needCropGroupForElement = imageFitForReplace !== "fill" || clipShapeForReplace && clipShapeForReplace !== "none";
17505
17516
  const plainImageNeedsCropGroup = hasUrl && !isCropGroup2 && existingObj instanceof fabric.FabricImage && needCropGroupForElement;
17506
- if (hasUrl && (needsReload || isPlaceholder || plainImageNeedsCropGroup || needsCropGroupFadeUpdate)) {
17517
+ if (hasUrl && (needsReload || isPlaceholder || plainImageNeedsCropGroup || needsCropGroupFadeUpdate || cropFrameSizeChanged)) {
17507
17518
  if (needsReload && !isBeingTransformed && (!wasJustModified || sourceUrlChanged)) {
17508
17519
  loadImageAsync2(element, existingObj, fc);
17509
17520
  } else if (plainImageNeedsCropGroup) {
@@ -17613,6 +17624,15 @@ const PageCanvas = forwardRef(
17613
17624
  existingObj.clipPath = newClip;
17614
17625
  }
17615
17626
  }
17627
+ const elFit = element.imageFit ?? ((_h = element.style) == null ? void 0 : _h.imageFit);
17628
+ if (elFit === "contain") {
17629
+ ct.fit = "contain";
17630
+ ct.alignH = element.imageAlignH ?? "center";
17631
+ ct.alignV = element.imageAlignV ?? "middle";
17632
+ ct.containScale = Math.max(1, Math.min(3, Number(element.containScale ?? 1)));
17633
+ } else if (elFit) {
17634
+ ct.fit = elFit;
17635
+ }
17616
17636
  updateCoverLayout(existingObj);
17617
17637
  applyEdgeFadeFrameClipPath(existingObj, element, ct.frameW, ct.frameH, ct.shape || "rect", ct.rx || 0);
17618
17638
  if (allowEditing) {
@@ -17711,6 +17731,21 @@ const PageCanvas = forwardRef(
17711
17731
  flipY: element.flipY ?? false,
17712
17732
  opacity: isHidden ? 0 : element.opacity ?? 1
17713
17733
  });
17734
+ try {
17735
+ const ctSync = existingObj.__cropData;
17736
+ if (ctSync) {
17737
+ const elFitSync = element.imageFit ?? ((_i = element.style) == null ? void 0 : _i.imageFit);
17738
+ if (elFitSync === "contain") {
17739
+ ctSync.fit = "contain";
17740
+ ctSync.alignH = element.imageAlignH ?? "center";
17741
+ ctSync.alignV = element.imageAlignV ?? "middle";
17742
+ ctSync.containScale = Math.max(1, Math.min(3, Number(element.containScale ?? 1)));
17743
+ updateCoverLayout(existingObj);
17744
+ existingObj.dirty = true;
17745
+ }
17746
+ }
17747
+ } catch {
17748
+ }
17714
17749
  existingObj.setCoords();
17715
17750
  fc.requestRenderAll();
17716
17751
  if (wasJustModified) justModifiedIdsRef.current.delete(element.id);
@@ -17930,7 +17965,7 @@ const PageCanvas = forwardRef(
17930
17965
  fc.add(placeholder);
17931
17966
  fc.bringObjectToFront(placeholder);
17932
17967
  const activeObj = fc.getActiveObject();
17933
- if (activeObj && (((_h = activeObj._ct) == null ? void 0 : _h.isCropGroup) || activeObj.__cropGroup)) {
17968
+ if (activeObj && (((_j = activeObj._ct) == null ? void 0 : _j.isCropGroup) || activeObj.__cropGroup)) {
17934
17969
  fc.setActiveObject(activeObj);
17935
17970
  }
17936
17971
  placeholder.dirty = true;
@@ -17970,7 +18005,7 @@ const PageCanvas = forwardRef(
17970
18005
  fc.add(obj);
17971
18006
  fc.bringObjectToFront(obj);
17972
18007
  const activeObj = fc.getActiveObject();
17973
- if (activeObj && (((_i = activeObj._ct) == null ? void 0 : _i.isCropGroup) || activeObj.__cropGroup)) {
18008
+ if (activeObj && (((_k = activeObj._ct) == null ? void 0 : _k.isCropGroup) || activeObj.__cropGroup)) {
17974
18009
  fc.setActiveObject(activeObj);
17975
18010
  }
17976
18011
  obj.dirty = true;
@@ -18003,7 +18038,7 @@ const PageCanvas = forwardRef(
18003
18038
  isRebuildingRef.current = false;
18004
18039
  fc.requestRenderAll();
18005
18040
  if (activeBeforeSync && fc.getObjects().includes(activeBeforeSync)) {
18006
- const isCropGroup2 = ((_j = activeBeforeSync._ct) == null ? void 0 : _j.isCropGroup) || activeBeforeSync.__cropGroup;
18041
+ const isCropGroup2 = ((_l = activeBeforeSync._ct) == null ? void 0 : _l.isCropGroup) || activeBeforeSync.__cropGroup;
18007
18042
  if (isCropGroup2) {
18008
18043
  fc.setActiveObject(activeBeforeSync);
18009
18044
  fc.requestRenderAll();
@@ -18090,7 +18125,7 @@ const PageCanvas = forwardRef(
18090
18125
  }
18091
18126
  if (fc.__activeEditingGroupId) {
18092
18127
  try {
18093
- (_k = fc.__updateDrilledGroupOutline) == null ? void 0 : _k.call(fc);
18128
+ (_m = fc.__updateDrilledGroupOutline) == null ? void 0 : _m.call(fc);
18094
18129
  } catch {
18095
18130
  }
18096
18131
  }
@@ -26255,9 +26290,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26255
26290
  }
26256
26291
  return svgString;
26257
26292
  }
26258
- const resolvedPackageVersion = "0.5.463";
26293
+ const resolvedPackageVersion = "0.5.465";
26259
26294
  const PACKAGE_VERSION = resolvedPackageVersion;
26260
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.463";
26295
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.465";
26261
26296
  const roundParityValue = (value) => {
26262
26297
  if (typeof value !== "number") return value;
26263
26298
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27071,7 +27106,7 @@ class PixldocsRenderer {
27071
27106
  await this.waitForCanvasScene(container, cloned, i);
27072
27107
  }
27073
27108
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27074
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BlCi6g1y.js");
27109
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CVeVbCo7.js");
27075
27110
  const prepared = preparePagesForExport(
27076
27111
  cloned.pages,
27077
27112
  canvasWidth,
@@ -29391,7 +29426,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29391
29426
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29392
29427
  sanitizeSvgTreeForPdf(svgToDraw);
29393
29428
  try {
29394
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BlCi6g1y.js");
29429
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CVeVbCo7.js");
29395
29430
  try {
29396
29431
  await logTextMeasurementDiagnostic(svgToDraw);
29397
29432
  } catch {
@@ -29708,4 +29743,4 @@ export {
29708
29743
  buildTeaserBlurFlatKeys as y,
29709
29744
  collectFontDescriptorsFromConfig as z
29710
29745
  };
29711
- //# sourceMappingURL=index-CJ3vY_6d.js.map
29746
+ //# sourceMappingURL=index-DmkAdvKz.js.map