@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.
@@ -11202,8 +11202,23 @@ function applyWarpAwareSelectionBorders(selection) {
11202
11202
  ));
11203
11203
  const worldAngles = worldMatrices.map((m) => norm(fabric__namespace.util.qrDecompose(m).angle ?? 0));
11204
11204
  const first = worldAngles[0] ?? 0;
11205
- const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= 0.5);
11205
+ const ALL_SAME_TOL_DEG = 2;
11206
+ const allSame = Math.abs(first) > 0.5 && worldAngles.every((a) => angleDelta(a, first) <= ALL_SAME_TOL_DEG);
11207
+ const anyRotated = worldAngles.some((a) => Math.abs(a) > 0.5);
11208
+ let targetAngle = null;
11206
11209
  if (allSame) {
11210
+ targetAngle = first;
11211
+ } else if (anyRotated) {
11212
+ const rad = (d) => d * Math.PI / 180;
11213
+ const deg = (r) => r * 180 / Math.PI;
11214
+ let sx = 0, sy = 0;
11215
+ for (const a of worldAngles) {
11216
+ sx += Math.cos(rad(a));
11217
+ sy += Math.sin(rad(a));
11218
+ }
11219
+ targetAngle = norm(deg(Math.atan2(sy, sx)));
11220
+ }
11221
+ if (targetAngle != null) {
11207
11222
  const restoreKidsFromWorld = () => {
11208
11223
  const invSelection = fabric__namespace.util.invertTransform(
11209
11224
  selection.calcTransformMatrix()
@@ -11218,7 +11233,7 @@ function applyWarpAwareSelectionBorders(selection) {
11218
11233
  k.dirty = true;
11219
11234
  });
11220
11235
  };
11221
- selection.set({ angle: first, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11236
+ selection.set({ angle: targetAngle, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11222
11237
  restoreKidsFromWorld();
11223
11238
  try {
11224
11239
  (_a2 = selection.triggerLayout) == null ? void 0 : _a2.call(selection);
@@ -11227,20 +11242,8 @@ function applyWarpAwareSelectionBorders(selection) {
11227
11242
  restoreKidsFromWorld();
11228
11243
  selection.setCoords();
11229
11244
  selection.dirty = true;
11230
- selection.__pixldocsAlignedAngle = first;
11231
- } else {
11232
- const anyRotated = worldAngles.some((a) => Math.abs(a) > 0.5);
11233
- if (anyRotated) {
11234
- try {
11235
- selection.setControlsVisibility({
11236
- ml: false,
11237
- mr: false,
11238
- mt: false,
11239
- mb: false
11240
- });
11241
- } catch {
11242
- }
11243
- }
11245
+ selection.__pixldocsAlignedAngle = targetAngle;
11246
+ if (!allSame) selection.__pixldocsMixedRotation = true;
11244
11247
  }
11245
11248
  }
11246
11249
  }
@@ -13585,10 +13588,21 @@ const PageCanvas = react.forwardRef(
13585
13588
  fabricCanvas.on("selection:cleared", () => {
13586
13589
  });
13587
13590
  fabricCanvas.on("object:scaling", (e) => {
13588
- var _a2, _b2, _c, _d, _e, _f;
13591
+ var _a2, _b2, _c, _d, _e, _f, _g;
13589
13592
  if (!isActiveRef.current) return;
13590
13593
  const t = e.target;
13591
13594
  if (t) lastResizeScaleTargetRef.current = t;
13595
+ try {
13596
+ if (t instanceof fabric__namespace.ActiveSelection && t.__pixldocsMixedRotation) {
13597
+ const corner2 = (_a2 = e.transform) == null ? void 0 : _a2.corner;
13598
+ if (corner2 === "ml" || corner2 === "mr") {
13599
+ t.scaleY = t.scaleX;
13600
+ } else if (corner2 === "mt" || corner2 === "mb") {
13601
+ t.scaleX = t.scaleY;
13602
+ }
13603
+ }
13604
+ } catch {
13605
+ }
13592
13606
  prepareGroupSelectionTransformStart(t);
13593
13607
  markTransforming(t);
13594
13608
  didTransformRef.current = true;
@@ -13752,7 +13766,7 @@ const PageCanvas = react.forwardRef(
13752
13766
  time: Math.round(performance.now()),
13753
13767
  corner,
13754
13768
  groupSelectionId: obj.__pixldocsGroupSelection,
13755
- currentTransformAction: (_a2 = fabricCanvas._currentTransform) == null ? void 0 : _a2.action,
13769
+ currentTransformAction: (_b2 = fabricCanvas._currentTransform) == null ? void 0 : _b2.action,
13756
13770
  selection: summarizeFabricObjectForResizeDebug(obj),
13757
13771
  textChildren: obj.getObjects().filter((child) => child instanceof fabric__namespace.Textbox).map((child) => summarizeFabricObjectForResizeDebug(child))
13758
13772
  };
@@ -13762,13 +13776,13 @@ const PageCanvas = react.forwardRef(
13762
13776
  const isXSide = corner === "ml" || corner === "mr";
13763
13777
  const sAxis = isXSide ? Math.abs(obj.scaleX ?? 1) : Math.abs(obj.scaleY ?? 1);
13764
13778
  if (sAxis > 1e-3) {
13765
- if (isXSide && ((_b2 = groupShiftReflowSnapshotRef.current) == null ? void 0 : _b2.selection) !== obj) {
13779
+ if (isXSide && ((_c = groupShiftReflowSnapshotRef.current) == null ? void 0 : _c.selection) !== obj) {
13766
13780
  groupShiftReflowSnapshotRef.current = null;
13767
13781
  const logicalGroupId = obj.__pixldocsGroupSelection;
13768
13782
  if (logicalGroupId) {
13769
13783
  try {
13770
13784
  const state = useEditorStore.getState();
13771
- const pageChildren2 = ((_c = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _c.children) ?? [];
13785
+ const pageChildren2 = ((_d = state.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
13772
13786
  const groupNode = findNodeById(pageChildren2, logicalGroupId);
13773
13787
  if (groupNode && isGroup(groupNode) && !isStackLayoutMode(groupNode.layoutMode)) {
13774
13788
  const entries = obj.getObjects().map((c) => ({
@@ -13798,7 +13812,7 @@ const PageCanvas = react.forwardRef(
13798
13812
  const asRect0 = obj.getBoundingRect();
13799
13813
  let didReflowTextChild = false;
13800
13814
  for (const child of obj.getObjects()) {
13801
- if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_d = child._ct) == null ? void 0 : _d.isCropGroup))) {
13815
+ if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_e = child._ct) == null ? void 0 : _e.isCropGroup))) {
13802
13816
  const ct = child.__cropData;
13803
13817
  if (!ct) continue;
13804
13818
  if (isXSide) {
@@ -13903,7 +13917,7 @@ const PageCanvas = react.forwardRef(
13903
13917
  didReflowTextChild = true;
13904
13918
  }
13905
13919
  }
13906
- if (isXSide && ((_e = groupShiftReflowSnapshotRef.current) == null ? void 0 : _e.selection) === obj) {
13920
+ if (isXSide && ((_f = groupShiftReflowSnapshotRef.current) == null ? void 0 : _f.selection) === obj) {
13907
13921
  const snap = groupShiftReflowSnapshotRef.current;
13908
13922
  const anchorEntry = snap.children[0];
13909
13923
  const anchorTopLive = anchorEntry.obj.top ?? 0;
@@ -14059,7 +14073,7 @@ const PageCanvas = react.forwardRef(
14059
14073
  setGuides(gridGuidesForScale.length ? [...scaleGuides, ...gridGuidesForScale] : scaleGuides);
14060
14074
  if (drilledGroupIdRef.current) {
14061
14075
  try {
14062
- (_f = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _f.call(fabricCanvas);
14076
+ (_g = fabricCanvas.__updateDrilledGroupOutline) == null ? void 0 : _g.call(fabricCanvas);
14063
14077
  } catch {
14064
14078
  }
14065
14079
  }
@@ -24289,9 +24303,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24289
24303
  }
24290
24304
  return svgString;
24291
24305
  }
24292
- const resolvedPackageVersion = "0.5.314";
24306
+ const resolvedPackageVersion = "0.5.316";
24293
24307
  const PACKAGE_VERSION = resolvedPackageVersion;
24294
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.314";
24308
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.316";
24295
24309
  const roundParityValue = (value) => {
24296
24310
  if (typeof value !== "number") return value;
24297
24311
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25105,7 +25119,7 @@ class PixldocsRenderer {
25105
25119
  await this.waitForCanvasScene(container, cloned, i);
25106
25120
  }
25107
25121
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25108
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CkSLQ4vT.cjs"));
25122
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CFD-x_MA.cjs"));
25109
25123
  const prepared = preparePagesForExport(
25110
25124
  cloned.pages,
25111
25125
  canvasWidth,
@@ -27425,7 +27439,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27425
27439
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27426
27440
  sanitizeSvgTreeForPdf(svgToDraw);
27427
27441
  try {
27428
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CkSLQ4vT.cjs"));
27442
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CFD-x_MA.cjs"));
27429
27443
  try {
27430
27444
  await logTextMeasurementDiagnostic(svgToDraw);
27431
27445
  } catch {
@@ -27822,4 +27836,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27822
27836
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27823
27837
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27824
27838
  exports.warmTemplateFromForm = warmTemplateFromForm;
27825
- //# sourceMappingURL=index-CivzkA4l.cjs.map
27839
+ //# sourceMappingURL=index-CnPI9yBL.cjs.map