@pixldocs/canvas-renderer 0.5.271 → 0.5.272

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.
@@ -12722,7 +12722,9 @@ const PageCanvas = react.forwardRef(
12722
12722
  const selection = new fabric__namespace.ActiveSelection(members, { canvas: fc });
12723
12723
  restoreGroupSelectionVisualState(selection, groupId);
12724
12724
  fc.setActiveObject(selection);
12725
- selection.setCoords();
12725
+ if (!selection.getObjects().every((obj) => !(obj instanceof fabric__namespace.Group))) {
12726
+ selection.setCoords();
12727
+ }
12726
12728
  fc.requestRenderAll();
12727
12729
  } finally {
12728
12730
  requestAnimationFrame(() => {
@@ -14356,7 +14358,9 @@ const PageCanvas = react.forwardRef(
14356
14358
  const bakedSelection = reselectionObjects.length > 1 ? new fabric__namespace.ActiveSelection(reselectionObjects, { canvas: fabricCanvas }) : activeObj;
14357
14359
  restoreGroupSelectionVisualState(bakedSelection, groupSelectionId);
14358
14360
  fabricCanvas.setActiveObject(bakedSelection);
14359
- bakedSelection.setCoords();
14361
+ if (!(bakedSelection instanceof fabric__namespace.ActiveSelection && bakedSelection.getObjects().every((obj) => !(obj instanceof fabric__namespace.Group)))) {
14362
+ bakedSelection.setCoords();
14363
+ }
14360
14364
  }
14361
14365
  selectElements([groupSelectionId], false, false);
14362
14366
  fabricCanvas.requestRenderAll();
@@ -15138,9 +15142,42 @@ const PageCanvas = react.forwardRef(
15138
15142
  };
15139
15143
  fc.add(sectionGroup);
15140
15144
  }
15145
+ const getActiveSelectionContainingObject = (obj) => {
15146
+ const active = fc.getActiveObject();
15147
+ return active instanceof fabric__namespace.ActiveSelection && active.getObjects().includes(obj) ? active : null;
15148
+ };
15149
+ const shouldPreserveActiveSelectionMemberPosition = (obj) => {
15150
+ if (syncTriggeredByPanelRef.current) return false;
15151
+ const activeSelection = getActiveSelectionContainingObject(obj);
15152
+ if (!activeSelection) return false;
15153
+ const logicalActiveSelection = activeSelection;
15154
+ const logicalGroupId = logicalActiveSelection.__pixldocsGroupSelection;
15155
+ const logicalGroupIds = logicalActiveSelection.__pixldocsLogicalGroupIds;
15156
+ if (logicalGroupId || Array.isArray(logicalGroupIds)) return true;
15157
+ const id = getObjectId(obj);
15158
+ const preserved = preserveActiveSelectionAfterTransformRef.current;
15159
+ return !!(id && (preserved == null ? void 0 : preserved.memberIds.includes(id)) && (!preserved.expiresAt || preserved.expiresAt > Date.now()));
15160
+ };
15161
+ const getObjectSyncComparePosition = (obj) => {
15162
+ const activeSelection = getActiveSelectionContainingObject(obj);
15163
+ if (!activeSelection) return { left: obj.left ?? 0, top: obj.top ?? 0 };
15164
+ const point = fabric__namespace.util.transformPoint({ x: obj.left ?? 0, y: obj.top ?? 0 }, activeSelection.calcTransformMatrix());
15165
+ let left = point.x;
15166
+ let top = point.y;
15167
+ const cropObj = obj;
15168
+ if (obj instanceof fabric__namespace.Group && cropObj.__cropGroup) {
15169
+ const ct = cropObj.__cropData;
15170
+ left -= ((ct == null ? void 0 : ct.frameW) ?? obj.width ?? 0) * Math.abs(obj.scaleX ?? 1) / 2;
15171
+ top -= ((ct == null ? void 0 : ct.frameH) ?? obj.height ?? 0) * Math.abs(obj.scaleY ?? 1) / 2;
15172
+ } else if (obj instanceof fabric__namespace.FabricImage && (obj.originX === "center" || obj.originY === "center")) {
15173
+ left -= (obj.width ?? 0) * Math.abs(obj.scaleX ?? 1) / 2;
15174
+ top -= (obj.height ?? 0) * Math.abs(obj.scaleY ?? 1) / 2;
15175
+ }
15176
+ return { left, top };
15177
+ };
15141
15178
  for (const element of elementsToSync) {
15142
15179
  if (sectionDescendantIds.has(element.id)) continue;
15143
- let existingObj = currentFabricObjects.get(element.id);
15180
+ const existingObj = currentFabricObjects.get(element.id);
15144
15181
  const isHidden = !element.visible;
15145
15182
  if (existingObj) {
15146
15183
  const isBeingTransformed = transformingIdsRef.current.has(element.id);
@@ -15434,7 +15471,9 @@ const PageCanvas = react.forwardRef(
15434
15471
  const node = findNodeById(pageTree, element.id);
15435
15472
  return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
15436
15473
  })() : { left: element.left ?? 0, top: element.top ?? 0 };
15437
- const positionChanged = Math.abs((existingObj.left ?? 0) - storePosForImg.left) > 0.1 || Math.abs((existingObj.top ?? 0) - storePosForImg.top) > 0.1;
15474
+ const comparePosForImg = getObjectSyncComparePosition(existingObj);
15475
+ const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
15476
+ const positionChanged = !preserveSelectionMemberPosition && (Math.abs(comparePosForImg.left - storePosForImg.left) > 0.1 || Math.abs(comparePosForImg.top - storePosForImg.top) > 0.1);
15438
15477
  if (visibilityChanged && !positionChanged || visibilityUpdateInProgressRef.current) {
15439
15478
  const isDynamicField = dynamicFieldIds.includes(element.id);
15440
15479
  const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
@@ -15449,7 +15488,7 @@ const PageCanvas = react.forwardRef(
15449
15488
  previousVisibilityRef.current.set(element.id, currentVisible);
15450
15489
  } else {
15451
15490
  if (!visibilityUpdateInProgressRef.current) {
15452
- updateFabricObject(existingObj, element, wasJustModified);
15491
+ updateFabricObject(existingObj, element, wasJustModified || preserveSelectionMemberPosition);
15453
15492
  }
15454
15493
  const isDynamicField = dynamicFieldIds.includes(element.id);
15455
15494
  const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
@@ -15471,8 +15510,9 @@ const PageCanvas = react.forwardRef(
15471
15510
  if (!isBeingTransformed && !isBeingTextEdited && !shouldSkipUpdates2) {
15472
15511
  previousVisibilityRef.current.get(element.id) ?? true;
15473
15512
  const currentVisible = element.visible !== false;
15474
- const fabricLeft = existingObj.left ?? 0;
15475
- const fabricTop = existingObj.top ?? 0;
15513
+ const comparePos = getObjectSyncComparePosition(existingObj);
15514
+ const fabricLeft = comparePos.left;
15515
+ const fabricTop = comparePos.top;
15476
15516
  const storePos = pageTree.length ? (() => {
15477
15517
  const node = findNodeById(pageTree, element.id);
15478
15518
  return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
@@ -15481,7 +15521,8 @@ const PageCanvas = react.forwardRef(
15481
15521
  const storeTop = storePos.top;
15482
15522
  const deltaX = Math.abs(fabricLeft - storeLeft);
15483
15523
  const deltaY = Math.abs(fabricTop - storeTop);
15484
- let positionChanged = deltaX > 0.1 || deltaY > 0.1;
15524
+ const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
15525
+ let positionChanged = !preserveSelectionMemberPosition && (deltaX > 0.1 || deltaY > 0.1);
15485
15526
  const activeObj = fc.getActiveObject();
15486
15527
  const isInActiveSelection = activeObj && (activeObj instanceof fabric__namespace.ActiveSelection ? activeObj.getObjects().includes(existingObj) : activeObj === existingObj);
15487
15528
  const isInSelectedIds = selectedIdsFromStore.has(element.id);
@@ -15533,7 +15574,7 @@ const PageCanvas = react.forwardRef(
15533
15574
  });
15534
15575
  previousVisibilityRef.current.set(element.id, currentVisible);
15535
15576
  } else {
15536
- const skipPositionBecauseSelection = isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15577
+ const skipPositionBecauseSelection = preserveSelectionMemberPosition || isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15537
15578
  const anyChange = positionChanged || otherPropsChanged || forceApplyFromPanel;
15538
15579
  if (!visibilityUpdateInProgressRef.current) {
15539
15580
  if (anyChange && !skipPositionBecauseSelection) {
@@ -23715,9 +23756,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23715
23756
  }
23716
23757
  return svgString;
23717
23758
  }
23718
- const resolvedPackageVersion = "0.5.271";
23759
+ const resolvedPackageVersion = "0.5.272";
23719
23760
  const PACKAGE_VERSION = resolvedPackageVersion;
23720
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.271";
23761
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.272";
23721
23762
  const roundParityValue = (value) => {
23722
23763
  if (typeof value !== "number") return value;
23723
23764
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24531,7 +24572,7 @@ class PixldocsRenderer {
24531
24572
  await this.waitForCanvasScene(container, cloned, i);
24532
24573
  }
24533
24574
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24534
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DjBUHamz.cjs"));
24575
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CdiLpR0-.cjs"));
24535
24576
  const prepared = preparePagesForExport(
24536
24577
  cloned.pages,
24537
24578
  canvasWidth,
@@ -26851,7 +26892,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26851
26892
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26852
26893
  sanitizeSvgTreeForPdf(svgToDraw);
26853
26894
  try {
26854
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DjBUHamz.cjs"));
26895
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CdiLpR0-.cjs"));
26855
26896
  try {
26856
26897
  await logTextMeasurementDiagnostic(svgToDraw);
26857
26898
  } catch {
@@ -27248,4 +27289,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27248
27289
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27249
27290
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27250
27291
  exports.warmTemplateFromForm = warmTemplateFromForm;
27251
- //# sourceMappingURL=index-6188mLJ2.cjs.map
27292
+ //# sourceMappingURL=index-BYfp_ae9.cjs.map