@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.
@@ -12204,6 +12204,7 @@ const PageCanvas = react.forwardRef(
12204
12204
  const preserveSelectionAfterTransformIdRef = react.useRef(null);
12205
12205
  const groupSelectionTransformStartRef = react.useRef(null);
12206
12206
  const activeSelectionMoveStartRef = react.useRef(null);
12207
+ const lastLiveSelectionRectRef = react.useRef(null);
12207
12208
  const sectionGroupTransientImagesRef = react.useRef(null);
12208
12209
  setGroupOverlayLiveBoundsRef.current = setGroupOverlayLiveBounds;
12209
12210
  const {
@@ -13161,6 +13162,7 @@ const PageCanvas = react.forwardRef(
13161
13162
  fabricCanvas.on("mouse:down", () => {
13162
13163
  groupSelectionTransformStartRef.current = null;
13163
13164
  activeSelectionMoveStartRef.current = null;
13165
+ lastLiveSelectionRectRef.current = null;
13164
13166
  activeSelectionResizeHandleRef.current = null;
13165
13167
  const active = fabricCanvas.getActiveObject();
13166
13168
  if (active instanceof fabric__namespace.ActiveSelection) {
@@ -13340,6 +13342,17 @@ const PageCanvas = react.forwardRef(
13340
13342
  }
13341
13343
  const active = fabricCanvas.getActiveObject();
13342
13344
  if (!active) return;
13345
+ if (active instanceof fabric__namespace.ActiveSelection) {
13346
+ try {
13347
+ const liveRect = active.getBoundingRect();
13348
+ lastLiveSelectionRectRef.current = {
13349
+ selection: active,
13350
+ left: liveRect.left,
13351
+ top: liveRect.top
13352
+ };
13353
+ } catch {
13354
+ }
13355
+ }
13343
13356
  const state = useEditorStore.getState();
13344
13357
  const canvasPage = (_b2 = state.canvas.pages) == null ? void 0 : _b2.find((p) => p.id === pageId);
13345
13358
  const children = (canvasPage == null ? void 0 : canvasPage.children) ?? [];
@@ -15960,7 +15973,8 @@ const PageCanvas = react.forwardRef(
15960
15973
  let activeObjects = fabricCanvas.getActiveObjects();
15961
15974
  const activeSelectionMoveStart = activeObj instanceof fabric__namespace.ActiveSelection && ((_g = activeSelectionMoveStartRef.current) == null ? void 0 : _g.selection) === activeObj ? activeSelectionMoveStartRef.current : null;
15962
15975
  const activeSelectionDelta = activeObj instanceof fabric__namespace.ActiveSelection && activeSelectionMoveStart ? (() => {
15963
- const rect = activeObj.getBoundingRect();
15976
+ const live = lastLiveSelectionRectRef.current;
15977
+ const rect = live && live.selection === activeObj ? { left: live.left, top: live.top } : activeObj.getBoundingRect();
15964
15978
  return {
15965
15979
  x: rect.left - activeSelectionMoveStart.selectionLeft,
15966
15980
  y: rect.top - activeSelectionMoveStart.selectionTop
@@ -16017,7 +16031,9 @@ const PageCanvas = react.forwardRef(
16017
16031
  return !!(node && isGroup(node));
16018
16032
  });
16019
16033
  const activeSelectionHadTransform = activeObj instanceof fabric__namespace.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);
16020
- if (!anyCropGroup && activeSelectionDelta && !activeSelectionHadTransform && selectedLogicalGroupIds.length > 0) {
16034
+ const activeLogicalGroupSelectionId = activeObj instanceof fabric__namespace.ActiveSelection ? activeObj.__pixldocsGroupSelection : void 0;
16035
+ const isPureLogicalGroupMoveWithCrop = !!(anyCropGroup && activeLogicalGroupSelectionId && activeSelectionDelta && !activeSelectionHadTransform);
16036
+ if ((!anyCropGroup || isPureLogicalGroupMoveWithCrop) && activeSelectionDelta && !activeSelectionHadTransform && selectedLogicalGroupIds.length > 0) {
16021
16037
  const selectedStoreIds = useEditorStore.getState().canvas.selectedIds ?? [];
16022
16038
  const groupMemberIds = /* @__PURE__ */ new Set();
16023
16039
  selectedLogicalGroupIds.forEach((gid) => {
@@ -16057,7 +16073,7 @@ const PageCanvas = react.forwardRef(
16057
16073
  return;
16058
16074
  }
16059
16075
  }
16060
- if (selectedElementIds.length > 0 && !anyCropGroup) {
16076
+ if (selectedElementIds.length > 0 && (!anyCropGroup || isPureLogicalGroupMoveWithCrop)) {
16061
16077
  const firstObj = activeObjects[0];
16062
16078
  const firstId = getObjectId(firstObj);
16063
16079
  const parentGroups = selectedElementIds.map((id) => findParentGroup(pageChildren2, id)).filter((g) => g !== null);
@@ -16079,8 +16095,12 @@ const PageCanvas = react.forwardRef(
16079
16095
  const groupAbs = getAbsoluteBounds(groupToMove, pageChildren2);
16080
16096
  let movedGroupLeft = groupAbs.left;
16081
16097
  let movedGroupTop = groupAbs.top;
16082
- if (activeObj instanceof fabric__namespace.ActiveSelection && (transformStart == null ? void 0 : transformStart.groupId) === groupToMove.id) {
16083
- const selectionRect = activeObj.getBoundingRect();
16098
+ if (activeObj instanceof fabric__namespace.ActiveSelection && activeLogicalGroupSelectionId === groupToMove.id && activeSelectionDelta && !activeSelectionHadTransform) {
16099
+ movedGroupLeft = groupAbs.left + activeSelectionDelta.x;
16100
+ movedGroupTop = groupAbs.top + activeSelectionDelta.y;
16101
+ } else if (activeObj instanceof fabric__namespace.ActiveSelection && (transformStart == null ? void 0 : transformStart.groupId) === groupToMove.id) {
16102
+ const live = lastLiveSelectionRectRef.current;
16103
+ const selectionRect = live && live.selection === activeObj ? { left: live.left, top: live.top } : activeObj.getBoundingRect();
16084
16104
  movedGroupLeft = transformStart.groupLeft + (selectionRect.left - transformStart.selectionLeft);
16085
16105
  movedGroupTop = transformStart.groupTop + (selectionRect.top - transformStart.selectionTop);
16086
16106
  } else if (activeObj instanceof fabric__namespace.ActiveSelection && firstId && firstObj) {
@@ -26420,9 +26440,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
26420
26440
  }
26421
26441
  return svgString;
26422
26442
  }
26423
- const resolvedPackageVersion = "0.5.485";
26443
+ const resolvedPackageVersion = "0.5.487";
26424
26444
  const PACKAGE_VERSION = resolvedPackageVersion;
26425
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.485";
26445
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.487";
26426
26446
  const roundParityValue = (value) => {
26427
26447
  if (typeof value !== "number") return value;
26428
26448
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -27236,7 +27256,7 @@ class PixldocsRenderer {
27236
27256
  await this.waitForCanvasScene(container, cloned, i);
27237
27257
  }
27238
27258
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
27239
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-pylbB5Ls.cjs"));
27259
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-SQN2BQR0.cjs"));
27240
27260
  const prepared = preparePagesForExport(
27241
27261
  cloned.pages,
27242
27262
  canvasWidth,
@@ -29556,7 +29576,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
29556
29576
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
29557
29577
  sanitizeSvgTreeForPdf(svgToDraw);
29558
29578
  try {
29559
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-pylbB5Ls.cjs"));
29579
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-SQN2BQR0.cjs"));
29560
29580
  try {
29561
29581
  await logTextMeasurementDiagnostic(svgToDraw);
29562
29582
  } catch {
@@ -29870,4 +29890,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
29870
29890
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
29871
29891
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
29872
29892
  exports.warmTemplateFromForm = warmTemplateFromForm;
29873
- //# sourceMappingURL=index-DG8BpcY2.cjs.map
29893
+ //# sourceMappingURL=index-eyHORcg9.cjs.map