@pixldocs/canvas-renderer 0.5.467 → 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.
@@ -5255,22 +5255,6 @@ function updateCoverLayout(g) {
5255
5255
  if (g.clipPath) {
5256
5256
  g.clipPath.dirty = true;
5257
5257
  }
5258
- if (fitContain && g.clipPath) {
5259
- const clip = g.clipPath;
5260
- const isSpecialMask = isSvgMaskClipPath(clip) || isLuminanceMaskClipPath(clip) || clip.__svgMask || clip.__edgeFadeMask;
5261
- if (!isSpecialMask) {
5262
- const clipW = Math.max(frameW, dispW);
5263
- const clipH = Math.max(frameH, dispH);
5264
- if (clip instanceof fabric__namespace.Rect) {
5265
- const rxRatioCt = Number(ct.rx) || 0;
5266
- const rxPx = rxRatioCt > 0.5 ? Math.min(rxRatioCt, clipW / 2, clipH / 2) : Math.max(0, Math.min(rxRatioCt * Math.min(clipW, clipH), clipW / 2, clipH / 2));
5267
- clip.set({ width: clipW, height: clipH, rx: rxPx, ry: rxPx, left: offsetX, top: offsetY });
5268
- } else if (clip instanceof fabric__namespace.Ellipse) {
5269
- clip.set({ rx: clipW / 2, ry: clipH / 2, left: offsetX, top: offsetY });
5270
- }
5271
- clip.dirty = true;
5272
- }
5273
- }
5274
5258
  finalizeCropGroupCoords(g);
5275
5259
  if (g.canvas) {
5276
5260
  g.setCoords();
@@ -12315,18 +12299,21 @@ const PageCanvas = react.forwardRef(
12315
12299
  if (id && id !== "__background__") {
12316
12300
  const width = (obj.width ?? 0) * (obj.scaleX ?? 1);
12317
12301
  const height = (obj.height ?? 0) * (obj.scaleY ?? 1);
12318
- let left = obj.left ?? 0;
12319
- let top = obj.top ?? 0;
12320
- if (obj instanceof fabric__namespace.Group && obj.__cropGroup) {
12321
- left = left - width / 2;
12322
- top = top - height / 2;
12323
- } else if (obj.originX === "center" || obj.originY === "center") {
12324
- const offsetX = obj.originX === "center" ? width / 2 : 0;
12325
- const offsetY = obj.originY === "center" ? height / 2 : 0;
12326
- left = left - offsetX;
12327
- top = top - offsetY;
12302
+ const angle = obj.angle ?? 0;
12303
+ let left;
12304
+ let top;
12305
+ const centerFn = obj.getCenterPoint;
12306
+ if (typeof centerFn === "function") {
12307
+ const c = centerFn.call(obj);
12308
+ left = c.x - width / 2;
12309
+ top = c.y - height / 2;
12310
+ } else {
12311
+ left = obj.left ?? 0;
12312
+ top = obj.top ?? 0;
12313
+ if (obj.originX === "center") left -= width / 2;
12314
+ if (obj.originY === "center") top -= height / 2;
12328
12315
  }
12329
- result.set(id, { left, top, width, height });
12316
+ result.set(id, { left, top, width, height, angle });
12330
12317
  }
12331
12318
  });
12332
12319
  return result;
@@ -17501,6 +17488,17 @@ const PageCanvas = react.forwardRef(
17501
17488
  const fadeKeyChanged = newFadeKey !== oldFadeKey || newFadeKey !== innerOldKey || cropFadeRendererMissing;
17502
17489
  const needsReload = sourceUrlChanged || colorMapChanged || fadeKeyChanged && !isCropGroup2;
17503
17490
  const needsCropGroupFadeUpdate = isCropGroup2 && fadeKeyChanged;
17491
+ let cropFrameSizeChanged = false;
17492
+ if (isCropGroup2) {
17493
+ const liveCt = existingObj.__cropData;
17494
+ const liveW = Number(liveCt == null ? void 0 : liveCt.frameW) || 0;
17495
+ const liveH = Number(liveCt == null ? void 0 : liveCt.frameH) || 0;
17496
+ const schemaW = (Number(element.width) || 0) * (Number(element.scaleX) || 1);
17497
+ const schemaH = (Number(element.height) || 0) * (Number(element.scaleY) || 1);
17498
+ if (schemaW > 0 && schemaH > 0 && (Math.abs(schemaW - liveW) > 0.5 || Math.abs(schemaH - liveH) > 0.5)) {
17499
+ cropFrameSizeChanged = true;
17500
+ }
17501
+ }
17504
17502
  const hadUrlBefore = storedImageUrl && String(storedImageUrl).trim() !== "";
17505
17503
  if (!hasUrl && hadUrlBefore) {
17506
17504
  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 };
@@ -17537,7 +17535,7 @@ const PageCanvas = react.forwardRef(
17537
17535
  const clipShapeForReplace = element.clipShape ?? ((_g = element.style) == null ? void 0 : _g.imageFrameShape) ?? (isPreviewMode ? "rectangle" : "none");
17538
17536
  const needCropGroupForElement = imageFitForReplace !== "fill" || clipShapeForReplace && clipShapeForReplace !== "none";
17539
17537
  const plainImageNeedsCropGroup = hasUrl && !isCropGroup2 && existingObj instanceof fabric__namespace.FabricImage && needCropGroupForElement;
17540
- if (hasUrl && (needsReload || isPlaceholder || plainImageNeedsCropGroup || needsCropGroupFadeUpdate)) {
17538
+ if (hasUrl && (needsReload || isPlaceholder || plainImageNeedsCropGroup || needsCropGroupFadeUpdate || cropFrameSizeChanged)) {
17541
17539
  if (needsReload && !isBeingTransformed && (!wasJustModified || sourceUrlChanged)) {
17542
17540
  loadImageAsync2(element, existingObj, fc);
17543
17541
  } else if (plainImageNeedsCropGroup) {
@@ -20476,7 +20474,9 @@ function PreviewCanvas({
20476
20474
  border: isHovered ? "2px solid rgb(59 130 246)" : "none",
20477
20475
  backgroundColor: isHovered ? "rgba(59, 130, 246, 0.1)" : "transparent",
20478
20476
  borderRadius: 4,
20479
- pointerEvents: "auto"
20477
+ pointerEvents: "auto",
20478
+ transform: (bounds == null ? void 0 : bounds.angle) ? `rotate(${bounds.angle}deg)` : void 0,
20479
+ transformOrigin: "center center"
20480
20480
  },
20481
20481
  onMouseEnter: () => setHoveredFieldId(element.id),
20482
20482
  onMouseLeave: () => setHoveredFieldId(null),
@@ -26313,9 +26313,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26313
26313
  }
26314
26314
  return svgString;
26315
26315
  }
26316
- const resolvedPackageVersion = "0.5.467";
26316
+ const resolvedPackageVersion = "0.5.468";
26317
26317
  const PACKAGE_VERSION = resolvedPackageVersion;
26318
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.467";
26318
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.468";
26319
26319
  const roundParityValue = (value) => {
26320
26320
  if (typeof value !== "number") return value;
26321
26321
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27129,7 +27129,7 @@ class PixldocsRenderer {
27129
27129
  await this.waitForCanvasScene(container, cloned, i);
27130
27130
  }
27131
27131
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27132
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CYxG1Qy-.cjs"));
27132
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CsY4HpZu.cjs"));
27133
27133
  const prepared = preparePagesForExport(
27134
27134
  cloned.pages,
27135
27135
  canvasWidth,
@@ -29449,7 +29449,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29449
29449
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29450
29450
  sanitizeSvgTreeForPdf(svgToDraw);
29451
29451
  try {
29452
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CYxG1Qy-.cjs"));
29452
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CsY4HpZu.cjs"));
29453
29453
  try {
29454
29454
  await logTextMeasurementDiagnostic(svgToDraw);
29455
29455
  } catch {
@@ -29763,4 +29763,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29763
29763
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29764
29764
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29765
29765
  exports.warmTemplateFromForm = warmTemplateFromForm;
29766
- //# sourceMappingURL=index-JJbf0DOF.cjs.map
29766
+ //# sourceMappingURL=index-DoJk8IkH.cjs.map