@pixldocs/canvas-renderer 0.5.465 → 0.5.466

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.
@@ -5243,6 +5243,53 @@ function updateCoverLayout(g) {
5243
5243
  g.canvas.requestRenderAll();
5244
5244
  }
5245
5245
  }
5246
+ function shrinkContainGroupToImageBounds(g) {
5247
+ const ct = g.__cropData;
5248
+ if (!ct || ct.fit !== "contain") return;
5249
+ const img = ct._img;
5250
+ if (!img) return;
5251
+ const clip = g.clipPath;
5252
+ if (clip && (isSvgMaskClipPath(clip) || isLuminanceMaskClipPath(clip) || clip.__svgMask || clip.__edgeFadeMask)) return;
5253
+ const iw = img.width || 0;
5254
+ const ih = img.height || 0;
5255
+ const sx = Math.abs(img.scaleX || 1);
5256
+ const sy = Math.abs(img.scaleY || 1);
5257
+ const dispW = iw * sx;
5258
+ const dispH = ih * sy;
5259
+ if (dispW <= 0 || dispH <= 0) return;
5260
+ const frameW = Number(ct.frameW) || g.width || dispW;
5261
+ const frameH = Number(ct.frameH) || g.height || dispH;
5262
+ const alignH = ct.alignH ?? "center";
5263
+ const alignV = ct.alignV ?? "middle";
5264
+ const slackX = frameW - dispW;
5265
+ const slackY = frameH - dispH;
5266
+ const offsetX = alignH === "left" ? -slackX / 2 : alignH === "right" ? slackX / 2 : 0;
5267
+ const offsetY = alignV === "top" ? -slackY / 2 : alignV === "bottom" ? slackY / 2 : 0;
5268
+ const angleRad = fabric.util.degreesToRadians(g.angle || 0);
5269
+ const cos = Math.cos(angleRad);
5270
+ const sin = Math.sin(angleRad);
5271
+ const worldDx = offsetX * cos - offsetY * sin;
5272
+ const worldDy = offsetX * sin + offsetY * cos;
5273
+ g.set({
5274
+ left: (g.left || 0) + worldDx,
5275
+ top: (g.top || 0) + worldDy,
5276
+ width: dispW,
5277
+ height: dispH
5278
+ });
5279
+ img.set({ left: 0, top: 0 });
5280
+ if (clip) {
5281
+ if (clip instanceof fabric.Rect) {
5282
+ const rxRatio = Number(ct.rx) || 0;
5283
+ const rxPx = rxRatio > 0.5 ? Math.min(rxRatio, dispW / 2, dispH / 2) : Math.max(0, Math.min(rxRatio * Math.min(dispW, dispH), dispW / 2, dispH / 2));
5284
+ clip.set({ width: dispW, height: dispH, rx: rxPx, ry: rxPx });
5285
+ } else if (clip instanceof fabric.Ellipse) {
5286
+ clip.set({ rx: dispW / 2, ry: dispH / 2 });
5287
+ }
5288
+ clip.dirty = true;
5289
+ }
5290
+ g.dirty = true;
5291
+ g.setCoords();
5292
+ }
5246
5293
  function getDomEvent(eventData) {
5247
5294
  return (eventData == null ? void 0 : eventData.e) ?? eventData ?? null;
5248
5295
  }
@@ -17634,6 +17681,7 @@ const PageCanvas = forwardRef(
17634
17681
  ct.fit = elFit;
17635
17682
  }
17636
17683
  updateCoverLayout(existingObj);
17684
+ shrinkContainGroupToImageBounds(existingObj);
17637
17685
  applyEdgeFadeFrameClipPath(existingObj, element, ct.frameW, ct.frameH, ct.shape || "rect", ct.rx || 0);
17638
17686
  if (allowEditing) {
17639
17687
  installImageResizeControlsWithSnap(existingObj);
@@ -17741,6 +17789,7 @@ const PageCanvas = forwardRef(
17741
17789
  ctSync.alignV = element.imageAlignV ?? "middle";
17742
17790
  ctSync.containScale = Math.max(1, Math.min(3, Number(element.containScale ?? 1)));
17743
17791
  updateCoverLayout(existingObj);
17792
+ shrinkContainGroupToImageBounds(existingObj);
17744
17793
  existingObj.dirty = true;
17745
17794
  }
17746
17795
  }
@@ -19707,6 +19756,7 @@ const PageCanvas = forwardRef(
19707
19756
  updateCoverLayout(cropGroup);
19708
19757
  }
19709
19758
  applyEdgeFadeFrameClipPath(cropGroup, element, frameW, frameH, shape, rxRatio);
19759
+ shrinkContainGroupToImageBounds(cropGroup);
19710
19760
  setObjectData(cropGroup, element.id);
19711
19761
  cropGroup.__imageElement = cropImg;
19712
19762
  cropGroup.__imageSrc = imageUrl;
@@ -26290,9 +26340,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26290
26340
  }
26291
26341
  return svgString;
26292
26342
  }
26293
- const resolvedPackageVersion = "0.5.465";
26343
+ const resolvedPackageVersion = "0.5.466";
26294
26344
  const PACKAGE_VERSION = resolvedPackageVersion;
26295
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.465";
26345
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.466";
26296
26346
  const roundParityValue = (value) => {
26297
26347
  if (typeof value !== "number") return value;
26298
26348
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27106,7 +27156,7 @@ class PixldocsRenderer {
27106
27156
  await this.waitForCanvasScene(container, cloned, i);
27107
27157
  }
27108
27158
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27109
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CVeVbCo7.js");
27159
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CYNj9Z_A.js");
27110
27160
  const prepared = preparePagesForExport(
27111
27161
  cloned.pages,
27112
27162
  canvasWidth,
@@ -29426,7 +29476,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29426
29476
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29427
29477
  sanitizeSvgTreeForPdf(svgToDraw);
29428
29478
  try {
29429
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CVeVbCo7.js");
29479
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CYNj9Z_A.js");
29430
29480
  try {
29431
29481
  await logTextMeasurementDiagnostic(svgToDraw);
29432
29482
  } catch {
@@ -29743,4 +29793,4 @@ export {
29743
29793
  buildTeaserBlurFlatKeys as y,
29744
29794
  collectFontDescriptorsFromConfig as z
29745
29795
  };
29746
- //# sourceMappingURL=index-DmkAdvKz.js.map
29796
+ //# sourceMappingURL=index-B_lTeUY-.js.map