@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.
@@ -7160,10 +7160,20 @@ function applyTextPathControls(textbox) {
7160
7160
  ctx.stroke();
7161
7161
  ctx.restore();
7162
7162
  };
7163
- obj.controls.crN = new fabric__namespace.Control({ x: 0, y: -0.5, cursorStyle: "ns-resize", actionName: "textPath", actionHandler: dragRadius("N"), positionHandler: positionAtRing("N"), render: renderRingHandle });
7164
- obj.controls.crE = new fabric__namespace.Control({ x: 0.5, y: 0, cursorStyle: "ew-resize", actionName: "textPath", actionHandler: dragRadius("E"), positionHandler: positionAtRing("E"), render: renderRingHandle });
7165
- obj.controls.crS = new fabric__namespace.Control({ x: 0, y: 0.5, cursorStyle: "ns-resize", actionName: "textPath", actionHandler: dragRadius("S"), positionHandler: positionAtRing("S"), render: renderRingHandle });
7166
- obj.controls.crW = new fabric__namespace.Control({ x: -0.5, y: 0, cursorStyle: "ew-resize", actionName: "textPath", actionHandler: dragRadius("W"), positionHandler: positionAtRing("W"), render: renderRingHandle });
7163
+ const radialCursorHandler = (dir) => (_e2, _control, fabricObject) => {
7164
+ var _a3;
7165
+ const baseAngle = dir === "N" || dir === "S" ? 90 : 0;
7166
+ const objAngle = ((_a3 = fabricObject == null ? void 0 : fabricObject.getTotalAngle) == null ? void 0 : _a3.call(fabricObject)) ?? (fabricObject == null ? void 0 : fabricObject.angle) ?? 0;
7167
+ let a = ((baseAngle + objAngle) % 180 + 180) % 180;
7168
+ if (a < 22.5 || a >= 157.5) return "ew-resize";
7169
+ if (a < 67.5) return "nesw-resize";
7170
+ if (a < 112.5) return "ns-resize";
7171
+ return "nwse-resize";
7172
+ };
7173
+ obj.controls.crN = new fabric__namespace.Control({ x: 0, y: -0.5, cursorStyleHandler: radialCursorHandler("N"), actionName: "textPath", actionHandler: dragRadius("N"), positionHandler: positionAtRing("N"), render: renderRingHandle });
7174
+ obj.controls.crE = new fabric__namespace.Control({ x: 0.5, y: 0, cursorStyleHandler: radialCursorHandler("E"), actionName: "textPath", actionHandler: dragRadius("E"), positionHandler: positionAtRing("E"), render: renderRingHandle });
7175
+ obj.controls.crS = new fabric__namespace.Control({ x: 0, y: 0.5, cursorStyleHandler: radialCursorHandler("S"), actionName: "textPath", actionHandler: dragRadius("S"), positionHandler: positionAtRing("S"), render: renderRingHandle });
7176
+ obj.controls.crW = new fabric__namespace.Control({ x: -0.5, y: 0, cursorStyleHandler: radialCursorHandler("W"), actionName: "textPath", actionHandler: dragRadius("W"), positionHandler: positionAtRing("W"), render: renderRingHandle });
7167
7177
  (_g = obj.setControlVisible) == null ? void 0 : _g.call(obj, "crN", true);
7168
7178
  (_h = obj.setControlVisible) == null ? void 0 : _h.call(obj, "crE", true);
7169
7179
  (_i = obj.setControlVisible) == null ? void 0 : _i.call(obj, "crS", true);
@@ -11188,6 +11198,50 @@ const PageCanvas = react.forwardRef(
11188
11198
  }
11189
11199
  }
11190
11200
  applyWarpAwareSelectionBorders(selection);
