@pixldocs/canvas-renderer 0.5.466 → 0.5.468

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,53 +5243,6 @@ 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
- }
5293
5246
  function getDomEvent(eventData) {
5294
5247
  return (eventData == null ? void 0 : eventData.e) ?? eventData ?? null;
5295
5248
  }
@@ -12328,18 +12281,21 @@ const PageCanvas = forwardRef(
12328
12281
  if (id && id !== "__background__") {
12329
12282
  const width = (obj.width ?? 0) * (obj.scaleX ?? 1);
12330
12283
  const height = (obj.height ?? 0) * (obj.scaleY ?? 1);
12331
- let left = obj.left ?? 0;
12332
- let top = obj.top ?? 0;
12333
- if (obj instanceof fabric.Group && obj.__cropGroup) {
12334
- left = left - width / 2;
12335
- top = top - height / 2;
12336
- } else if (obj.originX === "center" || obj.originY === "center") {
12337
- const offsetX = obj.originX === "center" ? width / 2 : 0;
12338
- const offsetY = obj.originY === "center" ? height / 2 : 0;
12339
- left = left - offsetX;
12340
- top = top - offsetY;
12284
+ const angle = obj.angle ?? 0;
12285
+ let left;
12286
+ let top;
12287
+ const centerFn = obj.getCenterPoint;
12288
+ if (typeof centerFn === "function") {
12289
+ const c = centerFn.call(obj);
12290
+ left = c.x - width / 2;
12291
+ top = c.y - height / 2;
12292
+ } else {
12293
+ left = obj.left ?? 0;
12294
+ top = obj.top ?? 0;
12295
+ if (obj.originX === "center") left -= width / 2;
12296
+ if (obj.originY === "center") top -= height / 2;
12341
12297
  }
12342
- result.set(id, { left, top, width, height });
12298
+ result.set(id, { left, top, width, height, angle });
12343
12299
  }
12344
12300
  });
12345
12301
  return result;
@@ -17681,7 +17637,6 @@ const PageCanvas = forwardRef(
17681
17637
  ct.fit = elFit;
17682
17638
  }
17683
17639
  updateCoverLayout(existingObj);
17684
- shrinkContainGroupToImageBounds(existingObj);
17685
17640
  applyEdgeFadeFrameClipPath(existingObj, element, ct.frameW, ct.frameH, ct.shape || "rect", ct.rx || 0);
17686
17641
  if (allowEditing) {
17687
17642
  installImageResizeControlsWithSnap(existingObj);
@@ -17789,7 +17744,6 @@ const PageCanvas = forwardRef(
17789
17744
  ctSync.alignV = element.imageAlignV ?? "middle";
17790
17745
  ctSync.containScale = Math.max(1, Math.min(3, Number(element.containScale ?? 1)));
17791
17746
  updateCoverLayout(existingObj);
17792
- shrinkContainGroupToImageBounds(existingObj);
17793
17747
  existingObj.dirty = true;
17794
17748
  }
17795
17749
  }
@@ -19756,7 +19710,6 @@ const PageCanvas = forwardRef(
19756
19710
  updateCoverLayout(cropGroup);
19757
19711
  }
19758
19712
  applyEdgeFadeFrameClipPath(cropGroup, element, frameW, frameH, shape, rxRatio);
19759
- shrinkContainGroupToImageBounds(cropGroup);
19760
19713
  setObjectData(cropGroup, element.id);
19761
19714
  cropGroup.__imageElement = cropImg;
19762
19715
  cropGroup.__imageSrc = imageUrl;
@@ -20503,7 +20456,9 @@ function PreviewCanvas({
20503
20456
  border: isHovered ? "2px solid rgb(59 130 246)" : "none",
20504
20457
  backgroundColor: isHovered ? "rgba(59, 130, 246, 0.1)" : "transparent",
20505
20458
  borderRadius: 4,
20506
- pointerEvents: "auto"
20459
+ pointerEvents: "auto",
20460
+ transform: (bounds == null ? void 0 : bounds.angle) ? `rotate(${bounds.angle}deg)` : void 0,
20461
+ transformOrigin: "center center"
20507
20462
  },
20508
20463
  onMouseEnter: () => setHoveredFieldId(element.id),
20509
20464
  onMouseLeave: () => setHoveredFieldId(null),
@@ -26340,9 +26295,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26340
26295
  }
26341
26296
  return svgString;
26342
26297
  }
26343
- const resolvedPackageVersion = "0.5.466";
26298
+ const resolvedPackageVersion = "0.5.468";
26344
26299
  const PACKAGE_VERSION = resolvedPackageVersion;
26345
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.466";
26300
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.468";
26346
26301
  const roundParityValue = (value) => {
26347
26302
  if (typeof value !== "number") return value;
26348
26303
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27156,7 +27111,7 @@ class PixldocsRenderer {
27156
27111
  await this.waitForCanvasScene(container, cloned, i);
27157
27112
  }
27158
27113
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27159
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CYNj9Z_A.js");
27114
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-C7FmPpVD.js");
27160
27115
  const prepared = preparePagesForExport(
27161
27116
  cloned.pages,
27162
27117
  canvasWidth,
@@ -29476,7 +29431,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29476
29431
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29477
29432
  sanitizeSvgTreeForPdf(svgToDraw);
29478
29433
  try {
29479
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CYNj9Z_A.js");
29434
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-C7FmPpVD.js");
29480
29435
  try {
29481
29436
  await logTextMeasurementDiagnostic(svgToDraw);
29482
29437
  } catch {
@@ -29793,4 +29748,4 @@ export {
29793
29748
  buildTeaserBlurFlatKeys as y,
29794
29749
  collectFontDescriptorsFromConfig as z
29795
29750
  };
29796
- //# sourceMappingURL=index-B_lTeUY-.js.map
29751
+ //# sourceMappingURL=index-CGFOtPDx.js.map