@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.
@@ -12704,7 +12704,9 @@ const PageCanvas = forwardRef(
12704
12704
  const selection = new fabric.ActiveSelection(members, { canvas: fc });
12705
12705
  restoreGroupSelectionVisualState(selection, groupId);
12706
12706
  fc.setActiveObject(selection);
12707
- selection.setCoords();
12707
+ if (!selection.getObjects().every((obj) => !(obj instanceof fabric.Group))) {
12708
+ selection.setCoords();
12709
+ }
12708
12710
  fc.requestRenderAll();
12709
12711
  } finally {
12710
12712
  requestAnimationFrame(() => {
@@ -14338,7 +14340,9 @@ const PageCanvas = forwardRef(
14338
14340
  const bakedSelection = reselectionObjects.length > 1 ? new fabric.ActiveSelection(reselectionObjects, { canvas: fabricCanvas }) : activeObj;
14339
14341
  restoreGroupSelectionVisualState(bakedSelection, groupSelectionId);
14340
14342
  fabricCanvas.setActiveObject(bakedSelection);
14341
- bakedSelection.setCoords();
14343
+ if (!(bakedSelection instanceof fabric.ActiveSelection && bakedSelection.getObjects().every((obj) => !(obj instanceof fabric.Group)))) {
14344
+ bakedSelection.setCoords();
14345
+ }
14342
14346
  }
14343
14347
  selectElements([groupSelectionId], false, false);
14344
14348
  fabricCanvas.requestRenderAll();
@@ -15120,9 +15124,42 @@ const PageCanvas = forwardRef(
15120
15124
  };
15121
15125
  fc.add(sectionGroup);
15122
15126
  }
15127
+ const getActiveSelectionContainingObject = (obj) => {
15128
+ const active = fc.getActiveObject();
15129
+ return active instanceof fabric.ActiveSelection && active.getObjects().includes(obj) ? active : null;
15130
+ };
15131
+ const shouldPreserveActiveSelectionMemberPosition = (obj) => {
15132
+ if (syncTriggeredByPanelRef.current) return false;
15133
+ const activeSelection = getActiveSelectionContainingObject(obj);
15134
+ if (!activeSelection) return false;
15135
+ const logicalActiveSelection = activeSelection;
15136
+ const logicalGroupId = logicalActiveSelection.__pixldocsGroupSelection;
15137
+ const logicalGroupIds = logicalActiveSelection.__pixldocsLogicalGroupIds;
15138
+ if (logicalGroupId || Array.isArray(logicalGroupIds)) return true;
15139
+ const id = getObjectId(obj);
15140
+ const preserved = preserveActiveSelectionAfterTransformRef.current;
15141
+ return !!(id && (preserved == null ? void 0 : preserved.memberIds.includes(id)) && (!preserved.expiresAt || preserved.expiresAt > Date.now()));
15142
+ };
15143
+ const getObjectSyncComparePosition = (obj) => {
15144
+ const activeSelection = getActiveSelectionContainingObject(obj);
15145
+ if (!activeSelection) return { left: obj.left ?? 0, top: obj.top ?? 0 };
15146
+ const point = fabric.util.transformPoint({ x: obj.left ?? 0, y: obj.top ?? 0 }, activeSelection.calcTransformMatrix());
15147
+ let left = point.x;
15148
+ let top = point.y;
15149
+ const cropObj = obj;
15150
+ if (obj instanceof fabric.Group && cropObj.__cropGroup) {
15151
+ const ct = cropObj.__cropData;
15152
+ left -= ((ct == null ? void 0 : ct.frameW) ?? obj.width ?? 0) * Math.abs(obj.scaleX ?? 1) / 2;
15153
+ top -= ((ct == null ? void 0 : ct.frameH) ?? obj.height ?? 0) * Math.abs(obj.scaleY ?? 1) / 2;
15154
+ } else if (obj instanceof fabric.FabricImage && (obj.originX === "center" || obj.originY === "center")) {
15155
+ left -= (obj.width ?? 0) * Math.abs(obj.scaleX ?? 1) / 2;
15156
+ top -= (obj.height ?? 0) * Math.abs(obj.scaleY ?? 1) / 2;
15157
+ }
15158
+ return { left, top };
15159
+ };
15123
15160
  for (const element of elementsToSync) {
15124
15161
  if (sectionDescendantIds.has(element.id)) continue;
15125
- let existingObj = currentFabricObjects.get(element.id);
15162
+ const existingObj = currentFabricObjects.get(element.id);
15126
15163
  const isHidden = !element.visible;
15127
15164
  if (existingObj) {
15128
15165
  const isBeingTransformed = transformingIdsRef.current.has(element.id);
@@ -15416,7 +15453,9 @@ const PageCanvas = forwardRef(
15416
15453
  const node = findNodeById(pageTree, element.id);
15417
15454
  return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
15418
15455
  })() : { left: element.left ?? 0, top: element.top ?? 0 };
15419
- const positionChanged = Math.abs((existingObj.left ?? 0) - storePosForImg.left) > 0.1 || Math.abs((existingObj.top ?? 0) - storePosForImg.top) > 0.1;
15456
+ const comparePosForImg = getObjectSyncComparePosition(existingObj);
15457
+ const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
15458
+ const positionChanged = !preserveSelectionMemberPosition && (Math.abs(comparePosForImg.left - storePosForImg.left) > 0.1 || Math.abs(comparePosForImg.top - storePosForImg.top) > 0.1);
15420
15459
  if (visibilityChanged && !positionChanged || visibilityUpdateInProgressRef.current) {
15421
15460
  const isDynamicField = dynamicFieldIds.includes(element.id);
15422
15461
  const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
@@ -15431,7 +15470,7 @@ const PageCanvas = forwardRef(
15431
15470
  previousVisibilityRef.current.set(element.id, currentVisible);
15432
15471
  } else {
15433
15472
  if (!visibilityUpdateInProgressRef.current) {
15434
- updateFabricObject(existingObj, element, wasJustModified);
15473
+ updateFabricObject(existingObj, element, wasJustModified || preserveSelectionMemberPosition);
15435
15474
  }
15436
15475
  const isDynamicField = dynamicFieldIds.includes(element.id);
15437
15476
  const canBeEvented = isEditorMode || isPreviewMode && isDynamicField;
@@ -15453,8 +15492,9 @@ const PageCanvas = forwardRef(
15453
15492
  if (!isBeingTransformed && !isBeingTextEdited && !shouldSkipUpdates2) {
15454
15493
  previousVisibilityRef.current.get(element.id) ?? true;
15455
15494
  const currentVisible = element.visible !== false;
15456
- const fabricLeft = existingObj.left ?? 0;
15457
- const fabricTop = existingObj.top ?? 0;
15495
+ const comparePos = getObjectSyncComparePosition(existingObj);
15496
+ const fabricLeft = comparePos.left;
15497
+ const fabricTop = comparePos.top;
15458
15498
  const storePos = pageTree.length ? (() => {
15459
15499
  const node = findNodeById(pageTree, element.id);
15460
15500
  return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
@@ -15463,7 +15503,8 @@ const PageCanvas = forwardRef(
15463
15503
  const storeTop = storePos.top;
15464
15504
  const deltaX = Math.abs(fabricLeft - storeLeft);
15465
15505
  const deltaY = Math.abs(fabricTop - storeTop);
15466
- let positionChanged = deltaX > 0.1 || deltaY > 0.1;
15506
+ const preserveSelectionMemberPosition = shouldPreserveActiveSelectionMemberPosition(existingObj);
15507
+ let positionChanged = !preserveSelectionMemberPosition && (deltaX > 0.1 || deltaY > 0.1);
15467
15508
  const activeObj = fc.getActiveObject();
15468
15509
  const isInActiveSelection = activeObj && (activeObj instanceof fabric.ActiveSelection ? activeObj.getObjects().includes(existingObj) : activeObj === existingObj);
15469
15510
  const isInSelectedIds = selectedIdsFromStore.has(element.id);
@@ -15515,7 +15556,7 @@ const PageCanvas = forwardRef(
15515
15556
  });
15516
15557
  previousVisibilityRef.current.set(element.id, currentVisible);
15517
15558
  } else {
15518
- const skipPositionBecauseSelection = isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15559
+ const skipPositionBecauseSelection = preserveSelectionMemberPosition || isSelected && (deltaX > 0.1 || deltaY > 0.1) && (wasJustModified || isBeingTransformed);
15519
15560
  const anyChange = positionChanged || otherPropsChanged || forceApplyFromPanel;
15520
15561
  if (!visibilityUpdateInProgressRef.current) {
15521
15562
  if (anyChange && !skipPositionBecauseSelection) {
@@ -23697,9 +23738,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23697
23738
  }
23698
23739
  return svgString;
23699
23740
  }
23700
- const resolvedPackageVersion = "0.5.271";
23741
+ const resolvedPackageVersion = "0.5.272";
23701
23742
  const PACKAGE_VERSION = resolvedPackageVersion;
23702
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.271";
23743
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.272";
23703
23744
  const roundParityValue = (value) => {
23704
23745
  if (typeof value !== "number") return value;
23705
23746
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24513,7 +24554,7 @@ class PixldocsRenderer {
24513
24554
  await this.waitForCanvasScene(container, cloned, i);
24514
24555
  }
24515
24556
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24516
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-0BizqdiS.js");
24557
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BySFN17q.js");
24517
24558
  const prepared = preparePagesForExport(
24518
24559
  cloned.pages,
24519
24560
  canvasWidth,
@@ -26833,7 +26874,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26833
26874
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26834
26875
  sanitizeSvgTreeForPdf(svgToDraw);
26835
26876
  try {
26836
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-0BizqdiS.js");
26877
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BySFN17q.js");
26837
26878
  try {
26838
26879
  await logTextMeasurementDiagnostic(svgToDraw);
26839
26880
  } catch {
@@ -27233,4 +27274,4 @@ export {
27233
27274
  buildTeaserBlurFlatKeys as y,
27234
27275
  collectFontDescriptorsFromConfig as z
27235
27276
  };
27236
- //# sourceMappingURL=index-BpY8sZ_v.js.map
27277
+ //# sourceMappingURL=index-CHIScvwH.js.map