@pixldocs/canvas-renderer 0.5.255 → 0.5.257

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.
@@ -7142,10 +7142,20 @@ function applyTextPathControls(textbox) {
7142
7142
  ctx.stroke();
7143
7143
  ctx.restore();
7144
7144
  };
7145
- obj.controls.crN = new fabric.Control({ x: 0, y: -0.5, cursorStyle: "ns-resize", actionName: "textPath", actionHandler: dragRadius("N"), positionHandler: positionAtRing("N"), render: renderRingHandle });
7146
- obj.controls.crE = new fabric.Control({ x: 0.5, y: 0, cursorStyle: "ew-resize", actionName: "textPath", actionHandler: dragRadius("E"), positionHandler: positionAtRing("E"), render: renderRingHandle });
7147
- obj.controls.crS = new fabric.Control({ x: 0, y: 0.5, cursorStyle: "ns-resize", actionName: "textPath", actionHandler: dragRadius("S"), positionHandler: positionAtRing("S"), render: renderRingHandle });
7148
- obj.controls.crW = new fabric.Control({ x: -0.5, y: 0, cursorStyle: "ew-resize", actionName: "textPath", actionHandler: dragRadius("W"), positionHandler: positionAtRing("W"), render: renderRingHandle });
7145
+ const radialCursorHandler = (dir) => (_e2, _control, fabricObject) => {
7146
+ var _a3;
7147
+ const baseAngle = dir === "N" || dir === "S" ? 90 : 0;
7148
+ const objAngle = ((_a3 = fabricObject == null ? void 0 : fabricObject.getTotalAngle) == null ? void 0 : _a3.call(fabricObject)) ?? (fabricObject == null ? void 0 : fabricObject.angle) ?? 0;
7149
+ let a = ((baseAngle + objAngle) % 180 + 180) % 180;
7150
+ if (a < 22.5 || a >= 157.5) return "ew-resize";
7151
+ if (a < 67.5) return "nesw-resize";
7152
+ if (a < 112.5) return "ns-resize";
7153
+ return "nwse-resize";
7154
+ };
7155
+ obj.controls.crN = new fabric.Control({ x: 0, y: -0.5, cursorStyleHandler: radialCursorHandler("N"), actionName: "textPath", actionHandler: dragRadius("N"), positionHandler: positionAtRing("N"), render: renderRingHandle });
7156
+ obj.controls.crE = new fabric.Control({ x: 0.5, y: 0, cursorStyleHandler: radialCursorHandler("E"), actionName: "textPath", actionHandler: dragRadius("E"), positionHandler: positionAtRing("E"), render: renderRingHandle });
7157
+ obj.controls.crS = new fabric.Control({ x: 0, y: 0.5, cursorStyleHandler: radialCursorHandler("S"), actionName: "textPath", actionHandler: dragRadius("S"), positionHandler: positionAtRing("S"), render: renderRingHandle });
7158
+ obj.controls.crW = new fabric.Control({ x: -0.5, y: 0, cursorStyleHandler: radialCursorHandler("W"), actionName: "textPath", actionHandler: dragRadius("W"), positionHandler: positionAtRing("W"), render: renderRingHandle });
7149
7159
  (_g = obj.setControlVisible) == null ? void 0 : _g.call(obj, "crN", true);
7150
7160
  (_h = obj.setControlVisible) == null ? void 0 : _h.call(obj, "crE", true);
7151
7161
  (_i = obj.setControlVisible) == null ? void 0 : _i.call(obj, "crS", true);
@@ -11170,6 +11180,50 @@ const PageCanvas = forwardRef(
11170
11180
  }
11171
11181
  }
11172
11182
  applyWarpAwareSelectionBorders(selection);
