@pixldocs/canvas-renderer 0.5.338 → 0.5.339

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.
@@ -11360,10 +11360,20 @@ const PageCanvas = react.forwardRef(
11360
11360
  const [ready, setReady] = react.useState(false);
11361
11361
  const [unlockRequestId, setUnlockRequestId] = react.useState(0);
11362
11362
  const applyLogicalGroupSelectionVisualState = react.useCallback((selection, groupId) => {
11363
- var _a2;
11363
+ var _a2, _b2;
11364
11364
  selection.__pixldocsGroupSelection = groupId;
11365
11365
  delete selection.__pixldocsLogicalGroupIds;
11366
11366
  selection.hasBorders = true;
11367
+ try {
11368
+ const pageChildren2 = ((_a2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _a2.children) ?? [];
11369
+ const groupNode = findNodeById(pageChildren2, groupId);
11370
+ const groupAngle = groupNode && isGroup(groupNode) ? Number(groupNode.angle ?? 0) : 0;
11371
+ if (Number.isFinite(groupAngle) && Math.abs(groupAngle) > 0.01) {
11372
+ selection.set({ angle: groupAngle, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11373
+ selection.setCoords();
11374
+ }
11375
+ } catch {
11376
+ }
11367
11377
  const members = selection.getObjects();
11368
11378
  for (const prev of suppressGroupMemberBordersRef.current) {
11369
11379
  if (members.includes(prev)) continue;
@@ -11387,7 +11397,7 @@ const PageCanvas = react.forwardRef(
11387
11397
  if (m.__pixldocsOrigHasControls === void 0) m.__pixldocsOrigHasControls = m.hasControls;
11388
11398
  m.hasBorders = false;
11389
11399
  m.hasControls = false;
11390
- if (m.__cropGroup || ((_a2 = m._ct) == null ? void 0 : _a2.isCropGroup)) {
11400
+ if (m.__cropGroup || ((_b2 = m._ct) == null ? void 0 : _b2.isCropGroup)) {
11391
11401
  if (m.__pixldocsOrigLockScalingX === void 0) {
11392
11402
  m.__pixldocsOrigLockScalingX = m.lockScalingX;
11393
11403
  m.__pixldocsOrigLockScalingY = m.lockScalingY;
@@ -11397,7 +11407,7 @@ const PageCanvas = react.forwardRef(
11397
11407
  }
11398
11408
  }
11399
11409
  applyWarpAwareSelectionBorders(selection);
11400
- }, []);
11410
+ }, [pageId]);
11401
11411
  const pageBoundsOptions = react.useMemo(
11402
11412
  () => ({ pageContentWidth: canvasWidth, pageContentHeight: canvasHeight }),
11403
11413
  [canvasWidth, canvasHeight]
@@ -14841,6 +14851,11 @@ const PageCanvas = react.forwardRef(
14841
14851
  }
14842
14852
  }
14843
14853
  const isActiveSelectionSideResize = isActiveSelection && (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb");
14854
+ const normalizeAngle = (angle) => (angle % 360 + 360) % 360;
14855
+ const shortestAngleDelta = (a, b) => {
14856
+ const diff = Math.abs(normalizeAngle(a) - normalizeAngle(b));
14857
+ return Math.min(diff, 360 - diff);
14858
+ };
14844
14859
  if (selectedElementIds.length > 0) {
14845
14860
  const firstObj = activeObjects[0];
14846
14861
  const firstId = getObjectId(firstObj);
@@ -14904,12 +14919,9 @@ const PageCanvas = react.forwardRef(
14904
14919
  const deltaY = movedGroupTop - groupAbs.top;
14905
14920
  const hadResizeHandle = isActiveSelection && !!activeSelectionResizeHandle;
14906
14921
  const hadScale = isActiveSelection && activeObj && (hadResizeHandle || Math.abs((activeObj.scaleX ?? 1) - 1) > 0.01 || Math.abs((activeObj.scaleY ?? 1) - 1) > 0.01);
14907
- const startSelAngle = (((transformStart == null ? void 0 : transformStart.selectionAngle) ?? 0) % 360 + 360) % 360;
14908
- const currentSelAngle = isActiveSelection && activeObj ? ((activeObj.angle ?? 0) % 360 + 360) % 360 : 0;
14909
- const angleDelta = Math.min(
14910
- Math.abs(currentSelAngle - startSelAngle),
14911
- 360 - Math.abs(currentSelAngle - startSelAngle)
14912
- );
14922
+ const startSelAngle = normalizeAngle((transformStart == null ? void 0 : transformStart.selectionAngle) ?? 0);
14923
+ const currentSelAngle = isActiveSelection && activeObj ? normalizeAngle(activeObj.angle ?? 0) : 0;
14924
+ const angleDelta = shortestAngleDelta(currentSelAngle, startSelAngle);
14913
14925
  const hadRotation = isActiveSelection && activeObj && angleDelta > 0.01;
14914
14926
  if (!isActiveSelectionSideResize && !hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14915
14927
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
@@ -14952,6 +14964,35 @@ const PageCanvas = react.forwardRef(
14952
14964
  unlockEditsSoon();
14953
14965
  return;
14954
14966
  }
14967
+ if (activeGroupSelectionId === groupToMove.id && hadRotation && !hadScale && !activeSelectionResizeHandle && activeObj instanceof fabric__namespace.ActiveSelection) {
14968
+ const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14969
+ const nextAngle = currentSelAngle;
14970
+ updateNodeStore(groupToMove.id, { angle: nextAngle }, { recordHistory: false, skipLayoutRecalc: true });
14971
+ commitHistoryStore();
14972
+ const groupSelectionId = activeGroupSelectionId;
14973
+ elementsRef.current = getCurrentElements();
14974
+ for (const obj of activeObjects) {
14975
+ const objId = getObjectId(obj);
14976
+ if (objId && objId !== "__background__") {
14977
+ justModifiedIdsRef.current.add(objId);
14978
+ modifiedIdsThisRound.add(objId);
14979
+ }
14980
+ }
14981
+ setTimeout(() => modifiedIdsThisRound.forEach((id) => justModifiedIdsRef.current.delete(id)), 150);
14982
+ groupSelectionTransformStartRef.current = null;
14983
+ activeSelectionMoveStartRef.current = null;
14984
+ activeSelectionResizeHandleRef.current = null;
14985
+ const rotateRestoreSnapshot = {
14986
+ memberIds: activeObjects.map((obj) => getObjectId(obj)).filter((id) => !!id && id !== "__background__"),
14987
+ groupSelectionId,
14988
+ expiresAt: Date.now() + 1200
14989
+ };
14990
+ recentGroupSelectionRestoreRef.current = rotateRestoreSnapshot;
14991
+ preserveActiveSelectionAfterTransformRef.current = rotateRestoreSnapshot;
14992
+ fabricCanvas.requestRenderAll();
14993
+ unlockEditsSoon();
14994
+ return;
14995
+ }
14955
14996
  }
14956
14997
  }
14957
14998
  const pendingCropGroupFrameBakes = [];
@@ -24597,9 +24638,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24597
24638
  }
24598
24639
  return svgString;
24599
24640
  }
24600
- const resolvedPackageVersion = "0.5.338";
24641
+ const resolvedPackageVersion = "0.5.339";
24601
24642
  const PACKAGE_VERSION = resolvedPackageVersion;
24602
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.338";
24643
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.339";
24603
24644
  const roundParityValue = (value) => {
24604
24645
  if (typeof value !== "number") return value;
24605
24646
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25413,7 +25454,7 @@ class PixldocsRenderer {
25413
25454
  await this.waitForCanvasScene(container, cloned, i);
25414
25455
  }
25415
25456
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25416
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-B_BXZamD.cjs"));
25457
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Dh2REogs.cjs"));
25417
25458
  const prepared = preparePagesForExport(
25418
25459
  cloned.pages,
25419
25460
  canvasWidth,
@@ -27733,7 +27774,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27733
27774
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27734
27775
  sanitizeSvgTreeForPdf(svgToDraw);
27735
27776
  try {
27736
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-B_BXZamD.cjs"));
27777
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Dh2REogs.cjs"));
27737
27778
  try {
27738
27779
  await logTextMeasurementDiagnostic(svgToDraw);
27739
27780
  } catch {
@@ -28130,4 +28171,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28130
28171
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28131
28172
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28132
28173
  exports.warmTemplateFromForm = warmTemplateFromForm;
28133
- //# sourceMappingURL=index-qdd3MkaO.cjs.map
28174
+ //# sourceMappingURL=index-BLwO7N0h.cjs.map