11201
+ try {
11202
+ if (members.length >= 2 && Math.abs((selection.angle ?? 0) % 360) < 0.01 && !selection.__pixldocsGroupAngleApplied) {
11203
+ const someBusy = members.some((m) => m.__pdCircleRadiusDrag || m.__pixldocsSectionGroup);
11204
+ if (!someBusy) {
11205
+ const first = ((members[0].angle ?? 0) % 360 + 360) % 360;
11206
+ const EPS = 0.5;
11207
+ const allSame = members.every((m) => {
11208
+ const a = ((m.angle ?? 0) % 360 + 360) % 360;
11209
+ const d = Math.min(Math.abs(a - first), 360 - Math.abs(a - first));
11210
+ return d <= EPS;
11211
+ });
11212
+ if (allSame && first > EPS && first < 360 - EPS) {
11213
+ const worldMatrices = members.map((c) => c.calcTransformMatrix());
11214
+ selection.set({ angle: first });
11215
+ selection.setCoords();
11216
+ const selMatrix = selection.calcTransformMatrix();
11217
+ const invSel = fabric__namespace.util.invertTransform(selMatrix);
11218
+ for (let i = 0; i < members.length; i++) {
11219
+ const child = members[i];
11220
+ const rel = fabric__namespace.util.multiplyTransformMatrices(invSel, worldMatrices[i]);
11221
+ const d = fabric__namespace.util.qrDecompose(rel);
11222
+ child.flipX = false;
11223
+ child.flipY = false;
11224
+ child.set({
11225
+ scaleX: d.scaleX,
11226
+ scaleY: d.scaleY,
11227
+ skewX: d.skewX,
11228
+ skewY: d.skewY,
11229
+ angle: d.angle
11230
+ });
11231
+ child.setPositionByOrigin(
11232
+ new fabric__namespace.Point(d.translateX, d.translateY),
11233
+ "center",
11234
+ "center"
11235
+ );
11236
+ child.setCoords();
11237
+ }
11238
+ selection.__pixldocsGroupAngleApplied = first;
11239
+ }
11240
+ }
11241
+ }
11242
+ } catch (err) {
11243
+ console.warn("[group-rotation-align] skipped", err);
11244
+ }
11191
11245
  }, []);
11192
11246
  const pageBoundsOptions = react.useMemo(
11193
11247
  () => ({ pageContentWidth: canvasWidth, pageContentHeight: canvasHeight }),
@@ -12537,7 +12591,8 @@ const PageCanvas = react.forwardRef(
12537
12591
  selectionLeft: rect.left,
12538
12592
  selectionTop: rect.top,
12539
12593
  groupLeft: groupAbs.left,
12540
- groupTop: groupAbs.top
12594
+ groupTop: groupAbs.top,
12595
+ selectionAngle: ((active.angle ?? 0) % 360 + 360) % 360
12541
12596
  };
12542
12597
  };
12543
12598
  const restoreGroupSelectionVisualState = (selection, groupId) => {
@@ -14178,7 +14233,13 @@ const PageCanvas = react.forwardRef(
14178
14233
  const deltaX = movedGroupLeft - groupAbs.left;
14179
14234
  const deltaY = movedGroupTop - groupAbs.top;
14180
14235
  const hadScale = isActiveSelection && activeObj && (Math.abs((activeObj.scaleX ?? 1) - 1) > 0.01 || Math.abs((activeObj.scaleY ?? 1) - 1) > 0.01);
14181
- const hadRotation = isActiveSelection && activeObj && Math.abs((activeObj.angle ?? 0) % 360) > 0.01;
14236
+ const startSelAngle = (((transformStart == null ? void 0 : transformStart.selectionAngle) ?? 0) % 360 + 360) % 360;
14237
+ const currentSelAngle = isActiveSelection && activeObj ? ((activeObj.angle ?? 0) % 360 + 360) % 360 : 0;
14238
+ const angleDelta = Math.min(
14239
+ Math.abs(currentSelAngle - startSelAngle),
14240
+ 360 - Math.abs(currentSelAngle - startSelAngle)
14241
+ );
14242
+ const hadRotation = isActiveSelection && activeObj && angleDelta > 0.01;
14182
14243
  if (!hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14183
14244
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14184
14245
  const newLeft = (groupToMove.left ?? 0) + deltaX;
@@ -23529,9 +23590,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23529
23590
  }
23530
23591
  return svgString;
23531
23592
  }
23532
- const resolvedPackageVersion = "0.5.255";
23593
+ const resolvedPackageVersion = "0.5.257";
23533
23594
  const PACKAGE_VERSION = resolvedPackageVersion;
23534
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.255";
23595
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.257";
23535
23596
  const roundParityValue = (value) => {
23536
23597
  if (typeof value !== "number") return value;
23537
23598
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24345,7 +24406,7 @@ class PixldocsRenderer {
24345
24406
  await this.waitForCanvasScene(container, cloned, i);
24346
24407
  }
24347
24408
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24348
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BK2ntULQ.cjs"));
24409
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-EysRHv2h.cjs"));
24349
24410
  const prepared = preparePagesForExport(
24350
24411
  cloned.pages,
24351
24412
  canvasWidth,
@@ -26665,7 +26726,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26665
26726
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26666
26727
  sanitizeSvgTreeForPdf(svgToDraw);
26667
26728
  try {
26668
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BK2ntULQ.cjs"));
26729
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-EysRHv2h.cjs"));
26669
26730
  try {
26670
26731
  await logTextMeasurementDiagnostic(svgToDraw);
26671
26732
  } catch {
@@ -27062,4 +27123,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27062
27123
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27063
27124
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27064
27125
  exports.warmTemplateFromForm = warmTemplateFromForm;
27065
- //# sourceMappingURL=index-5whx8gZE.cjs.map
27126
+ //# sourceMappingURL=index-oOI_SYzS.cjs.map