@pixldocs/canvas-renderer 0.5.462 → 0.5.464

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.
@@ -4379,7 +4379,8 @@ async function loadImageAsync(element, placeholder, fc, fabricRef, syncLockedRef
4379
4379
  } else if (imageFit2 === "contain") {
4380
4380
  const scaleX = elementWidth / imgNaturalWidth;
4381
4381
  const scaleY = elementHeight / imgNaturalHeight;
4382
- const scale = Math.min(scaleX, scaleY);
4382
+ const containScale = Math.max(1, Math.min(3, Number(element.containScale ?? 1)));
4383
+ const scale = Math.min(scaleX, scaleY) * containScale;
4383
4384
  baseScaleX = scale;
4384
4385
  baseScaleY = scale;
4385
4386
  } else {
@@ -5197,7 +5198,7 @@ function updateCoverLayout(g) {
5197
5198
  const ih = img.height || 1;
5198
5199
  const fitContain = ct.fit === "contain";
5199
5200
  const baseScale = fitContain ? Math.min(frameW / iw, frameH / ih) : Math.max(frameW / iw, frameH / ih);
5200
- const zoom = fitContain ? 1 : Math.max(1, img._ct.zoom ?? 1);
5201
+ const zoom = fitContain ? Math.max(1, Math.min(3, ct.containScale ?? 1)) : Math.max(1, img._ct.zoom ?? 1);
5201
5202
  const finalScale = baseScale * zoom;
5202
5203
  img.set({
5203
5204
  scaleX: finalScale,
@@ -5222,8 +5223,8 @@ function updateCoverLayout(g) {
5222
5223
  if (fitContain) {
5223
5224
  const alignH = ct.alignH ?? "center";
5224
5225
  const alignV = ct.alignV ?? "middle";
5225
- const slackX = Math.max(0, frameW - dispW);
5226
- const slackY = Math.max(0, frameH - dispH);
5226
+ const slackX = frameW - dispW;
5227
+ const slackY = frameH - dispH;
5227
5228
  offsetX = alignH === "left" ? -slackX / 2 : alignH === "right" ? slackX / 2 : 0;
5228
5229
  offsetY = alignV === "top" ? -slackY / 2 : alignV === "bottom" ? slackY / 2 : 0;
5229
5230
  } else {
@@ -5605,7 +5606,8 @@ async function createMaskedImageElement({
5605
5606
  zoom = 1,
5606
5607
  fit = "cover",
5607
5608
  alignH = "center",
5608
- alignV = "middle"
5609
+ alignV = "middle",
5610
+ containScale = 1
5609
5611
  }) {
5610
5612
  const img = image || (url ? await fabric.FabricImage.fromURL(getProxiedImageUrl(url), { crossOrigin: "anonymous" }) : null);
5611
5613
  if (!img) {
@@ -5730,6 +5732,7 @@ async function createMaskedImageElement({
5730
5732
  fit,
5731
5733
  alignH,
5732
5734
  alignV,
5735
+ containScale: Math.max(1, Math.min(3, containScale || 1)),
5733
5736
  _img: img,
5734
5737
  _border: border
5735
5738
  };
@@ -17231,7 +17234,7 @@ const PageCanvas = forwardRef(
17231
17234
  visibilityUpdateInProgressRef.current = false;
17232
17235
  }
17233
17236
  doSyncRef.current = () => {
17234
- 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;
17235
17238
  const shouldSkipUpdates2 = syncLockedRef.current || editLockRef.current;
17236
17239
  const state = useEditorStore.getState();
17237
17240
  const elementsToSync = elements;
@@ -17610,6 +17613,15 @@ const PageCanvas = forwardRef(
17610
17613
  existingObj.clipPath = newClip;
17611
17614
  }
17612
17615
  }
17616
+ const elFit = element.imageFit ?? ((_h = element.style) == null ? void 0 : _h.imageFit);
17617
+ if (elFit === "contain") {
17618
+ ct.fit = "contain";
17619
+ ct.alignH = element.imageAlignH ?? "center";
17620
+ ct.alignV = element.imageAlignV ?? "middle";
17621
+ ct.containScale = Math.max(1, Math.min(3, Number(element.containScale ?? 1)));
17622
+ } else if (elFit) {
17623
+ ct.fit = elFit;
17624
+ }
17613
17625
  updateCoverLayout(existingObj);
17614
17626
  applyEdgeFadeFrameClipPath(existingObj, element, ct.frameW, ct.frameH, ct.shape || "rect", ct.rx || 0);
17615
17627
  if (allowEditing) {
@@ -17708,6 +17720,21 @@ const PageCanvas = forwardRef(
17708
17720
  flipY: element.flipY ?? false,
17709
17721
  opacity: isHidden ? 0 : element.opacity ?? 1
17710
17722
  });
17723
+ try {
17724
+ const ctSync = existingObj.__cropData;
17725
+ if (ctSync) {
17726
+ const elFitSync = element.imageFit ?? ((_i = element.style) == null ? void 0 : _i.imageFit);
17727
+ if (elFitSync === "contain") {
17728
+ ctSync.fit = "contain";
17729
+ ctSync.alignH = element.imageAlignH ?? "center";
17730
+ ctSync.alignV = element.imageAlignV ?? "middle";
17731
+ ctSync.containScale = Math.max(1, Math.min(3, Number(element.containScale ?? 1)));
17732
+ updateCoverLayout(existingObj);
17733
+ existingObj.dirty = true;
17734
+ }
17735
+ }
17736
+ } catch {
17737
+ }
17711
17738
  existingObj.setCoords();
17712
17739
  fc.requestRenderAll();
17713
17740
  if (wasJustModified) justModifiedIdsRef.current.delete(element.id);
@@ -17927,7 +17954,7 @@ const PageCanvas = forwardRef(
17927
17954
  fc.add(placeholder);
17928
17955
  fc.bringObjectToFront(placeholder);
17929
17956
  const activeObj = fc.getActiveObject();
17930
- if (activeObj && (((_h = activeObj._ct) == null ? void 0 : _h.isCropGroup) || activeObj.__cropGroup)) {
17957
+ if (activeObj && (((_j = activeObj._ct) == null ? void 0 : _j.isCropGroup) || activeObj.__cropGroup)) {
17931
17958
  fc.setActiveObject(activeObj);
17932
17959
  }
17933
17960
  placeholder.dirty = true;
@@ -17967,7 +17994,7 @@ const PageCanvas = forwardRef(
17967
17994
  fc.add(obj);
17968
17995
  fc.bringObjectToFront(obj);
17969
17996
  const activeObj = fc.getActiveObject();
17970
- if (activeObj && (((_i = activeObj._ct) == null ? void 0 : _i.isCropGroup) || activeObj.__cropGroup)) {
17997
+ if (activeObj && (((_k = activeObj._ct) == null ? void 0 : _k.isCropGroup) || activeObj.__cropGroup)) {
17971
17998
  fc.setActiveObject(activeObj);
17972
17999
  }
17973
18000
  obj.dirty = true;
@@ -18000,7 +18027,7 @@ const PageCanvas = forwardRef(
18000
18027
  isRebuildingRef.current = false;
18001
18028
  fc.requestRenderAll();
18002
18029
  if (activeBeforeSync && fc.getObjects().includes(activeBeforeSync)) {
18003
- const isCropGroup2 = ((_j = activeBeforeSync._ct) == null ? void 0 : _j.isCropGroup) || activeBeforeSync.__cropGroup;
18030
+ const isCropGroup2 = ((_l = activeBeforeSync._ct) == null ? void 0 : _l.isCropGroup) || activeBeforeSync.__cropGroup;
18004
18031
  if (isCropGroup2) {
18005
18032
  fc.setActiveObject(activeBeforeSync);
18006
18033
  fc.requestRenderAll();
@@ -18087,7 +18114,7 @@ const PageCanvas = forwardRef(
18087
18114
  }
18088
18115
  if (fc.__activeEditingGroupId) {
18089
18116
  try {
18090
- (_k = fc.__updateDrilledGroupOutline) == null ? void 0 : _k.call(fc);
18117
+ (_m = fc.__updateDrilledGroupOutline) == null ? void 0 : _m.call(fc);
18091
18118
  } catch {
18092
18119
  }
18093
18120
  }
@@ -19644,7 +19671,8 @@ const PageCanvas = forwardRef(
19644
19671
  // edge (instead of being silently cover-cropped).
19645
19672
  fit: imageFitFinal === "contain" ? "contain" : "cover",
19646
19673
  alignH: element.imageAlignH ?? "center",
19647
- alignV: element.imageAlignV ?? "middle"
19674
+ alignV: element.imageAlignV ?? "middle",
19675
+ containScale: Math.max(1, Math.min(3, Number(element.containScale ?? 1)))
19648
19676
  });
19649
19677
  cropGroup.__maintainResolution = element.maintainResolution !== false;
19650
19678
  cropGroup.set({
@@ -26251,9 +26279,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26251
26279
  }
26252
26280
  return svgString;
26253
26281
  }
26254
- const resolvedPackageVersion = "0.5.462";
26282
+ const resolvedPackageVersion = "0.5.464";
26255
26283
  const PACKAGE_VERSION = resolvedPackageVersion;
26256
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.462";
26284
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.464";
26257
26285
  const roundParityValue = (value) => {
26258
26286
  if (typeof value !== "number") return value;
26259
26287
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27067,7 +27095,7 @@ class PixldocsRenderer {
27067
27095
  await this.waitForCanvasScene(container, cloned, i);
27068
27096
  }
27069
27097
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27070
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CFxK100y.js");
27098
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-pt3O47hm.js");
27071
27099
  const prepared = preparePagesForExport(
27072
27100
  cloned.pages,
27073
27101
  canvasWidth,
@@ -29387,7 +29415,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29387
29415
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29388
29416
  sanitizeSvgTreeForPdf(svgToDraw);
29389
29417
  try {
29390
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CFxK100y.js");
29418
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-pt3O47hm.js");
29391
29419
  try {
29392
29420
  await logTextMeasurementDiagnostic(svgToDraw);
29393
29421
  } catch {
@@ -29704,4 +29732,4 @@ export {
29704
29732
  buildTeaserBlurFlatKeys as y,
29705
29733
  collectFontDescriptorsFromConfig as z
29706
29734
  };
29707
- //# sourceMappingURL=index-DzpYcUNd.js.map
29735
+ //# sourceMappingURL=index-TvXdi5B9.js.map