@pixldocs/canvas-renderer 0.5.339 → 0.5.341

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.
@@ -11350,8 +11350,16 @@ const PageCanvas = forwardRef(
11350
11350
  const pageChildren2 = ((_a2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _a2.children) ?? [];
11351
11351
  const groupNode = findNodeById(pageChildren2, groupId);
11352
11352
  const groupAngle = groupNode && isGroup(groupNode) ? Number(groupNode.angle ?? 0) : 0;
11353
+ const groupAbs = groupNode && isGroup(groupNode) ? getAbsoluteBounds(groupNode, pageChildren2) : null;
11353
11354
  if (Number.isFinite(groupAngle) && Math.abs(groupAngle) > 0.01) {
11354
11355
  selection.set({ angle: groupAngle, scaleX: 1, scaleY: 1, skewX: 0, skewY: 0 });
11356
+ if (groupAbs) {
11357
+ selection.setPositionByOrigin(
11358
+ new fabric.Point(groupAbs.left + groupAbs.width / 2, groupAbs.top + groupAbs.height / 2),
11359
+ "center",
11360
+ "center"
11361
+ );
11362
+ }
11355
11363
  selection.setCoords();
11356
11364
  }
11357
11365
  } catch {
@@ -12822,13 +12830,18 @@ const PageCanvas = forwardRef(
12822
12830
  if (!groupNode) return;
12823
12831
  const groupAbs = getAbsoluteBounds(groupNode, pageChildren2);
12824
12832
  const rect = active.getBoundingRect();
12833
+ const center = active.getCenterPoint();
12825
12834
  groupSelectionTransformStartRef.current = {
12826
12835
  groupId,
12827
12836
  selection: active,
12828
12837
  selectionLeft: rect.left,
12829
12838
  selectionTop: rect.top,
12839
+ selectionCenterX: center.x,
12840
+ selectionCenterY: center.y,
12830
12841
  groupLeft: groupAbs.left,
12831
12842
  groupTop: groupAbs.top,
12843
+ groupWidth: groupAbs.width,
12844
+ groupHeight: groupAbs.height,
12832
12845
  selectionAngle: ((active.angle ?? 0) % 360 + 360) % 360
12833
12846
  };
12834
12847
  };
@@ -14905,6 +14918,44 @@ const PageCanvas = forwardRef(
14905
14918
  const currentSelAngle = isActiveSelection && activeObj ? normalizeAngle(activeObj.angle ?? 0) : 0;
14906
14919
  const angleDelta = shortestAngleDelta(currentSelAngle, startSelAngle);
14907
14920
  const hadRotation = isActiveSelection && activeObj && angleDelta > 0.01;
14921
+ if (activeGroupSelectionId === groupToMove.id && hadRotation && !hadScale && !activeSelectionResizeHandle && activeObj instanceof fabric.ActiveSelection) {
14922
+ const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14923
+ const center = activeObj.getCenterPoint();
14924
+ const nextAbsLeft = center.x - groupAbs.width / 2;
14925
+ const nextAbsTop = center.y - groupAbs.height / 2;
14926
+ const storePos = absoluteToStorePosition(nextAbsLeft, nextAbsTop, groupToMove.id, pageChildren2);
14927
+ updateNodeStore(groupToMove.id, {
14928
+ left: storePos.left,
14929
+ top: storePos.top,
14930
+ angle: currentSelAngle
14931
+ }, { recordHistory: false, skipLayoutRecalc: true });
14932
+ commitHistoryStore();
14933
+ restoreGroupSelectionVisualState(activeObj, groupToMove.id);
14934
+ fabricCanvas.setActiveObject(activeObj);
14935
+ activeObj.setCoords();
14936
+ selectElements([groupToMove.id], false, false);
14937
+ fabricCanvas.requestRenderAll();
14938
+ elementsRef.current = getCurrentElements();
14939
+ const restoreSnapshot = {
14940
+ memberIds: activeObj.getObjects().map((obj) => getObjectId(obj)).filter((id) => !!id && id !== "__background__"),
14941
+ groupSelectionId: groupToMove.id,
14942
+ expiresAt: Date.now() + 1200
14943
+ };
14944
+ recentGroupSelectionRestoreRef.current = restoreSnapshot;
14945
+ activeObj.getObjects().forEach((obj) => {
14946
+ const objId = getObjectId(obj);
14947
+ if (objId && objId !== "__background__") {
14948
+ justModifiedIdsRef.current.add(objId);
14949
+ modifiedIdsThisRound.add(objId);
14950
+ }
14951
+ });
14952
+ setTimeout(() => modifiedIdsThisRound.forEach((id) => justModifiedIdsRef.current.delete(id)), 150);
14953
+ groupSelectionTransformStartRef.current = null;
14954
+ activeSelectionMoveStartRef.current = null;
14955
+ activeSelectionResizeHandleRef.current = null;
14956
+ unlockEditsSoon();
14957
+ return;
14958
+ }
14908
14959
  if (!isActiveSelectionSideResize && !hadScale && !hadRotation && (Math.abs(deltaX) > 0.1 || Math.abs(deltaY) > 0.1)) {
14909
14960
  const { updateNode: updateNodeStore, commitHistory: commitHistoryStore, getCurrentElements } = useEditorStore.getState();
14910
14961
  const newLeft = (groupToMove.left ?? 0) + deltaX;
@@ -14946,35 +14997,6 @@ const PageCanvas = forwardRef(
14946
14997
  unlockEditsSoon();
14947
14998
  return;
14948
14999
  }
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
- }
14978
15000
  }
14979
15001
  }
14980
15002
  const pendingCropGroupFrameBakes = [];
@@ -15490,8 +15512,7 @@ const PageCanvas = forwardRef(
15490
15512
  for (const gid of stackGroupsToReflow) {
15491
15513
  useEditorStore.getState().reflowStackGroupInPage(pageId, gid);
15492
15514
  }
15493
- const shouldRebuildActiveSelectionAfterPersist = activeObj instanceof fabric.ActiveSelection && (!!activeSelectionResizeHandle || pendingCropGroupFrameBakes.length > 0 || Math.abs((activeObj.scaleX ?? 1) - 1) > 1e-3 || Math.abs((activeObj.scaleY ?? 1) - 1) > 1e-3);
15494
- if (activeObj instanceof fabric.ActiveSelection && activeObjects.length > 0 && shouldRebuildActiveSelectionAfterPersist) {
15515
+ if (activeObj instanceof fabric.ActiveSelection && activeObjects.length > 0) {
15495
15516
  const wasGroupSel = activeObj.__pixldocsGroupSelection;
15496
15517
  const membersToReselect = activeObjects.filter((o) => {
15497
15518
  const oid = getObjectId(o);
@@ -24620,9 +24641,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
24620
24641
  }
24621
24642
  return svgString;
24622
24643
  }
24623
- const resolvedPackageVersion = "0.5.339";
24644
+ const resolvedPackageVersion = "0.5.341";
24624
24645
  const PACKAGE_VERSION = resolvedPackageVersion;
24625
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.339";
24646
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.341";
24626
24647
  const roundParityValue = (value) => {
24627
24648
  if (typeof value !== "number") return value;
24628
24649
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25436,7 +25457,7 @@ class PixldocsRenderer {
25436
25457
  await this.waitForCanvasScene(container, cloned, i);
25437
25458
  }
25438
25459
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25439
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-GeBepP7g.js");
25460
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Bq49zb70.js");
25440
25461
  const prepared = preparePagesForExport(
25441
25462
  cloned.pages,
25442
25463
  canvasWidth,
@@ -27756,7 +27777,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
27756
27777
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
27757
27778
  sanitizeSvgTreeForPdf(svgToDraw);
27758
27779
  try {
27759
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-GeBepP7g.js");
27780
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Bq49zb70.js");
27760
27781
  try {
27761
27782
  await logTextMeasurementDiagnostic(svgToDraw);
27762
27783
  } catch {
@@ -28156,4 +28177,4 @@ export {
28156
28177
  buildTeaserBlurFlatKeys as y,
28157
28178
  collectFontDescriptorsFromConfig as z
28158
28179
  };
28159
- //# sourceMappingURL=index-DFhDFJ4X.js.map
28180
+ //# sourceMappingURL=index-8AH1NCZZ.js.map