@pixldocs/canvas-renderer 0.5.406 → 0.5.408

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.
@@ -13237,23 +13237,27 @@ const PageCanvas = forwardRef(
13237
13237
  transformingIdsRef.current.clear();
13238
13238
  };
13239
13239
  const prepareGroupSelectionTransformStart = (target) => {
13240
- var _a2, _b2, _c2;
13240
+ var _a2, _b2, _c2, _d, _e;
13241
13241
  const active = target instanceof fabric.ActiveSelection ? target : fabricCanvas.getActiveObject();
13242
13242
  if (!(active instanceof fabric.ActiveSelection)) return;
13243
13243
  try {
13244
- const asScaleX = Math.abs(active.scaleX ?? 1);
13245
- const asScaleY = Math.abs(active.scaleY ?? 1);
13246
- if (Math.abs(asScaleX - 1) > 1e-4 || Math.abs(asScaleY - 1) > 1e-4) {
13247
- const newW = Math.max(1, (active.width ?? 0) * asScaleX);
13248
- const newH = Math.max(1, (active.height ?? 0) * asScaleY);
13249
- active.set({ width: newW, height: newH, scaleX: 1, scaleY: 1 });
13244
+ const canvasWithTransform = fabricCanvas;
13245
+ const ct = canvasWithTransform._currentTransform;
13246
+ const rawScaleX = Number(active.scaleX ?? 1) || 1;
13247
+ const rawScaleY = Number(active.scaleY ?? 1) || 1;
13248
+ const originalScaleX = Number((ct == null ? void 0 : ct.target) === active ? (_a2 = ct == null ? void 0 : ct.original) == null ? void 0 : _a2.scaleX : rawScaleX) || 1;
13249
+ const originalScaleY = Number((ct == null ? void 0 : ct.target) === active ? (_b2 = ct == null ? void 0 : ct.original) == null ? void 0 : _b2.scaleY : rawScaleY) || 1;
13250
+ const liveDeltaX = Math.abs(rawScaleX / originalScaleX);
13251
+ const liveDeltaY = Math.abs(rawScaleY / originalScaleY);
13252
+ const hasResidualOriginal = Math.abs(Math.abs(originalScaleX) - 1) > 1e-4 || Math.abs(Math.abs(originalScaleY) - 1) > 1e-4;
13253
+ const hasNoLiveDragDelta = Math.abs(liveDeltaX - 1) < 5e-4 && Math.abs(liveDeltaY - 1) < 5e-4;
13254
+ const canNormalize = (ct == null ? void 0 : ct.target) === active ? hasResidualOriginal && hasNoLiveDragDelta : Math.abs(Math.abs(rawScaleX) - 1) > 1e-4 || Math.abs(Math.abs(rawScaleY) - 1) > 1e-4;
13255
+ if (canNormalize) {
13256
+ active.set({ scaleX: 1, scaleY: 1 });
13250
13257
  active.setCoords();
13251
- const ct = fabricCanvas._currentTransform;
13252
13258
  if (ct && ct.target === active && ct.original) {
13253
13259
  ct.original.scaleX = 1;
13254
13260
  ct.original.scaleY = 1;
13255
- ct.original.width = newW;
13256
- ct.original.height = newH;
13257
13261
  }
13258
13262
  }
13259
13263
  } catch {
@@ -13268,14 +13272,14 @@ const PageCanvas = forwardRef(
13268
13272
  }
13269
13273
  const groupId = active.__pixldocsGroupSelection;
13270
13274
  if (!groupId) return;
13271
- if (((_a2 = groupSelectionTransformStartRef.current) == null ? void 0 : _a2.groupId) === groupId && groupSelectionTransformStartRef.current.selection === active) return;
13272
- const pageChildren2 = ((_b2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _b2.children) ?? [];
13275
+ if (((_c2 = groupSelectionTransformStartRef.current) == null ? void 0 : _c2.groupId) === groupId && groupSelectionTransformStartRef.current.selection === active) return;
13276
+ const pageChildren2 = ((_d = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
13273
13277
  const groupNode = findNodeById(pageChildren2, groupId);
13274
13278
  if (!groupNode) return;
13275
13279
  const groupAbs = getAbsoluteBounds(groupNode, pageChildren2);
13276
13280
  const rect = active.getBoundingRect();
13277
13281
  const currentTransform = fabricCanvas._currentTransform;
13278
- const originalSelectionAngle = (currentTransform == null ? void 0 : currentTransform.target) === active && typeof ((_c2 = currentTransform == null ? void 0 : currentTransform.original) == null ? void 0 : _c2.angle) === "number" ? currentTransform.original.angle : active.angle ?? 0;
13282
+ const originalSelectionAngle = (currentTransform == null ? void 0 : currentTransform.target) === active && typeof ((_e = currentTransform == null ? void 0 : currentTransform.original) == null ? void 0 : _e.angle) === "number" ? currentTransform.original.angle : active.angle ?? 0;
13279
13283
  groupSelectionTransformStartRef.current = {
13280
13284
  groupId,
13281
13285
  selection: active,
@@ -14658,14 +14662,15 @@ const PageCanvas = forwardRef(
14658
14662
  }
14659
14663
  const normalizedScaleAngle = ((obj.angle ?? 0) % 360 + 360) % 360;
14660
14664
  const isRotatedActiveSelectionCorner = obj instanceof fabric.ActiveSelection && isCornerResizeHandle(corner) && Math.min(normalizedScaleAngle, 360 - normalizedScaleAngle) > 0.5;
14661
- if (!isRotatedActiveSelectionCorner) {
14665
+ const isRotatedActiveSelectionSide = obj instanceof fabric.ActiveSelection && (corner === "mt" || corner === "mb" || corner === "ml" || corner === "mr") && Math.min(normalizedScaleAngle, 360 - normalizedScaleAngle) > 0.5;
14666
+ if (!isRotatedActiveSelectionCorner && !isRotatedActiveSelectionSide) {
14662
14667
  snapDuringScaleCallback(obj, corner);
14663
14668
  }
14664
- const scaleGuides = isRotatedActiveSelectionCorner ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14669
+ const scaleGuides = isRotatedActiveSelectionCorner || isRotatedActiveSelectionSide ? [] : calculateScaleSnapGuidesCallback(obj, corner);
14665
14670
  const gridGuidesForScale = [];
14666
14671
  try {
14667
14672
  const psGrid = projectSettingsRef.current;
14668
- const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !obj.__cropGroup && !obj.__resizeSnapHandler;
14673
+ const canApplyGridSnap = psGrid.snapToGrid && corner && !isRotatedActiveSelectionCorner && !isRotatedActiveSelectionSide && !obj.__cropGroup && !obj.__resizeSnapHandler;
14669
14674
  if (canApplyGridSnap) {
14670
14675
  const gridX = psGrid.gridSizeX ?? psGrid.gridSize ?? 0;
14671
14676
  const gridY = psGrid.gridSizeY ?? psGrid.gridSize ?? 0;
@@ -25156,9 +25161,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25156
25161
  }
25157
25162
  return svgString;
25158
25163
  }
25159
- const resolvedPackageVersion = "0.5.406";
25164
+ const resolvedPackageVersion = "0.5.408";
25160
25165
  const PACKAGE_VERSION = resolvedPackageVersion;
25161
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.406";
25166
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.408";
25162
25167
  const roundParityValue = (value) => {
25163
25168
  if (typeof value !== "number") return value;
25164
25169
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25972,7 +25977,7 @@ class PixldocsRenderer {
25972
25977
  await this.waitForCanvasScene(container, cloned, i);
25973
25978
  }
25974
25979
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25975
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BSFv6jYQ.js");
25980
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-PXI2Nd-d.js");
25976
25981
  const prepared = preparePagesForExport(
25977
25982
  cloned.pages,
25978
25983
  canvasWidth,
@@ -28292,7 +28297,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28292
28297
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28293
28298
  sanitizeSvgTreeForPdf(svgToDraw);
28294
28299
  try {
28295
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BSFv6jYQ.js");
28300
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-PXI2Nd-d.js");
28296
28301
  try {
28297
28302
  await logTextMeasurementDiagnostic(svgToDraw);
28298
28303
  } catch {
@@ -28692,4 +28697,4 @@ export {
28692
28697
  buildTeaserBlurFlatKeys as y,
28693
28698
  collectFontDescriptorsFromConfig as z
28694
28699
  };
28695
- //# sourceMappingURL=index-D-UEBi3B.js.map
28700
+ //# sourceMappingURL=index-D_anatnh.js.map