@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.
@@ -17252,7 +17252,7 @@ const PageCanvas = react.forwardRef(
17252
17252
  visibilityUpdateInProgressRef.current = false;
17253
17253
  }
17254
17254
  doSyncRef.current = () => {
17255
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
17255
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
17256
17256
  const shouldSkipUpdates2 = syncLockedRef.current || editLockRef.current;
17257
17257
  const state = useEditorStore.getState();
17258
17258
  const elementsToSync = elements;
@@ -17485,6 +17485,17 @@ const PageCanvas = react.forwardRef(
17485
17485
  const fadeKeyChanged = newFadeKey !== oldFadeKey || newFadeKey !== innerOldKey || cropFadeRendererMissing;
17486
17486
  const needsReload = sourceUrlChanged || colorMapChanged || fadeKeyChanged && !isCropGroup2;
17487
17487
  const needsCropGroupFadeUpdate = isCropGroup2 && fadeKeyChanged;
17488
+ let cropFrameSizeChanged = false;
17489
+ if (isCropGroup2) {
17490
+ const liveCt = existingObj.__cropData;
17491
+ const liveW = Number(liveCt == null ? void 0 : liveCt.frameW) || 0;
17492
+ const liveH = Number(liveCt == null ? void 0 : liveCt.frameH) || 0;
17493
+ const schemaW = (Number(element.width) || 0) * (Number(element.scaleX) || 1);
17494
+ const schemaH = (Number(element.height) || 0) * (Number(element.scaleY) || 1);
17495
+ if (schemaW > 0 && schemaH > 0 && (Math.abs(schemaW - liveW) > 0.5 || Math.abs(schemaH - liveH) > 0.5)) {
17496
+ cropFrameSizeChanged = true;
17497
+ }
17498
+ }
17488
17499
  const hadUrlBefore = storedImageUrl && String(storedImageUrl).trim() !== "";
17489
17500
  if (!hasUrl && hadUrlBefore) {
17490
17501
  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 };
@@ -17521,7 +17532,7 @@ const PageCanvas = react.forwardRef(
17521
17532
  const clipShapeForReplace = element.clipShape ?? ((_g = element.style) == null ? void 0 : _g.imageFrameShape) ?? (isPreviewMode ? "rectangle" : "none");
17522
17533
  const needCropGroupForElement = imageFitForReplace !== "fill" || clipShapeForReplace && clipShapeForReplace !== "none";
17523
17534
  const plainImageNeedsCropGroup = hasUrl && !isCropGroup2 && existingObj instanceof fabric__namespace.FabricImage && needCropGroupForElement;
17524
- if (hasUrl && (needsReload || isPlaceholder || plainImageNeedsCropGroup || needsCropGroupFadeUpdate)) {
17535
+ if (hasUrl && (needsReload || isPlaceholder || plainImageNeedsCropGroup || needsCropGroupFadeUpdate || cropFrameSizeChanged)) {
17525
17536
  if (needsReload && !isBeingTransformed && (!wasJustModified || sourceUrlChanged)) {
17526
17537
  loadImageAsync2(element, existingObj, fc);
17527
17538
  } else if (plainImageNeedsCropGroup) {
@@ -17631,6 +17642,15 @@ const PageCanvas = react.forwardRef(
17631
17642
  existingObj.clipPath = newClip;
17632
17643
  }
17633
17644
  }
17645
+ const elFit = element.imageFit ?? ((_h = element.style) == null ? void 0 : _h.imageFit);
17646
+ if (elFit === "contain") {
17647
+ ct.fit = "contain";
17648
+ ct.alignH = element.imageAlignH ?? "center";
17649
+ ct.alignV = element.imageAlignV ?? "middle";
17650
+ ct.containScale = Math.max(1, Math.min(3, Number(element.containScale ?? 1)));
17651
+ } else if (elFit) {
17652
+ ct.fit = elFit;
17653
+ }
17634
17654
  updateCoverLayout(existingObj);
17635
17655
  applyEdgeFadeFrameClipPath(existingObj, element, ct.frameW, ct.frameH, ct.shape || "rect", ct.rx || 0);
17636
17656
  if (allowEditing) {
@@ -17729,6 +17749,21 @@ const PageCanvas = react.forwardRef(
17729
17749
  flipY: element.flipY ?? false,
17730
17750
  opacity: isHidden ? 0 : element.opacity ?? 1
17731
17751
  });
17752
+ try {
17753
+ const ctSync = existingObj.__cropData;
17754
+ if (ctSync) {
17755
+ const elFitSync = element.imageFit ?? ((_i = element.style) == null ? void 0 : _i.imageFit);
17756
+ if (elFitSync === "contain") {
17757
+ ctSync.fit = "contain";
17758
+ ctSync.alignH = element.imageAlignH ?? "center";
17759
+ ctSync.alignV = element.imageAlignV ?? "middle";
17760
+ ctSync.containScale = Math.max(1, Math.min(3, Number(element.containScale ?? 1)));
17761
+ updateCoverLayout(existingObj);
17762
+ existingObj.dirty = true;
17763
+ }
17764
+ }
17765
+ } catch {
17766
+ }
17732
17767
  existingObj.setCoords();
17733
17768
  fc.requestRenderAll();
17734
17769
  if (wasJustModified) justModifiedIdsRef.current.delete(element.id);
@@ -17948,7 +17983,7 @@ const PageCanvas = react.forwardRef(
17948
17983
  fc.add(placeholder);
17949
17984
  fc.bringObjectToFront(placeholder);
17950
17985
  const activeObj = fc.getActiveObject();
17951
- if (activeObj && (((_h = activeObj._ct) == null ? void 0 : _h.isCropGroup) || activeObj.__cropGroup)) {
17986
+ if (activeObj && (((_j = activeObj._ct) == null ? void 0 : _j.isCropGroup) || activeObj.__cropGroup)) {
17952
17987
  fc.setActiveObject(activeObj);
17953
17988
  }
17954
17989
  placeholder.dirty = true;
@@ -17988,7 +18023,7 @@ const PageCanvas = react.forwardRef(
17988
18023
  fc.add(obj);
17989
18024
  fc.bringObjectToFront(obj);
17990
18025
  const activeObj = fc.getActiveObject();
17991
- if (activeObj && (((_i = activeObj._ct) == null ? void 0 : _i.isCropGroup) || activeObj.__cropGroup)) {
18026
+ if (activeObj && (((_k = activeObj._ct) == null ? void 0 : _k.isCropGroup) || activeObj.__cropGroup)) {
17992
18027
  fc.setActiveObject(activeObj);
17993
18028
  }
17994
18029
  obj.dirty = true;
@@ -18021,7 +18056,7 @@ const PageCanvas = react.forwardRef(
18021
18056
  isRebuildingRef.current = false;
18022
18057
  fc.requestRenderAll();
18023
18058
  if (activeBeforeSync && fc.getObjects().includes(activeBeforeSync)) {
18024
- const isCropGroup2 = ((_j = activeBeforeSync._ct) == null ? void 0 : _j.isCropGroup) || activeBeforeSync.__cropGroup;
18059
+ const isCropGroup2 = ((_l = activeBeforeSync._ct) == null ? void 0 : _l.isCropGroup) || activeBeforeSync.__cropGroup;
18025
18060
  if (isCropGroup2) {
18026
18061
  fc.setActiveObject(activeBeforeSync);
18027
18062
  fc.requestRenderAll();
@@ -18108,7 +18143,7 @@ const PageCanvas = react.forwardRef(
18108
18143
  }
18109
18144
  if (fc.__activeEditingGroupId) {
18110
18145
  try {
18111
- (_k = fc.__updateDrilledGroupOutline) == null ? void 0 : _k.call(fc);
18146
+ (_m = fc.__updateDrilledGroupOutline) == null ? void 0 : _m.call(fc);
18112
18147
  } catch {
18113
18148
  }
18114
18149
  }
@@ -26273,9 +26308,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26273
26308
  }
26274
26309
  return svgString;
26275
26310
  }
26276
- const resolvedPackageVersion = "0.5.463";
26311
+ const resolvedPackageVersion = "0.5.465";
26277
26312
  const PACKAGE_VERSION = resolvedPackageVersion;
26278
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.463";
26313
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.465";
26279
26314
  const roundParityValue = (value) => {
26280
26315
  if (typeof value !== "number") return value;
26281
26316
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27089,7 +27124,7 @@ class PixldocsRenderer {
27089
27124
  await this.waitForCanvasScene(container, cloned, i);
27090
27125
  }
27091
27126
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27092
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DFhh1h5p.cjs"));
27127
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Bsd1V19b.cjs"));
27093
27128
  const prepared = preparePagesForExport(
27094
27129
  cloned.pages,
27095
27130
  canvasWidth,
@@ -29409,7 +29444,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29409
29444
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29410
29445
  sanitizeSvgTreeForPdf(svgToDraw);
29411
29446
  try {
29412
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DFhh1h5p.cjs"));
29447
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Bsd1V19b.cjs"));
29413
29448
  try {
29414
29449
  await logTextMeasurementDiagnostic(svgToDraw);
29415
29450
  } catch {
@@ -29723,4 +29758,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29723
29758
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29724
29759
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29725
29760
  exports.warmTemplateFromForm = warmTemplateFromForm;
29726
- //# sourceMappingURL=index-kf9OkhGi.cjs.map
29761
+ //# sourceMappingURL=index-Co301SkV.cjs.map