@pixldocs/canvas-renderer 0.5.485 → 0.5.487

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.
@@ -12186,6 +12186,7 @@ const PageCanvas = forwardRef(
12186
12186
  const preserveSelectionAfterTransformIdRef = useRef(null);
12187
12187
  const groupSelectionTransformStartRef = useRef(null);
12188
12188
  const activeSelectionMoveStartRef = useRef(null);
12189
+ const lastLiveSelectionRectRef = useRef(null);
12189
12190
  const sectionGroupTransientImagesRef = useRef(null);
12190
12191
  setGroupOverlayLiveBoundsRef.current = setGroupOverlayLiveBounds;
12191
12192
  const {
@@ -13143,6 +13144,7 @@ const PageCanvas = forwardRef(
13143
13144
  fabricCanvas.on("mouse:down", () => {
13144
13145
  groupSelectionTransformStartRef.current = null;
13145
13146
  activeSelectionMoveStartRef.current = null;
13147
+ lastLiveSelectionRectRef.current = null;
13146
13148
  activeSelectionResizeHandleRef.current = null;
13147
13149
  const active = fabricCanvas.getActiveObject();
13148
13150
  if (active instanceof fabric.ActiveSelection) {
@@ -13322,6 +13324,17 @@ const PageCanvas = forwardRef(
13322
13324
  }
13323
13325
  const active = fabricCanvas.getActiveObject();
13324
13326
  if (!active) return;
13327
+ if (active instanceof fabric.ActiveSelection) {
13328
+ try {
13329
+ const liveRect = active.getBoundingRect();
13330
+ lastLiveSelectionRectRef.current = {
13331
+ selection: active,
13332
+ left: liveRect.left,
13333
+ top: liveRect.top
13334
+ };
13335
+ } catch {
13336
+ }
13337
+ }
13325
13338
  const state = useEditorStore.getState();
13326
13339
  const canvasPage = (_b2 = state.canvas.pages) == null ? void 0 : _b2.find((p) => p.id === pageId);
13327
13340
  const children = (canvasPage == null ? void 0 : canvasPage.children) ?? [];
@@ -15942,7 +15955,8 @@ const PageCanvas = forwardRef(
15942
15955
  let activeObjects = fabricCanvas.getActiveObjects();
15943
15956
  const activeSelectionMoveStart = activeObj instanceof fabric.ActiveSelection && ((_g = activeSelectionMoveStartRef.current) == null ? void 0 : _g.selection) === activeObj ? activeSelectionMoveStartRef.current : null;
15944
15957
  const activeSelectionDelta = activeObj instanceof fabric.ActiveSelection && activeSelectionMoveStart ? (() => {
15945
- const rect = activeObj.getBoundingRect();
15958
+ const live = lastLiveSelectionRectRef.current;
15959
+ const rect = live && live.selection === activeObj ? { left: live.left, top: live.top } : activeObj.getBoundingRect();
15946
15960
  return {
15947
15961
  x: rect.left - activeSelectionMoveStart.selectionLeft,
15948
15962
  y: rect.top - activeSelectionMoveStart.selectionTop
@@ -15999,7 +16013,9 @@ const PageCanvas = forwardRef(
15999
16013
  return !!(node && isGroup(node));
16000
16014
  });
16001
16015
  const activeSelectionHadTransform = activeObj instanceof fabric.ActiveSelection && (Math.abs((activeObj.scaleX ?? 1) - 1) > 0.01 || Math.abs((activeObj.scaleY ?? 1) - 1) > 0.01 || Math.abs((activeObj.angle ?? 0) % 360) > 0.01);
16002
- if (!anyCropGroup && activeSelectionDelta && !activeSelectionHadTransform && selectedLogicalGroupIds.length > 0) {
16016
+ const activeLogicalGroupSelectionId = activeObj instanceof fabric.ActiveSelection ? activeObj.__pixldocsGroupSelection : void 0;
16017
+ const isPureLogicalGroupMoveWithCrop = !!(anyCropGroup && activeLogicalGroupSelectionId && activeSelectionDelta && !activeSelectionHadTransform);
16018
+ if ((!anyCropGroup || isPureLogicalGroupMoveWithCrop) && activeSelectionDelta && !activeSelectionHadTransform && selectedLogicalGroupIds.length > 0) {
16003
16019
  const selectedStoreIds = useEditorStore.getState().canvas.selectedIds ?? [];
16004
16020
  const groupMemberIds = /* @__PURE__ */ new Set();
16005
16021
  selectedLogicalGroupIds.forEach((gid) => {
@@ -16039,7 +16055,7 @@ const PageCanvas = forwardRef(
16039
16055
  return;
16040
16056
  }
16041
16057
  }
16042
- if (selectedElementIds.length > 0 && !anyCropGroup) {
16058
+ if (selectedElementIds.length > 0 && (!anyCropGroup || isPureLogicalGroupMoveWithCrop)) {
16043
16059
  const firstObj = activeObjects[0];
16044
16060
  const firstId = getObjectId(firstObj);
16045
16061
  const parentGroups = selectedElementIds.map((id) => findParentGroup(pageChildren2, id)).filter((g) => g !== null);
@@ -16061,8 +16077,12 @@ const PageCanvas = forwardRef(
16061
16077
  const groupAbs = getAbsoluteBounds(groupToMove, pageChildren2);
16062
16078
  let movedGroupLeft = groupAbs.left;
16063
16079
  let movedGroupTop = groupAbs.top;
16064
- if (activeObj instanceof fabric.ActiveSelection && (transformStart == null ? void 0 : transformStart.groupId) === groupToMove.id) {
16065
- const selectionRect = activeObj.getBoundingRect();
16080
+ if (activeObj instanceof fabric.ActiveSelection && activeLogicalGroupSelectionId === groupToMove.id && activeSelectionDelta && !activeSelectionHadTransform) {
16081
+ movedGroupLeft = groupAbs.left + activeSelectionDelta.x;
16082
+ movedGroupTop = groupAbs.top + activeSelectionDelta.y;
16083
+ } else if (activeObj instanceof fabric.ActiveSelection && (transformStart == null ? void 0 : transformStart.groupId) === groupToMove.id) {
16084
+ const live = lastLiveSelectionRectRef.current;
16085
+ const selectionRect = live && live.selection === activeObj ? { left: live.left, top: live.top } : activeObj.getBoundingRect();
16066
16086
  movedGroupLeft = transformStart.groupLeft + (selectionRect.left - transformStart.selectionLeft);
16067
16087
  movedGroupTop = transformStart.groupTop + (selectionRect.top - transformStart.selectionTop);
16068
16088
  } else if (activeObj instanceof fabric.ActiveSelection && firstId && firstObj) {
@@ -26402,9 +26422,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26402
26422
  }
26403
26423
  return svgString;
26404
26424
  }
26405
- const resolvedPackageVersion = "0.5.485";
26425
+ const resolvedPackageVersion = "0.5.487";
26406
26426
  const PACKAGE_VERSION = resolvedPackageVersion;
26407
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.485";
26427
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.487";
26408
26428
  const roundParityValue = (value) => {
26409
26429
  if (typeof value !== "number") return value;
26410
26430
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27218,7 +27238,7 @@ class PixldocsRenderer {
27218
27238
  await this.waitForCanvasScene(container, cloned, i);
27219
27239
  }
27220
27240
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27221
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BaxoJICy.js");
27241
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CjRFYSDp.js");
27222
27242
  const prepared = preparePagesForExport(
27223
27243
  cloned.pages,
27224
27244
  canvasWidth,
@@ -29538,7 +29558,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29538
29558
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29539
29559
  sanitizeSvgTreeForPdf(svgToDraw);
29540
29560
  try {
29541
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BaxoJICy.js");
29561
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CjRFYSDp.js");
29542
29562
  try {
29543
29563
  await logTextMeasurementDiagnostic(svgToDraw);
29544
29564
  } catch {
@@ -29855,4 +29875,4 @@ export {
29855
29875
  buildTeaserBlurFlatKeys as y,
29856
29876
  collectFontDescriptorsFromConfig as z
29857
29877
  };
29858
- //# sourceMappingURL=index-BPh2zj_A.js.map
29878
+ //# sourceMappingURL=index-CqRau2aM.js.map