@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.
@@ -11342,10 +11342,20 @@ const PageCanvas = forwardRef(
11342
11342
  const [ready, setReady] = useState(false);
11343
11343
  const [unlockRequestId, setUnlockRequestId] = useState(0);
11344
11344
  const applyLogicalGroupSelectionVisualState = useCallback((selection, groupId) => {
11345
- var _a2;
11345
+ var _a2, _b2;
11346
11346
  selection.__pixldocsGroupSelection = groupId;
11347
11347
  delete selection.__pixldocsLogicalGroupIds;
11348
11348
  selection.hasBorders = true;
11349
+ try {
11350
+ const pageChildren2 = ((_a2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _a2.children) ?? [];
11351
+ const groupNode = findNodeById(pageChildren2, groupId);
11352
+ const groupAngle = groupNode && isGroup(groupNode) ? Number(groupNode.angle ?? 0) : 0;
11353
+ if (Number.isFinite(groupAngle) && Math.abs(groupAngle) > 0.01) {
11354
+ selection.set({ angle: groupAngle, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11355
+ selection.setCoords();
11356
+ }
11357
+ } catch {
11358
+ }
11349
11359
  const members = selection.getObjects();
11350
11360
  for (const prev of suppressGroupMemberBordersRef.current) {
11351
11361
  if (members.includes(prev)) continue;
@@ -11369,7 +11379,7 @@ const PageCanvas = forwardRef(
11369
11379
  if (m.__pixldocsOrigHasControls === void 0) m.__pixldocsOrigHasControls = m.hasControls;
11370
11380
  m.hasBorders = false;
11371
11381
  m.hasControls = false;
11372
- if (m.__cropGroup || ((_a2 = m._ct) == null ? void 0 : _a2.isCropGroup)) {
11382
+ if (m.__cropGroup || ((_b2 = m._ct) == null ? void 0 : _b2.isCropGroup)) {
11373
11383
  if (m.__pixldocsOrigLockScalingX === void 0) {
11374
11384
  m.__pixldocsOrigLockScalingX = m.lockScalingX;
11375
11385
  m.__pixldocsOrigLockScalingY = m.lockScalingY;
@@ -11379,7 +11389,7 @@ const PageCanvas = forwardRef(
11379
11389
  }
11380
11390
  }
11381
11391
  applyWarpAwareSelectionBorders(selection);
11382
- }, []);
11392
+ }, [pageId]);
11383
11393
  const pageBoundsOptions = useMemo(
11384
11394
  () => ({ pageContentWidth: canvasWidth, pageContentHeight: canvasHeight }),
11385
11395
  [canvasWidth, canvasHeight]
@@ -14823,6 +14833,11 @@ const PageCanvas = forwardRef(
14823
14833
  }
14824
14834
  }
14825
14835
  const isActiveSelectionSideResize = isActiveSelection && (activeSelectionResizeHandle === "ml" || activeSelectionResizeHandle === "mr" || activeSelectionResizeHandle === "mt" || activeSelectionResizeHandle === "mb");
14836
+ const normalizeAngle = (angle) => (angle % 360 + 360) % 360;
14837
+ const shortestAngleDelta = (a, b) => {
14838
+ const diff = Math.abs(normalizeAngle(a) - normalizeAngle(b));
14839
+ return Math.min(diff, 360 - diff);
14840
+ };
14826
14841
  if (selectedElementIds.length > 0) {
14827
14842
  const firstObj = activeObjects[0];
14828
14843
  const firstId = getObjectId(firstObj);
@@ -14886,12 +14901,9 @@ const PageCanvas = forwardRef(
14886
14901
  const deltaY = movedGroupTop - groupAbs.top;
14887
14902
  const hadResizeHandle = isActiveSelection && !!activeSelectionResizeHandle;
14888
14903
  const hadScale = isActiveSelection && activeObj && (hadResizeHandle || Math.abs((activeObj.scaleX ?? 1) - 1) > 0.01 || Math.abs((activeObj.scaleY ?? 1) - 1) > 0.01);
14889
- const startSelAngle = (((transformStart == null ? void 0 : transformStart.selectionAngle) ?? 0) % 360 + 360) % 360;
14890
- const currentSelAngle = isActiveSelection && activeObj ? ((activeObj.angle ?? 0) % 360 + 360) % 360 : 0;
14891
- const angleDelta = Math.min(
14892
- Math.abs(currentSelAngle - startSelAngle),
14893
- 360 - Math.abs(currentSelAngle - startSelAngle)
14894
- );
14904
+ const startSelAngle = normalizeAngle((transformStart == null ? void 0 : transformStart.selectionAngle) ?? 0);
14905
+ const currentSelAngle = isActiveSelection && activeObj ? normalizeAngle(activeObj.angle ?? 0) : 0;
14906
+ const angleDelta = shortestAngleDelta(currentSelAngle, startSelAngle);
14895
14907
  const hadRotation = isActiveSelection && activeObj && angleDelta > 0.01;
14896
14908
  if (!isActiveSelectionSideResize && !hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14897
14909
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
@@ -14934,6 +14946,35 @@ const PageCanvas = forwardRef(
14934
14946
  unlockEditsSoon();
14935
14947
  return;
14936
14948
  }
14949
+ if (activeGroupSelectionId === groupToMove.id && hadRotation && !hadScale && !activeSelectionResizeHandle && activeObj instanceof fabric.ActiveSelection) {
14950
+ const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14951
+ const nextAngle = currentSelAngle;
14952
+ updateNodeStore(groupToMove.id, { angle: nextAngle }, { recordHistory: false, skipLayoutRecalc: true });
14953
+ commitHistoryStore();
14954
+ const groupSelectionId = activeGroupSelectionId;
14955
+ elementsRef.current = getCurrentElements();
14956
+ for (const obj of activeObjects) {
14957
+ const objId = getObjectId(obj);
14958
+ if (objId && objId !== "__background__") {
14959
+ justModifiedIdsRef.current.add(objId);
14960
+ modifiedIdsThisRound.add(objId);
14961
+ }
14962
+ }
14963
+ setTimeout(() => modifiedIdsThisRound.forEach((id) => justModifiedIdsRef.current.delete(id)), 150);
14964
+ groupSelectionTransformStartRef.current = null;
14965
+ activeSelectionMoveStartRef.current = null;
14966
+ activeSelectionResizeHandleRef.current = null;
14967
+ const rotateRestoreSnapshot = {
14968
+ memberIds: activeObjects.map((obj) => getObjectId(obj)).filter((id) => !!id && id !== "__background__"),
14969
+ groupSelectionId,
14970
+ expiresAt: Date.now() + 1200
14971
+ };
14972
+ recentGroupSelectionRestoreRef.current = rotateRestoreSnapshot;
14973
+ preserveActiveSelectionAfterTransformRef.current = rotateRestoreSnapshot;
14974
+ fabricCanvas.requestRenderAll();
14975
+ unlockEditsSoon();
14976
+ return;
14977
+ }
14937
14978
  }
14938
14979
  }
14939
14980
  const pendingCropGroupFrameBakes = [];
@@ -24579,9 +24620,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24579
24620
  }
24580
24621
  return svgString;
24581
24622
  }
24582
- const resolvedPackageVersion = "0.5.338";
24623
+ const resolvedPackageVersion = "0.5.339";
24583
24624
  const PACKAGE_VERSION = resolvedPackageVersion;
24584
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.338";
24625
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.339";
24585
24626
  const roundParityValue = (value) => {
24586
24627
  if (typeof value !== "number") return value;
24587
24628
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25395,7 +25436,7 @@ class PixldocsRenderer {
25395
25436
  await this.waitForCanvasScene(container, cloned, i);
25396
25437
  }
25397
25438
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25398
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DM-aUSae.js");
25439
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-GeBepP7g.js");
25399
25440
  const prepared = preparePagesForExport(
25400
25441
  cloned.pages,
25401
25442
  canvasWidth,
@@ -27715,7 +27756,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27715
27756
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27716
27757
  sanitizeSvgTreeForPdf(svgToDraw);
27717
27758
  try {
27718
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DM-aUSae.js");
27759
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-GeBepP7g.js");
27719
27760
  try {
27720
27761
  await logTextMeasurementDiagnostic(svgToDraw);
27721
27762
  } catch {
@@ -28115,4 +28156,4 @@ export {
28115
28156
  buildTeaserBlurFlatKeys as y,
28116
28157
  collectFontDescriptorsFromConfig as z
28117
28158
  };
28118
- //# sourceMappingURL=index-BwAnIzvN.js.map
28159
+ //# sourceMappingURL=index-DFhDFJ4X.js.map