@pixldocs/canvas-renderer 0.5.314 → 0.5.316

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.
@@ -11184,8 +11184,23 @@ function applyWarpAwareSelectionBorders(selection) {
11184
11184
  ));
11185
11185
  const worldAngles = worldMatrices.map((m) => norm(fabric.util.qrDecompose(m).angle ?? 0));
11186
11186
  const first = worldAngles[0] ?? 0;
11187
- const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= 0.5);
11187
+ const ALL_SAME_TOL_DEG = 2;
11188
+ const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= ALL_SAME_TOL_DEG);
11189
+ const anyRotated = worldAngles.some((a) => Math.abs(a) > 0.5);
11190
+ let targetAngle = null;
11188
11191
  if (allSame) {
11192
+ targetAngle = first;
11193
+ } else if (anyRotated) {
11194
+ const rad = (d) => d * Math.PI / 180;
11195
+ const deg = (r) => r * 180 / Math.PI;
11196
+ let sx = 0, sy = 0;
11197
+ for (const a of worldAngles) {
11198
+ sx += Math.cos(rad(a));
11199
+ sy += Math.sin(rad(a));
11200
+ }
11201
+ targetAngle = norm(deg(Math.atan2(sy, sx)));
11202
+ }
11203
+ if (targetAngle != null) {
11189
11204
  const restoreKidsFromWorld = () => {
11190
11205
  const invSelection = fabric.util.invertTransform(
11191
11206
  selection.calcTransformMatrix()
@@ -11200,7 +11215,7 @@ function applyWarpAwareSelectionBorders(selection) {
11200
11215
  k.dirty = true;
11201
11216
  });
11202
11217
  };
11203
- selection.set({ angle: first, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11218
+ selection.set({ angle: targetAngle, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11204
11219
  restoreKidsFromWorld();
11205
11220
  try {
11206
11221
  (_a2 = selection.triggerLayout) == null ? void 0 : _a2.call(selection);
@@ -11209,20 +11224,8 @@ function applyWarpAwareSelectionBorders(selection) {
11209
11224
  restoreKidsFromWorld();
11210
11225
  selection.setCoords();
11211
11226
  selection.dirty = true;
11212
- selection.__pixldocsAlignedAngle = first;
11213
- } else {
11214
- const anyRotated = worldAngles.some((a) => Math.abs(a) > 0.5);
11215
- if (anyRotated) {
11216
- try {
11217
- selection.setControlsVisibility({
11218
- ml: false,
11219
- mr: false,
11220
- mt: false,
11221
- mb: false
11222
- });
11223
- } catch {
11224
- }
11225
- }
11227
+ selection.__pixldocsAlignedAngle = targetAngle;
11228
+ if (!allSame) selection.__pixldocsMixedRotation = true;
11226
11229
  }
11227
11230
  }
11228
11231
  }
@@ -13567,10 +13570,21 @@ const PageCanvas = forwardRef(
13567
13570
  fabricCanvas.on("selection:cleared", () => {
13568
13571
  });
13569
13572
  fabricCanvas.on("object:scaling", (e) => {
13570
- var _a2, _b2, _c, _d, _e, _f;
13573
+ var _a2, _b2, _c, _d, _e, _f, _g;
13571
13574
  if (!isActiveRef.current) return;
13572
13575
  const t = e.target;
13573
13576
  if (t) lastResizeScaleTargetRef.current = t;
13577
+ try {
13578
+ if (t instanceof fabric.ActiveSelection && t.__pixldocsMixedRotation) {
13579
+ const corner2 = (_a2 = e.transform) == null ? void 0 : _a2.corner;
13580
+ if (corner2 === "ml" || corner2 === "mr") {
13581
+ t.scaleY = t.scaleX;
13582
+ } else if (corner2 === "mt" || corner2 === "mb") {
13583
+ t.scaleX = t.scaleY;
13584
+ }
13585
+ }
13586
+ } catch {
13587
+ }
13574
13588
  prepareGroupSelectionTransformStart(t);
13575
13589
  markTransforming(t);
13576
13590
  didTransformRef.current = true;
@@ -13734,7 +13748,7 @@ const PageCanvas = forwardRef(
13734
13748
  time: Math.round(performance.now()),
13735
13749
  corner,
13736
13750
  groupSelectionId: obj.__pixldocsGroupSelection,
13737
- currentTransformAction: (_a2 = fabricCanvas._currentTransform) == null ? void 0 : _a2.action,
13751
+ currentTransformAction: (_b2 = fabricCanvas._currentTransform) == null ? void 0 : _b2.action,
13738
13752
  selection: summarizeFabricObjectForResizeDebug(obj),
13739
13753
  textChildren: obj.getObjects().filter((child) => child instanceof fabric.Textbox).map((child) => summarizeFabricObjectForResizeDebug(child))
13740
13754
  };
@@ -13744,13 +13758,13 @@ const PageCanvas = forwardRef(
13744
13758
  const isXSide = corner === "ml" || corner === "mr";
13745
13759
  const sAxis = isXSide ? Math.abs(obj.scaleX ?? 1) : Math.abs(obj.scaleY ?? 1);
13746
13760
  if (sAxis > 1e-3) {
13747
- if (isXSide && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13761
+ if (isXSide && ((_c = groupShiftReflowSnapshotRef.current) == null ? void 0 : _c.selection) !== obj) {
13748
13762
  groupShiftReflowSnapshotRef.current = null;
13749
13763
  const logicalGroupId = obj.__pixldocsGroupSelection;
13750
13764
  if (logicalGroupId) {
13751
13765
  try {
13752
13766
  const state = useEditorStore.getState();
13753
- const pageChildren2 = ((_c = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _c.children) ?? [];
13767
+ const pageChildren2 = ((_d = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
13754
13768
  const groupNode = findNodeById(pageChildren2, logicalGroupId);
13755
13769
  if (groupNode && isGroup(groupNode) && !isStackLayoutMode(groupNode.layoutMode)) {
13756
13770
  const entries = obj.getObjects().map((c) => ({
@@ -13780,7 +13794,7 @@ const PageCanvas = forwardRef(
13780
13794
  const asRect0 = obj.getBoundingRect();
13781
13795
  let didReflowTextChild = false;
13782
13796
  for (const child of obj.getObjects()) {
13783
- if (child instanceof fabric.Group && (child.__cropGroup || ((_d = child._ct) == null ? void 0 : _d.isCropGroup))) {
13797
+ if (child instanceof fabric.Group && (child.__cropGroup || ((_e = child._ct) == null ? void 0 : _e.isCropGroup))) {
13784
13798
  const ct = child.__cropData;
13785
13799
  if (!ct) continue;
13786
13800
  if (isXSide) {
@@ -13885,7 +13899,7 @@ const PageCanvas = forwardRef(
13885
13899
  didReflowTextChild = true;
13886
13900
  }
13887
13901
  }
13888
- if (isXSide && ((_e = groupShiftReflowSnapshotRef.current) == null ? void 0 : _e.selection) === obj) {
13902
+ if (isXSide && ((_f = groupShiftReflowSnapshotRef.current) == null ? void 0 : _f.selection) === obj) {
13889
13903
  const snap = groupShiftReflowSnapshotRef.current;
13890
13904
  const anchorEntry = snap.children[0];
13891
13905
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -14041,7 +14055,7 @@ const PageCanvas = forwardRef(
14041
14055
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
14042
14056
  if (drilledGroupIdRef.current) {
14043
14057
  try {
14044
- (_f = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _f.call(fabricCanvas);
14058
+ (_g = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _g.call(fabricCanvas);
14045
14059
  } catch {
14046
14060
  }
14047
14061
  }
@@ -24271,9 +24285,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24271
24285
  }
24272
24286
  return svgString;
24273
24287
  }
24274
- const resolvedPackageVersion = "0.5.314";
24288
+ const resolvedPackageVersion = "0.5.316";
24275
24289
  const PACKAGE_VERSION = resolvedPackageVersion;
24276
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.314";
24290
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.316";
24277
24291
  const roundParityValue = (value) => {
24278
24292
  if (typeof value !== "number") return value;
24279
24293
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25087,7 +25101,7 @@ class PixldocsRenderer {
25087
25101
  await this.waitForCanvasScene(container, cloned, i);
25088
25102
  }
25089
25103
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25090
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DBoLqkEn.js");
25104
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DR523IAy.js");
25091
25105
  const prepared = preparePagesForExport(
25092
25106
  cloned.pages,
25093
25107
  canvasWidth,
@@ -27407,7 +27421,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27407
27421
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27408
27422
  sanitizeSvgTreeForPdf(svgToDraw);
27409
27423
  try {
27410
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DBoLqkEn.js");
27424
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DR523IAy.js");
27411
27425
  try {
27412
27426
  await logTextMeasurementDiagnostic(svgToDraw);
27413
27427
  } catch {
@@ -27807,4 +27821,4 @@ export {
27807
27821
  buildTeaserBlurFlatKeys as y,
27808
27822
  collectFontDescriptorsFromConfig as z
27809
27823
  };
27810
- //# sourceMappingURL=index-Dr4Grd18.js.map
27824
+ //# sourceMappingURL=index-D23LGkaT.js.map