11183
+ try {
11184
+ if (members.length >= 2 && Math.abs((selection.angle ?? 0) % 360) < 0.01 && !selection.__pixldocsGroupAngleApplied) {
11185
+ const someBusy = members.some((m) => m.__pdCircleRadiusDrag || m.__pixldocsSectionGroup);
11186
+ if (!someBusy) {
11187
+ const first = ((members[0].angle ?? 0) % 360 + 360) % 360;
11188
+ const EPS = 0.5;
11189
+ const allSame = members.every((m) => {
11190
+ const a = ((m.angle ?? 0) % 360 + 360) % 360;
11191
+ const d = Math.min(Math.abs(a - first), 360 - Math.abs(a - first));
11192
+ return d <= EPS;
11193
+ });
11194
+ if (allSame && first > EPS && first < 360 - EPS) {
11195
+ const worldMatrices = members.map((c) => c.calcTransformMatrix());
11196
+ selection.set({ angle: first });
11197
+ selection.setCoords();
11198
+ const selMatrix = selection.calcTransformMatrix();
11199
+ const invSel = fabric.util.invertTransform(selMatrix);
11200
+ for (let i = 0; i < members.length; i++) {
11201
+ const child = members[i];
11202
+ const rel = fabric.util.multiplyTransformMatrices(invSel, worldMatrices[i]);
11203
+ const d = fabric.util.qrDecompose(rel);
11204
+ child.flipX = false;
11205
+ child.flipY = false;
11206
+ child.set({
11207
+ scaleX: d.scaleX,
11208
+ scaleY: d.scaleY,
11209
+ skewX: d.skewX,
11210
+ skewY: d.skewY,
11211
+ angle: d.angle
11212
+ });
11213
+ child.setPositionByOrigin(
11214
+ new fabric.Point(d.translateX, d.translateY),
11215
+ "center",
11216
+ "center"
11217
+ );
11218
+ child.setCoords();
11219
+ }
11220
+ selection.__pixldocsGroupAngleApplied = first;
11221
+ }
11222
+ }
11223
+ }
11224
+ } catch (err) {
11225
+ console.warn("[group-rotation-align] skipped", err);
11226
+ }
11173
11227
  }, []);
11174
11228
  const pageBoundsOptions = useMemo(
11175
11229
  () => ({ pageContentWidth: canvasWidth, pageContentHeight: canvasHeight }),
@@ -12519,7 +12573,8 @@ const PageCanvas = forwardRef(
12519
12573
  selectionLeft: rect.left,
12520
12574
  selectionTop: rect.top,
12521
12575
  groupLeft: groupAbs.left,
12522
- groupTop: groupAbs.top
12576
+ groupTop: groupAbs.top,
12577
+ selectionAngle: ((active.angle ?? 0) % 360 + 360) % 360
12523
12578
  };
12524
12579
  };
12525
12580
  const restoreGroupSelectionVisualState = (selection, groupId) => {
@@ -14160,7 +14215,13 @@ const PageCanvas = forwardRef(
14160
14215
  const deltaX = movedGroupLeft - groupAbs.left;
14161
14216
  const deltaY = movedGroupTop - groupAbs.top;
14162
14217
  const hadScale = isActiveSelection && activeObj && (Math.abs((activeObj.scaleX ?? 1) - 1) > 0.01 || Math.abs((activeObj.scaleY ?? 1) - 1) > 0.01);
14163
- const hadRotation = isActiveSelection && activeObj && Math.abs((activeObj.angle ?? 0) % 360) > 0.01;
14218
+ const startSelAngle = (((transformStart == null ? void 0 : transformStart.selectionAngle) ?? 0) % 360 + 360) % 360;
14219
+ const currentSelAngle = isActiveSelection && activeObj ? ((activeObj.angle ?? 0) % 360 + 360) % 360 : 0;
14220
+ const angleDelta = Math.min(
14221
+ Math.abs(currentSelAngle - startSelAngle),
14222
+ 360 - Math.abs(currentSelAngle - startSelAngle)
14223
+ );
14224
+ const hadRotation = isActiveSelection && activeObj && angleDelta > 0.01;
14164
14225
  if (!hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14165
14226
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14166
14227
  const newLeft = (groupToMove.left ?? 0) + deltaX;
@@ -23511,9 +23572,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23511
23572
  }
23512
23573
  return svgString;
23513
23574
  }
23514
- const resolvedPackageVersion = "0.5.255";
23575
+ const resolvedPackageVersion = "0.5.257";
23515
23576
  const PACKAGE_VERSION = resolvedPackageVersion;
23516
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.255";
23577
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.257";
23517
23578
  const roundParityValue = (value) => {
23518
23579
  if (typeof value !== "number") return value;
23519
23580
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24327,7 +24388,7 @@ class PixldocsRenderer {
24327
24388
  await this.waitForCanvasScene(container, cloned, i);
24328
24389
  }
24329
24390
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24330
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DunkNPyo.js");
24391
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-tca2qSZa.js");
24331
24392
  const prepared = preparePagesForExport(
24332
24393
  cloned.pages,
24333
24394
  canvasWidth,
@@ -26647,7 +26708,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26647
26708
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26648
26709
  sanitizeSvgTreeForPdf(svgToDraw);
26649
26710
  try {
26650
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DunkNPyo.js");
26711
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-tca2qSZa.js");
26651
26712
  try {
26652
26713
  await logTextMeasurementDiagnostic(svgToDraw);
26653
26714
  } catch {
@@ -27047,4 +27108,4 @@ export {
27047
27108
  buildTeaserBlurFlatKeys as y,
27048
27109
  collectFontDescriptorsFromConfig as z
27049
27110
  };
27050
- //# sourceMappingURL=index-BF-sKPH7.js.map
27111
+ //# sourceMappingURL=index-bZ7LCfUb.js.map